/** * Tell if the mail must be sent or not. * For exemple a mail will not be sent if the concerned event is in * the past. */ private function mustBeSent($old, $new) { $today = Of_Date::today(); $willBeSent = false; if(isset($new) && $new instanceof OBM_Event) { if($new->date_end->compare($today) > 0) { $willBeSent = true; } if($new->repeat_kind != 'none' && $new->repeat_end->compare($today) > 0) { $willBeSent = true; } } if(isset($old) && $old instanceof OBM_Event) { if($old->date_end->compare($today) > 0) { $willBeSent = true; } if($old->repeat_kind != 'none' && $old->repeat_end->compare($today) > 0) { $willBeSent = true; } } return $willBeSent; }
if ($params['others_attendees'] != "") { $others_attendees = run_query_insert_others_attendees($params); $entities['contact'] = array_merge($entities['contact'], $others_attendees); } // Insert "other files" as private documents if (count($params['other_files']) > 0) { $other_files = run_query_insert_other_files($params); if (!$other_files) { $display['msg'] .= display_warn_msg("$l_event : $l_warn_file_upload"); } else { $entities['document'] = array_merge($entities['document'], $other_files); } } $event_id = run_query_calendar_add_event($params, $entities); $params["calendar_id"] = $event_id; if ($params['date_begin']->compare(Of_Date::today()) <= 0) { $display['msg'] .= display_warn_msg("$l_event : $l_warn_date_past"); } if ($params['show_user_calendar']) $current_view->set_users($params['sel_user_id']); if ($params['show_resource_calendar']) $current_view->set_resources($params['sel_resource_id']); $current_view->set_date($params["date_begin"]); $detailurl = basename($_SERVER['SCRIPT_NAME'])."?action=detailconsult&calendar_id=$event_id"; $detail = "<a class='B' href='$detailurl'>".phpStringToJsString($GLOBALS[l_details])."</a>"; if($GLOBALS['display']['warm_add_organizer'] == true){ redirect_warn($params, "$l_event: $l_insert_ok - $l_event_add_organizer - $detail"); } else { redirect_ok($params, "$l_event: $l_insert_ok - $detail"); } }
/** * execute * * @param mixed $date * @access public * @return void */ function execute($date) { global $obm; include('obminclude/lang/fr/calendar.inc'); $lang_file = 'conf/lang/fr/calendar.inc'; if (file_exists("{$includePath}/{$lang_file}")) { include("$lang_file"); } $date = new Of_Date($date); $end = clone $date; $end = $end->addSecond($this->jobDelta); $this->getAlerts($date, $end); $of = &OccurrenceFactory::getInstance(); $occurrences = $of->getOccurrences(); foreach($occurrences as $occurrence) { $event = $occurrence->event; $delta = $this->getAlertDelta($event->id, $occurrence->id); if($occurrence->date->compare($date)>=0 && $occurrence->date->compare($end)<0) { $current = clone $occurrence->date; $this->logger->debug("Alert for event ".$event->id." will be sent"); $consult_link = "$GLOBALS[cgp_host]/calendar/calendar_index.php?action=detailconsult&calendar_id=".$event->id; if(isset($events[$event->id])) { $recipients = $events[$event->id]['recipients']; } else { $recipients = array(); } array_push($recipients, $occurrence->id); $events[$event->id] = array ( "subject" => sprintf($l_alert_mail_subject,($event->title)), "message" => sprintf($l_alert_mail_body, ($event->title), $current->addSecond($delta)->getOutputDateTime(), $current->addSecond($event->duration)->getOutputDateTime(), ($delta/60), $event->location, $consult_link, Of_Date::today()->getOutputDate(), Of_Date::today()->get(Of_Date::TIME_SHORT) ,$GLOBALS['cgp_host'] ), "recipients" => array_unique($recipients), "owner" => $event->owner ); } } if(is_array($events)) { foreach($events as $event_id => $event) { $obm["uid"] = $event["owner"]; send_mail($event["subject"], $event["message"], $event["recipients"], array(), false); $this->logger->info("Alert sent to ".implode(",",$event["recipients"])." about $event[subject] by $obm[uid]"); } } $current = clone $date; $this->deleteDeprecatedAlerts($current->addSecond($this->jobDelta)); return true; }