コード例 #1
0
	public function check() {
		$user = KunenaUserHelper::get($this->userid);
		$message = KunenaForumMessageHelper::get($this->mesid);
		if ($this->userid != 0 && !$user->exists()) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_USER_INVALID', (int) $user->userid));
		}
		if (!$message->exists()) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_MESSAGE_INVALID', (int) $message->id));
		}
		$this->folder = trim($this->folder, '/');
		if (!$this->folder) {
			$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FOLDER'));
		}
		if (!$this->filename) {
			$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FILENAME'));
		}
		$file = JPATH_ROOT . "/{$this->folder}/{$this->filename}";
		if (!file_exists($file)) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_FILE_MISSING', "{$this->folder}/{$this->filename}"));
		} else {
			if (!$this->hash) $this->hash = md5_file ( $file );
			if (!$this->size) $this->size = filesize ( $file );
		}
		return ($this->getError () == '');
	}
コード例 #2
0
ファイル: display.php プロジェクト: BillVGN/PortalPRP
	/**
	 * 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');
	}
コード例 #3
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Prepare report message form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     $me = KunenaUserHelper::getMyself();
     if (!$this->config->reportmsg) {
         // Deny access if report feature has been disabled.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     if (!$me->exists()) {
         // Deny access if user is guest.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $this->topic->tryAuthorise();
     } else {
         $this->message = KunenaForumMessageHelper::get($mesid);
         $this->message->tryAuthorise();
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $this->uri = "index.php?option=com_kunena&view=topic&layout=report&catid={$this->category->id}" . "&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
 }
コード例 #4
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Prepare topics by pre-loading needed information.
  *
  * @param   array  $userIds  List of additional user Ids to be loaded.
  * @param   array  $mesIds   List of additional message Ids to be loaded.
  *
  * @return  void
  */
 protected function prepareTopics(array $userIds = array(), array $mesIds = array())
 {
     // Collect user Ids for avatar prefetch when integrated.
     $lastIds = array();
     foreach ($this->topics as $topic) {
         $userIds[(int) $topic->first_post_userid] = (int) $topic->first_post_userid;
         $userIds[(int) $topic->last_post_userid] = (int) $topic->last_post_userid;
         $lastIds[(int) $topic->last_post_id] = (int) $topic->last_post_id;
     }
     // Prefetch all users/avatars to avoid user by user queries during template iterations.
     if (!empty($userIds)) {
         KunenaUserHelper::loadUsers($userIds);
     }
     $topicIds = array_keys($this->topics);
     KunenaForumTopicHelper::getUserTopics($topicIds);
     /* KunenaForumTopicHelper::getKeywords($topicIds); */
     $mesIds += KunenaForumTopicHelper::fetchNewStatus($this->topics);
     // Fetch also last post positions when user can see unapproved or deleted posts.
     // TODO: Optimize? Take account of configuration option...
     if ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
         $mesIds += $lastIds;
     }
     // Load position information for all selected messages.
     if ($mesIds) {
         KunenaForumMessageHelper::loadLocation($mesIds);
     }
 }
コード例 #5
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare reply history display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $this->topic = KunenaForumTopicHelper::get($id);
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
     $this->replycount = $this->topic->getReplies();
     $this->historycount = count($this->history);
     KunenaAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'history');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
     // FIXME: need to improve BBCode class on this...
     $this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
     $this->inline_attachments = array();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
