Пример #1
0
	function sync() {
		// FIXME: remove option:
		$usercache = JRequest::getBool ( 'usercache', 0 );
		$useradd = JRequest::getBool ( 'useradd', 0 );
		$userdel = JRequest::getBool ( 'userdel', 0 );
		$userrename = JRequest::getBool ( 'userrename', 0 );

		$app = JFactory::getApplication ();
		$db = JFactory::getDBO ();
		if (!JRequest::checkToken()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->setRedirect(KunenaRoute::_($this->baseurl, false));
			return;
		}

		if ($useradd) {
			$db->setQuery ( "INSERT INTO #__kunena_users (userid) SELECT a.id FROM #__users AS a LEFT JOIN #__kunena_users AS b ON b.userid=a.id WHERE b.userid IS NULL" );
			$db->query ();
			if (KunenaError::checkDatabaseError()) return;
			$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_ADD') . ' ' . $db->getAffectedRows () );
		}
		if ($userdel) {
			$db->setQuery ( "DELETE a FROM #__kunena_users AS a LEFT JOIN #__users AS b ON a.userid=b.id WHERE b.username IS NULL" );
			$db->query ();
			if (KunenaError::checkDatabaseError()) return;
			$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_DEL') . ' ' . $db->getAffectedRows () );
		}
		if ($userrename) {
			$model = $this->getModel('Syncusers');
			$cnt = $model->KupdateNameInfo ();
			$app->enqueueMessage ( JText::_('COM_KUNENA_SYNC_USERS_DO_RENAME') . " $cnt" );
		}

		$this->setRedirect(KunenaRoute::_($this->baseurl, false));
	}
Пример #2
0
	function displayAnnouncement($tpl = null) {
		if (KunenaFactory::getConfig()->showannouncement > 0) {
			$moderator = intval($this->me->isModerator('global'));
			$cache = JFactory::getCache('com_kunena', 'output');
			if ($cache->start("{$this->template->name}.common.announcement.{$moderator}", 'com_kunena.template')) return;

			// User needs to be global moderator to edit announcements
			if ($moderator) {
				$this->canEdit = true;
			} else {
				$this->canEdit = false;
			}
			// FIXME: move into model
			$db = JFactory::getDBO();
			$query = "SELECT * FROM #__kunena_announcement WHERE published='1' ORDER BY created DESC";
			$db->setQuery ( $query, 0, 1 );
			$this->announcement = $db->loadObject ();
			if (KunenaError::checkDatabaseError()) return;
			if ($this->announcement) {
				$this->annTitle = KunenaHtmlParser::parseText($this->announcement->title);
				$this->annDescription = $this->announcement->sdescription ? KunenaHtmlParser::parseBBCode($this->announcement->sdescription) : KunenaHtmlParser::parseBBCode($this->announcement->description, 300);
				$this->annDate = KunenaDate::getInstance($this->announcement->created);
				$this->annListURL = KunenaRoute::_("index.php?option=com_kunena&view=announcement&layout=list");
				$this->annMoreURL = !empty($this->announcement->description) ? KunenaRoute::_("index.php?option=com_kunena&view=announcement&id={$this->announcement->id}") : null;
				$result = $this->loadTemplate($tpl);
				if (JError::isError($result)) {
					return $result;
				}
				echo $result;
			} else {
				echo ' ';
			}
			$cache->end();
		} else echo ' ';
	}
Пример #3
0
 protected function _getDefaultMenuItem($menu, $active, $visited = array())
 {
     if (empty($active->query['defaultmenu']) || $active->id == $active->query['defaultmenu']) {
         // There is no highlighted menu item
         return null;
     }
     $item = $menu->getItem($active->query['defaultmenu']);
     if (!$item) {
         // Menu item points to nowhere, abort
         KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_EXISTS'), 'menu');
         return null;
     } elseif (isset($visited[$item->id])) {
         // Menu loop detected, abort
         KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_LOOP'), 'menu');
         return null;
     } elseif (empty($item->component) || $item->component != 'com_kunena' || !isset($item->query['view'])) {
         // Menu item doesn't point to Kunena, abort
         KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_KUNENA'), 'menu');
         return null;
     } elseif ($item->query['view'] == 'home') {
         // Menu item is pointing to another Home Page, try to find default menu item from there
         $visited[$item->id] = 1;
         $item = $this->_getDefaultMenuItem($menu, $item->query['defaultmenu'], $visited);
     }
     return $item;
 }
