/** * check for pending notification and send corresponding emails (trigger by cronjob) * @return void */ public static function do_notification_queue() { $l = new OC_L10N('mailnotify'); $nm_upload = self::db_get_nm_upload(); $shares = self::db_get_share(); $mailTo = array(); $filesList = array(); $fileInfo = array(); //list all unique nm_upload path. add most recent timestamp and list editors. foreach ($nm_upload as $upload) { $filesList[$upload['path']] = array(); if (!isset($filesList[$upload['path']]['timestamp']) || $filesList[$upload['path']]['timestamp'] < $upload['timestamp']) { $filesList[$upload['path']]['timestamp'] = $upload['timestamp']; } } // find who want wich notifications foreach ($filesList as $filePath => $Mod_timestamp) { foreach ($shares as $sharesKey => $row) { if (self::is_under($row["file_source"], $filePath)) { if (!self::is_uid_exclude('/Shared' . $row['file_target'], $row['share_with'])) { $mailTo[$row['share_with']][] = $sharesKey; } elseif (!self::is_uid_exclude($row['file_target'], $row['uid_owner'])) { $mailTo[$row['uid_owner']][] = $sharesKey; } if (self::db_isgroup($row['share_with'])) { foreach (self::db_get_usersOfGroup($row['share_with']) as $key => $user) { if (!self::is_uid_exclude('/Shared' . $row['file_target'], $row['share_with'])) { //if shared with user $mailTo[$user][] = $sharesKey; } } } } } } //var_dump($mailTo); //assamble emails if (!empty($mailTo)) { foreach ($mailTo as $uid => $files) { $msg = '<ul> Following files have been modified. <br><br>'; foreach ($files as $rowId) { $url_path = self::db_get_filecash_path($shares[$rowId]['item_source']); $url_name = substr($shares[$rowId]['file_target'], 1); $msg .= '<li><a href="' . OCP\Util::linkTo('index.php/apps/files?dir=//Shared', '') . '" target="_blank">' . $url_name . '</a></li>'; //FIXME static redirection :( OC_MailNotify_Mailing::db_remove_all_nmuploads_for($shares[$rowId]['file_source']); } OC_MailNotify_Mailing::sendEmail($msg, $l->t('New upload'), $uid); } } }