Ejemplo n.º 1
0
 protected function _getTagMatchUsers(array $matches)
 {
     $usersByMatch = parent::_getTagMatchUsers($matches);
     if (bdTagMe_Option::get('groupTag')) {
         $engine = bdTagMe_Engine::getInstance();
         $taggableUserGroups = $engine->getTaggableUserGroups();
         $matchesToLower = array();
         foreach ($matches as $key => $match) {
             $matchesToLower[$key] = utf8_strtolower($match[1][0]);
         }
         $userGroupTitlesToLower = array();
         foreach ($taggableUserGroups as $taggableUserGroup) {
             $userGroupTitlesToLower[$taggableUserGroup['user_group_id']] = utf8_strtolower($taggableUserGroup['title']);
         }
         $changedMatchKeys = array();
         foreach ($userGroupTitlesToLower as $userGroupId => $userGroupTitleToLower) {
             foreach ($matchesToLower as $matchKey => $matchToLower) {
                 if (strpos($userGroupTitleToLower, $matchToLower) === 0) {
                     $userGroupInfo = array('user_id' => 'ug_' . $userGroupId, 'username' => $taggableUserGroups[$userGroupId]['title'], 'lower' => $userGroupTitleToLower, 'user_group_id' => $userGroupId);
                     $usersByMatch[$matchKey][$userGroupInfo['user_id']] = $userGroupInfo;
                     $changedMatchKeys[$matchKey] = true;
                 }
             }
         }
         foreach (array_keys($changedMatchKeys) as $matchKey) {
             uasort($usersByMatch[$matchKey], array(__CLASS__, 'sortByLowerLength'));
         }
     }
     return $usersByMatch;
 }
Ejemplo n.º 2
0
 public function actionBdtagmeFind()
 {
     if (bdTagMe_Option::get('reorder')) {
         /** @var bdTagMe_XenForo_Model_User $userModel */
         $userModel = $this->_getUserModel();
         $userModel->bdTagMe_setOrderByMemberActivity(true);
     }
     $response = parent::actionFind();
     if ($response instanceof XenForo_ControllerResponse_View) {
         $users =& $response->params['users'];
         $q = utf8_strtolower($this->_input->filterSingle('q', XenForo_Input::STRING));
         if (!empty($q) and bdTagMe_Option::get('groupTag')) {
             $userGroups = bdTagMe_Engine::getInstance()->getTaggableUserGroups();
             $userGroupTitlesToLower = array();
             foreach ($userGroups as $userGroup) {
                 $userGroupTitlesToLower[$userGroup['user_group_id']] = utf8_strtolower($userGroup['title']);
             }
             foreach ($userGroupTitlesToLower as $userGroupId => $userGroupTitleToLower) {
                 if (strpos($userGroupTitleToLower, $q) === 0) {
                     // run extra check to eliminate users with matching username with this user group
                     foreach (array_keys($users) as $userId) {
                         if (utf8_strtolower($users[$userId]['username']) == $userGroupTitleToLower) {
                             unset($users[$userId]);
                         }
                     }
                     array_unshift($users, array('user_id' => -1, 'username' => $userGroups[$userGroupId]['title'], 'gravatar' => bdTagMe_Option::get('userGroupGravatar')));
                 }
             }
         }
     }
     return $response;
 }
Ejemplo n.º 3
0
 public function bdTagMe_actionContactDetailsSave(XenForo_DataWriter_User $dw)
 {
     if (bdTagMe_Option::get('alertEmail')) {
         $settings = $this->_input->filter(array('bdtagme_email' => XenForo_Input::UINT));
         $dw->bulkSet($settings);
     }
     unset($GLOBALS['bdTagMe_XenForo_ControllerPublic_Account#actionContactDetailsSave']);
 }
Ejemplo n.º 4
0
 public function notifyUserIds($contentType, $contentId, $contentUserId, $contentUserName, $alertAction, array $userIds, array $noAlertUserIds, array $noEmailUserIds, XenForo_Model_User $userModel, array $options)
 {
     if (!empty($userIds)) {
         $fetchOptions = array();
         if (!empty($options['users']['fetchOptions'])) {
             $fetchOptions = $options['users']['fetchOptions'];
         }
         if (empty($fetchOptions['join'])) {
             $fetchOptions['join'] = 0;
         }
         $fetchOptions['join'] |= XenForo_Model_User::FETCH_USER_OPTION;
         $fetchOptions['join'] |= XenForo_Model_User::FETCH_USER_PROFILE;
         $users = $userModel->getUsersByIds($userIds, $fetchOptions);
     } else {
         $users = array();
     }
     foreach ($users as $user) {
         if ($user['user_id'] == $contentUserId) {
             // it's stupid to notify one's self
             continue;
         }
         if (!empty($options[self::OPTION_USER_CALLBACK])) {
             $userCallbackResult = call_user_func($options[self::OPTION_USER_CALLBACK], $userModel, $user, $options);
             if ($userCallbackResult === false) {
                 // user callback returns false, do not continue
                 continue;
             }
         }
         if (!$userModel->isUserIgnored($user, $contentUserId)) {
             $shouldAlert = true;
             if (!XenForo_Model_Alert::userReceivesAlert($user, $contentType, $alertAction)) {
                 $shouldAlert = false;
             }
             if (in_array($user['user_id'], $noAlertUserIds) || in_array($user['user_id'], $noEmailUserIds)) {
                 $shouldAlert = false;
             }
             if ($shouldAlert) {
                 XenForo_Model_Alert::alert($user['user_id'], $contentUserId, $contentUserName, $contentType, $contentId, $alertAction);
             }
             if (bdTagMe_Option::get('alertEmail') && !empty($user['bdtagme_email'])) {
                 $shouldEmail = true;
                 if (in_array($user['user_id'], $noEmailUserIds)) {
                     $shouldEmail = false;
                 }
                 if ($shouldEmail) {
                     /** @var bdTagMe_XenForo_Model_Alert $alertModel */
                     $alertModel = $userModel->getModelFromCache('XenForo_Model_Alert');
                     $viewLink = $alertModel->bdTagMe_getContentLink($contentType, $contentId);
                     if (!empty($viewLink)) {
                         $mail = XenForo_Mail::create('bdtagme_tagged', array('sender' => array('user_id' => $contentUserId, 'username' => $contentUserName), 'receiver' => $user, 'contentType' => $contentType, 'contentId' => $contentId, 'viewLink' => $viewLink), $user['language_id']);
                         $mail->enableAllLanguagePreCache();
                         $mail->queue($user['email'], $user['username']);
                     }
                 }
             }
         }
     }
     return true;
 }