Пример #4
0
 /**
  * Sets up the fixture.
  */
 public static function setUpBeforeClass()
 {
     $queries[] = "TRUNCATE TABLE #__kunena_categories";
     $queries[] = "TRUNCATE TABLE #__kunena_topics";
     $queries[] = "TRUNCATE TABLE #__kunena_messages";
     $queries[] = "TRUNCATE TABLE #__kunena_messages_text";
     $queries[] = "TRUNCATE TABLE #__kunena_users";
     $queries[] = "TRUNCATE TABLE #__kunena_users_banned";
     $queries[] = "TRUNCATE TABLE #__kunena_user_categories";
     $queries[] = "TRUNCATE TABLE #__kunena_user_read";
     $queries[] = "TRUNCATE TABLE #__kunena_user_topics";
     $queries[] = "TRUNCATE TABLE #__kunena_thankyou";
     $queries[] = "TRUNCATE TABLE #__kunena_keywords";
     $queries[] = "TRUNCATE TABLE #__kunena_keywords_map";
     $queries[] = "TRUNCATE TABLE #__kunena_polls_users";
     $queries[] = "TRUNCATE TABLE #__kunena_polls_options";
     $queries[] = "TRUNCATE TABLE #__kunena_polls";
     $queries[] = "TRUNCATE TABLE #__kunena_sessions";
     $db = JFactory::getDBO();
     foreach ($queries as $query) {
         $db->setQuery($query);
         $db->query();
         KunenaError::checkDatabaseError();
     }
     KunenaFactory::loadLanguage();
     KunenaFactory::getUser(42)->save();
 }
Пример #5
0
	/**
	 *    Return JSON results of smilies available
	 *
	 * @param string $tpl
	 *
	 * @since K4.0
	 *
	 * @return void
	 */
	public function displayListEmoji($tpl = null)
	{
		$response = array();

		if ($this->me->exists())
		{
			$search = $this->app->input->get('search');

			$db     = JFactory::getDBO();
			$kquery = new KunenaDatabaseQuery;
			$kquery->select('*')->from("{$db->qn('#__kunena_smileys')}")->where("code LIKE '%{$db->escape($search)}%' AND emoticonbar=1");
			$db->setQuery($kquery);
			$smileys = $db->loadObjectList();
			KunenaError::checkDatabaseError();

			foreach ($smileys as $smiley)
			{
				$emojis['key']  = $smiley->code;
				$emojis['name'] = $smiley->code;
				$emojis['url']  = JUri::root() . 'media/kunena/emoticons/' . $smiley->location;

				$response['emojis'][] = $emojis;
			}
		}

		// Set the MIME type and header for JSON output.
		$this->document->setMimeEncoding('application/json');
		JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"');

		echo json_encode($response);
	}
Пример #6
0
	public static function getEmoticons($grayscale = false, $emoticonbar = false)
	{
		$db = JFactory::getDBO ();
		$grayscale == true ? $column = "greylocation" : $column = "location";
		$sql = "SELECT code, {$db->quoteName($column)} AS file FROM #__kunena_smileys";

		if ($emoticonbar == true)
		{
			$sql .= " WHERE emoticonbar='1'";
		}

		$db->setQuery ( $sql );
		$smilies = $db->loadObjectList ();
		KunenaError::checkDatabaseError();

		$smileyArray = array ();
		$template = KunenaFactory::getTemplate();

		foreach ( $smilies as $smiley )
		{
			// We load all smileys in array, so we can sort them
			$smileyArray [$smiley->code] = JUri::root(true) .'/'. $template->getSmileyPath($smiley->file);
		}

		if ($emoticonbar == 0)
		{
			// don't sort when it's only for use in the emoticonbar
			array_multisort ( array_keys ( $smileyArray ), SORT_DESC, $smileyArray );
			reset ( $smileyArray );
		}
		return $smileyArray;
	}