コード例 #6
0
ファイル: kunena20.php プロジェクト: bobozhangshao/HeartCare
 /**
  * @param  UserTable    $viewer  Viewing User
  * @param  UserTable    $user    Viewed at User
  * @param  TabTable     $tab     Current Tab
  * @param  PluginTable  $plugin  Current Plugin
  * @return string                HTML
  */
 public static function getPosts($viewer, $user, $tab, $plugin)
 {
     global $_CB_framework, $_CB_database;
     if (!class_exists('KunenaForumMessageHelper')) {
         return CBTxt::T('Kunena not installed, enabled, or failed to load.');
     }
     $exclude = $plugin->params->get('forum_exclude', null);
     if ($exclude) {
         $exclude = explode('|*|', $exclude);
         cbArrayToInts($exclude);
         $exclude = implode(',', $exclude);
     }
     cbimport('cb.pagination');
     cbforumsClass::getTemplate('tab_posts');
     $limit = (int) $tab->params->get('tab_posts_limit', 15);
     $limitstart = $_CB_framework->getUserStateFromRequest('tab_posts_limitstart{com_comprofiler}', 'tab_posts_limitstart');
     $filterSearch = $_CB_framework->getUserStateFromRequest('tab_posts_search{com_comprofiler}', 'tab_posts_search');
     $where = array();
     if (isset($filterSearch) && $filterSearch != '') {
         $where[] = '( m.' . $_CB_database->NameQuote('subject') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' OR t.' . $_CB_database->NameQuote('message') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' )';
     }
     $searching = count($where) ? true : false;
     if ($exclude) {
         $where[] = '( m.' . $_CB_database->NameQuote('catid') . ' NOT IN ( ' . $exclude . ' ) )';
     }
     $params = array('user' => (int) $user->id, 'starttime' => -1, 'where' => count($where) ? implode(' AND ', $where) : null);
     $posts = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $params);
     $total = array_shift($posts);
     if ($total <= $limitstart) {
         $limitstart = 0;
     }
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     $pageNav->setInputNamePrefix('tab_posts_');
     if ($tab->params->get('tab_posts_paging', 1)) {
         $posts = KunenaForumMessageHelper::getLatestMessages(false, (int) $pageNav->limitstart, (int) $pageNav->limit, $params);
         $posts = array_pop($posts);
     } else {
         $posts = array_pop($posts);
     }
     $rows = array();
     /** @var KunenaForumMessage[] $posts */
     if ($posts) {
         foreach ($posts as $post) {
             $row = new stdClass();
             $row->id = $post->id;
             $row->subject = $post->subject;
             $row->message = $post->message;
             $row->date = $post->time;
             $row->url = $post->getUrl();
             $row->category_id = $post->getCategory()->id;
             $row->category_name = $post->getCategory()->name;
             $row->category_url = $post->getCategory()->getUrl();
             $rows[] = $row;
         }
     }
     $input = array();
     $input['search'] = '<input type="text" name="tab_posts_search" value="' . htmlspecialchars($filterSearch) . '" onchange="document.forumPostsForm.submit();" placeholder="' . htmlspecialchars(CBTxt::T('Search Posts...')) . '" class="form-control" />';
     return HTML_cbforumsTabPosts::showPosts($rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin);
 }
コード例 #7
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Prepare topic reply form.
  *
  * @return void
  *
  * @throws RuntimeException
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid');
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     $quote = $this->input->getBool('quote', false);
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $parent = KunenaForumMessageHelper::get($this->topic->first_post_id);
     } else {
         $parent = KunenaForumMessageHelper::get($mesid);
         $this->topic = $parent->getTopic();
     }
     $this->category = $this->topic->getCategory();
     if ($parent->isAuthorised('reply') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
                 $this->captchaEnabled = $result[0];
             }
         } else {
             $this->captchaEnabled = false;
         }
     }
     $parent->tryAuthorise('reply');
     // Run event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     // Can user edit topic icons?
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     list($this->topic, $this->message) = $parent->newReply($saved ? $saved : $quote);
     $this->action = 'post';
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     $this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_BUTTON_MESSAGE_REPLY') . ' ' . $this->topic->subject;
 }
