本文整理汇总了PHP中KunenaForumMessageHelper::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumMessageHelper::getMessages方法的具体用法?PHP KunenaForumMessageHelper::getMessages怎么用?PHP KunenaForumMessageHelper::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaForumMessageHelper
的用法示例。
在下文中一共展示了KunenaForumMessageHelper::getMessages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare user attachments list.
*
* @return void
*/
protected function before()
{
parent::before();
$userid = $this->input->getInt('userid');
$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
$this->template = KunenaFactory::getTemplate();
$this->me = KunenaUserHelper::getMyself();
$this->profile = KunenaUserHelper::get($userid);
$this->attachments = KunenaAttachmentHelper::getByUserid($this->profile, $params);
// Pre-load messages.
$messageIds = array();
foreach ($this->attachments as $attachment)
{
$messageIds[] = (int) $attachment->mesid;
}
$messages = KunenaForumMessageHelper::getMessages($messageIds, 'none');
// Pre-load topics.
$topicIds = array();
foreach ($messages as $message)
{
$topicIds[] = $message->thread;
}
KunenaForumTopicHelper::getTopics($topicIds, 'none');
$this->headerText = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
}
示例2: before
/**
* Prepare category subscriptions display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$me = KunenaUserHelper::getMyself();
if (!$me->exists()) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
}
$limit = $this->input->getInt('limit', 0);
if ($limit < 1 || $limit > 100) {
$limit = 20;
}
$limitstart = $this->input->getInt('limitstart', 0);
if ($limitstart < 0) {
$limitstart = 0;
}
list($total, $this->categories) = KunenaForumCategoryHelper::getLatestSubscriptions($me->userid);
$topicIds = array();
$userIds = array();
$postIds = array();
foreach ($this->categories as $category) {
// Get list of topics.
if ($category->last_topic_id) {
$topicIds[$category->last_topic_id] = $category->last_topic_id;
}
}
// Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
$topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
// Pre-fetch users (and get last post ids for moderators).
foreach ($topics as $topic) {
$userIds[$topic->last_post_userid] = $topic->last_post_userid;
$postIds[$topic->id] = $topic->last_post_id;
}
KunenaUserHelper::loadUsers($userIds);
KunenaForumMessageHelper::getMessages($postIds);
// Pre-fetch user related stuff.
if ($me->exists() && !$me->isBanned()) {
// Load new topic counts.
KunenaForumCategoryHelper::getNewTopics(array_keys($this->categories));
}
$this->actions = $this->getActions();
$this->pagination = new JPagination($total, $limitstart, $limit);
$this->headerText = JText::_('COM_KUNENA_CATEGORY_SUBSCRIPTIONS');
}
示例3: getPurgeItems
/**
* Method to get details on selected items.
*
* @return Array
* @since 1.6
*/
public function getPurgeItems() {
kimport('kunena.error');
$app = JFactory::getApplication ();
$ids = $app->getUserState ( 'com_kunena.purge' );
$topic = $app->getUserState('com_kunena.topic');
$message = $app->getUserState('com_kunena.message');
$ids = implode ( ',', $ids );
if ( $topic ) {
$items = KunenaForumTopicHelper::getTopics($ids);
} elseif ( $message ) {
$items = KunenaForumMessageHelper::getMessages($ids);
} else {
}
return $items;
}
示例4: displayAttachments
/**
*
*/
function displayAttachments()
{
$this->title = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
$this->items = $this->userattachs;
if (!empty($this->userattachs)) {
// Preload messages
$attach_mesids = array();
foreach ($this->userattachs as $attach) {
$attach_mesids[] = (int) $attach->mesid;
}
$messages = KunenaForumMessageHelper::getMessages($attach_mesids, 'none');
// Preload topics
$topic_ids = array();
foreach ($messages as $message) {
$topic_ids[] = $message->thread;
}
KunenaForumTopicHelper::getTopics($topic_ids, 'none');
}
echo $this->loadTemplateFile('attachments');
}
示例5: _getList
/**
* @param string $query
* @param int $limitstart
* @param int $limit
*
* @return KunenaAttachment[]
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$this->_db->setQuery($query, $limitstart, $limit);
$ids = $this->_db->loadColumn();
$results = KunenaAttachmentHelper::getById($ids);
$userids = array();
$mesids = array();
foreach ($results as $result) {
$userids[$result->userid] = $result->userid;
$mesids[$result->mesid] = $result->mesid;
}
KunenaUserHelper::loadUsers($userids);
KunenaForumMessageHelper::getMessages($mesids);
return $results;
}
示例6: restore
function restore()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
$cid = JRequest::getVar('cid', array(), 'post', 'array');
// Array of integers
JArrayHelper::toInteger($cid);
$type = JRequest::getCmd('type', 'topics', 'post');
if (empty($cid)) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_A_NO_MESSAGES_SELECTED'), 'notice');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
$nb_items = 0;
if ($type == 'messages') {
$messages = KunenaForumMessageHelper::getMessages($cid, 'none');
foreach ($messages as $target) {
if ($target->publish(KunenaForum::PUBLISHED)) {
$nb_items++;
} else {
$this->app->enqueueMessage($target->getError(), 'notice');
}
}
} elseif ($type == 'topics') {
$topics = KunenaForumTopicHelper::getTopics($cid, 'none');
foreach ($topics as $target) {
if ($target->publish(KunenaForum::PUBLISHED)) {
$nb_items++;
} else {
$this->app->enqueueMessage($target->getError(), 'notice');
}
}
} else {
// Error...
}
if ($nb_items > 0) {
$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_TRASH_ITEMS_RESTORE_DONE', $nb_items));
}
KunenaUserHelper::recount();
KunenaForumTopicHelper::recount();
KunenaForumCategoryHelper::recount();
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
示例7: permdel_posts
function permdel_posts() {
kimport('kunena.forum.message.helper');
$app = JFactory::getApplication ();
if (! JRequest::checkToken ()) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$this->redirectBack ();
}
$success = 0;
$messages = KunenaForumMessageHelper::getMessages(array_keys(JRequest::getVar('posts', array ( 0 ), 'post', 'array')));
if (!$messages) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_NO_MESSAGES_SELECTED' ) );
} else {
foreach ( $messages as $message ) {
if ($message->authorise('permdelete') && $message->delete()) {
$success++;
} else {
$app->enqueueMessage ( $message->getError (), 'notice' );
}
}
}
if ($success) $app->enqueueMessage ( JText::_ ( 'COM_KUNENA_BULKMSG_DELETED' ) );
$this->redirectBack ();
}
示例8: getPurgeItems
/**
* Method to get details on selected items.
*
* @return Array
* @since 1.6
*/
public function getPurgeItems()
{
$ids = (array) $this->app->getUserState('com_kunena.purge');
$type = (string) $this->app->getUserState('com_kunena.type');
$items = array();
if ($type == 'topics') {
$items = KunenaForumTopicHelper::getTopics($ids, 'none');
} elseif ($type == 'messages') {
$items = KunenaForumMessageHelper::getMessages($ids, 'none');
}
return $items;
}
示例9: restore
function restore() {
$app = JFactory::getApplication ();
if (! JRequest::checkToken ()) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
$kunena_db = JFactory::getDBO ();
$cid = JRequest::getVar ( 'cid', array (), 'post', 'array' );
$topics = JRequest::getInt ( 'topics', 0, 'post' );
$messages = JRequest::getInt ( 'messages', 0, 'post' );
if (empty ( $cid )) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_A_NO_MESSAGES_SELECTED' ), 'notice' );
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
$msg = JText::_('COM_KUNENA_TRASH_RESTORE_DONE');
if ( $messages ) {
$messages = KunenaForumMessageHelper::getMessages($cid);
foreach ( $messages as $target ) {
if ( $target->authorise('undelete') && $target->publish(KunenaForum::PUBLISHED) ) {
$app->enqueueMessage ( $msg );
} else {
$app->enqueueMessage ( $target->getError(), 'notice' );
}
}
} elseif ( $topics ) {
$topics = KunenaForumTopicHelper::getTopics($cid);
foreach ( $topics as $target ) {
if ( $target->authorise('undelete') && $target->publish(KunenaForum::PUBLISHED) ) {
$app->enqueueMessage ( $msg );
} else {
$app->enqueueMessage ( $target->getError(), 'notice' );
}
}
} else {
// error
}
KunenaUserHelper::recount();
KunenaForumTopicHelper::recount();
KunenaForumCategoryHelper::recount ();
$app->redirect(KunenaRoute::_($this->baseurl, false));
}
示例10: permdel_posts
function permdel_posts()
{
if (!JSession::checkToken('post')) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirectBack();
return;
}
$ids = array_keys(JRequest::getVar('posts', array(), 'post', 'array'));
// Array of integer keys
JArrayHelper::toInteger($ids);
$success = 0;
$messages = KunenaForumMessageHelper::getMessages($ids);
if (!$messages) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_NO_MESSAGES_SELECTED'));
} else {
foreach ($messages as $message) {
if ($message->authorise('permdelete') && $message->delete()) {
$success++;
} else {
$this->app->enqueueMessage($message->getError(), 'notice');
}
}
}
if ($success) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_BULKMSG_DELETED'));
}
$this->setRedirectBack();
}
示例11: getMessagesByCategory
protected function getMessagesByCategory($cat_id)
{
static $messages = array();
if (!$messages[$cat_id]) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('m.id');
$query->from('#__kunena_messages as m');
$query->join('INNER', '#__kunena_categories as c on m.catid = c.id');
$query->where('c.id = ' . $db->quote($cat_id));
$db->setQuery($query);
$ids = $db->loadColumn();
$messages[$cat_id] = KunenaForumMessageHelper::getMessages($ids);
}
return $messages[$cat_id];
}
示例12: getCategories
public function getCategories()
{
if ($this->items === false) {
$this->items = array();
$catid = $this->getState('item.id');
$layout = $this->getState('layout');
$flat = false;
if ($layout == 'user') {
$categories[0] = KunenaForumCategoryHelper::getSubscriptions();
$flat = true;
} elseif ($catid) {
$categories[0] = KunenaForumCategoryHelper::getCategories($catid);
if (empty($categories[0])) {
return array();
}
} else {
$categories[0] = KunenaForumCategoryHelper::getChildren();
}
if ($flat) {
$allsubcats = $categories[0];
} else {
$allsubcats = KunenaForumCategoryHelper::getChildren(array_keys($categories[0]), 1);
}
if (empty($allsubcats)) {
return array();
}
KunenaForumCategoryHelper::getNewTopics(array_keys($allsubcats));
$modcats = array();
$lastpostlist = array();
$userlist = array();
$topiclist = array();
foreach ($allsubcats as $subcat) {
if ($flat || isset($categories[0][$subcat->parent_id])) {
$last = $subcat->getLastCategory();
if ($last->last_topic_id) {
// Get list of topics
$topiclist[$last->last_topic_id] = $last->last_topic_id;
}
if ($this->config->listcat_show_moderators) {
// Get list of moderators
$subcat->moderators = $subcat->getModerators(false, false);
$userlist += $subcat->moderators;
}
if ($this->me->isModerator($subcat)) {
$modcats[] = $subcat->id;
}
}
$categories[$subcat->parent_id][] = $subcat;
}
// Prefetch topics
$topics = KunenaForumTopicHelper::getTopics($topiclist);
foreach ($topics as $topic) {
// Prefetch users
$userlist[$topic->last_post_userid] = $topic->last_post_userid;
$lastpostlist[$topic->id] = $topic->last_post_id;
}
if ($this->me->ordering != 0) {
$topic_ordering = $this->me->ordering == 1 ? true : false;
} else {
$topic_ordering = $this->config->default_sort == 'asc' ? false : true;
}
$this->pending = array();
if ($this->me->userid && count($modcats)) {
$catlist = implode(',', $modcats);
$db = JFactory::getDBO();
$db->setQuery("SELECT catid, COUNT(*) AS count\n\t\t\t\tFROM #__kunena_messages\n\t\t\t\tWHERE catid IN ({$catlist}) AND hold=1\n\t\t\t\tGROUP BY catid");
$pending = $db->loadAssocList();
KunenaError::checkDatabaseError();
foreach ($pending as $item) {
if ($item['count']) {
$this->pending[$item['catid']] = $item['count'];
}
}
}
// Fix last post position when user can see unapproved or deleted posts
if ($lastpostlist && !$topic_ordering && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
KunenaForumMessageHelper::getMessages($lastpostlist);
KunenaForumMessageHelper::loadLocation($lastpostlist);
}
// Prefetch all users/avatars to avoid user by user queries during template iterations
KunenaUserHelper::loadUsers($userlist);
if ($flat) {
$this->items = $allsubcats;
} else {
$this->items = $categories;
}
}
return $this->items;
}
示例13: before
/**
* Prepare category index display.
*
* @return void
*/
protected function before()
{
parent::before();
$this->me = KunenaUserHelper::getMyself();
// Get sections to display.
$catid = $this->input->getInt('catid', 0);
if ($catid) {
$sections = KunenaForumCategoryHelper::getCategories($catid);
} else {
$sections = KunenaForumCategoryHelper::getChildren();
}
$sectionIds = array();
$this->more[$catid] = 0;
foreach ($sections as $key => $category) {
$this->categories[$category->id] = array();
$this->more[$category->id] = 0;
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 0) {
if ($catid || $category->params->get('display.index.children', 3) > 1) {
$sectionIds[] = $category->id;
} else {
$this->more[$category->id]++;
}
} else {
$this->more[$category->parent_id]++;
unset($sections[$key]);
continue;
}
}
// Get categories and subcategories.
if (empty($sections)) {
return;
}
$this->sections = $sections;
$categories = KunenaForumCategoryHelper::getChildren($sectionIds);
if (empty($categories)) {
return;
}
$categoryIds = array();
$topicIds = array();
$userIds = array();
$postIds = array();
foreach ($categories as $key => $category) {
$this->more[$category->id] = 0;
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 1) {
if ($catid || $category->getParent()->params->get('display.index.children', 3) > 2 && $category->params->get('display.index.children', 3) > 2) {
$categoryIds[] = $category->id;
} else {
$this->more[$category->id]++;
}
} else {
$this->more[$category->parent_id]++;
unset($categories[$key]);
continue;
}
// Get list of topics.
$last = $category->getLastCategory();
if ($last->last_topic_id) {
$topicIds[$last->last_topic_id] = $last->last_topic_id;
}
$this->categories[$category->parent_id][] = $category;
$rssURL = $category->getRSSUrl();
if (!empty($rssURL)) {
$category->rssURL = $category->getRSSUrl();
}
}
$subcategories = KunenaForumCategoryHelper::getChildren($categoryIds);
foreach ($subcategories as $category) {
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 2) {
$this->categories[$category->parent_id][] = $category;
} else {
$this->more[$category->parent_id]++;
}
}
// Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
$topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
// Pre-fetch users (and get last post ids for moderators).
foreach ($topics as $topic) {
$userIds[$topic->last_post_userid] = $topic->last_post_userid;
$postIds[$topic->id] = $topic->last_post_id;
}
KunenaUserHelper::loadUsers($userIds);
KunenaForumMessageHelper::getMessages($postIds);
// Pre-fetch user related stuff.
$this->pending = array();
if ($this->me->exists() && !$this->me->isBanned()) {
// Load new topic counts.
KunenaForumCategoryHelper::getNewTopics(array_keys($categories + $subcategories));
// Get categories which are moderated by current user.
$access = KunenaAccess::getInstance();
$moderate = $access->getAdminStatus($this->me) + $access->getModeratorStatus($this->me);
if (!empty($moderate[0])) {
// Global moderators.
//.........这里部分代码省略.........
示例14: getItems
/**
* Method to get a list of content items to index.
*
* @param integer $offset The list offset.
* @param integer $limit The list limit.
* @param JDatabaseQuery $sql A JDatabaseQuery object. [optional]
*
* @return array An array of FinderIndexerResult objects.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getItems($offset, $limit, $sql = null)
{
JLog::add("FinderIndexerAdapter::getItems({$offset}, {$limit})", JLog::INFO);
// Get the list query.
$sql = $this->db->getQuery(true);
$sql->select('id')->from('#__kunena_messages')->where('id>' . $this->db->quote($offset));
// Get the content items to index.
$this->db->setQuery($sql, 0, $limit);
$ids = $this->db->loadColumn();
// Check for a database error.
if ($this->db->getErrorNum()) {
// Throw database error exception.
throw new Exception($this->db->getErrorMsg(), 500);
}
// Convert the items to result objects.
$messages = KunenaForumMessageHelper::getMessages($ids, 'none');
$items = array();
foreach ($messages as &$message) {
$items[] = $this->createIndexerResult($message);
}
KunenaForumMessageHelper::cleanup();
KunenaRoute::cleanup();
return $items;
}
示例15: find
/**
* Get messages.
*
* @param string $access Kunena action access control check.
* @return array|KunenaForumMessage[]
*/
public function find($access = 'read')
{
$results = parent::find();
return KunenaForumMessageHelper::getMessages($results, $access);
}