Пример #7
0
 public function getCatsDetails($catids)
 {
     $query = "SELECT * FROM #__kunena_categories WHERE id={$this->_db->Quote($catids)} AND published='1'";
     $this->_db->setQuery($query);
     $results = $this->_db->loadObject();
     KunenaError::checkDatabaseError();
     return $results;
 }
Пример #8
0
	public function _getTopHits($limit=0) {
		$db = JFactory::getDBO ();
		$query = "SELECT userid AS id, profileviews AS count FROM #__alpha_userpoints WHERE a.profileviews>0 ORDER BY profileviews DESC";
		$db->setQuery ( $query, 0, $limit );
		$top = $db->loadObjectList ();
		KunenaError::checkDatabaseError ();
		return $top;
	}
Пример #9
0
	public static function cleanup() {
		if (self::$enabled && (--self::$enabled) == 0) {
			if (self::$handler) {
				restore_error_handler ();
				self::$handler = false;
			}
		}
	}
Пример #10
0
	public function _getTopHits($limit=0) {
		$db = JFactory::getDBO ();
		$query = "SELECT userid AS id, uhits AS count FROM #__kunena_users WHERE uhits>0 ORDER BY uhits DESC";
		$db->setQuery ( $query, 0, $limit );
		$top = $db->loadObjectList ();
		KunenaError::checkDatabaseError();
		return $top;
	}
Пример #11
0
 /**
  * adds the link for the connect param
  * @since 1.7.3
  * @param  $user pass-by-reference
  * @return void
  */
 private function getUserLink(&$user)
 {
     $username = KunenaFactory::getUser($user['userid'])->getName();
     if ($user['leapcorrection'] == $this->timeo->format('z', true) + 1) {
         $subject = getSubject($username);
         $db = JFactory::getDBO();
         $query = "SELECT id,catid,subject,time as year FROM #__kunena_messages WHERE subject='{$subject}'";
         $db->setQuery($query, 0, 1);
         $post = $db->loadAssoc();
         if ($db->getErrorMsg()) {
             KunenaError::checkDatabaseError();
         }
         $catid = $this->params->get('bcatid');
         $postyear = new JDate($post['year'], $this->soffset);
         if (empty($post) && !empty($catid) || !empty($post) && !empty($catid) && $postyear->format('Y', true) < $this->timeo->format('Y', true)) {
             $botname = $this->params->get('swkbbotname', JText::_('SW_KBIRTHDAY_FORUMPOST_BOTNAME_DEF'));
             $botid = $this->params->get('swkbotid');
             $time = CKunenaTimeformat::internalTime();
             //Insert the birthday thread into DB
             $query = "INSERT INTO #__kunena_messages (catid,name,userid,email,subject,time, ip)\n\t\t    \t\tVALUES({$catid},'{$botname}',{$botid}, '','{$subject}', {$time}, '')";
             $db->setQuery($query);
             $db->query();
             if ($db->getErrorMsg()) {
                 KunenaError::checkDatabaseError();
             }
             //What ID get our thread?
             $messid = (int) $db->insertID();
             //Insert the thread message into DB
             $message = getMessage($username);
             $query = "INSERT INTO #__kunena_messages_text (mesid,message)\n                    VALUES({$messid},'{$message}')";
             $db->setQuery($query);
             $db->query();
             if ($db->getErrorMsg()) {
                 KunenaError::checkDatabaseError();
             }
             //We know the thread ID so we can update the parent thread id with it's own ID because we know it's
             //the first post
             $query = "UPDATE #__kunena_messages SET thread={$messid} WHERE id={$messid}";
             $db->setQuery($query);
             $db->query();
             if ($db->getErrorMsg()) {
                 KunenaError::checkDatabaseError();
             }
             // now increase the #s in categories
             CKunenaTools::modifyCategoryStats($messid, 0, $time, $catid);
             $user['link'] = CKunenaLink::GetViewLink('view', $messid, $catid, '', $username);
             $uri = JFactory::getURI();
             if ($uri->getVar('option') == 'com_kunena') {
                 $app =& JFactory::getApplication();
                 $app->redirect($uri->toString());
             }
         } elseif (!empty($post)) {
             $user['link'] = CKunenaLink::GetViewLink('view', $post['id'], $post['catid'], '', $username);
         }
     } else {
         $user['link'] = CKunenaLink::GetProfileLink($user['userid']);
     }
 }