コード例 #8
0
ファイル: kunena20.php プロジェクト: kosmosby/medicine-prof
	static public function getForum( $tabs, $row, $user, $plugin ) {
		global $_CB_database;

		if ( ! class_exists( 'KunenaForumMessageHelper' ) ) {
			return CBTxt::T( 'Kunena not installed, enabled, or failed to load.' );
		}

		$params				=	$row->getParams();
		$forumId			=	$params->get( 'forum_id', null );

		cbgjClass::getTemplate( 'cbgroupjiveforums' );

		$paging				=	new cbgjPaging( 'forum' );

		$limit				=	$paging->getlimit( (int) $plugin->params->get( 'forum_limit', 15 ) );
		$limitstart			=	$paging->getLimistart();
		$search				=	$paging->getFilter( 'search' );
		$where				=	array();

		if ( isset( $search ) && ( $search != '' ) ) {
			$where[]		=	'( m.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
							.	' OR t.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
		}

		$params				=	array(	'starttime' => -1,
										'where' => ( count( $where ) ? implode( ' AND ', $where ) : null )
									);

		$rows				=	KunenaForumMessageHelper::getLatestMessages( $forumId, 0, 0, $params );
		$total				=	array_shift( $rows );

		if ( $total <= $limitstart ) {
			$limitstart		=	0;
		}

		$pageNav			=	$paging->getPageNav( $total, $limitstart, $limit );

		if ( $plugin->params->get( 'forum_paging', 1 ) ) {
			$rows			=	KunenaForumMessageHelper::getLatestMessages( $forumId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
			$rows			=	array_pop( $rows );
		} else {
			$rows			=	array_pop( $rows );
		}

		$pageNav->search	=	$paging->getInputSearch( 'gjForm_forum', 'search', CBTxt::T( 'Search Forums...' ), $search );
		$pageNav->searching	=	( $search ? true : false );
		$pageNav->limitbox	=	$paging->getLimitbox( $pageNav );
		$pageNav->pagelinks	=	$paging->getPagesLinks( $pageNav );

		if ( class_exists( 'HTML_cbgroupjiveforums' ) ) {
			return HTML_cbgroupjiveforums::showForums( $rows, $pageNav, $tabs, $row, $user, $plugin );
		} else {
			return cbgjForumsPlugin::showForum( $rows, $pageNav, $tabs, $row, $user, $plugin );
		}
	}
コード例 #9
0
ファイル: display.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * Redirect unread layout to the page that contains the first unread message.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     $catid = $this->input->getInt('catid', 0);
     $id = $this->input->getInt('id', 0);
     $category = KunenaForumCategoryHelper::get($catid);
     $category->tryAuthorise();
     $topic = KunenaForumTopicHelper::get($id);
     $topic->tryAuthorise();
     KunenaForumTopicHelper::fetchNewStatus(array($topic->id => $topic));
     $message = KunenaForumMessageHelper::get($topic->lastread ? $topic->lastread : $topic->last_post_id);
     $message->tryAuthorise();
     while (@ob_end_clean()) {
     }
     $this->app->redirect($topic->getUrl($category, false, $message));
 }
