mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:51:59 +01:00
a few fixes
This commit is contained in:
parent
4e6946feca
commit
989cd68054
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -192,6 +192,7 @@ $config['SPHINX_TAG_INDEX'] = 'tag1';
|
||||
$config['SPHINX_NOTE_INDEX'] = 'note1';
|
||||
|
||||
$config['RELOAD_COMMAND'] = 'sudo -n /etc/init.d/rc.piler reload';
|
||||
$config['PILERIMPORT_IMAP_COMMAND'] = '/usr/local/bin/pilerimport -d /var/piler/imap -q -r';
|
||||
|
||||
$config['LDAP_IMPORT_CONFIG_FILE'] = '/usr/local/etc/ldap-import.cfg';
|
||||
|
||||
|
@ -129,6 +129,8 @@ class ModelGoogleGoogle extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
if($count > 0) { $this->run_import_command(); }
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
@ -158,6 +160,13 @@ class ModelGoogleGoogle extends Model {
|
||||
}
|
||||
|
||||
|
||||
private function run_import_command() {
|
||||
syslog(LOG_INFO, "importing emails ...");
|
||||
system(PILERIMPORT_IMAP_COMMAND, $val);
|
||||
syslog(LOG_INFO, "importing emails done");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user