예제 #1
0
 public function sendNotificationToWatchUsersOnMessage(array $post, array $thread = null, array $noAlerts = array(), array $noEmail = array())
 {
     $result = parent::sendNotificationToWatchUsersOnMessage($post, $thread, $noAlerts, $noEmail);
     Tinhte_XenTag_Integration::updateNoEmailAndAlert('post', $post['post_id'], $noEmail, $noAlerts);
     $emailed = array();
     if (!empty($result['emailed'])) {
         $emailed = $result['emailed'];
     }
     $alerted = array();
     if (!empty($result['alerted'])) {
         $alerted = $result['alerted'];
     }
     Tinhte_XenTag_Integration::updateNoEmailAndAlert('post', $post['post_id'], $emailed, $alerted);
     return $result;
 }
예제 #2
0
파일: TagWatch.php 프로젝트: Sywooch/forums
 public function sendNotificationToWatchUsersOnTagged($tag, array $contentData = array(), array $contentPermissionConfig = array())
 {
     $userModel = $this->getModelFromCache('XenForo_Model_User');
     list($noEmail, $noAlert) = Tinhte_XenTag_Integration::getNoEmailAndAlert($contentData['content_type'], $contentData['content_id']);
     $emailed = array();
     $alerted = array();
     $emailTemplate = 'tinhte_xentag_watch_tag_' . $contentData['content_type'];
     if (XenForo_Application::get('options')->emailWatchedThreadIncludeMessage) {
         $parseBbCode = true;
     } else {
         $parseBbCode = false;
     }
     // fetch a full user record if we don't have one already
     if (!isset($contentData['avatar_width']) or !isset($contentData['custom_title'])) {
         $contentUser = $userModel->getUserById($contentData['user_id']);
         if ($contentUser) {
             $contentData = array_merge($contentUser, $contentData);
         } else {
             $contentData['avatar_width'] = 0;
             $contentData['custom_title'] = '';
         }
     }
     if (!empty($contentPermissionConfig['content_type']) and !empty($contentPermissionConfig['content_id'])) {
         $users = $this->getUsersWatchingTag($tag['tag_id'], $contentPermissionConfig['content_type'], $contentPermissionConfig['content_id']);
     } else {
         $users = $this->getUsersWatchingTag($tag['tag_id']);
     }
     foreach ($users as $user) {
         if ($user['user_id'] == $contentData['user_id']) {
             // self notification? That's silly
             continue;
         }
         if ($userModel->isUserIgnored($user, $contentData['user_id'])) {
             continue;
         }
         $globalPermissions = XenForo_Permission::unserializePermissions($user['global_permission_cache']);
         if (!XenForo_Permission::hasPermission($globalPermissions, 'general', Tinhte_XenTag_Constants::PERM_USER_WATCH)) {
             // no tag watch permission (or revoked)
             continue;
         }
         if (!empty($contentPermissionConfig['content_type']) and !empty($contentPermissionConfig['content_id']) and !empty($contentPermissionConfig['permissions'])) {
             $contentPermissions = XenForo_Permission::unserializePermissions($user['content_permission_cache']);
             $contentPermissionFound = true;
             foreach ($contentPermissionConfig['permissions'] as $contentPermissionRequired) {
                 if (!XenForo_Permission::hasContentPermission($contentPermissions, $contentPermissionRequired)) {
                     $contentPermissionFound = false;
                 }
             }
             if (!$contentPermissionFound) {
                 // no content permission
                 continue;
             }
         }
         if ($user['send_email'] and $user['email'] and $user['user_state'] == 'valid' and !in_array($user['user_id'], $noEmail)) {
             if (!empty($contentData['message']) and !isset($contentData['messageText']) and $parseBbCode) {
                 $bbCodeParserText = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Text'));
                 $contentData['messageText'] = new XenForo_BbCode_TextWrapper($contentData['message'], $bbCodeParserText);
                 $bbCodeParserHtml = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('HtmlEmail'));
                 $contentData['messageHtml'] = new XenForo_BbCode_TextWrapper($contentData['message'], $bbCodeParserHtml);
             }
             if (!empty($contentData['title']) and !isset($contentData['titleCensored'])) {
                 $contentData['titleCensored'] = XenForo_Helper_String::censorString($contentData['title']);
             }
             $user['email_confirm_key'] = $userModel->getUserEmailConfirmKey($user);
             $mail = XenForo_Mail::create($emailTemplate, array('tag' => $tag, 'contentType' => $contentData['content_type'], 'contentId' => $contentData['content_id'], 'contentData' => $contentData, 'receiver' => $user), $user['language_id']);
             $mail->enableAllLanguagePreCache();
             $mail->queue($user['email'], $user['username']);
             $emailed[] = $user['user_id'];
         }
         if ($user['send_alert'] and !in_array($user['user_id'], $noAlert)) {
             call_user_func_array(array('XenForo_Model_Alert', 'alert'), array($user['user_id'], $contentData['user_id'], $contentData['username'], $contentData['content_type'], $contentData['content_id'], 'tinhte_xentag_tag_watch', array('tag' => $tag)));
             $alerted[] = $user['user_id'];
         }
     }
     Tinhte_XenTag_Integration::updateNoEmailAndAlert($contentData['content_type'], $contentData['content_id'], $emailed, $alerted);
 }