Beispiel #1
0
 //in class.flyspray.conf
 touch(Flyspray::get_tmp_dir() . '/flysprayreminders.run');
 $user = new User(0);
 $now = time();
 ############ Task one: Send reminders ############
 $reminders = $db->x->getAll("SELECT  r.reminder_message AS message, r.*\n                                   FROM  {reminders} r\n                             INNER JOIN  {users}     u ON u.user_id = r.to_user_id\n                             INNER JOIN  {tasks}     t ON r.task_id = t.task_id\n                             INNER JOIN  {projects}  p ON t.project_id = p.project_id\n                                  WHERE  t.is_closed = '0' AND r.start_time < ?\n                                                           AND r.last_sent + r.how_often < ?\n                               ORDER BY  r.reminder_id", null, array(time(), time()));
 foreach ($reminders as $row) {
     if (Notifications::send_now($row['to_user_id'], ADDRESS_USER, NOTIFY_REMINDER, $row)) {
         // Update the database with the time sent
         $db->x->execParam('UPDATE  {reminders}
                     SET  last_sent = ?
                   WHERE  reminder_id = ?', null, array(time(), $row['reminder_id']));
     }
 }
 ############ Task two: send stored notifications ############
 Notifications::send_stored();
 ############ Task three: send project manager digests ############
 $sql = $db->x->getAll('SELECT project_id, project_title, last_digest, project_prefix
                  FROM {projects}
                 WHERE send_digest = 1 AND last_digest < ?', null, time() - 60 * 60 * 24 * 7);
 foreach ($sql as $project) {
     // find out all project managers
     $pms = $db->x->GetCol('SELECT uig.user_id
                       FROM {users_in_groups} uig
                  LEFT JOIN {groups} g ON uig.group_id = g.group_id
                      WHERE g.project_id = ? AND g.manage_project = 1', null, $project['project_id']);
     // Now generate the message, we are interested in opened/reopened, closed and assigned tasks
     $opened = $reopened = $closed = $assigned = array();
     $message = L('digestfor') . ' ' . $project['project_title'] . ":\n\n";
     $evt = $db->x->getAll('SELECT h.event_type, lr.item_name AS resolution_name, t.task_id,
                             t.item_summary, u.user_name, u.real_name, t.prefix_id