Пример #12
0
 function cleanup()
 {
     if (self::$enabled && --self::$enabled == 0) {
         if (self::$handler) {
             restore_error_handler();
             self::$handler = false;
         }
     }
 }
Пример #13
0
 protected function loadModerators()
 {
     $db = JFactory::getDBO();
     $query = "SELECT u.id AS userid, m.catid\n\t\t\t\tFROM #__users AS u\n\t\t\t\tINNER JOIN #__kunena_users AS ku ON u.id=ku.userid\n\t\t\t\tLEFT JOIN #__kunena_moderation AS m ON u.id=m.userid\n\t\t\t\tLEFT JOIN #__kunena_categories AS c ON m.catid=c.id\n\t\t\t\tWHERE u.block='0' AND ku.moderator='1' AND (m.catid IS NULL OR c.moderated='1')";
     $db->setQuery($query);
     $list = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return parent::loadModerators($list);
 }
Пример #14
0
 public function _getTopHits($limit = 0)
 {
     $db = JFactory::getDBO();
     $query = "SELECT u.id, ku.uhits AS count\n\t\t\tFROM #__kunena_users AS ku\n\t\t\tINNER JOIN #__users AS u ON u.id=ku.userid\n\t\t\tWHERE ku.uhits>0\n\t\t\tORDER BY ku.uhits DESC";
     $db->setQuery($query, 0, $limit);
     $top = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $top;
 }
Пример #15
0
	public function getAnnouncement() {
		$db = JFactory::getDBO();
		$query = "SELECT * FROM #__kunena_announcement WHERE published='1' ORDER BY created DESC";
		$db->setQuery ( $query, 0, 1 );
		$announcement = $db->loadObject ();
		if (KunenaError::checkDatabaseError()) return;

		return $announcement;
	}
Пример #16
0
 public function _getTopHits($limit = 0)
 {
     $db = JFactory::getDBO();
     $query = "SELECT cu.user_id AS id, cu.hits AS count\r\n\t\t\tFROM #__comprofiler AS cu\r\n\t\t\tINNER JOIN #__users AS u ON u.id=cu.user_id\r\n\t\t\tWHERE cu.hits>0\r\n\t\t\tORDER BY cu.hits DESC";
     $db->setQuery($query, 0, $limit);
     $top = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $top;
 }
Пример #17
0
 public function _getTopHits($limit = 0)
 {
     $db = JFactory::getDBO();
     $query = "SELECT a.userid AS id, a.profileviews AS count\n\t\t\tFROM #__alpha_userpoints AS a\n\t\t\tINNER JOIN #__users AS u ON u.id=a.userid\n\t\t\tWHERE a.profileviews>0\n\t\t\tORDER BY a.profileviews DESC";
     $db->setQuery($query, 0, $limit);
     $top = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $top;
 }
Пример #18
0
	public function loadModerators() {
		$db = JFactory::getDBO ();
		$query = "SELECT uc.user_id AS userid, category_id AS catid
			FROM #__kunena_user_categories AS uc
			INNER JOIN #__users AS u ON u.id=uc.user_id AND u.block=0
			WHERE uc.role=1";
		$db->setQuery ( $query );
		$list = (array) $db->loadObjectList ();
		KunenaError::checkDatabaseError ();
		return $this->storeModerators($list);
	}
