function __construct($group_id, $url, $feedback) { parent::__construct(); $this->_group_id = $group_id; $this->_url = $url; $this->_listeners = array(); $this->_feedback = $feedback; $this->_item_factory = $this->_getItemFactory(); $this->_messages = array(); if (($g = $this->_groupGetObject($group_id)) && !$g->isError()) { $this->_group_name = $g->getPublicName(); } }
function __construct(Project $project, $url, $feedback, MailBuilder $mail_builder) { parent::__construct(); $this->project = $project; $this->_url = $url; $this->_listeners = array(); $this->_feedback = $feedback; $this->_item_factory = $this->_getItemFactory(); $this->notifications = array(); $this->mail_builder = $mail_builder; if ($project && !$project->isError()) { $this->_group_name = $project->getPublicName(); } }
/** * Parse a post/comment body for quotes and notify all quoted users that have quote notifications enabled. * @param string $Body * @param int $PostID * @param string $Page * @param int $PageID */ public static function quote_notify($Body, $PostID, $Page, $PageID) { $QueryID = G::$DB->get_query_id(); /* * Explanation of the parameters PageID and Page: Page contains where * this quote comes from and can be forums, artist, collages, requests * or torrents. The PageID contains the additional value that is * necessary for the users_notify_quoted table. The PageIDs for the * different Page are: forums: TopicID artist: ArtistID collages: * CollageID requests: RequestID torrents: GroupID */ $Matches = array(); preg_match_all('/\\[quote(?:=(.*)(?:\\|.*)?)?]|\\[\\/quote]/iU', $Body, $Matches, PREG_SET_ORDER); if (count($Matches)) { $Usernames = array(); $Level = 0; foreach ($Matches as $M) { if ($M[0] != '[/quote]') { if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) { $Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]); // wut? } ++$Level; } else { --$Level; } } } // remove any dupes in the array (the fast way) $Usernames = array_flip(array_flip($Usernames)); G::$DB->query("\n\t\t\tSELECT m.ID\n\t\t\tFROM users_main AS m\n\t\t\t\tLEFT JOIN users_info AS i ON i.UserID = m.ID\n\t\t\tWHERE m.Username IN ('" . implode("', '", $Usernames) . "')\n\t\t\t\tAND i.NotifyOnQuote = '1'\n\t\t\t\tAND i.UserID != " . G::$LoggedUser['ID']); $Results = G::$DB->to_array(); foreach ($Results as $Result) { $UserID = db_string($Result['ID']); $QuoterID = db_string(G::$LoggedUser['ID']); $Page = db_string($Page); $PageID = db_string($PageID); $PostID = db_string($PostID); G::$DB->query("\n\t\t\t\tINSERT IGNORE INTO users_notify_quoted\n\t\t\t\t\t(UserID, QuoterID, Page, PageID, PostID, Date)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$UserID}', '{$QuoterID}', '{$Page}', '{$PageID}', '{$PostID}', '" . sqltime() . "')"); G::$Cache->delete_value("notify_quoted_{$UserID}"); if ($Page == 'forums') { $URL = site_url() . "forums.php?action=viewthread&postid={$PostID}"; } else { $URL = site_url() . "comments.php?action=jump&postid={$PostID}"; } NotificationsManager::send_push($UserID, 'New Quote!', 'Quoted by ' . G::$LoggedUser['Username'] . " {$URL}", $URL, NotificationsManager::QUOTES); } G::$DB->set_query_id($QueryID); }
/** * Sends a PM from $FromId to $ToId. * * @param string $ToID ID of user to send PM to. If $ToID is an array and $ConvID is empty, a message will be sent to multiple users. * @param string $FromID ID of user to send PM from, 0 to send from system * @param string $Subject * @param string $Body * @param int $ConvID The conversation the message goes in. Leave blank to start a new conversation. * @return */ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') { global $Time; $UnescapedSubject = $Subject; $UnescapedBody = $Body; $Subject = db_string($Subject); $Body = db_string($Body); if ($ToID == 0 || $ToID == $FromID) { // Don't allow users to send messages to the system or themselves return; } $QueryID = G::$DB->get_query_id(); if ($ConvID == '') { // Create a new conversation. G::$DB->query("\n\t\t\t\tINSERT INTO pm_conversations (Subject)\n\t\t\t\tVALUES ('{$Subject}')"); $ConvID = G::$DB->inserted_id(); G::$DB->query("\n\t\t\t\tINSERT INTO pm_conversations_users\n\t\t\t\t\t(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$ToID}', '{$ConvID}', '1','0','" . sqltime() . "', '" . sqltime() . "', '1')"); if ($FromID != 0) { G::$DB->query("\n\t\t\t\t\tINSERT INTO pm_conversations_users\n\t\t\t\t\t\t(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('{$FromID}', '{$ConvID}', '0','1','" . sqltime() . "', '" . sqltime() . "', '0')"); } $ToID = array($ToID); } else { // Update the pre-existing conversations. G::$DB->query("\n\t\t\t\tUPDATE pm_conversations_users\n\t\t\t\tSET\n\t\t\t\t\tInInbox = '1',\n\t\t\t\t\tUnRead = '1',\n\t\t\t\t\tReceivedDate = '" . sqltime() . "'\n\t\t\t\tWHERE UserID IN (" . implode(',', $ToID) . ")\n\t\t\t\t\tAND ConvID = '{$ConvID}'"); G::$DB->query("\n\t\t\t\tUPDATE pm_conversations_users\n\t\t\t\tSET\n\t\t\t\t\tInSentbox = '1',\n\t\t\t\t\tSentDate = '" . sqltime() . "'\n\t\t\t\tWHERE UserID = '{$FromID}'\n\t\t\t\t\tAND ConvID = '{$ConvID}'"); } // Now that we have a $ConvID for sure, send the message. G::$DB->query("\n\t\t\tINSERT INTO pm_messages\n\t\t\t\t(SenderID, ConvID, SentDate, Body)\n\t\t\tVALUES\n\t\t\t\t('{$FromID}', '{$ConvID}', '" . sqltime() . "', '{$Body}')"); // Update the cached new message count. foreach ($ToID as $ID) { G::$DB->query("\n\t\t\t\tSELECT COUNT(ConvID)\n\t\t\t\tFROM pm_conversations_users\n\t\t\t\tWHERE UnRead = '1'\n\t\t\t\t\tAND UserID = '{$ID}'\n\t\t\t\t\tAND InInbox = '1'"); list($UnRead) = G::$DB->next_record(); G::$Cache->cache_value("inbox_new_{$ID}", $UnRead); } G::$DB->query("\n\t\t\tSELECT Username\n\t\t\tFROM users_main\n\t\t\tWHERE ID = '{$FromID}'"); list($SenderName) = G::$DB->next_record(); foreach ($ToID as $ID) { G::$DB->query("\n\t\t\t\tSELECT COUNT(ConvID)\n\t\t\t\tFROM pm_conversations_users\n\t\t\t\tWHERE UnRead = '1'\n\t\t\t\t\tAND UserID = '{$ID}'\n\t\t\t\t\tAND InInbox = '1'"); list($UnRead) = G::$DB->next_record(); G::$Cache->cache_value("inbox_new_{$ID}", $UnRead); NotificationsManager::send_push($ID, "Message from {$SenderName}, Subject: {$UnescapedSubject}", $UnescapedBody, site_url() . 'inbox.php', NotificationsManager::INBOX); } G::$DB->set_query_id($QueryID); return $ConvID; }
<?php if (!check_perms("users_mod")) { error(404); } if ($_POST['set']) { $Expiration = $_POST['length'] * 60; NotificationsManager::set_global_notification($_POST['message'], $_POST['url'], $_POST['importance'], $Expiration); } elseif ($_POST['delete']) { NotificationsManager::delete_global_notification(); } header("Location: tools.php?action=global_notification");
<?php $Skip = array(); $Skip[] = db_string($_GET['skip']); $NotificationsManager = new NotificationsManager($LoggedUser['ID'], $Skip); json_die("success", $NotificationsManager->get_notifications()); //echo '{"status":"success","response":[[{"message":"1st notification","url":"https:\/\/www.google.com\/","importance":"alert","AutoExpire":false},{"message":"2nd notification","url":"","importance":"alert","AutoExpire":true}]]}';
} else { $DB->query(" UPDATE lastfm_users SET Username = '******' WHERE ID = '$UserID'"); } } } elseif (!empty($LastFMUsername)) { $DB->query(" INSERT INTO lastfm_users (ID, Username) VALUES ('$UserID', '$LastFMUsername')"); } G::$Cache->delete_value("lastfm_username_$UserID"); Donations::update_rewards($UserID); NotificationsManager::save_settings($UserID); // Information on how the user likes to download torrents is stored in cache if ($DownloadAlt != $LoggedUser['DownloadAlt']) { $Cache->delete_value('user_'.$LoggedUser['torrent_pass']); } $Cache->begin_transaction("user_info_$UserID"); $Cache->update_row(false, array( 'Avatar' => display_str($_POST['avatar']), 'Paranoia' => $Paranoia )); $Cache->commit_transaction(0); $Cache->begin_transaction("user_info_heavy_$UserID"); $Cache->update_row(false, array(
function parse() { ?> <table class=tb> <tr> <td colspan="2" align="center"><span id="storagetext">正 在 推 送 信 息...</span></td> </tr> <tr> <td colspan="2" align="center">推送信息状态 <div id="refreshlentext" align="left"></div> </td> </tr> </table> <?php global $db, $parse_appid_restkey; $t_id = be("all", "ids"); if (!isN($t_id)) { $sql = "SELECT a.channels as channels, vod.d_remarks ,vod.d_state, a.id as id, vod.webUrls as webUrls, vod.d_type as d_type, vod.d_name as vod_name,vod.d_id as vod_id FROM {pre}vod_pasre_item a,{pre}vod vod where a.prod_id=vod.d_id AND id in (" . $t_id . ")"; $rs = $db->query($sql); $list = array(); while ($row = $db->fetch_array($rs)) { $msg = new Notification(); $id = $row["id"]; $vod_id = $row["vod_id"]; $d_type = $row["d_type"]; if (!isN($row["d_remarks"])) { $d_remarks = $row["d_remarks"]; } if (!isN($row["d_state"])) { $d_state = $row["d_state"]; } if ($d_type === '1') { $content = '亲,您想看的《' . $row["vod_name"] . '》已经上线啦,快来看看哦~'; } else { if ($d_type === '3') { $content = '亲,你关注的《' . $row["vod_name"] . '》有更新啦,'; if (!isN($d_state) && !isN($row["webUrls"])) { $itemArray = explode("{Array}", $row["webUrls"]); $flag = true; foreach ($itemArray as $itemName) { $nameUrls = explode("\$", $itemName); if (strpos($nameUrls[0], $d_state) !== false) { $names = trim(replaceStr($nameUrls[0], $d_state, '')); if ($names) { $flag = false; $content .= $names; break; } } } if ($flag) { $content = '亲,你关注的《' . $row["vod_name"] . '》更新到了' . $d_state . '期,快来收看吧~'; } } } else { if (!isN($d_state) && $d_state !== $d_remarks) { $content = '亲,你关注的《' . $row["vod_name"] . '》更新到了第' . $d_state . '集,快来收看吧~'; } else { $content = '亲,你关注的《' . $row["vod_name"] . '》已更新完结,快来收看吧~'; } } } $msg->alert = $content; $msg->prod_id = $vod_id; $msg->prod_type = $d_type; $msg->push_type = '2'; $msg->channels = array('CHANNEL_PROD_' . $vod_id); $channels = $row["channels"]; if (isN($channels)) { $appKeys = array_keys($parse_appid_restkey); $channels = implode(",", $appKeys); } else { $appKeys = explode(",", $channels); } $pushFlag = true; foreach ($appKeys as $appkey) { if ($appkey == null || trim($appkey) == '') { } else { $msg->appid = $parse_appid_restkey[$appkey]['appid']; $msg->restkey = $parse_appid_restkey[$appkey]['restkey']; $result = NotificationsManager::push($msg); if ($result['code'] . '' == '200') { $channels = replaceStr($channels, $appkey . ',', ''); $channels = replaceStr($channels, $appkey, ''); appendMsg($content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 成功 "); writetofile("parsemsg.log", $content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 成功 "); } else { $pushFlag = false; appendMsg($content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 失败:" . $result['response']); writetofile("parsemsg.log", $content . "====消息推送 到 [" . $parse_appid_restkey[$appkey]['appname'] . "] 失败:" . $result['response']); } } } if ($pushFlag) { $list[] = $id; } else { $db->query("update {pre}vod_pasre_item set channels='" . $channels . "' where id in (" . $id . ")"); } } unset($rs); if (is_array($list) && count($list) > 0) { $ids = implode(",", $list); $db->query('delete from {pre}vod_pasre_item where id in (' . $ids . ')'); } echo "推送完毕"; } else { echo "你至少需要选择一个视频"; } }
/> <label for="autosubscribe">Enable automatic thread subscriptions</label> </td> </tr> <tr id="notif_unseeded_tr"> <td class="label tooltip" title="Enabling this will send you a PM alert before your uploads are deleted for being unseeded."><strong>Unseeded torrent alerts</strong></td> <td> <input type="checkbox" name="unseededalerts" id="unseededalerts"<?php echo checked($UnseededAlerts); ?> /> <label for="unseededalerts">Enable unseeded torrent alerts</label> </td> </tr> <?php NotificationsManagerView::render_settings(NotificationsManager::get_settings($UserID)); ?> </table> <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="personal_settings"> <tr class="colhead_dark"> <td colspan="2"> <strong>Personal Settings</strong> </td> </tr> <tr id="pers_avatar_tr"> <td class="label tooltip_interactive" title="Please link to an avatar which follows the <a href="rules.php">site rules</a>. The avatar width should be 150 pixels and will be resized if necessary." data-title-plain="Please link to an avatar which follows the site rules. The avatar width should be 150 pixels and will be resized if necessary."><strong>Avatar URL</strong></td> <td> <input type="text" size="50" name="avatar" id="avatar" value="<?php echo display_str($Avatar); ?> " />
if ($LoggedUser['BytesUploaded'] >= $Amount && $Filled === '0') { // Create vote! $DB->query("\n\t\tINSERT IGNORE INTO requests_votes\n\t\t\t(RequestID, UserID, Bounty)\n\t\tVALUES\n\t\t\t({$RequestID}, " . $LoggedUser['ID'] . ", {$Bounty})"); if ($DB->affected_rows() < 1) { //Insert failed, probably a dupe vote, just increase their bounty. $DB->query("\n\t\t\t\tUPDATE requests_votes\n\t\t\t\tSET Bounty = (Bounty + {$Bounty})\n\t\t\t\tWHERE UserID = " . $LoggedUser['ID'] . "\n\t\t\t\t\tAND RequestID = {$RequestID}"); echo 'dupe'; } $DB->query("\n\t\tUPDATE requests\n\t\tSET LastVote = NOW()\n\t\tWHERE ID = {$RequestID}"); $Cache->delete_value("request_{$RequestID}"); $Cache->delete_value("request_votes_{$RequestID}"); $ArtistForm = Requests::get_artists($RequestID); foreach ($ArtistForm as $Importance) { foreach ($Importance as $Artist) { $Cache->delete_value('artists_requests_' . $Artist['id']); } } // Subtract amount from user $DB->query("\n\t\tUPDATE users_main\n\t\tSET Uploaded = (Uploaded - {$Amount})\n\t\tWHERE ID = " . $LoggedUser['ID']); $Cache->delete_value('user_stats_' . $LoggedUser['ID']); Requests::update_sphinx_requests($RequestID); echo 'success'; $DB->query("\n\t\tSELECT UserID\n\t\tFROM requests_votes\n\t\tWHERE RequestID = '{$RequestID}'\n\t\t\tAND UserID != '{$LoggedUser['ID']}'"); $UserIDs = array(); while (list($UserID) = $DB->next_record()) { $UserIDs[] = $UserID; } NotificationsManager::notify_users($UserIDs, NotificationsManager::REQUESTALERTS, Format::get_size($Amount) . " of bounty has been added to a request you've voted on!", "requests.php?action=view&id=" . $RequestID); } elseif ($LoggedUser['BytesUploaded'] < $Amount) { echo 'bankrupt'; }
} } if ($OldSticky != $Sticky) { if (!$OldSticky) { $TopicNotes[] = 'Stickied'; } else { $TopicNotes[] = 'Unstickied'; } } if ($OldRanking != $Ranking) { $TopicNotes[] = "Ranking changed from \"{$OldRanking}\" to \"{$Ranking}\""; } if ($ForumID != $OldForumID) { $TopicNotes[] = "Moved from [url=" . site_url() . "forums.php?action=viewforum&forumid={$OldForumID}]{$OldForumName}[/url] to [url=" . site_url() . "forums.php?action=viewforum&forumid={$ForumID}]{$ForumName}[/url]"; } break; case 'trashing': $TopicNotes[] = "Trashed (moved from [url=" . site_url() . "forums.php?action=viewforum&forumid={$OldForumID}]{$OldForumName}[/url] to [url=" . site_url() . "forums.php?action=viewforum&forumid={$ForumID}]{$ForumName}[/url])"; $Notification = "Your thread \"{$NewLastTitle}\" has been trashed"; break; default: break; } if (isset($Notification)) { NotificationsManager::notify_user($ThreadAuthorID, NotificationsManager::FORUMALERTS, $Notification, "forums.php?action=viewthread&threadid={$TopicID}"); } if (count($TopicNotes) > 0) { Forums::add_topic_note($TopicID, implode("\n", $TopicNotes)); } header("Location: forums.php?action=viewthread&threadid={$TopicID}&page={$Page}"); }
<?php authorize(); if (!check_perms('users_mod') && $_GET['userid'] != $LoggedUser['ID']) { error(403); } $UserID = db_string($_GET['userid']); NotificationsManager::send_push($UserID, 'Push!', 'You\'ve been pushed by ' . $LoggedUser['Username']); header('Location: user.php?action=edit&userid=' . $UserID . "");
break; case NotificationsManager::NEWS: NotificationsManager::clear_news(); break; case NotificationsManager::BLOG: NotificationsManager::clear_blog(); break; case NotificationsManager::STAFFPM: NotificationsManager::clear_staff_pms(); break; case NotificationsManager::TORRENTS: NotificationsManager::clear_torrents(); break; case NotificationsManager::QUOTES: NotificationsManager::clear_quotes(); break; case NotificationsManager::SUBSCRIPTIONS: NotificationsManager::clear_subscriptions(); break; case NotificationsManager::COLLAGES: NotificationsManager::clear_collages(); break; case NotificationsManager::GLOBALNOTICE: NotificationsManager::clear_global_notification(); break; default: break; } if (strpos($Type, "oneread_") === 0) { NotificationsManager::clear_one_read($Type); }
function _EDIT_EMAIL_TEMPLATE() { global $templateid; JToolBarHelper::title(_JOOMLMS_COMP_NAME . ':' . ($templateid ? _JLMS_NOTS_EDIT_EML_TPL : _JLMS_NOTS_NEW_EML_TPL), 'config.png'); $id = intval(mosGetParam($_REQUEST, 'id', 0)); $native = NotificationsManager::getNativeEmailTemplate($id); if (!$native) { JToolBarHelper::save('save_email_template'); JToolBarHelper::spacer(); JToolBarHelper::apply('apply_email_template', _JLMS_APPLY); JToolBarHelper::spacer(); } JToolBarHelper::cancel('email_templates'); JToolBarHelper::spacer(); }
static function pushBaidu($notifyMsg) { if ($notifyMsg->type === NotificationsManager::DEVICE_ISO) { $channel = NotificationsManager::initBaiduCertIOS($notifyMsg); } else { $channel = new Channel($notifyMsg->appid, $notifyMsg->restkey); } $message_key = md5(date('Y-m-d-H-M-S', time())); $optional[Channel::MESSAGE_TYPE] = 1; // if(isset($notifyMsg->channels) && is_array($notifyMsg->channels) && count($notifyMsg->channels)>0){ // $push_type = 2; // }else { // $push_type = 3; //推送广播消息 // } $push_type = 3; $message = array(); if ($notifyMsg->type === NotificationsManager::DEVICE_ISO) { $optional[Channel::DEVICE_TYPE] = 4; $apps = array(); if (isset($notifyMsg->title) && !is_null($notifyMsg->title)) { $message['title'] = $notifyMsg->title; } $optional[Channel::DEVICE_TYPE] = 4; if (isset($notifyMsg->prod_id) && !is_null($notifyMsg->prod_id)) { $message['prod_id'] = $notifyMsg->prod_id; } if (isset($notifyMsg->prod_type) && !is_null($notifyMsg->prod_type)) { $message['prod_type'] = $notifyMsg->prod_type; } if (isset($notifyMsg->push_type) && !is_null($notifyMsg->push_type)) { $message['push_type'] = $notifyMsg->push_type; } if (isset($notifyMsg->alert) && !is_null($notifyMsg->alert)) { $apps['alert'] = $notifyMsg->alert; } $apps['Sound'] = ''; $apps['Badge'] = 0; $message['aps'] = $apps; } else { if ($notifyMsg->type === NotificationsManager::DEVICE_ANDROID) { $custom_content = array(); if (isset($notifyMsg->title) && !is_null($notifyMsg->title)) { $message['title'] = $notifyMsg->title; } $optional[Channel::DEVICE_TYPE] = 3; if (isset($notifyMsg->prod_id) && !is_null($notifyMsg->prod_id)) { $custom_content['prod_id'] = $notifyMsg->prod_id; } if (isset($notifyMsg->prod_type) && !is_null($notifyMsg->prod_type)) { $custom_content['prod_type'] = $notifyMsg->prod_type; } if (isset($notifyMsg->push_type) && !is_null($notifyMsg->push_type)) { $custom_content['push_type'] = $notifyMsg->push_type; } if (isset($notifyMsg->alert) && !is_null($notifyMsg->alert)) { $message['description'] = $notifyMsg->alert; } $message['custom_content'] = $custom_content; } } // var_dump($message); var_dump($optional); $ret = $channel->pushMessage($push_type, $message, $message_key, $optional); if (false === $ret) { return array('code' => '201', 'response' => $channel->errmsg()); } else { return array('code' => '200', 'response' => $ret); } }
function notifyMsg() { $d_id = be("get", "prod_id"); $prod_type = be("get", "prod_type"); $device_type = be("get", "device_type"); $content = be("get", "content"); $msg = new Notification(); $msg->alert = $content; $msg->prod_id = $d_id; $msg->prod_type = $prod_type; if (isset($device_type) && !is_null($device_type)) { $msg->type = $device_type; } // $msg->action='com.joyplus.UPDATE_PROGRAM'; //$manager = new NotificationsManager(); $result = NotificationsManager::push($msg); // var_dump($result['response']); if ($result['code'] . '' == '200') { echo "消息推送成功"; } else { echo "消息推送失败:" . $result['response']; } }
function getEmailTemplate($id) { static $templates; if (!isset($templates[$id])) { $db = JFactory::getDBO(); $nativeEmailTemplate = NotificationsManager::getNativeEmailTemplate($id); if ($nativeEmailTemplate) { $row = new stdClass(); $row->id = $nativeEmailTemplate->id; $row->name = isset($nativeEmailTemplate->name) ? $nativeEmailTemplate->name : ''; $row->subject = isset($nativeEmailTemplate->subject) ? $nativeEmailTemplate->subject : ''; $row->template_html = $nativeEmailTemplate->template_html; $row->template_alt_text = isset($nativeEmailTemplate->template_alt_text) ? $nativeEmailTemplate->template_alt_text : ''; $row->disabled = false; $row->native = true; $row->notification_type = $nativeEmailTemplate->notification_type; } else { $sql = "SELECT id, name, body_html AS template_html, body_text AS template_alt_text, notification_type, subject, disabled, '0' AS native FROM #__lms_email_templates WHERE id = '" . $id . "'"; $db->setQuery($sql); $row = $db->loadObject(); } $templates[$id] = $row; } return php4_clone($templates[$id]); }
<?php if (!check_perms("users_mod")) { error(404); } View::show_header("Global Notification"); $GlobalNotification = NotificationsManager::get_global_notification(); $Expiration = $GlobalNotification['Expiration'] ? $GlobalNotification['Expiration'] / 60 : ""; ?> <h2>Set global notification</h2> <div class="thin box pad"> <form action="tools.php" method="post"> <input type="hidden" name="action" value="take_global_notification" /> <input type="hidden" name="type" value="set" /> <table align="center"> <tr> <td class="label">Message</td> <td> <input type="text" name="message" id="message" size="50" value="<?php echo $GlobalNotification['Message']; ?> " /> </td> </tr> <tr> <td class="label">URL</td> <td> <input type="text" name="url" id="url" size="50" value="<?php echo $GlobalNotification['URL'];
function notifyMsg() { $d_id = be("all", "notify_msg_prod_id"); $prod_type = be("all", "notify_msg_prod_type"); global $parse_appid_restkey, $parse_appid_restkey_baidu; $can_search_device = be("all", "channel"); if (!isN($can_search_device)) { $content = be("all", "content"); $msg = new Notification(); $msg->alert = $content; $msg->prod_id = $d_id; $msg->prod_type = $prod_type; $msg->push_type = '1'; $msg->channels = explode(",", $can_search_device); $isoFlag = false; $androidFlag = false; if (strpos($can_search_device, 'CHANNEL_ANDROID') !== false || strpos($can_search_device, 'CHANNEL_TV') !== false) { $androidFlag = true; } if (strpos($can_search_device, 'CHANNEL_IOS') !== false || strpos($can_search_device, 'CHANNEL_IPAD') !== false || strpos($can_search_device, 'CHANNEL_IPHONE') !== false) { $isoFlag = true; } if ($isoFlag && !$androidFlag) { $msg->type = NotificationsManager::DEVICE_ISO; } if ($androidFlag && !$isoFlag) { $msg->type = NotificationsManager::DEVICE_ANDROID; } if (strpos($can_search_device, '_BAIDU') === false) { $appname = $parse_appid_restkey[$can_search_device]['appname']; $msg->appid = $parse_appid_restkey[$can_search_device]['appid']; $msg->restkey = $parse_appid_restkey[$can_search_device]['restkey']; $result = NotificationsManager::push($msg); $appname = $parse_appid_restkey[$can_search_device]['appname']; } else { if ($isoFlag && !$androidFlag) { $msg->iosCertPath = $parse_appid_restkey_baidu[$can_search_device]['iosCertPath']; $msg->iosCertPathRel = $parse_appid_restkey_baidu[$can_search_device]['iosCertPathRel']; } $appname = $parse_appid_restkey_baidu[$can_search_device]['appname']; $msg->appid = $parse_appid_restkey_baidu[$can_search_device]['appid']; $msg->restkey = $parse_appid_restkey_baidu[$can_search_device]['restkey']; // var_dump($parse_appid_restkey_baidu); $result = NotificationsManager::pushBaidu($msg); } if ($result['code'] . '' == '200') { echo "消息推送到 [" . $appname . "] 成功"; } else { echo "消息推送到 [" . $appname . "] 失败:" . $result['response']; } } else { echo "你必须要选择一个频道发送"; } }
" type="text/javascript"></script> <?php } if ($Mobile) { ?> <script src="<?php echo STATIC_SERVER; ?> styles/mobile/style.js" type="text/javascript"></script> <?php } global $ClassLevels; // Get notifications early to change menu items if needed global $NotificationSpans; $NotificationsManager = new NotificationsManager(G::$LoggedUser['ID']); $Notifications = $NotificationsManager->get_notifications(); $UseNoty = $NotificationsManager->use_noty(); $NewSubscriptions = false; $NotificationSpans = array(); foreach ($Notifications as $Type => $Notification) { if ($Type === NotificationsManager::SUBSCRIPTIONS) { $NewSubscriptions = true; } if ($UseNoty) { $NotificationSpans[] = "<span class=\"noty-notification\" style=\"display: none;\" data-noty-type=\"{$Type}\" data-noty-id=\"{$Notification['id']}\" data-noty-importance=\"{$Notification['importance']}\" data-noty-url=\"{$Notification['url']}\">{$Notification['message']}</span>"; } } if ($UseNoty && !empty($NotificationSpans)) { NotificationsManagerView::load_js(); }
} else { $ThreadID = Misc::create_thread(ANNOUNCEMENT_FORUM_ID, $LoggedUser[ID], $Title, $Body); if ($ThreadID < 1) { error(0); } } $DB->query("\n\t\t\t\t\tINSERT INTO blog\n\t\t\t\t\t\t(UserID, Title, Body, Time, ThreadID, Important)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $LoggedUser['ID'] . "',\n\t\t\t\t\t\t'" . db_string($_POST['title']) . "',\n\t\t\t\t\t\t'" . db_string($_POST['body']) . "',\n\t\t\t\t\t\t'" . sqltime() . "',\n\t\t\t\t\t\t{$ThreadID},\n\t\t\t\t\t\t'" . ($_POST['important'] == '1' ? '1' : '0') . "')"); $Cache->delete_value('blog'); if ($_POST['important'] == '1') { $Cache->delete_value('blog_latest_id'); } if (isset($_POST['subscribe'])) { $DB->query("\n\t\t\t\t\t\tINSERT IGNORE INTO users_subscriptions\n\t\t\t\t\t\tVALUES ('{$LoggedUser['ID']}', {$ThreadID})"); $Cache->delete_value('subscriptions_user_' . $LoggedUser['ID']); } NotificationsManager::send_push(NotificationsManager::get_push_enabled_users(), $_POST['title'], $_POST['body'], site_url() . 'index.php', NotificationsManager::BLOG); header('Location: blog.php'); break; } } ?> <div class="box thin"> <div class="head"> <?php echo empty($_GET['action']) ? 'Create a blog post' : 'Edit blog post'; ?> </div> <form class="<?php echo empty($_GET['action']) ? 'create_form' : 'edit_form'; ?> " name="blog_post" action="blog.php" method="post">
function sendNotification($params) { $db = JFactory::getDBO(); $mailManager =& MailManager::getChildInstance(); $app = JFactory::getApplication(); $notification_event = NotificationsManager::getNotificationEventByActionName($params['action_name']); if (!$notification_event) { return ''; } if (!isset($params['sender'])) { $params['sender'] = array($app->getCfg('mailfrom'), $app->getCfg('fromname')); } $sql = "SELECT learner_template, manager_template, selected_manager_roles, learner_template_disabled, manager_template_disabled, disabled FROM #__lms_email_notifications WHERE id = " . $db->quote($notification_event->id); $db->setQuery($sql); $row = $db->loadObject(); if ($row) { $notification_event->disabled = $row->disabled; $notification_event->learner_template = $row->learner_template; $notification_event->manager_template = $row->manager_template; $notification_event->learner_template_disabled = $row->learner_template_disabled; $notification_event->manager_template_disabled = $row->manager_template_disabled; $notification_event->selected_manager_roles = explode(',', $row->selected_manager_roles); } if ($notification_event->disabled || !$notification_event->learner_template && !$notification_event->manager_template) { return ''; } $learner_template = ''; $manager_template = ''; if ($notification_event->learner_template) { $learner_template = NotificationsManager::getEmailTemplate($notification_event->learner_template); } if ($notification_event->manager_template) { $manager_template = NotificationsManager::getEmailTemplate($notification_event->manager_template); } if (!is_object($learner_template) && !is_object($manager_template)) { return ''; } if (isset($params['markers']) && is_array($params['markers'])) { $params['markers'] = NotificationsManager::addDateTimeMarkers($params['markers']); } else { $params['markers'] = NotificationsManager::addDateTimeMarkers(array()); } if (isset($params['markers']) && count($params['markers'])) { $markers_keys = array_keys($params['markers']); $markers_values = array_values($params['markers']); if (isset($params['markers_nohtml']) && is_array($params['markers_nohtml'])) { $markers_nohtml_keys = array_keys($params['markers_nohtml']); $markers_nohtml_values = array_values($params['markers_nohtml']); } else { $markers_nohtml_keys = array(); $markers_nohtml_values = array(); } if (is_object($learner_template) && $notification_event->learner_template && $notification_event->use_learner_template) { $learner_template->subject = str_replace($markers_keys, $markers_values, $learner_template->subject); $learner_template->template_html = str_replace($markers_keys, $markers_values, $learner_template->template_html); $learner_template->template_alt_text = str_replace($markers_nohtml_keys, $markers_nohtml_values, $learner_template->template_alt_text); $learner_template->template_alt_text = str_replace($markers_keys, $markers_values, $learner_template->template_alt_text); } if (is_object($manager_template) && $notification_event->manager_template && $notification_event->use_manager_template && !$notification_event->skip_managers) { $manager_template->subject = str_replace($markers_keys, $markers_values, $manager_template->subject); $manager_template->template_html = str_replace($markers_keys, $markers_values, $manager_template->template_html); $manager_template->template_alt_text = str_replace($markers_nohtml_keys, $markers_nohtml_values, $manager_template->template_alt_text); $manager_template->template_alt_text = str_replace($markers_keys, $markers_values, $manager_template->template_alt_text); } } if (isset($params['wrappers']) && count($params['wrappers'])) { if (is_object($learner_template) && $notification_event->learner_template && $notification_event->use_learner_template) { $learner_template->subject = NotificationsManager::replaceWrappers($params['wrappers'], $learner_template->subject); $learner_template->template_html = NotificationsManager::replaceWrappers($params['wrappers'], $learner_template->template_html); $learner_template->template_alt_text = NotificationsManager::replaceWrappers($params['wrappers'], $learner_template->template_alt_text); } if (is_object($manager_template) && $notification_event->manager_template && $notification_event->use_manager_template && !$notification_event->skip_managers) { $manager_template->subject = NotificationsManager::replaceWrappers($params['wrappers'], $manager_template->subject); $manager_template->template_html = NotificationsManager::replaceWrappers($params['wrappers'], $manager_template->template_html); $manager_template->template_alt_text = NotificationsManager::replaceWrappers($params['wrappers'], $manager_template->template_alt_text); } } $managers_array = array(); $already_sent_users = array(); if (is_object($learner_template) && $notification_event->use_learner_template && !$notification_event->learner_template_disabled) { if (isset($params['user_id']) && $params['user_id']) { $sql = "SELECT email, name FROM #__users WHERE id = " . $db->quote($params['user_id']); $db->setQuery($sql); $user = $db->loadObject(); $params['recipient'] = $user->email; //array( $user->name, $user->email ); $params['subject'] = $learner_template->subject; $params['body'] = $learner_template->template_html; $params['alttext'] = $learner_template->template_alt_text; if (isset($notification_event->notification_type) && $notification_event->notification_type == 2) { $params['attachment']->file_source = getCertificateFile($params); $params['attachment']->file_name = 'Certificate.png'; } $mailManager->prepareEmail($params); $mailManager->sendEmail(); $already_sent_users[] = intval($params['user_id']); unset($params['attachment']); } } if (is_object($manager_template) && $notification_event->use_manager_template && !$notification_event->manager_template_disabled && !$notification_event->skip_managers) { if (isset($params['course_id']) && $params['course_id'] && isset($notification_event->selected_manager_roles[0])) { $all_teachers_role_ids = JLMS_ACL_HELPER::getTeachersRoleIds(); $teachers_role_ids = array_intersect($notification_event->selected_manager_roles, $all_teachers_role_ids); $teachers = JLMS_ACL_HELPER::getCourseTeachers($params['course_id'], $teachers_role_ids); $all_assistans_role_ids = JLMS_ACL_HELPER::getAssistansRolesIds(); $assistans_role_ids = array_intersect($notification_event->selected_manager_roles, $all_assistans_role_ids); $teachers = JLMS_ACL_HELPER::getCourseTeachers($params['course_id'], $teachers_role_ids); $assistans = JLMS_ACL_HELPER::getCourseAssistans($params['course_id'], $assistans_role_ids); if (isset($teachers[0])) { foreach ($teachers as $teacher) { if (!in_array($teacher->id, $already_sent_users)) { $params['recipient'] = $teacher->email; //array( $teacher->name, $teacher->email ); $params['subject'] = $manager_template->subject; $params['body'] = $manager_template->template_html; $params['alttext'] = $manager_template->template_alt_text; $mailManager->prepareEmail($params); $mailManager->sendEmail(); $already_sent_users[] = $teacher->id; } } } if (isset($assistans[0])) { foreach ($assistans as $assistan) { if (!in_array($assistan->id, $already_sent_users)) { $params['recipient'] = $assistan->email; //array( $assistan->name, $assistan->email ); $params['subject'] = $manager_template->subject; $params['body'] = $manager_template->template_html; $params['alttext'] = $manager_template->template_alt_text; $mailManager->prepareEmail($params); $mailManager->sendEmail(); $already_sent_users[] = $assistan->id; } } } } if (isset($params['user_id']) && $params['user_id'] && isset($notification_event->selected_manager_roles[0])) { $all_CEO_role_ids = JLMS_ACL_HELPER::getCEORoleIds(); $CEO_role_ids = array_intersect($notification_event->selected_manager_roles, $all_CEO_role_ids); $all_user_CEO = JLMS_ACL_HELPER::getUserCEO($params['user_id'], $CEO_role_ids); if (isset($all_user_CEO[0])) { foreach ($all_user_CEO as $CEO) { if (!in_array($CEO->id, $already_sent_users)) { $params['recipient'] = $CEO->email; //array( $CEO->name, $CEO->email ); $params['subject'] = $manager_template->subject; $params['body'] = $manager_template->template_html; $params['alttext'] = $manager_template->template_alt_text; $mailManager->prepareEmail($params); $mailManager->sendEmail(); $already_sent_users[] = $CEO->id; } } } } if (isset($notification_event->selected_manager_roles[0])) { $all_admin_role_ids = JLMS_ACL_HELPER::getAdminsRoleIds(); $admin_role_ids = array_intersect($notification_event->selected_manager_roles, $all_admin_role_ids); $admins = JLMS_ACL_HELPER::getAdmins($admin_role_ids); if (isset($admins[0])) { foreach ($admins as $admin) { if (!in_array($admin->id, $already_sent_users)) { $params['recipient'] = $admin->email; //array( $admin->name, $admin->email ); $params['subject'] = $manager_template->subject; $params['body'] = $manager_template->template_html; $params['alttext'] = $manager_template->template_alt_text; $mailManager->prepareEmail($params); $mailManager->sendEmail(); $already_sent_users[] = $admin->id; } } } } } }