コード例 #10
0
ファイル: display.php プロジェクト: anawu2006/PeerLearning
 /**
  * Prepare topic moderate display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid');
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $this->topic->tryAuthorise('move');
     } else {
         $this->message = KunenaForumMessageHelper::get($mesid);
         $this->message->tryAuthorise('move');
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $this->uri = "index.php?option=com_kunena&view=topic&layout=moderate" . "&catid={$this->category->id}&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
     $this->title = !$this->message ? JText::_('COM_KUNENA_TITLE_MODERATE_TOPIC') : JText::_('COM_KUNENA_TITLE_MODERATE_MESSAGE');
     // Load topic icons if available.
     if ($this->config->topicicons) {
         $this->template = KunenaTemplate::getInstance();
         $this->template->setCategoryIconset();
         $this->topicIcons = $this->template->getTopicIcons(false);
     }
     // Have a link to moderate user as well.
     if (isset($this->message)) {
         $user = $this->message->getAuthor();
         if ($user->exists()) {
             $username = $user->getName();
             $this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
         }
     }
     if ($this->message) {
         $this->banHistory = KunenaUserBan::getUserHistory($this->message->userid);
         $this->me = KunenaFactory::getUser();
         // Get thread and reply count from current message:
         $db = JFactory::getDbo();
         $query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->message->id)}";
         $db->setQuery($query, 0, 1);
         $this->replies = $db->loadResult();
         if (KunenaError::checkDatabaseError()) {
             return;
         }
     }
     $this->banInfo = KunenaUserBan::getInstanceByUserid(JFactory::getUser()->id, true);
 }
コード例 #11
0
ファイル: display.php プロジェクト: densem-2013/exikom
 /**
  * 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');
 }
コード例 #12
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare topic edit form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->catid = $this->input->getInt('catid');
     $mesid = $this->input->getInt('mesid');
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise('edit');
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->template->setCategoryIconset($this->topic->getCategory()->iconset);
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     // Run onKunenaPrepare event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     $this->action = 'edit';
     // Get attachments.
     $this->attachments = $this->message->getAttachments();
     // Get poll.
     if ($this->message->parent == 0 && $this->topic->isAuthorised(!$this->topic->poll_id ? 'poll.create' : 'poll.edit')) {
         $this->poll = $this->topic->getPoll();
     }
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($saved) {
         // Update message contents.
         $this->message->edit($saved);
     }
     $this->post_anonymous = isset($saved['anonymous']) ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = isset($saved['subscribe']) ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->modified_reason = isset($saved['modified_reason']) ? $saved['modified_reason'] : '';
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
コード例 #13
0
ファイル: topics.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * @param   array $userlist
  * @param   array $postlist
  */
 protected function _common(array $userlist = array(), array $postlist = array())
 {
     if ($this->total > 0) {
         // collect user ids for avatar prefetch when integrated
         $lastpostlist = array();
         foreach ($this->topics as $topic) {
             $userlist[intval($topic->first_post_userid)] = intval($topic->first_post_userid);
             $userlist[intval($topic->last_post_userid)] = intval($topic->last_post_userid);
             $lastpostlist[intval($topic->last_post_id)] = intval($topic->last_post_id);
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         if (!empty($userlist)) {
             KunenaUserHelper::loadUsers($userlist);
         }
         KunenaForumTopicHelper::getUserTopics(array_keys($this->topics));
         KunenaForumTopicHelper::getKeywords(array_keys($this->topics));
         $lastreadlist = KunenaForumTopicHelper::fetchNewStatus($this->topics);
         // Fetch last / new post positions when user can see unapproved or deleted posts
         if ($postlist || $lastreadlist || $this->me->userid && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
             KunenaForumMessageHelper::loadLocation($postlist + $lastpostlist + $lastreadlist);
         }
     }
 }
コード例 #14
0
ファイル: topic.php プロジェクト: sillysachin/teamtogether
 public function getMessages()
 {
     if ($this->messages === false) {
         $layout = $this->getState('layout');
         $threaded = $layout == 'indented' || $layout == 'threaded';
         $this->messages = KunenaForumMessageHelper::getMessagesByTopic($this->getState('item.id'), $this->getState('list.start'), $this->getState('list.limit'), $this->getState('list.direction'), $this->getState('hold'), $threaded);
         // Get thankyous for all messages in the page
         $thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
         // First collect ids and users
         $userlist = array();
         $this->threaded = array();
         $location = $this->getState('list.start');
         foreach ($this->messages as $message) {
             $message->replynum = ++$location;
             if ($threaded) {
                 // Threaded ordering
                 if (isset($this->messages[$message->parent])) {
                     $this->threaded[$message->parent][] = $message->id;
                 } else {
                     $this->threaded[0][] = $message->id;
                 }
             }
             $userlist[intval($message->userid)] = intval($message->userid);
             $userlist[intval($message->modified_by)] = intval($message->modified_by);
             $thankyou_list = $thankyous[$message->id]->getList();
             $message->thankyou = array();
             if (!empty($thankyou_list)) {
                 $message->thankyou = $thankyou_list;
             }
         }
         if (!isset($this->messages[$this->getState('item.mesid')]) && !empty($this->messages)) {
             $this->setState('item.mesid', reset($this->messages)->id);
         }
         if ($threaded) {
             if (!isset($this->messages[$this->topic->first_post_id])) {
                 $this->messages = $this->getThreadedOrdering(0, array('edge'));
             } else {
                 $this->messages = $this->getThreadedOrdering();
             }
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         KunenaUserHelper::loadUsers($userlist);
         // Get attachments
         KunenaForumMessageAttachmentHelper::getByMessage($this->messages);
     }
     return $this->messages;
 }
コード例 #15
0
ファイル: helper.php プロジェクト: proyectoseb/University
 /**
  * Free up memory by cleaning up all cached items.
  */
 public static function cleanup()
 {
     self::$_instances = array();
     self::$_location = array();
 }
コード例 #16
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare displaying message.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $mesid = $this->input->getInt('mesid', 0);
     $this->me = KunenaUserHelper::getMyself();
     $this->location = $this->input->getInt('location', 0);
     $this->detail = $this->input->get('detail', false);
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise();
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->profile = $this->message->getAuthor();
     $this->ktemplate = KunenaFactory::getTemplate();
     $this->captchaEnabled = false;
     if ($this->message->isAuthorised('reply') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', "dynamic_recaptcha_{$this->message->id}");
                 $this->captchaEnabled = $result[0];
             }
         }
     }
     // Thank you info and buttons.
     $this->thankyou = array();
     $this->total_thankyou = 0;
     $this->more_thankyou = 0;
     $this->thankyou_delete = array();
     if (isset($this->message->thankyou)) {
         if ($this->config->showthankyou && $this->profile->exists()) {
             $task = "index.php?option=com_kunena&view=topic&task=%s&catid={$this->category->id}" . "&id={$this->topic->id}&mesid={$this->message->id}&" . JSession::getFormToken() . '=1';
             // Ror normal users, show only limited number of thankyou (config->thankyou_max).
             if (!$this->me->isAdmin() && !$this->me->isModerator()) {
                 if (count($this->message->thankyou) > $this->config->thankyou_max) {
                     $this->more_thankyou = count($this->message->thankyou) - $this->config->thankyou_max;
                 }
                 $this->total_thankyou = count($this->message->thankyou);
                 $thankyous = array_slice($this->message->thankyou, 0, $this->config->thankyou_max, true);
             } else {
                 $thankyous = $this->message->thankyou;
             }
             $userids_thankyous = array();
             foreach ($thankyous as $userid => $time) {
                 $userids_thankyous[] = $userid;
             }
             $loaded_users = KunenaUserHelper::loadUsers($userids_thankyous);
             foreach ($loaded_users as $userid => $user) {
                 if ($this->message->authorise('unthankyou') && $this->me->isModerator($this->message->getCategory())) {
                     $this->thankyou_delete[$userid] = KunenaRoute::_(sprintf($task, "unthankyou&userid={$userid}"));
                 }
                 $this->thankyou[$userid] = $loaded_users[$userid]->getLink();
             }
         }
     }
     if ($this->config->reportmsg && $this->me->exists()) {
         if ($this->config->user_report && $this->me->userid == $this->message->userid && !$this->me->isModerator()) {
             $this->reportMessageLink = JHTML::_('kunenaforum.link', 'index.php?option=com_kunena&view=topic&layout=report&catid=' . intval($this->category->id) . '&id=' . intval($this->message->thread) . '&mesid=' . intval($this->message->id), JText::_('COM_KUNENA_REPORT'), JText::_('COM_KUNENA_REPORT'));
         }
     }
     // Show admins the IP address of the user.
     if ($this->category->isAuthorised('admin') || $this->category->isAuthorised('moderate') && !$this->config->hide_ip) {
         if (!empty($this->message->ip)) {
             $this->ipLink = '<a href="http://whois.domaintools.com/' . $this->message->ip . '" target="_blank"> IP: ' . $this->message->ip . '</a>';
         } else {
             $this->ipLink = '&nbsp;';
         }
     }
 }