Пример #19
0
	public function getRank() {
		$db = JFactory::getDBO ();

		if ( $this->getState('item.id') ) {
			$db->setQuery ( "SELECT * FROM #__kunena_ranks WHERE rank_id = '{$this->getState('item.id')}'" );
			$rankselected = $db->loadObject ();
			if (KunenaError::checkDatabaseError()) return;

			return $rankselected;
		}
		return;
	}
Пример #20
0
	public function _getTopHits($limit=0) {
		$db = JFactory::getDBO ();
		$query = "SELECT cu.userid AS id, cu.view AS count
			FROM #__community_users AS cu
			INNER JOIN #__users AS u ON u.id=cu.userid
			WHERE cu.view>0
			ORDER BY cu.view DESC";
		$db->setQuery ( $query, 0, $limit );
		$top = (array) $db->loadObjectList ();
		KunenaError::checkDatabaseError();
		return $top;
	}
Пример #21
0
 protected function loadAllowedCategories($userid)
 {
     $allowed = $this->joomlaAccess->getAllowedCategories($userid);
     $db = JFactory::getDBO();
     $query = "SELECT c.id FROM #__kunena_categories AS c\n\t\t\tINNER JOIN #__community_groups_members AS g ON c.accesstype='jomsocial' AND c.access=g.groupid\n\t\t\tWHERE c.published=1 AND g.approved=1 AND g.memberid={$db->quote($userid)}";
     $db->setQuery($query);
     $list = (array) $db->loadResultArray();
     KunenaError::checkDatabaseError();
     foreach ($list as $catid) {
         $allowed[$catid] = $catid;
     }
     return $allowed;
 }
Пример #22
0
 public function getSmiley()
 {
     $db = JFactory::getDBO();
     if ($this->getState('item.id')) {
         $db->setQuery("SELECT * FROM #__kunena_smileys WHERE id = '{$this->getState('item.id')}'");
         $selected = $db->loadObject();
         if (KunenaError::checkDatabaseError()) {
             return;
         }
         return $selected;
     }
     return null;
 }
Пример #23
0
 public function getRank()
 {
     $db = JFactory::getDBO();
     $id = $this->getState($this->getName() . '.id');
     if ($id) {
         $db->setQuery("SELECT * FROM #__kunena_ranks WHERE rank_id={$db->quote($id)}");
         $selected = $db->loadObject();
         if (KunenaError::checkDatabaseError()) {
             return null;
         }
         return $selected;
     }
     return null;
 }
Пример #24
0
 public function getProfileView($PopUserCount = 0)
 {
     $_db =& JFactory::getDBO();
     $_config = KunenaFactory::getConfig();
     $queryName = $_config->username ? "username" : "name";
     if (!$PopUserCount) {
         $PopUserCount = $_config->popusercount;
     }
     $query = "SELECT u.uhits AS hits, u.userid AS user_id, j.id, j.{$queryName} AS user FROM #__kunena_users AS u\n\t\t\t\t\tINNER JOIN #__users AS j ON j.id = u.userid\n\t\t\t\t\tWHERE u.uhits>'0' AND j.block=0 ORDER BY u.uhits DESC";
     $_db->setQuery($query, 0, $PopUserCount);
     $topKunenaProfileView = $_db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $topKunenaProfileView;
 }
Пример #25
0
 public function getProfileView($PopUserCount = 0)
 {
     $_db =& JFactory::getDBO();
     $_config = KunenaFactory::getConfig();
     $queryName = $_config->username ? "username" : "name";
     if (!$PopUserCount) {
         $PopUserCount = $_config->popusercount;
     }
     $query = "SELECT u.id AS user_id, c.view AS hits, u.{$queryName} AS user FROM #__community_users as c\n\t\t\t\t\tLEFT JOIN #__users as u on u.id=c.userid\n\t\t\t\t\tWHERE c.view>'0' ORDER BY c.view DESC";
     $_db->setQuery($query, 0, $PopUserCount);
     $topJomsocialProfileView = $_db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $topJomsocialProfileView;
 }
