mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-13 03:37:02 +02:00
a few fixes
This commit is contained in:
@ -17,7 +17,6 @@ alter table retention_rule add column `attachment_name` varchar(128) default nul
|
||||
alter table archiving_rule drop index `from`;
|
||||
create unique index `entry` on archiving_rule (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`);
|
||||
|
||||
alter table retention_rule drop index `entry`;
|
||||
create unique index `entry` on retention_rule (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`);
|
||||
|
||||
|
||||
@ -26,7 +25,7 @@ alter table ldap add column ldap_account_objectclass varchar(128) default null;
|
||||
alter table ldap add column ldap_distributionlist_attr varchar(128) default null;
|
||||
alter table ldap add column ldap_distributionlist_objectclass varchar(128) default null;
|
||||
|
||||
alter table google change column id id char(32) not null primary key;
|
||||
alter table google change column id id char(32) not null;
|
||||
alter table google_imap change column id id char(32) not null primary key;
|
||||
|
||||
|
||||
|
@ -3,8 +3,33 @@
|
||||
ini_set("session.save_path", "/tmp");
|
||||
|
||||
$webuidir = "";
|
||||
$daemonize = 0;
|
||||
|
||||
|
||||
$opts = 'hd::';
|
||||
$lopts = array(
|
||||
'webui:'
|
||||
);
|
||||
|
||||
|
||||
if($options = getopt($opts, $lopts)) {
|
||||
|
||||
if(isset($options['webui'])) {
|
||||
$webuidir = $options['webui'];
|
||||
}
|
||||
else {
|
||||
echo("\nError: must provide path to WebUI directory\n\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($options['d'])) {
|
||||
$daemonize = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_SERVER['argv'][1])) { $webuidir = $_SERVER['argv'][1]; }
|
||||
|
||||
require_once($webuidir . "/config.php");
|
||||
|
||||
@ -41,17 +66,38 @@ $loader->model('google/google');
|
||||
|
||||
openlog("piler-gmail-import", LOG_PID, LOG_MAIL);
|
||||
|
||||
$ug = new ModelUserGoogle();
|
||||
$g = new ModelGoogleGoogle();
|
||||
if($daemonize == 1) {
|
||||
while(1) {
|
||||
syslog(LOG_INFO, "started another imap poll");
|
||||
|
||||
poll_imap_accounts();
|
||||
|
||||
sleep(300);
|
||||
}
|
||||
}
|
||||
else {
|
||||
poll_imap_accounts();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$query = $db->query("SELECT email FROM " . TABLE_GOOGLE);
|
||||
if(isset($query->rows)) {
|
||||
foreach($query->rows as $q) {
|
||||
$access_token = $ug->refresh_access_token($q['email']);
|
||||
$g->download_users_emails($q['email'], $access_token);
|
||||
|
||||
function poll_imap_accounts() {
|
||||
$db = Registry::get('db');
|
||||
|
||||
$ug = new ModelUserGoogle();
|
||||
$g = new ModelGoogleGoogle();
|
||||
|
||||
|
||||
$query = $db->query("SELECT email FROM " . TABLE_GOOGLE);
|
||||
|
||||
if(isset($query->rows)) {
|
||||
foreach($query->rows as $q) {
|
||||
$access_token = $ug->refresh_access_token($q['email']);
|
||||
$g->download_users_emails($q['email'], $access_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user