コード例 #17
0
ファイル: user.php プロジェクト: proyectoseb/University
 function ban()
 {
     $user = KunenaFactory::getUser(JRequest::getInt('userid', 0));
     if (!$user->exists() || !JSession::checkToken('post')) {
         $this->app->redirect($user->getUrl(false), JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         return;
     }
     $ban = KunenaUserBan::getInstanceByUserid($user->userid, true);
     if (!$ban->canBan()) {
         $this->setRedirect($user->getUrl(false), $ban->getError(), 'error');
         return;
     }
     $ip = JRequest::getString('ip', '');
     $block = JRequest::getInt('block', 0);
     $expiration = JRequest::getString('expiration', '');
     $reason_private = JRequest::getString('reason_private', '');
     $reason_public = JRequest::getString('reason_public', '');
     $comment = JRequest::getString('comment', '');
     if (!$ban->id) {
         $ban->ban($user->userid, $ip, $block, $expiration, $reason_private, $reason_public, $comment);
         $success = $ban->save();
         $this->report($user->userid);
     } else {
         $delban = JRequest::getString('delban', '');
         if ($delban) {
             $ban->unBan($comment);
             $success = $ban->save();
         } else {
             $ban->blocked = $block;
             $ban->setExpiration($expiration, $comment);
             $ban->setReason($reason_public, $reason_private);
             $success = $ban->save();
         }
     }
     if ($block) {
         if ($ban->isEnabled()) {
             $message = JText::_('COM_KUNENA_USER_BLOCKED_DONE');
         } else {
             $message = JText::_('COM_KUNENA_USER_UNBLOCKED_DONE');
         }
     } else {
         if ($ban->isEnabled()) {
             $message = JText::_('COM_KUNENA_USER_BANNED_DONE');
         } else {
             $message = JText::_('COM_KUNENA_USER_UNBANNED_DONE');
         }
     }
     if (!$success) {
         $this->app->enqueueMessage($ban->getError(), 'error');
     } else {
         $this->app->enqueueMessage($message);
     }
     $banDelPosts = JRequest::getString('bandelposts', '');
     $DelAvatar = JRequest::getString('delavatar', '');
     $DelSignature = JRequest::getString('delsignature', '');
     $DelProfileInfo = JRequest::getString('delprofileinfo', '');
     if (!empty($DelAvatar) || !empty($DelProfileInfo)) {
         jimport('joomla.filesystem.file');
         $avatar_deleted = '';
         // Delete avatar from file system
         if (JFile::exists(JPATH_ROOT . '/media/kunena/avatars/' . $user->avatar) && !stristr($user->avatar, 'gallery/')) {
             JFile::delete(JPATH_ROOT . '/media/kunena/avatars/' . $user->avatar);
             $avatar_deleted = JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR_FILESYSTEM');
         }
         $user->avatar = '';
         $user->save();
         $this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR') . $avatar_deleted);
     }
     if (!empty($DelProfileInfo)) {
         $user->personalText = '';
         $user->birthdate = '0000-00-00';
         $user->location = '';
         $user->gender = 0;
         $user->icq = '';
         $user->aim = '';
         $user->yim = '';
         $user->msn = '';
         $user->skype = '';
         $user->gtalk = '';
         $user->twitter = '';
         $user->facebook = '';
         $user->myspace = '';
         $user->linkedin = '';
         $user->delicious = '';
         $user->friendfeed = '';
         $user->digg = '';
         $user->blogspot = '';
         $user->flickr = '';
         $user->bebo = '';
         $user->websitename = '';
         $user->websiteurl = '';
         $user->signature = '';
         $user->save();
         $this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_PROFILEINFO'));
     } elseif (!empty($DelSignature)) {
         $user->signature = '';
         $user->save();
         $this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_SIGNATURE'));
     }
     if (!empty($banDelPosts)) {
         $params = array('starttime' => '-1', 'user' => $user->userid, 'mode' => 'unapproved');
         list($total, $messages) = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $params);
         $parmas_recent = array('starttime' => '-1', 'user' => $user->userid);
         list($total, $messages_recent) = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $parmas_recent);
         $messages = array_merge($messages_recent, $messages);
         foreach ($messages as $mes) {
             $mes->publish(KunenaForum::DELETED);
         }
         $this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_MESSAGES'));
     }
     $this->app->redirect($user->getUrl(false));
 }