Пример #26
0
 public function getProfileView($PopUserCount = 0)
 {
     $_db =& JFactory::getDBO();
     $_config = KunenaFactory::getConfig();
     $queryName = $_config->username ? "username" : "name";
     if (!$PopUserCount) {
         $PopUserCount = $_config->popusercount;
     }
     $query = "SELECT a.profileviews AS hits, u.id AS user_id, u.{$queryName} AS user FROM #__alpha_userpoints AS a\n\t\t\t\t\tINNER JOIN #__users AS u ON u.id = a.userid\n\t\t\t\t\tWHERE a.profileviews>'0' ORDER BY a.profileviews DESC";
     $_db->setQuery($query, 0, $PopUserCount);
     $topAUPProfileView = $_db->loadObjectList();
     KunenaError::checkDatabaseError();
     return $topAUPProfileView;
 }
Пример #27
0
	function kUpdateNameInfo() {
		$db = JFactory::getDBO();
		$config = KunenaFactory::getConfig ();

		$queryName = $config->username ? "username" : "name";

		$query = "UPDATE #__kunena_messages AS m, #__users AS u
				SET m.name = u.$queryName
				WHERE m.userid = u.id";
		$db->setQuery($query);
		$db->query();
		KunenaError::checkDatabaseError();
		return $db->getAffectedRows();
	}
Пример #28
0
 public function getItems()
 {
     $db = JFactory::getDBO();
     $where = '';
     if ($this->getState('list.search')) {
         $where = ' WHERE LOWER( a.filename ) LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false) . ' OR LOWER( a.filetype ) LIKE ' . $db->Quote('%' . $db->getEscaped($this->getState('list.search'), true) . '%', false);
     }
     $orderby = ' ORDER BY ' . $this->getState('list.ordering') . ' ' . $this->getState('list.direction');
     $query = "SELECT a.*, b.catid, b.thread FROM #__kunena_attachments AS a LEFT JOIN #__kunena_messages AS b ON a.mesid=b.id" . $where . $orderby;
     $db->setQuery($query, $this->getState('list.start'), $this->getState('list.limit'));
     $uploaded = $db->loadObjectlist();
     if (KunenaError::checkDatabaseError()) {
         return;
     }
     $this->setState('list.total', count($uploaded));
     return $uploaded;
 }
Пример #29
0
 /**
  * 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);
 }
Пример #30
0
 function save()
 {
     $db = JFactory::getDBO();
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $newview = JRequest::getVar('newview');
     $newrank = JRequest::getVar('newrank');
     $signature = JRequest::getVar('signature');
     $deleteSig = JRequest::getVar('deleteSig');
     $moderator = JRequest::getInt('moderator');
     $uid = JRequest::getInt('uid');
     $avatar = JRequest::getVar('avatar');
     $deleteAvatar = JRequest::getVar('deleteAvatar');
     $neworder = JRequest::getInt('neworder');
     $modCatids = $moderator ? JRequest::getVar('catid', array()) : array();
     if ($deleteSig == 1) {
         $signature = "";
     }
     $avatar = '';
     if ($deleteAvatar == 1) {
         $avatar = ",avatar=''";
     }
     $db->setQuery("UPDATE #__kunena_users SET signature={$db->quote($signature)}, view='{$newview}', ordering='{$neworder}', rank='{$newrank}' {$avatar} WHERE userid='{$uid}'");
     $db->query();
     if (KunenaError::checkDatabaseError()) {
         return;
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY'));
     // Update moderator rights
     $categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin');
     $user = KunenaFactory::getUser($uid);
     foreach ($categories as $category) {
         $category->setModerator($user, in_array($category->id, $modCatids));
     }
     // Global moderator is a special case
     if ($this->me->isAdmin()) {
         KunenaAccess::getInstance()->setModerator(0, $user, in_array(0, $modCatids));
     }
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }