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; }
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; }
public function bdTagMe_actionSave(XenForo_DataWriter_UserGroup $dw) { $isTaggable = $this->_input->filterSingle('bdTagMe_isTaggable', XenForo_Input::BINARY); $userGroup = $dw->getMergedData(); $engine = bdTagMe_Engine::getInstance(); $engine->setTaggableUserGroup($userGroup, $isTaggable, $dw); unset($GLOBALS['bdTagMe_XenForo_ControllerAdmin_UserGroup#actionSave']); }
public function execute(array $deferred, array $data, $targetRunTime, &$status) { list($contentType, $contentId, $contentUserId, $contentUserName, $alertAction, $userIds, $noAlertUserIds, $noEmailUserIds, $options) = $data; /** @var XenForo_Model_User $userModel */ $userModel = XenForo_Model::create('XenForo_Model_User'); $engine = bdTagMe_Engine::getInstance(); $deferredUserIds = array(); if (count($userIds) > bdTagMe_Engine::USERS_PER_BATCH) { $deferredUserIds = array_slice($userIds, bdTagMe_Engine::USERS_PER_BATCH); $userIds = array_slice($userIds, 0, bdTagMe_Engine::USERS_PER_BATCH); } $engine->notifyUserIds($contentType, $contentId, $contentUserId, $contentUserName, $alertAction, $userIds, $noAlertUserIds, $noEmailUserIds, $userModel, $options); if (!empty($deferredUserIds)) { $data[5] = $deferredUserIds; return $data; } else { return false; } }
protected function _alertUser() { // reset _taggedUsers so the default routine will not resend alerts // of course, we kept our copy in local variable $taggedUsers $taggedUsers = $this->_taggedUsers; $this->_taggedUsers = array(); $response = parent::_alertUser(); // TODO: check for profile post validity before sending alerts? // currently it is not needed because _alertUser is called only when the post is // valid, maybe it will be required at a later time $engine = bdTagMe_Engine::getInstance(); $profilePost = $this->getMergedData(); /** @var bdTagMe_XenForo_Model_Alert $alertModel */ $alertModel = $this->getModelFromCache('XenForo_Model_Alert'); $noAlertUserIds = $alertModel->bdTagMe_getAlertedUserIds('profile_post', $profilePost['profile_post_id']); $noEmailUserIds = array(); $options = array(bdTagMe_Engine::OPTION_MAX_TAGGED_USERS => $this->getOption(self::OPTION_MAX_TAGGED_USERS)); $engine->notifyTaggedUsers3('profile_post', $profilePost['profile_post_id'], $profilePost['user_id'], $profilePost['username'], 'tag', $taggedUsers, $noAlertUserIds, $noEmailUserIds, $this->_getProfilePostModel(), $options); return $response; }
protected function _postSave() { // reset _taggedUsers so the default routine will not resend alerts // of course, we kept our copy in local variable $taggedUsers $taggedUsers = $this->_taggedUsers; $this->_taggedUsers = array(); parent::_postSave(); if ($this->isInsert()) { $engine = bdTagMe_Engine::getInstance(); $profilePost = $this->getExtraData(self::DATA_PROFILE_POST); if (!empty($profilePost)) { /** @var bdTagMe_XenForo_Model_Alert $alertModel */ $alertModel = $this->getModelFromCache('XenForo_Model_Alert'); $noAlertUserIds = $alertModel->bdTagMe_getAlertedUserIds('profile_post', $profilePost['profile_post_id']); $noEmailUserIds = array(); $options = array(bdTagMe_Engine::OPTION_MAX_TAGGED_USERS => $this->getOption(self::OPTION_MAX_TAGGED_USERS)); $engine->notifyTaggedUsers3('profile_post', $profilePost['profile_post_id'], $this->get('user_id'), $this->get('username'), 'tag_comment', $taggedUsers, $noAlertUserIds, $noEmailUserIds, $this->_getProfilePostModel(), $options); } } }
protected function _postSaveAfterTransaction() { // reset _taggedUsers so the default routine will not resend alerts // of course, we kept our copy in local variable $taggedUsers $taggedUsers = $this->_taggedUsers; $this->_taggedUsers = array(); parent::_postSaveAfterTransaction(); if ($this->get('message_state') == 'visible') { if ($this->isInsert() || $this->getExisting('message_state') == 'moderated') { $engine = bdTagMe_Engine::getInstance(); $post = $this->getMergedData(); $thread = $this->getDiscussionData(); $forum = $this->_getForumInfo(); /* @var bdTagMe_XenForo_Model_ForumWatch $forumWatchModel */ $forumWatchModel = $this->getModelFromCache('XenForo_Model_ForumWatch'); $notifiedUserIds = $forumWatchModel->bdTagMe_getNotifiedUserIds($post); $options = array(bdTagMe_Engine::OPTION_MAX_TAGGED_USERS => $this->getOption(self::OPTION_MAX_TAGGED_USERS), 'post' => $post, 'thread' => $thread, 'forum' => $forum, 'users' => array('fetchOptions' => array('nodeIdPermissions' => $thread['node_id'])), bdTagMe_Engine::OPTION_USER_CALLBACK => array('bdTagMe_UserCallback', 'XenForo_DataWriter_DiscussionMessage_Post')); $engine->notifyTaggedUsers3('post', $post['post_id'], $post['user_id'], $post['username'], 'tag', $taggedUsers, $notifiedUserIds['alerted'], $notifiedUserIds['emailed'], $forumWatchModel, $options); } } }
protected function _postSave() { $changedUserGroupIds = array(); if ($this->isChanged('user_group_id')) { if ($this->isUpdate()) { $changedUserGroupIds[] = $this->getExisting('user_group_id'); } $changedUserGroupIds[] = $this->get('user_group_id'); } if ($this->isChanged('secondary_group_ids')) { if ($this->isUpdate()) { $oldIds = explode(',', $this->getExisting('secondary_group_ids')); $newIds = explode(',', $this->get('secondary_group_ids')); foreach ($newIds as $id) { if (!empty($id) and !in_array($id, $oldIds)) { $changedUserGroupIds[] = $id; } } foreach ($oldIds as $id) { if (!empty($id) and !in_array($id, $newIds)) { $changedUserGroupIds[] = $id; } } } else { $ids = explode(',', $this->get('secondary_group_ids')); foreach ($ids as $id) { if (!empty($id)) { $changedUserGroupIds[] = $id; } } } } if (!empty($changedUserGroupIds)) { $changedUserGroupIds = array_unique($changedUserGroupIds); $engine = bdTagMe_Engine::getInstance(); $engine->updateTaggableUserGroups($changedUserGroupIds, $this); } parent::_postSave(); }
protected function _postDelete() { $engine = bdTagMe_Engine::getInstance(); $engine->setTaggableUserGroup($this->getMergedData(), false, $this); parent::_postDelete(); }