コード例 #18
0
ファイル: view.html.php プロジェクト: Ruud68/Kunena-Forum
 /**
  *
  */
 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');
 }
コード例 #19
0
ファイル: search.php プロジェクト: sillysachin/teamtogether
 public function getResults()
 {
     if ($this->messages !== false) {
         return $this->messages;
     }
     $q = $this->getState('searchwords');
     if (!$q && !$this->getState('query.searchuser')) {
         $this->setError(JText::_('COM_KUNENA_SEARCH_ERR_SHORTKEYWORD'));
         return array();
     }
     /* get results */
     $hold = $this->getState('query.show');
     if ($hold == 1) {
         $mode = 'unapproved';
     } elseif ($hold >= 2) {
         $mode = 'deleted';
     } else {
         $mode = 'recent';
     }
     $params = array('mode' => $mode, 'childforums' => $this->getState('query.childforums'), 'where' => $this->buildWhere(), 'orderby' => $this->buildOrderBy(), 'starttime' => -1);
     $limitstart = $this->getState('list.start');
     $limit = $this->getState('list.limit');
     list($this->total, $this->messages) = KunenaForumMessageHelper::getLatestMessages($this->getState('query.catids'), $limitstart, $limit, $params);
     if ($this->total < $limitstart) {
         $this->setState('list.start', intval($this->total / $limit) * $limit);
     }
     $topicids = array();
     $userids = array();
     foreach ($this->messages as $message) {
         $topicids[$message->thread] = $message->thread;
         $userids[$message->userid] = $message->userid;
     }
     if ($topicids) {
         $topics = KunenaForumTopicHelper::getTopics($topicids);
         foreach ($topics as $topic) {
             $userids[$topic->first_post_userid] = $topic->first_post_userid;
         }
     }
     KunenaUserHelper::loadUsers($userids);
     KunenaForumMessageHelper::loadLocation($this->messages);
     if (empty($this->messages)) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_SEARCH_NORESULTS_FOUND', $q));
     }
     return $this->messages;
 }
