本文整理汇总了PHP中XenForo_Application::arrayColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Application::arrayColumn方法的具体用法?PHP XenForo_Application::arrayColumn怎么用?PHP XenForo_Application::arrayColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Application
的用法示例。
在下文中一共展示了XenForo_Application::arrayColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getNotableMembers
/**
*
* @see XenForo_ControllerPublic_Member::_getNotableMembers()
*/
protected function _getNotableMembers($type, $limit)
{
if ($type == 'leaderboard') {
$leaderboardId = $this->_input->filterSingle('leaderboard_id', XenForo_Input::UINT);
$leaderboardModel = $this->_getLeaderboardModel();
$leaderboardEntries = $leaderboardModel->getLeaderboardEntries(array('leaderboard_id' => $leaderboardId));
$userIds = array();
foreach ($leaderboardEntries as $leaderboardEntry) {
$userIds[$leaderboardEntry['user_id']] = $leaderboardEntry['user_id'];
}
/* @var $userModel XenForo_Model_User */
$userModel = $this->_getUserModel();
$fetchOptions = array('join' => XenForo_Model_User::FETCH_USER_FULL);
$users = $userModel->getUsersByIds($userIds, $fetchOptions);
$entries = XenForo_Application::arrayColumn($leaderboardEntries, 'entry', 'user_id');
arsort($entries);
$sortedUsers = array();
foreach ($entries as $userId => $entry) {
if (!empty($users[$userId]) && $entry) {
$sortedUsers[$userId] = $users[$userId];
$sortedUsers[$userId]['leaderboard_entry'] = $entry;
}
}
return array($sortedUsers, 'leaderboard_entry');
}
return parent::_getNotableMembers($type, $limit);
}
示例2: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/** @var XenForo_Model_ProfilePost $profilePostModel */
$profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
$comments = $profilePostModel->getProfilePostCommentsByIds($contentIds);
$profilePostIds = XenForo_Application::arrayColumn($comments, 'profile_post_id');
$profilePosts = $profilePostModel->getProfilePostsByIds($profilePostIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY | XenForo_Model_ProfilePost::FETCH_USER_POSTER, 'visitingUser' => $viewingUser));
$output = array();
foreach ($comments as $key => &$comment) {
if (isset($profilePosts[$comment['profile_post_id']])) {
$comment['profilePost'] = $profilePosts[$comment['profile_post_id']];
$comment['profileUser'] = $profilePostModel->getProfileUserFromProfilePost($comment['profilePost'], $viewingUser);
if (!$comment['profilePost'] || !$comment['profileUser']) {
continue;
}
$canManage = true;
if (!$profilePostModel->canViewProfilePostAndContainer($comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
$canManage = false;
} else {
if (!$profilePostModel->canViewProfilePostComment($comment, $comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$canManage = false;
}
}
}
if ($canManage) {
$output[$comment['profile_post_comment_id']] = array('message' => $comment['message'], 'user' => array('user_id' => $comment['user_id'], 'username' => $comment['username']), 'title' => new XenForo_Phrase('profile_post_comment_by_x', array('username' => $comment['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts/comments', $comment), 'contentTypeTitle' => new XenForo_Phrase('profile_post_comment'), 'titleEdit' => false);
}
}
}
return $output;
}
示例3: getTagOptions
public static function getTagOptions($content, $params)
{
/* @var $contactGroupCategoryDataModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroupCategory */
$contactGroupCategoryDataModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroupCategory');
$contactGroupCategories = $contactGroupCategoryDataModel->getContactGroupCategories();
$contactGroupCategoryIds = XenForo_Application::arrayColumn($contactGroupCategories, 'Id');
/* @var $contactGroupDataModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroup */
$contactGroupDataModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroup');
$contactGroups = $contactGroupDataModel->getContactGroupsForCategory($contactGroupCategoryIds);
foreach ($contactGroups as $contactGroupId => $contactGroup) {
$contactGroupCategories[$contactGroup['GroupCategoryId']]['groups'][$contactGroupId] = $contactGroup;
}
$content .= '<select id="ctrl_user_criteriainfusionsoft_contact_group_id_thdatacontact_group_id" name="user_criteria[infusionsoft_contact_group_id_th][data][contact_group_id]" class="textCtrl autoSize" />';
foreach ($contactGroupCategories as $contactGroupCategory) {
if (!empty($contactGroupCategory['groups'])) {
$content .= '<optgroup label="' . $contactGroupCategory['CategoryName'] . '">';
foreach ($contactGroupCategory['groups'] as $contactGroupId => $contactGroup) {
$selected = $params['value'] == $contactGroupId ? ' selected="selected"' : '';
$content .= '<option value="' . $contactGroupId . '" label="' . $contactGroup['GroupName'] . '"' . $selected . '/>';
}
$content .= '</optgroup>';
}
}
$content .= '</select>';
return $content;
}
示例4: verifyOption
/**
* Verifies the registrationWelcome setting
*
* @param array $values
* @param XenForo_DataWriter $dw Calling DW
* @param string $fieldName Name of field/option
*
* @return true
*/
public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
{
if ($dw->isInsert()) {
// insert - just trust the default value
return true;
}
if (!empty($values['messageEnabled'])) {
/** @var XenForo_Model_User $userModel */
$userModel = XenForo_Model::create('XenForo_Model_User');
$participants = explode(',', $values['messageParticipants']);
$starter = array_shift($participants);
$participantUsers = $userModel->getUsersByNames($participants);
$starterUser = $userModel->getUserByName($starter);
if (!$starterUser) {
if ($starter) {
$dw->error(new XenForo_Phrase('the_following_recipients_could_not_be_found_x', array('names' => $starter)), $fieldName);
} else {
$dw->error(new XenForo_Phrase('please_enter_at_least_one_valid_recipient'), $fieldName);
}
return false;
}
/** @var XenForo_DataWriter_ConversationMaster $conversationDw */
$conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $starterUser);
$conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $values['messageBody']);
$conversationDw->set('user_id', $starterUser['user_id']);
$conversationDw->set('username', $starterUser['username']);
$conversationDw->set('title', $values['messageTitle']);
$conversationDw->addRecipientUserIds(array_keys($participantUsers));
// skips permissions
$messageDw = $conversationDw->getFirstMessageDw();
$messageDw->set('message', $values['messageBody']);
$conversationDw->preSave();
if ($conversationDw->hasErrors()) {
$errors = $conversationDw->getErrors();
// Skip recipient errors. We've already verified the recipients are valid.
if (isset($errors['recipients'])) {
unset($errors['recipients']);
}
if (count($errors)) {
$dw->error(reset($errors), $fieldName);
return false;
}
}
$validUsernames = XenForo_Application::arrayColumn($participantUsers, 'username');
array_unshift($validUsernames, $starter);
$values['messageParticipants'] = implode(', ', array_unique($validUsernames));
}
if (!empty($values['emailEnabled']) && !strlen(trim($values['emailBody']))) {
$dw->error(new XenForo_Phrase('you_must_enter_email_message_to_enable_welcome_email'), $fieldName);
return false;
}
return true;
}
示例5: actionAutoComplete
public function actionAutoComplete()
{
$q = $this->_input->filterSingle('q', XenForo_Input::STRING);
if ($q) {
$templates = $this->_getTemplateModel()->getEffectiveTemplateListForStyle(0, array('title' => array($q, 'r')), array('limit' => 10));
} else {
$templates = array();
}
$view = $this->responseView();
$view->jsonParams = array('results' => XenForo_Application::arrayColumn($templates, 'title', 'title'));
return $view;
}
示例6: actionAutoComplete
public function actionAutoComplete()
{
$q = $this->_input->filterSingle('q', XenForo_Input::STRING);
if ($q) {
$templates = $this->_getEmailTemplateModel()->getMasterEmailTemplatesLikeTitle($q, 'r', 10);
} else {
$templates = array();
}
$view = $this->responseView();
$view->jsonParams = array('results' => XenForo_Application::arrayColumn($templates, 'title', 'title'));
return $view;
}
示例7: renderOption
/**
* Renders the contact groups option.
*
* @param XenForo_View $view View object
* @param string $fieldPrefix Prefix for the HTML form field name
* @param array $preparedOption Prepared option info
* @param boolean $canEdit True if an "edit" link should appear
*
* @return XenForo_Template_Abstract Template object
*/
public static function renderOption(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
{
if (self::$_contactGroupCategories === null) {
/* @var $contactGroupCategoryDataModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroupCategory */
$contactGroupCategoryDataModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroupCategory');
$contactGroupCategories = $contactGroupCategoryDataModel->getContactGroupCategories();
$contactGroupCategoryIds = XenForo_Application::arrayColumn($contactGroupCategories, 'Id');
/* @var $contactGroupDataModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroup */
$contactGroupDataModel = XenForo_Model::create('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_ContactGroup');
$contactGroups = $contactGroupDataModel->getContactGroupsForCategory($contactGroupCategoryIds);
foreach ($contactGroups as $contactGroupId => $contactGroup) {
$contactGroupCategories[$contactGroup['GroupCategoryId']]['groups'][$contactGroupId] = $contactGroup;
}
self::$_contactGroupCategories = $contactGroupCategories;
}
$preparedOption['contactGroupCategories'] = self::$_contactGroupCategories;
return XenForo_ViewAdmin_Helper_Option::renderOptionTemplateInternal('th_option_template_tags_infusionsoftapi', $view, $fieldPrefix, $preparedOption, $canEdit);
}
示例8: actionThreadsByCategory
public function actionThreadsByCategory()
{
$this->_routeMatch->setSections('forums');
$threadModel = $this->_getThreadModel();
$visitor = XenForo_Visitor::getInstance();
$searchId = $this->_input->filterSingle('search_id', XenForo_Input::UINT);
if (!$searchId) {
return $this->findNewPosts();
}
$searchModel = $this->_getSearchModel();
$search = $searchModel->getSearchById($searchId);
if (!$search || $search['user_id'] != XenForo_Visitor::getUserId() || !in_array($search['search_type'], array('new-threads', 'recent-threads'))) {
return $this->findNewPosts();
}
$page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
$perPage = XenForo_Application::get('options')->discussionsPerPage;
$pageResultIds = $searchModel->sliceSearchResultsToPage($search, $page, $perPage);
$threadIds = XenForo_Application::arrayColumn($pageResultIds, 1);
$threadsMatched = $threadModel->getThreadsByIds($threadIds, array('join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER | XenForo_Model_Thread::FETCH_FIRSTPOST, 'permissionCombinationId' => $visitor['permission_combination_id'], 'readUserId' => $visitor['user_id'], 'includeForumReadDate' => true, 'watchUserId' => $visitor['user_id'], 'forumWatchUserId' => $visitor['user_id'], 'postCountUserId' => $visitor['user_id']));
$threads = array();
$inlineModOptions = array();
foreach ($threadIds as $threadId) {
if (!isset($threadsMatched[$threadId])) {
continue;
}
$thread = $threadsMatched[$threadId];
$thread['permissions'] = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions'])) {
continue;
}
$thread = $threadModel->prepareThread($thread, $thread, $thread['permissions']);
$thread['forum'] = array('node_id' => $thread['node_id'], 'node_name' => $thread['node_name'], 'title' => $thread['node_title']);
$threadModOptions = $threadModel->addInlineModOptionToThread($thread, $thread, $thread['permissions']);
$inlineModOptions += $threadModOptions;
$threads[$thread['thread_id']] = $thread;
}
if (!$threads) {
return $this->getNoPostsResponse();
}
$resultStartOffset = ($page - 1) * $perPage + 1;
$resultEndOffset = ($page - 1) * $perPage + count($threadIds);
$viewParams = array('search' => $search, 'threads' => $threads, 'inlineModOptions' => $inlineModOptions, 'threadStartOffset' => $resultStartOffset, 'threadEndOffset' => $resultEndOffset, 'ignoredNames' => $this->_getIgnoredContentUserNames($threads), 'page' => $page, 'perPage' => $perPage, 'totalThreads' => $search['result_count'], 'nextPage' => $resultEndOffset < $search['result_count'] ? $page + 1 : 0, 'showingNewPosts' => $search['search_type'] == 'new-posts');
return $this->getFindNewWrapper($this->responseView('XenForo_ViewPublic_FindNew_Posts', 'find_new_posts', $viewParams), 'posts');
}
示例9: alertTaggedMembers
public function alertTaggedMembers($content, $contentId, $contentType, $tagged, array $alreadyAlerted = array())
{
$userIds = XenForo_Application::arrayColumn($tagged, 'user_id');
$userIds = array_diff($userIds, $alreadyAlerted);
$alertedUserIds = array();
if ($userIds) {
$userModel = $this->_getUserModel();
$users = $userModel->getUsersByIds($userIds, array('join' => XenForo_Model_User::FETCH_USER_OPTION | XenForo_Model_User::FETCH_USER_PROFILE | XenForo_Model_User::FETCH_USER_PERMISSIONS));
foreach ($users as $user) {
if (isset($alertedUserIds[$user['user_id']]) || $user['user_id'] == $content['user_id'] || $user['user_id'] == $content['user_id']) {
continue;
}
$xfContentType = $this->_getXfContentType($contentType);
if (!$userModel->isUserIgnored($user, $content['user_id']) && !$userModel->isUserIgnored($user, $content['user_id']) && XenForo_Model_Alert::userReceivesAlert($user, $xfContentType, 'tagging')) {
$alertedUserIds[$user['user_id']] = true;
XenForo_Model_Alert::alert($user['user_id'], $content['user_id'], $content['username'], $contentType, $contentId, 'tagging');
}
}
}
return array_keys($alertedUserIds);
}
示例10: getContentByIds
/**
* Fetches related content (profile post comments) by IDs
*
* @param array $contentIds
* @param XenForo_Model_NewsFeed $model
* @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
*
* @return array
*/
public function getContentByIds(array $contentIds, $model, array $viewingUser)
{
$profilePostModel = $this->_getProfilePostModel();
$comments = $profilePostModel->getProfilePostCommentsByIds($contentIds);
$profilePostIds = XenForo_Application::arrayColumn($comments, 'profile_post_id');
$profilePosts = $profilePostModel->getProfilePostsByIds($profilePostIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY | XenForo_Model_ProfilePost::FETCH_USER_POSTER, 'visitingUser' => $viewingUser));
foreach ($comments as $key => &$comment) {
if (isset($profilePosts[$comment['profile_post_id']])) {
$comment['profilePost'] = $profilePosts[$comment['profile_post_id']];
$comment['profileUser'] = $profilePostModel->getProfileUserFromProfilePost($comment['profilePost'], $viewingUser);
if (!$comment['profilePost'] || !$comment['profileUser']) {
unset($comments[$key]);
continue;
}
if (!$profilePostModel->canViewProfilePostAndContainer($comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
unset($comments[$key]);
}
} else {
unset($comments[$key]);
}
}
return $comments;
}
示例11: pullContacts
/**
*
* @param array $contacts
* @param int $position
*/
public function pullContacts(array $contacts, $position = 0, $targetRunTime = 0)
{
/* @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
$contactIds = XenForo_Application::arrayColumn($contacts, 'Id');
if (!$contactIds) {
return $position;
}
$contactUsers = $userModel->getUsersByContactIds($contactIds);
$userContactIds = XenForo_Application::arrayColumn($contactUsers, 'infusionsoft_contact_id_th', 'user_id');
$emails = XenForo_Application::arrayColumn($contacts, 'Email');
$emails = array_unique(array_filter($emails));
$fetchOptions = array('join' => XenForo_Model_User::FETCH_USER_PROFILE);
$emailUsers = $userModel->getUsersByEmails($emails, $fetchOptions);
$userEmails = XenForo_Application::arrayColumn($emailUsers, 'email', 'user_id');
$s = microtime(true);
foreach ($contacts as $contactId => $contact) {
$targetRunTime = $this->getTargetRunTime($targetRunTime);
if ($targetRunTime && microtime(true) - $s > $targetRunTime) {
break;
}
$position++;
$user = in_array($contactId, $userContactIds) ? $contactUsers[array_search($contactId, $userContactIds)] : false;
if (!$user && !empty($contact['Email'])) {
$user = in_array($contact['Email'], $userEmails) ? $emailUsers[array_search($contact['Email'], $userEmails)] : false;
if ($user && !empty($user['infusionsoft_contact_id_th'])) {
continue;
}
}
$this->pullContact($contact, $user);
}
return $position;
}
示例12: getTagCloudLevels
public function getTagCloudLevels(array $tags, $levels = 7)
{
if (!$tags) {
return array();
}
$uses = XenForo_Application::arrayColumn($tags, 'use_count');
$min = min($uses);
$max = max($uses);
$levelSize = ($max - $min) / $levels;
$output = array();
if ($min == $max) {
$middle = ceil($levels / 2);
foreach ($tags as $id => $tag) {
$output[$id] = $middle;
}
} else {
foreach ($tags as $id => $tag) {
$diffFromMin = $tag['use_count'] - $min;
if (!$diffFromMin) {
$level = 1;
} else {
$level = min($levels, ceil($diffFromMin / $levelSize));
}
$output[$id] = $level;
}
}
return $output;
}
示例13: actionMassToggle
public function actionMassToggle()
{
$addOnModel = $this->_getAddOnModel();
$allAddOns = $addOnModel->getAllAddOns();
if ($this->_input->filterSingle('enable', XenForo_Input::BOOLEAN)) {
if ($this->isConfirmedPost()) {
$addOns = $this->_input->filterSingle('add_ons', XenForo_Input::ARRAY_SIMPLE);
$dws = array();
foreach ($addOns as $addOnId) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AddOn');
$dw->setExistingData($addOnId);
$dw->set('active', 1);
$dw->preSave();
$dws[] = $dw;
}
XenForo_Db::beginTransaction();
foreach ($dws as $dw) {
$dw->save();
}
XenForo_Db::commit();
/** @var XenForo_Model_DataRegistry $dataRegistry */
$dataRegistry = $this->getModelFromCache('XenForo_Model_DataRegistry');
$dataRegistry->set('disabledAddOns', array());
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('add-ons'));
} else {
$disabledAddOns = $addOnModel->getDisabledAddOnsCache();
if (!$disabledAddOns) {
$disabledAddOns = $allAddOns;
}
$viewParams = array('addOns' => $allAddOns, 'disabledAddOns' => $disabledAddOns);
return $this->responseView('XenForo_ViewAdmin_AddOn_MassEnable', 'addon_mass_enable', $viewParams);
}
} else {
if ($this->isConfirmedPost()) {
$activeAddOns = array();
if (XenForo_Application::isRegistered('addOns')) {
$activeAddOns = XenForo_Application::get('addOns');
unset($activeAddOns['XenForo']);
$activeAddOns = array_combine(array_keys($activeAddOns), array_keys($activeAddOns));
}
$dws = array();
foreach ($activeAddOns as $addOnId => $versionId) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AddOn');
$dw->setExistingData($addOnId);
$dw->set('active', 0);
$dw->preSave();
$dws[] = $dw;
}
XenForo_Db::beginTransaction();
foreach ($dws as $dw) {
$dw->save();
}
XenForo_Db::commit();
/** @var XenForo_Model_DataRegistry $dataRegistry */
$dataRegistry = $this->getModelFromCache('XenForo_Model_DataRegistry');
$dataRegistry->set('disabledAddOns', $activeAddOns);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('add-ons'));
} else {
$activeAddOns = XenForo_Application::arrayColumn($allAddOns, 'active', 'addon_id');
$activeCount = array_sum($activeAddOns);
if ($activeCount === 0) {
return $this->responseError(new XenForo_Phrase('there_currently_no_add_ons_to_disable'));
}
$viewParams = array('disabledAddOns' => $addOnModel->getDisabledAddOnsCache());
return $this->responseView('XenForo_ViewAdmin_AddOn_MassDisable', 'addon_mass_disable', $viewParams);
}
}
}
示例14: alertTaggedMembers
public function alertTaggedMembers(array $profilePost, array $profileUser, array $tagged, array $alreadyAlerted = array(), $commentId = 0, array $taggingUser = null)
{
$userIds = XenForo_Application::arrayColumn($tagged, 'user_id');
$userIds = array_diff($userIds, $alreadyAlerted);
$alertedUserIds = array();
if (!$taggingUser) {
$taggingUser = $profilePost;
}
if ($userIds) {
$userModel = $this->_getUserModel();
$users = $userModel->getUsersByIds($userIds, array('join' => XenForo_Model_User::FETCH_USER_OPTION | XenForo_Model_User::FETCH_USER_PROFILE | XenForo_Model_User::FETCH_USER_PERMISSIONS));
foreach ($users as $user) {
if (isset($alertedUserIds[$user['user_id']])) {
continue;
}
$user['permissions'] = XenForo_Permission::unserializePermissions($user['global_permission_cache']);
if ($user['user_id'] != $taggingUser['user_id'] && !$userModel->isUserIgnored($user, $profilePost['user_id']) && !$userModel->isUserIgnored($user, $profileUser['user_id']) && XenForo_Model_Alert::userReceivesAlert($user, 'profile_post', 'tag') && $this->canViewProfilePostAndContainer($profilePost, $profileUser, $null, $user)) {
$alertedUserIds[$user['user_id']] = true;
XenForo_Model_Alert::alert($user['user_id'], $taggingUser['user_id'], $taggingUser['username'], 'profile_post' . ($commentId ? '_comment' : ''), $commentId ? $commentId : $profilePost['profile_post_id'], 'tag');
}
}
}
return array_keys($alertedUserIds);
}
示例15: unreadCategories
public static function unreadCategories()
{
$nodeModel = XenForo_Model::create('XenForo_Model_Node');
$nodeData = $nodeModel->getNodeDataForListDisplay(false, 0);
$xenOptions = XenForo_Application::get('options');
$categoryIds = array();
if (!empty($xenOptions->th_unreadCategories_nodeIds)) {
$categoryIds = $xenOptions->th_unreadCategories_nodeIds;
}
$nodes = array();
foreach ($nodeData['nodesGrouped'] as $parentNodeId => $groupedNodes) {
foreach ($groupedNodes as $nodeId => $node) {
if ($node['node_type_id'] == 'Category' && !empty($node['last_post_date']) && in_array($nodeId, $categoryIds)) {
$nodes[$nodeId] = $node;
}
}
}
$nodeLastPostDates = XenForo_Application::arrayColumn($nodes, 'last_post_date', 'node_id');
$db = XenForo_Application::getDb();
$timeNow = XenForo_Application::$time;
$whereClauses = array();
foreach ($nodeLastPostDates as $nodeId => $lastPostDate) {
if ($lastPostDate > $timeNow - $xenOptions->alertsPopupExpiryHours * 3600) {
$whereClauses[] = '(node_id = ' . $db->quote($nodeId) . ' AND category_read_date >= ' . $db->quote($lastPostDate) . ')';
} else {
unset($nodeLastPostDates[$nodeId]);
}
}
$readCategories = array();
if ($whereClauses) {
$readCategories = $db->fetchPairs('
SELECT user_id, GROUP_CONCAT(node_id SEPARATOR \',\') AS node_ids FROM xf_category_read_th
WHERE ' . implode(' OR ', $whereClauses) . '
GROUP BY user_id
');
}
$readCategoryCombinations = array();
$userCombinationIds = array();
foreach ($readCategories as $userId => $nodeIds) {
if (!in_array($nodeIds, $readCategoryCombinations)) {
$readCategoryCombinations[] = $nodeIds;
}
$userCombinationIds[array_search($nodeIds, $readCategoryCombinations)][] = $userId;
}
$allNodeIds = array_keys($nodeLastPostDates);
$updates = array();
foreach ($readCategoryCombinations as $combinationId => $nodeIds) {
$readNodeIds = explode(',', $nodeIds);
$unreadNodeIds = array_diff($allNodeIds, $readNodeIds);
$userIds = $userCombinationIds[$combinationId];
$updates[] = 'WHEN user_id IN (' . $db->quote($userIds) . ') THEN ' . $db->quote(implode(',', $unreadNodeIds));
}
if ($updates) {
$db->query('
UPDATE xf_user_profile SET unread_category_ids_th = CASE
' . implode(' ', $updates) . '
ELSE ' . $db->quote(implode(',', $allNodeIds)) . '
END
');
} else {
$db->query('
UPDATE xf_user_profile
SET unread_category_ids_th = ' . $db->quote(implode(',', $allNodeIds)) . '
');
}
}