/** * go through all accounts and collect information * * returns array of count of... [$num_notification_sent, $num_warnings] */ public static function sendNotifications() { global $PH; $people = Person::getPeople(array('visible_only' => false, 'can_login' => true)); $num_notifications_sent = 0; $num_warnings = 0; foreach ($people as $p) { if ($p->settings & USER_SETTING_NOTIFICATIONS) { if ($p->office_email || $p->personal_email) { $now = time(); $last = strToGMTime($p->notification_last); $period = $p->notification_period * 60 * 60 * 24; if (strToGMTime($p->notification_last) + $period < time() || $period == -1) { $email = new EmailNotification($p); if ($email->information_count) { $result = $email->send(); if ($result === true) { ### reset activation-flag ### $p->settings &= USER_SETTING_SEND_ACTIVATION ^ RIGHT_ALL; $p->notification_last = gmdate("Y-m-d H:i:s"); $p->update(); $num_notifications_sent++; } else { if ($result !== false) { $num_warnings++; new FeedbackWarning(sprintf(__('Failure sending mail: %s'), $result)); } } } } } } } return array($num_notifications_sent, $num_warnings); }
function auto_email_notification_members($activity_type, $params) { if (!PA::$network_info) { return; } //setting common variables $notification = new EmailNotification(); // mail to // FIXME: these two seemed not to be set in occasion $gid = @$params['gid'] ? $params['gid'] : @$_GET['gid']; $rid = @$params['related_uid']; if ($gid) { $network_owner_id = Group::get_owner_id($gid); $notification->network_owner = User::map_ids_to_logins($network_owner_id['user_id']); $group_owner = new User(); $group_owner->load((int) $network_owner_id['user_id']); $notification->to = $group_owner->email; $group_owner_name = $group_owner->login_name; //mail from $notification->from = (int) PA::$login_uid; $array_of_data = array('to' => $notification->to, 'from' => $notification->from, 'owner_name' => $group_owner_name, 'group_owner_id' => $network_owner_id['user_id']); } if ($rid) { $notification->network_owner = User::map_ids_to_logins(array($rid)); foreach ($notification->network_owner as $key => $value) { $rel_user = new User(); $rel_user->load((int) $key); $related_name = $rel_user->login_name; $notification->to = $rel_user->email; } $notification->from = (int) PA::$login_uid; $array_of_data = array('to' => $notification->to, 'from' => $notification->from, 'related_name' => $related_name); } $array_of_data['params'] = $params; $notification->send($activity_type, $array_of_data); }
foreach ($sales as $sale) { // loads the sale $sale = $sale->load($sale->getId()); // loads order id of current sale $orderID = $sale->getIncrementId(); // loads customer id of the current sale $customerID = $sale->getCustomerId(); // customer of current sale might be a guest if (null === $customerID) { $customerID = "guest"; } // loads parcel id of the sale (from karlie) $message = exec(GetParcelIDCommand . $customerID . "_" . $orderID); // fills up CRON notification email $color = "green"; switch ($message) { case "": case "null": case "parcelID: null": case null: $color = "red"; break; } EmailNotification::add("<span style='color:{$color}'>Bestellung: " . $customerID . "_" . $orderID . " {$message}</span>"); } // sends CRON notification email EmailNotification::add("<span style='color:black'>Der CRON Job Check Parcel ID endet.</span>"); EmailNotification::send(); // logs done message logger("Done: mygassi-check-parcels"); exit(1);
/** * Send notication mail for one person right now @ingroup pages */ function peopleFlushNotifications() { global $PH; global $auth; ### get person #### $ids = getPassedIds('person', 'people_*'); if (!$ids) { $PH->abortWarning(__("Select some people to notify")); return; } $counter = 0; $errors = 0; foreach ($ids as $id) { if (!($person = Person::getEditableById($id))) { $PH->abortWarning("Invalid person-id!"); } require_once confGet('DIR_STREBER') . 'std/class_email_notification.inc.php'; $email = new EmailNotification($person); if ($email->information_count) { $send_result = $email->send(); if ($send_result === true) { $counter++; } else { $errors++; } } } ### reset language ### setLang($auth->cur_user->language); if ($errors) { new FeedbackWarning(sprintf(__("Failed to mail %s people"), $errors)); } else { new FeedbackMessage(sprintf(__("Sent notification to %s person(s)"), $counter)); } ### display taskView #### if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $person->project)); } }