コード例 #20
0
ファイル: view.html.php プロジェクト: Jougito/DynWeb
 function displayThreadHistory()
 {
     if (!$this->hasThreadHistory()) {
         return;
     }
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering = 'DESC');
     $this->historycount = count($this->history);
     $this->replycount = $this->topic->getReplies();
     KunenaAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'history');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
     echo $this->loadTemplateFile('history');
 }
コード例 #21
0
ファイル: attachment.php プロジェクト: densem-2013/exikom
 /**
  * Get message to which attachment has been attached into.
  *
  * NOTE: Returns message object even if there isn't one. Please call $message->exists() to check if it exists.
  *
  * @return KunenaForumMessage
  *
  * @since  K4.0
  */
 public function getMessage()
 {
     return KunenaForumMessageHelper::get($this->mesid);
 }
コード例 #22
0
	static function GetReportMessageLink($catid, $id, $name, $rel = 'nofollow', $class = '', $title = '') {
		$message = KunenaForumMessageHelper::get($id);
		return self::GetSefHrefLink ( "index.php?option=com_kunena&view=topic&layout=report&catid={$catid}&id={$message->thread}&mesid={$message->id}", $name, $title, $rel, $class );
	}
コード例 #23
0
ファイル: topics.php プロジェクト: rich20/Kunena
	protected function _common() {
		if ($this->total > 0) {
			$config = KunenaFactory::getConfig ();

			// collect user ids for avatar prefetch when integrated
			$userlist = array();
			$lastpostlist = array();
			foreach ( $this->topics as $topic ) {
				$userlist[intval($topic->first_post_userid)] = intval($topic->first_post_userid);
				$userlist[intval($topic->last_post_userid)] = intval($topic->last_post_userid);
				$lastpostlist[intval($topic->last_post_id)] = intval($topic->last_post_id);
			}

			// Prefetch all users/avatars to avoid user by user queries during template iterations
			if ( !empty($userlist) ) KunenaUserHelper::loadUsers($userlist);

			KunenaForumTopicHelper::getUserTopics(array_keys($this->topics));
			KunenaForumTopicHelper::getKeywords(array_keys($this->topics));
			$lastreadlist = KunenaForumTopicHelper::fetchNewStatus($this->topics);
			// Fetch last / new post positions when user can see unapproved or deleted posts
			$me = KunenaUserHelper::get();
			if (($lastpostlist || $lastreadlist) && $me->userid && $me->isModerator()) {
				KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist);
			}
		}
	}
コード例 #24
0
ファイル: message.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * @return KunenaForumMessage
  */
 public function getParent()
 {
     return KunenaForumMessageHelper::get($this->parent);
 }
