/** * 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}" : ''); }
/** * 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'); }
/** * Prepare category display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); require_once KPATH_SITE . '/models/category.php'; $this->model = new KunenaModelCategory(); $this->me = KunenaUserHelper::getMyself(); $catid = $this->input->getInt('catid'); $limitstart = $this->input->getInt('limitstart', 0); $limit = $this->input->getInt('limit', 0); if ($limit < 1 || $limit > 100) { $limit = $this->config->threads_per_page; } // TODO: $direction = 'DESC'; $this->category = KunenaForumCategoryHelper::get($catid); $this->category->tryAuthorise(); $this->headerText = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name; $topic_ordering = $this->category->topic_ordering; $access = KunenaAccess::getInstance(); $hold = $access->getAllowedHold($this->me, $catid); $moved = 1; $params = array('hold' => $hold, 'moved' => $moved); switch ($topic_ordering) { case 'alpha': $params['orderby'] = 'tt.ordering DESC, tt.subject ASC '; break; case 'creation': $params['orderby'] = 'tt.ordering DESC, tt.first_post_time ' . $direction; break; case 'lastpost': default: $params['orderby'] = 'tt.ordering DESC, tt.last_post_time ' . $direction; } list($this->total, $this->topics) = KunenaForumTopicHelper::getLatestTopics($catid, $limitstart, $limit, $params); if ($this->total > 0) { // 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. if ($lastreadlist || $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) { KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist); } } $this->topicActions = $this->model->getTopicActions(); $this->actionMove = $this->model->getActionMove(); $this->pagination = new KunenaPagination($this->total, $limitstart, $limit); $this->pagination->setDisplayedPages(5); }
/** * Prepare search results display. * * @return void */ protected function before() { parent::before(); require_once KPATH_SITE . '/models/search.php'; $this->model = new KunenaModelSearch(array(), $this->input); $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false)); $this->state = $this->model->getState(); $this->me = KunenaUserHelper::getMyself(); $this->message_ordering = $this->me->getMessageOrdering(); $this->searchwords = $this->model->getSearchWords(); $this->isModerator = ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()); $this->results = array(); $this->total = $this->model->getTotal(); $this->results = $this->model->getResults(); $this->pagination = new KunenaPagination( $this->total, $this->state->get('list.start'), $this->state->get('list.limit') ); $this->error = $this->model->getError(); }
/** * Prepare announcement list display. * * @return void */ protected function before() { parent::before(); $limit = $this->input->getInt('limit', 0); if ($limit < 1 || $limit > 100) { $limit = 20; } $limitstart = $this->input->getInt('limitstart', 0); if ($limitstart < 0) { $limitstart = 0; } $moderator = KunenaUserHelper::getMyself()->isModerator(); $this->pagination = new KunenaPagination(KunenaForumAnnouncementHelper::getCount(!$moderator), $limitstart, $limit); $this->announcements = KunenaForumAnnouncementHelper::getAnnouncements( $this->pagination->limitstart, $this->pagination->limit, !$moderator ); }
/** * Load user list. * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $config = KunenaConfig::getInstance(); if ($config->userlist_allowed && JFactory::getUser()->guest) { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401'); } require_once KPATH_SITE . '/models/user.php'; $this->model = new KunenaModelUser(array(), $this->input); $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false)); $this->state = $this->model->getState(); $this->me = KunenaUserHelper::getMyself(); $this->config = KunenaConfig::getInstance(); $start = $this->state->get('list.start'); $limit = $this->state->get('list.limit'); // Get list of super admins to exclude or not in filter by configuration. $filter = JAccess::getUsersByGroup(8); $finder = new KunenaUserFinder(); $finder->filterByConfiguration($filter)->filterByName($this->state->get('list.search')); $this->total = $finder->count(); $this->pagination = new KunenaPagination($this->total, $start, $limit); $alias = 'ku'; $aliasList = array('id', 'name', 'username', 'email', 'block', 'registerDate', 'lastvisitDate'); if (in_array($this->state->get('list.ordering'), $aliasList)) { $alias = 'a'; } $this->users = $finder->order($this->state->get('list.ordering'), $this->state->get('list.direction') == 'asc' ? 1 : -1, $alias)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find(); }
/** * Prepare message actions display. * * @return void */ protected function before() { parent::before(); $catid = $this->input->getInt('id'); $me = KunenaUserHelper::getMyself(); $this->category = KunenaForumCategory::getInstance($catid); $token = JSession::getFormToken(); $task = "index.php?option=com_kunena&view=category&task=%s&catid={$catid}&{$token}=1"; $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}"; $this->template = KunenaFactory::getTemplate(); $this->categoryButtons = new JObject(); // Is user allowed to post new topic? if ($this->category->getNewTopicCategory()->exists()) { $this->categoryButtons->set('create', $this->getButton(sprintf($layout, 'create'), 'create', 'topic', 'communication', true)); } // Is user allowed to mark forums as read? if ($me->exists()) { $this->categoryButtons->set('markread', $this->getButton(sprintf($task, 'markread'), 'markread', 'category', 'user', true)); } // Is user allowed to subscribe category? if ($this->category->isAuthorised('subscribe')) { $subscribed = $this->category->getSubscribed($me->userid); if (!$subscribed) { $this->categoryButtons->set('subscribe', $this->getButton(sprintf($task, 'subscribe'), 'subscribe', 'category', 'user', true)); } else { $this->categoryButtons->set('unsubscribe', $this->getButton(sprintf($task, 'unsubscribe'), 'unsubscribe', 'category', 'user', true)); } } JPluginHelper::importPlugin('kunena'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onKunenaGetButtons', array('category.action', $this->categoryButtons, $this)); }
/** * Prepare login display. * * @return boolean */ protected function before() { parent::before(); $login = KunenaLogin::getInstance(); if (!$login->enabled()) { return false; } $this->me = KunenaUserHelper::getMyself(); $this->name = $this->me->exists() ? 'Widget/Login/Logout' : 'Widget/Login/Login'; $this->my = JFactory::getUser(); if ($this->my->guest) { $this->registrationUrl = $login->getRegistrationUrl(); $this->resetPasswordUrl = $login->getResetUrl(); $this->remindUsernameUrl = $login->getRemindUrl(); $this->rememberMe = $login->getRememberMe(); } else { $this->lastvisitDate = KunenaDate::getInstance($this->my->lastvisitDate); $private = KunenaFactory::getPrivateMessaging(); if ($private) { $count = $private->getUnreadCount($this->me->userid); $this->inboxCount = $count ? JText::sprintf('COM_KUNENA_PMS_INBOX_NEW', $count) : JText::_('COM_KUNENA_PMS_INBOX'); $this->pm_link = $private->getInboxURL(); } // Display announcements. if ($this->me->isModerator()) { $this->announcementsUrl = KunenaForumAnnouncementHelper::getUrl('list'); } } return true; }
/** * Load user profile. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); // If profile integration is disabled, this view doesn't exist. $integration = KunenaFactory::getProfile(); if (get_class($integration) == 'KunenaProfileNone') { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_PROFILE_DISABLED'), 404); } $userid = $this->input->getInt('userid'); require_once KPATH_SITE . '/models/user.php'; $this->model = new KunenaModelUser(array(), $this->input); $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false)); $this->state = $this->model->getState(); $this->me = KunenaUserHelper::getMyself(); $this->user = JFactory::getUser($userid); $this->profile = KunenaUserHelper::get($userid); $this->profile->tryAuthorise('read'); // Update profile hits. if (!$this->profile->exists() || !$this->profile->isMyself()) { $this->profile->uhits++; $this->profile->save(); } $this->headerText = JText::sprintf('COM_KUNENA_VIEW_USER_DEFAULT', $this->profile->getName()); }
/** * 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; }
/** * Prepare announcement box display. * * @return bool */ protected function before() { parent::before(); $config = KunenaConfig::getInstance(); if (!$config->showannouncement) { return false; } $items = KunenaForumAnnouncementHelper::getAnnouncements(); $this->announcement = array_pop($items); if (!$this->announcement || !$this->announcement->authorise('read')) { return false; } $view = $this->input->getWord('view', 'default'); $layout = $this->input->getWord('layout', 'default'); if ($view == 'topic' && $layout != 'default' || $view == 'user' || $view == 'search' || $view == 'announcement' && $layout == 'default') { return false; } return true; }
/** * Prepare menu display. * * @return bool */ protected function before() { parent::before(); $this->basemenu = $basemenu = KunenaRoute::getMenu(); if (!$basemenu) { return false; } $parameters = new JRegistry; $template = KunenaFactory::getTemplate(); $parameters->set('showAllChildren', $template->params->get('menu_showall', 0)); $parameters->set('menutype', $basemenu->menutype); $parameters->set('startLevel', $basemenu->level + 1); $parameters->set('endLevel', $basemenu->level + $template->params->get('menu_levels', 1)); $this->list = KunenaMenuHelper::getList($parameters); $this->menu = $this->app->getMenu(); $this->active = $this->menu->getActive(); $this->active_id = isset($this->active) ? $this->active->id : $this->menu->getDefault()->id; $this->path = isset($this->active) ? $this->active->tree : array(); $this->showAll = $parameters->get('showAllChildren'); $this->class_sfx = htmlspecialchars($parameters->get('pageclass_sfx'), ENT_COMPAT, 'UTF-8'); return true; }
/** * Prepare announcement form display. * * @return void */ protected function before() { parent::before(); $id = $this->input->getInt('id', null); $this->announcement = KunenaForumAnnouncementHelper::get($id); $this->announcement->tryAuthorise($id ? 'edit' : 'create'); }
/** * Prepare category display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); require_once KPATH_SITE . '/models/category.php'; $catid = $this->input->getInt('catid'); $this->category = KunenaForumCategoryHelper::get($catid); $this->category->tryAuthorise(); }
/** * Prepare credits display. * * @return void */ protected function before() { parent::before(); $this->logo = KunenaFactory::getTemplate()->getImagePath('icons/kunena-logo-48-white.png'); $this->intro = JText::sprintf('COM_KUNENA_CREDITS_INTRO', 'http://www.kunena.org/team'); $this->memberList = array(array('name' => 'Florian Dal Fitto', 'url' => 'http://www.kunena.org/forum/user/1288-xillibit', 'title' => JText::_('COM_KUNENA_CREDITS_DEVELOPMENT')), array('name' => 'Jelle Kok', 'url' => 'http://www.kunena.org/forum/user/634-810', 'title' => JText::sprintf('COM_KUNENA_CREDITS_X_AND_Y', JText::_('COM_KUNENA_CREDITS_DEVELOPMENT'), JText::_('COM_KUNENA_CREDITS_DESIGN'))), array('name' => 'Richard Binder', 'url' => 'http://www.kunena.org/forum/user/2198-rich', 'title' => JText::sprintf('COM_KUNENA_CREDITS_X_AND_Y', JText::_('COM_KUNENA_CREDITS_MODERATION'), JText::_('COM_KUNENA_CREDITS_TESTING'))), array('name' => 'Sami Haaranen', 'url' => 'http://www.kunena.org/forum/user/151-mortti', 'title' => JText::sprintf('COM_KUNENA_CREDITS_X_AND_Y', JText::_('COM_KUNENA_CREDITS_MODERATION'), JText::_('COM_KUNENA_CREDITS_TESTING'))), array('name' => 'Matias Griese', 'url' => 'http://www.kunena.org/forum/user/63-matias', 'title' => JText::_('COM_KUNENA_CREDITS_DEVELOPMENT')), array('name' => 'Joshua Weiss', 'url' => 'http://www.kunena.org/forum/user/10809-coder4life', 'title' => JText::sprintf('COM_KUNENA_CREDITS_X_AND_Y', JText::_('COM_KUNENA_CREDITS_DESIGN'), JText::_('COM_KUNENA_CREDITS_DEVELOPMENT'))), array('name' => 'Oliver Ratzesberger', 'url' => 'http://www.kunena.org/forum/user/64-fxstein', 'title' => JText::_('COM_KUNENA_CREDITS_FOUNDER'))); $this->thanks = JText::sprintf('COM_KUNENA_CREDITS_THANKS', 'http://www.kunena.org/team#special_thanks', 'https://www.transifex.com/projects/p/Kunena', 'http://www.kunena.org', 'https://github.com/Kunena/Kunena-Forum/graphs/contributors'); }
/** * Prepare ban form. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $userid = $this->input->getInt('userid'); $this->profile = KunenaUserHelper::get($userid); $this->profile->tryAuthorise('ban'); $this->banInfo = KunenaUserBan::getInstanceByUserid($userid, true); $this->headerText = $this->banInfo->exists() ? JText::_('COM_KUNENA_BAN_EDIT') : JText::_('COM_KUNENA_BAN_NEW'); }
/** * 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; }
/** * Prepare ban history. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $userid = $this->input->getInt('userid'); $this->me = KunenaUserHelper::getMyself(); $this->profile = KunenaUserHelper::get($userid); $this->profile->tryAuthorise('ban'); $this->banHistory = KunenaUserBan::getUserHistory($this->profile->userid); $this->headerText = JText::sprintf('COM_KUNENA_BAN_BANHISTORYFOR', $this->profile->getName()); }
/** * Prepare search form display. * * @return void */ protected function before() { parent::before(); require_once KPATH_SITE . '/models/search.php'; $this->model = new KunenaModelSearch(array(), $this->input); $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false)); $this->state = $this->model->getState(); $this->me = KunenaUserHelper::getMyself(); $this->isModerator = $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus(); $this->error = $this->model->getError(); }
/** * Prepare ban manager. * * @return void */ protected function before() { parent::before(); $this->me = KunenaUserHelper::getMyself(); // TODO: add authorisation // TODO: add pagination $this->userBans = KunenaUserBan::getBannedUsers(0, 50); if (!empty($this->userBans)) { KunenaUserHelper::loadUsers(array_keys($this->userBans)); } $this->headerText = JText::_('COM_KUNENA_BAN_BANMANAGER'); }
/** * Prepare user for editing. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); // If profile integration is disabled, this view doesn't exist. $integration = KunenaFactory::getProfile(); if (get_class($integration) == 'KunenaProfileNone') { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_PROFILE_DISABLED'), 404); } $userid = $this->input->getInt('userid'); $this->user = JFactory::getUser($userid); $this->profile = KunenaUserHelper::get($userid); $this->profile->tryAuthorise('edit'); $this->headerText = JText::sprintf('COM_KUNENA_VIEW_USER_DEFAULT', $this->profile->getName()); }
/** * Prepare statistics box display. * * @return boolean */ protected function before() { parent::before(); $this->config = KunenaConfig::getInstance(); if (!$this->config->get('showstats') || !$this->config->statslink_allowed && !KunenaUserHelper::get()->exists()) { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404'); } $statistics = KunenaForumStatistics::getInstance(); $statistics->loadGeneral(); $this->setProperties($statistics); $this->latestMemberLink = KunenaFactory::getUser(intval($this->lastUserId))->getLink(); $this->statisticsUrl = KunenaFactory::getProfile()->getStatisticsURL(); return true; }
/** * Prepare general statistics display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $this->config = KunenaConfig::getInstance(); if (!$this->config->get('showstats')) { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404'); } if (!$this->config->statslink_allowed && JFactory::getUser()->guest) { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '401'); } $statistics = KunenaForumStatistics::getInstance(); $statistics->loadAll(); $this->setProperties($statistics); $this->latestMemberLink = KunenaFactory::getUser((int) $this->lastUserId)->getLink(); $this->userlistUrl = KunenaFactory::getProfile()->getUserListUrl(); }
/** * 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); }
/** * Prepare Who is online display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $this->config = KunenaConfig::getInstance(); if (!$this->config->get('showwhoisonline')) { throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404'); } $me = KunenaUserHelper::getMyself(); $moderator = intval($me->isModerator()) + intval($me->isAdmin()); $users = KunenaUserHelper::getOnlineUsers(); KunenaUserHelper::loadUsers(array_keys($users)); $onlineusers = KunenaUserHelper::getOnlineCount(); $who = '<strong>' . $onlineusers['user'] . ' </strong>'; if ($onlineusers['user'] == 1) { $who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER') . ' '; } else { $who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS') . ' '; } $who .= JText::_('COM_KUNENA_WHO_AND'); $who .= '<strong> ' . $onlineusers['guest'] . ' </strong>'; if ($onlineusers['guest'] == 1) { $who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST') . ' '; } else { $who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS') . ' '; } $who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW'); $this->membersOnline = $who; $this->onlineList = array(); $this->hiddenList = array(); foreach ($users as $userid => $usertime) { $user = KunenaUserHelper::get($userid); if (!$user->showOnline) { if ($moderator) { $this->hiddenList[$user->getName()] = $user; } } else { $this->onlineList[$user->getName()] = $user; } } ksort($this->onlineList); ksort($this->hiddenList); $profile = KunenaFactory::getProfile(); $this->usersUrl = $profile->getUserListURL(); }
/** * 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'); }
/** * Prepare poll display. * * @return void * * @throws KunenaExceptionAuthorise */ protected function before() { parent::before(); $this->topic = KunenaForumTopicHelper::get($this->input->getInt('id')); $this->category = $this->topic->getCategory(); $this->config = KunenaFactory::getConfig(); $this->me = KunenaUserHelper::getMyself(); // Need to check if poll is allowed in this category. $this->topic->tryAuthorise('poll.read'); $this->poll = $this->topic->getPoll(); $this->usercount = $this->poll->getUserCount(); $this->usersvoted = $this->poll->getUsers(); $this->voted = $this->poll->getMyVotes(); if (!empty($this->alwaysVote)) { // Authorise forced vote. $this->topic->tryAuthorise('poll.vote'); $this->name = 'Topic/Poll/Vote'; } elseif (!$this->voted && $this->topic->isAuthorised('poll.vote')) { $this->name = 'Topic/Poll/Vote'; } else { $this->name = 'Topic/Poll/Results'; $this->show_title = true; $this->users_voted_list = array(); $this->users_voted_morelist = array(); if ($this->config->pollresultsuserslist && !empty($this->usersvoted)) { $userids_votes = array(); foreach ($this->usersvoted as $userid => $vote) { $userids_votes[] = $userid; } $loaded_users = KunenaUserHelper::loadUsers($userids_votes); $i = 0; foreach ($loaded_users as $userid => $user) { if ($i <= '4') { $this->users_voted_list[] = $loaded_users[$userid]->getLink(); } else { $this->users_voted_morelist[] = $loaded_users[$userid]->getLink(); } $i++; } } } $this->uri = "index.php?option=com_kunena&view=topic&layout=poll&catid={$this->category->id}&id={$this->topic->id}"; }
/** * 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; }
/** * Prepare topic actions display. * * @return void */ protected function before() { parent::before(); $id = $this->input->getInt('id'); $this->topic = KunenaForumTopic::getInstance($id); $catid = $this->topic->category_id; $token = JSession::getFormToken(); $task = "index.php?option=com_kunena&view=topic&task=%s&catid={$catid}&id={$id}&{$token}=1"; $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}&id={$id}"; $userTopic = $this->topic->getUserTopic(); $this->template = KunenaFactory::getTemplate(); $this->topicButtons = new JObject(); if ($this->topic->isAuthorised('reply')) { // Add Reply topic button. $this->topicButtons->set('reply', $this->getButton(sprintf($layout, 'reply'), 'reply', 'topic', 'communication')); } if ($userTopic->subscribed) { // User can always remove existing subscription. $this->topicButtons->set('subscribe', $this->getButton(sprintf($task, 'unsubscribe'), 'unsubscribe', 'topic', 'user')); } elseif ($this->topic->isAuthorised('subscribe')) { // Add subscribe topic button. $this->topicButtons->set('subscribe', $this->getButton(sprintf($task, 'subscribe'), 'subscribe', 'topic', 'user')); } if ($userTopic->favorite) { // User can always remove existing favorite. $this->topicButtons->set('favorite', $this->getButton(sprintf($task, 'unfavorite'), 'unfavorite', 'topic', 'user')); } elseif ($this->topic->isAuthorised('favorite')) { // Add favorite topic button. $this->topicButtons->set('favorite', $this->getButton(sprintf($task, 'favorite'), 'favorite', 'topic', 'user')); } if ($this->topic->getCategory()->isAuthorised('moderate')) { // Add moderator specific buttons. $sticky = $this->topic->ordering ? 'unsticky' : 'sticky'; $lock = $this->topic->locked ? 'unlock' : 'lock'; $this->topicButtons->set('sticky', $this->getButton(sprintf($task, $sticky), $sticky, 'topic', 'moderation')); $this->topicButtons->set('lock', $this->getButton(sprintf($task, $lock), $lock, 'topic', 'moderation')); $this->topicButtons->set('moderate', $this->getButton(sprintf($layout, 'moderate'), 'moderate', 'topic', 'moderation')); if ($this->topic->hold == 1) { $this->topicButtons->set('approve', $this->getButton(sprintf($task, 'approve'), 'moderate', 'topic', 'moderation')); } if ($this->topic->hold == 1 || $this->topic->hold == 0) { $this->topicButtons->set('delete', $this->getButton(sprintf($task, 'delete'), 'delete', 'topic', 'moderation')); } elseif ($this->topic->hold == 2 || $this->topic->hold == 3) { $this->topicButtons->set('undelete', $this->getButton(sprintf($task, 'undelete'), 'undelete', 'topic', 'moderation')); } } // Add buttons for changing between different layout modes. if (KunenaFactory::getConfig()->enable_threaded_layouts) { $url = "index.php?option=com_kunena&view=user&task=change&topic_layout=%s&{$token}=1"; if ($this->layout != 'default') { $this->topicButtons->set('flat', $this->getButton(sprintf($url, 'flat'), 'flat', 'layout', 'user')); } if ($this->layout != 'threaded') { $this->topicButtons->set('threaded', $this->getButton(sprintf($url, 'threaded'), 'threaded', 'layout', 'user')); } if ($this->layout != 'indented') { $this->topicButtons->set('indented', $this->getButton(sprintf($url, 'indented'), 'indented', 'layout', 'user')); } } JPluginHelper::importPlugin('kunena'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onKunenaGetButtons', array('topic.action', $this->topicButtons, $this)); }
/** * 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 = ' '; } } }