コード例 #25
0
ファイル: trash.php プロジェクト: rich20/Kunena
	/**
	 * 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;
	}
コード例 #26
0
ファイル: attachments.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * @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;
 }
コード例 #27
0
ファイル: category.php プロジェクト: rich20/Kunena
	public function getLastPostLocation($direction = 'asc', $hold = null) {
		if (!$this->_me->isModerator($this->id)) return $direction = 'asc' ? $this->last_topic_posts-1 : 0;
		return KunenaForumMessageHelper::getLocation($this->last_post_id, $direction, $hold);
	}
コード例 #28
0
ファイル: topic.php プロジェクト: rich20/Kunena
	public function getPostLocation($mesid, $direction = 'asc', $hold=null) {
		if (!isset($this->lastread)) {
			$this->lastread = $this->last_post_id;
			$this->unread = 0;
		}
		if ($mesid == 'unread') $mesid = $this->lastread;
		if ($this->moved_id || !$this->_me->isModerator($this->category_id)) {
			if ($mesid == 'first' || $mesid == $this->first_post_id) return $direction = 'asc' ? 0 : $this->posts-1;
			if ($mesid == 'last' || $mesid == $this->last_post_id) return $direction = 'asc' ? $this->posts-1 : 0;
			if ($mesid == $this->unread) return $direction = 'asc' ? $this->posts - max($this->unread, 1) : 0;
		}
		if ($mesid == 'first') $direction == 'asc' ? 0 : 'both';
		if ($mesid == 'last') $direction == 'asc' ? 'both' : 0;
		if (!$direction) return 0;
		return KunenaForumMessageHelper::getLocation($mesid, $direction, $hold);
	}
コード例 #29
0
ファイル: thankyou.php プロジェクト: madcsaba/li-de
 /**
  * Detele thank you from the database.
  *
  * @param mixed $user
  *
  * @return bool
  */
 public function delete($user)
 {
     $user = KunenaFactory::getUser($user);
     $message = KunenaForumMessageHelper::get($this->id);
     if (!$user->exists()) {
         $this->setError(JText::_('COM_KUNENA_THANKYOU_LOGIN'));
         return false;
     }
     if (!$this->exists($user->userid)) {
         $this->setError(JText::_('COM_KUNENA_THANKYOU_NOT_PRESENT'));
         return false;
     }
     $db = JFactory::getDBO();
     $query = "DELETE FROM #__kunena_thankyou WHERE postid={$db->quote($this->id)} AND userid={$db->quote($user->userid)}";
     $db->setQuery($query);
     $db->query();
     $query = "UPDATE #__kunena_users SET thankyou=thankyou-1 WHERE userid={$db->quote($message->userid)}";
     $db->setQuery($query);
     $db->query();
     // Check for an error message.
     if ($db->getErrorNum()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }
コード例 #30
0
ファイル: topic.php プロジェクト: giabmf11/Kunena-Forum
 /**
  * @param int $mesid
  * @param string|null $direction
  * @param mixed $hold
  *
  * @return int
  */
 public function getPostLocation($mesid, $direction = null, $hold = null)
 {
     if (is_null($direction)) {
         $direction = KunenaUserHelper::getMyself()->getMessageOrdering();
     }
     if (!isset($this->lastread)) {
         $this->lastread = $this->last_post_id;
         $this->unread = 0;
     }
     if ($mesid == 'unread') {
         $mesid = $this->lastread;
     }
     if ($this->moved_id || !KunenaUserHelper::getMyself()->isModerator($this->getCategory())) {
         if ($mesid == 'first' || $mesid == $this->first_post_id) {
             return $direction == 'asc' ? 0 : $this->posts - 1;
         }
         if ($mesid == 'last' || $mesid == $this->last_post_id) {
             return $direction == 'asc' ? $this->posts - 1 : 0;
         }
         if ($mesid == $this->unread) {
             return $direction == 'asc' ? $this->posts - max($this->unread, 1) : 0;
         }
     }
     if ($mesid == 'first') {
         $direction = $direction == 'asc' ? 0 : 'both';
     }
     if ($mesid == 'last') {
         $direction = $direction == 'asc' ? 'both' : 0;
     }
     return KunenaForumMessageHelper::getLocation($mesid, $direction, $hold);
 }