Example #1
0
 /**
  * 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');
 }
Example #2
0
 public function displayAll()
 {
     if ($this->me->isAdmin()) {
         if ($this->config->board_offline) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 'notice');
         }
         if ($this->config->debug) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_WARNING_DEBUG'), 'notice');
         }
     }
     if ($this->me->isBanned()) {
         $banned = KunenaUserBan::getInstanceByUserid($this->me->userid, true);
         if (!$banned->isLifetime()) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY', KunenaDate::getInstance($banned->expiration)->toKunena('date_today')), 'notice');
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS'), 'notice');
         }
     }
     $this->state = $this->get('State');
     $this->ktemplate->initialize();
     if (JFactory::getApplication()->isAdmin()) {
         $this->displayLayout();
     } else {
         $this->document->addHeadLink(KunenaRoute::_(), 'canonical', 'rel', '');
         include JPATH_SITE . '/' . $this->ktemplate->getFile('html/display.php');
         if ($this->config->get('credits', 1)) {
             $this->poweredBy();
         }
     }
 }
Example #3
0
	/**
	 * @param KunenaUserBan $instance
	 */
	private static function storeInstance($instance) {
		// Fill userid cache
		self::cacheUserid($instance->userid);
		self::cacheUserid($instance->created_by);
		self::cacheUserid($instance->modified_by);
		foreach ($instance->comments as $comment) {
			self::cacheUserid($comment->userid);
		}

		if ($instance->id) self::$_instances[$instance->id] = $instance;
		if ($instance->userid && ($instance->isEnabled() || !$instance->id)) {
			self::$_instancesByUserid[$instance->userid] = $instance;
		}
		if ($instance->ip && ($instance->isEnabled() || !$instance->id)) {
			self::$_instancesByIP[$instance->ip] = $instance;
		}
	}
Example #4
0
 /**
  * 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());
 }
Example #5
0
 /**
  * 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');
 }
Example #6
0
 /**
  * Constructor
  *
  * @access	protected
  */
 public function __construct($identifier = null)
 {
     if (self::$_now === null) {
         self::$_now = new JDate();
     }
     if (self::$_my === null) {
         self::$_my = JFactory::getUser();
     }
     // Always load the data -- if item does not exist: fill empty data
     $this->load($identifier);
     $this->_db = JFactory::getDBO();
 }
Example #7
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);
 }
Example #8
0
 public function displayAll()
 {
     if ($this->inLayout) {
         throw new LogicException(sprintf('HMVC template should not call %s::%s()', __CLASS__, __FUNCTION__));
     }
     if ($this->me->isAdmin()) {
         if ($this->config->board_offline) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 'notice');
         }
         if ($this->config->debug) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_WARNING_DEBUG'), 'notice');
         }
     }
     if ($this->me->isBanned()) {
         $banned = KunenaUserBan::getInstanceByUserid($this->me->userid, true);
         if (!$banned->isLifetime()) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY', KunenaDate::getInstance($banned->expiration)->toKunena('date_today')), 'notice');
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS'), 'notice');
         }
     }
     $this->state = $this->get('State');
     $this->ktemplate->initialize();
     $menu = $this->app->getMenu();
     $home = $menu->getItems('type', 'alias');
     $juricurrent = JURI::current();
     if (JFactory::getApplication()->isAdmin()) {
         $this->displayLayout();
     } elseif ($home) {
         $this->document->addHeadLink($juricurrent, 'canonical', 'rel', '');
         include JPATH_SITE . '/' . $this->ktemplate->getFile('html/display.php');
     } else {
         $this->document->addHeadLink(KunenaRoute::_(), 'canonical', 'rel', '');
         include JPATH_SITE . '/' . $this->ktemplate->getFile('html/display.php');
         if ($this->config->get('credits', 1)) {
             $this->poweredBy();
         }
     }
 }
Example #9
0
 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));
 }
Example #10
0
 /**
  *
  */
 function displayBanManager()
 {
     // TODO: move ban manager somewhere else and add pagination
     $this->bannedusers = KunenaUserBan::getBannedUsers(0, 50);
     if (!empty($this->bannedusers)) {
         KunenaUserHelper::loadUsers(array_keys($this->bannedusers));
     }
     echo $this->loadTemplateFile('banmanager');
 }
Example #11
0
 function ban()
 {
     $userid = JRequest::getInt('userid', 0);
     $ip = JRequest::getVar('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 (!JRequest::checkToken()) {
         while (@ob_end_clean()) {
         }
         $this->_app->redirect(CKunenaLink::GetProfileURL($this->profile->userid, false), COM_KUNENA_ERROR_TOKEN, 'error');
         return false;
     }
     kimport('userban');
     $ban = KunenaUserBan::getInstanceByUserid($userid, true);
     if (!$ban->id) {
         $ban->ban($userid, $ip, $block, $expiration, $reason_private, $reason_public, $comment);
         $success = $ban->save();
     } 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::getVar('bandelposts', '');
     $DelAvatar = JRequest::getVar('delavatar', '');
     $DelSignature = JRequest::getVar('delsignature', '');
     $DelProfileInfo = JRequest::getVar('delprofileinfo', '');
     if (!empty($DelAvatar)) {
         jimport('joomla.filesystem.file');
         $userprofile = KunenaFactory::getUser($userid);
         $this->_db->setQuery("UPDATE #__kunena_users SET avatar=null WHERE userid={$this->_db->Quote($userid)}");
         $this->_db->Query();
         KunenaError::checkDatabaseError();
         $avatar_deleted = '';
         // Delete avatar from file system
         if (JFile::exists(KUNENA_PATH_AVATAR_UPLOADED . '/' . $userprofile->avatar) && !stristr($userprofile->avatar, 'gallery/')) {
             JFile::delete(KUNENA_PATH_AVATAR_UPLOADED . '/' . $userprofile->avatar);
             $avatar_deleted = $this->_app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR_FILESYSTEM'));
         }
         $this->_app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR') . $avatar_deleted);
     }
     if (!empty($DelSignature)) {
         $this->_db->setQuery("UPDATE #__kunena_users SET signature=null WHERE userid={$this->_db->Quote($userid)}");
         $this->_db->Query();
         KunenaError::checkDatabaseError();
         $this->_app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_SIGNATURE'));
     }
     if (!empty($DelProfileInfo)) {
         $this->_db->setQuery("UPDATE #__kunena_users SET signature=null,avatar=null,karma=null,personalText=null,gender=0,birthdate=0000-00-00,location=null,ICQ=null,AIM=null,YIM=null,MSN=null,SKYPE=null,GTALK=null,websitename=null,websiteurl=null,rank=0,TWITTER=null,FACEBOOK=null,MYSPACE=null,LINKEDIN=null,DELICIOUS=null,FRIENDFEED=null,DIGG=null,BLOGSPOT=null,FLICKR=null,BEBO=null WHERE userid={$this->_db->Quote($userid)}");
         $this->_db->Query();
         KunenaError::checkDatabaseError();
         $this->_app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_PROFILEINFO'));
     }
     if (!empty($banDelPosts)) {
         //select only the messages which aren't already in the trash
         $this->_db->setQuery("UPDATE #__kunena_messages SET hold=2 WHERE hold!=2 AND userid={$this->_db->Quote($userid)}");
         $idusermessages = $this->_db->loadObjectList();
         KunenaError::checkDatabaseError();
         $this->_app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_DELETED_BAD_MESSAGES'));
     }
     while (@ob_end_clean()) {
     }
     $this->_app->redirect(CKunenaLink::GetProfileURL($this->profile->userid, false));
 }
Example #12
0
 /**
  * Throws an exception if user isn't authorised to do the action.
  *
  * @param string      $action
  * @param KunenaUser  $user
  * @param bool        $throw
  *
  * @return KunenaExceptionAuthorise|null
  * @throws KunenaExceptionAuthorise
  * @throws InvalidArgumentException
  *
  * @since  K4.0
  */
 public function tryAuthorise($action = 'read', KunenaUser $user = null, $throw = true)
 {
     // Special case to ignore authorisation.
     if ($action == 'none') {
         return null;
     }
     // Load user if not given.
     if ($user === null) {
         $user = KunenaUserHelper::getMyself();
     }
     $config = KunenaConfig::getInstance();
     $exception = null;
     switch ($action) {
         case 'read':
             if (!isset($this->registerDate) || !$user->exists() && !$config->pubprofile) {
                 $exception = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_PROFILEPAGE_NOT_ALLOWED_FOR_GUESTS'), $user->exists() ? 403 : 401);
             }
             break;
         case 'edit':
             if (!isset($this->registerDate) || !$this->isMyself()) {
                 $exception = new KunenaExceptionAuthorise(JText::sprintf('COM_KUNENA_VIEW_USER_EDIT_AUTH_FAILED', $this->getName()), $user->exists() ? 403 : 401);
             }
             break;
         case 'ban':
             $banInfo = KunenaUserBan::getInstanceByUserid($this->userid, true);
             if (!$banInfo->canBan()) {
                 $exception = new KunenaExceptionAuthorise($banInfo->getError(), $user->exists() ? 403 : 401);
             }
             break;
         default:
             throw new InvalidArgumentException(JText::sprintf('COM_KUNENA_LIB_AUTHORISE_INVALID_ACTION', $action), 500);
     }
     // Throw or return the exception.
     if ($throw && $exception) {
         throw $exception;
     }
     return $exception;
 }
Example #13
0
function userban($option, $userid, $block = 0)
{
    $kunena_app =& JFactory::getApplication();
    if (!JRequest::checkToken()) {
        $kunena_app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . "index.php?option={$option}&task=showprofiles");
    }
    kimport('userban');
    $userid = (int) array_shift($userid);
    $ban = KunenaUserBan::getInstanceByUserid($userid, true);
    if (!$ban->id) {
        $ban->ban($userid, null, $block);
        $success = $ban->save();
    } else {
        jimport('joomla.utilities.date');
        $now = new JDate();
        $ban->setExpiration($now);
        $success = $ban->save();
    }
    if ($block) {
        if ($ban->isEnabled()) {
            $message = JText::_('COM_KUNENA_USER_BLOCKED_DONE');
        } else {
            $message = JText::_('COM_KUNENA_USER_UNBLOCK_DONE');
        }
    } else {
        if ($ban->isEnabled()) {
            $message = JText::_('COM_KUNENA_USER_BANNED_DONE');
        } else {
            $message = JText::_('COM_KUNENA_USER_UNBAN_DONE');
        }
    }
    $kunena_app = JFactory::getApplication();
    if (!$success) {
        $kunena_app->enqueueMessage($ban->getError(), 'error');
    } else {
        $kunena_app->enqueueMessage($message);
    }
    while (@ob_end_clean()) {
    }
    $kunena_app->redirect(JURI::base() . "index.php?option=com_kunena&task=profiles");
}
Example #14
0
	protected function before()
	{
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.get_class($this).'::'.__FUNCTION__.'()') : null;

		if (!$this->exists())
		{
			KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.get_class($this).'::'.__FUNCTION__.'()') : null;
			throw new RuntimeException("Layout '{$this->input->getWord('view')}/{$this->input->getWord('layout', 'default')}' does not exist!", 404);
		}

		// Load language files.
		KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
		KunenaFactory::loadLanguage('com_kunena.templates');
		KunenaFactory::loadLanguage('com_kunena.models');
		KunenaFactory::loadLanguage('com_kunena.views');

		$this->me = KunenaUserHelper::getMyself();
		$this->config = KunenaConfig::getInstance();
		$this->document = JFactory::getDocument();
		$this->template = KunenaFactory::getTemplate();
		$this->template->initialize();

		if ($this->me->isAdmin ())
		{
			// Display warnings to the administrator if forum is either offline or debug has been turned on.
			if ($this->config->board_offline)
			{
				$this->app->enqueueMessage(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 'notice');
			}

			if ($this->config->debug)
			{
				$this->app->enqueueMessage(JText::_('COM_KUNENA_WARNING_DEBUG'), 'notice');
			}
		}

		if ($this->me->isBanned())
		{
			// Display warnings to the banned users.
			$banned = KunenaUserBan::getInstanceByUserid($this->me->userid, true);

			if (!$banned->isLifetime())
			{
				$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY',
					KunenaDate::getInstance($banned->expiration)->toKunena('date_today')), 'notice');
			}
			else
			{
				$this->app->enqueueMessage(JText::_ ( 'COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS'), 'notice');
			}
		}

		// Remove base and add canonical link.
		$this->document->setBase('');
		$this->document->addHeadLink( KunenaRoute::_(), 'canonical', 'rel');

		// Initialize breadcrumb.
		$this->breadcrumb = $this->app->getPathway();

		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.get_class($this).'::'.__FUNCTION__.'()') : null;
	}
Example #15
0
	protected function authoriseNotBanned($user) {
		$banned = $user->isBanned();
		if ($banned) {
			$banned = KunenaUserBan::getInstanceByUserid($user->userid, true);
			if (!$banned->isLifetime()) {
				return JText::sprintf ( 'COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY', KunenaDate::getInstance($banned->expiration)->toKunena());
			} else {
				return JText::_ ( 'COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS' );
			}
		}
	}
Example #16
0
 public function unblock()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirect(KunenaRoute::_($this->baseurl, false));
         return;
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     $userid = array_shift($cid);
     if ($userid <= 0) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_PROFILE_NO_USER'), 'error');
         $this->setRedirect(KunenaRoute::_($this->baseurl, false));
         return;
     }
     $ban = KunenaUserBan::getInstanceByUserid($userid, true);
     if (!$ban->id) {
         $ban->ban($userid, null, 1);
         $success = $ban->save();
     } else {
         jimport('joomla.utilities.date');
         $now = new JDate();
         $ban->setExpiration($now);
         $success = $ban->save();
     }
     $message = JText::_('COM_KUNENA_USER_UNBLOCK_DONE');
     if (!$success) {
         $this->app->enqueueMessage($ban->getError(), 'error');
     } else {
         $this->app->enqueueMessage($message);
     }
     $this->setRedirect(KunenaRoute::_($this->baseurl, false));
 }
Example #17
0
	function displayBanManager() {
		$this->bannedusers = KunenaUserBan::getBannedUsers();
		echo $this->loadTemplate('banmanager');
	}
Example #18
0
 /**
  * Method to get tabs for user profile
  *
  * @return array
  */
 public function getTabs()
 {
     $banInfo = KunenaUserBan::getInstanceByUserid($this->user->id, true);
     $myProfile = $this->profile->isMyself();
     $moderator = $this->me->isModerator();
     // Decide which tabs to display.
     $showPosts = true;
     $showSubscriptions = $this->config->allowsubscriptions && $myProfile;
     $showFavorites = $this->config->allowfavorites && $myProfile;
     $showThankYou = $this->config->showthankyou && $this->me->exists();
     $showUnapproved = $myProfile && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus());
     $showAttachments = $this->config->show_imgfiles_manage_profile && ($moderator || $myProfile);
     $showBanManager = $moderator && $myProfile;
     $showBanHistory = $banInfo->canBan();
     $showBanUser = $banInfo->canBan();
     // Define all tabs.
     $tabs = array();
     if ($showPosts) {
         $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'latest', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc', 'display' => $this->state->get('display', ''));
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_USERPOSTS');
         $tab->content = $this->subRequest('Message/List/Recent', new JInput($params), $params);
         $tab->active = true;
         $tabs['posts'] = $tab;
     }
     if ($showSubscriptions) {
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_SUBSCRIPTIONS');
         $tab->content = '';
         if ($this->config->category_subscriptions != 'disabled') {
             $params = array('embedded' => 1, 'userid' => $this->profile->userid, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
             $tab->content .= $this->subRequest('Category/Subscriptions', new JInput($params), $params);
         }
         if ($this->config->topic_subscriptions != 'disabled') {
             $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'subscriptions', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
             $tab->content .= $this->subRequest('Topic/List/User', new JInput($params), $params);
         }
         $tab->active = false;
         if ($tab->content) {
             $tabs['subscriptions'] = $tab;
         }
     }
     if ($showFavorites) {
         $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'favorites', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_FAVORITES');
         $tab->content = $this->subRequest('Topic/List/User', new JInput($params), $params);
         $tab->active = false;
         $tabs['favorites'] = $tab;
     }
     if ($showThankYou) {
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_THANK_YOU');
         $tab->content = '';
         $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'mythanks', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
         $tab->content .= $this->subRequest('Message/List/Recent', new JInput($params), $params);
         $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'thankyou', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
         $tab->content .= $this->subRequest('Message/List/Recent', new JInput($params), $params);
         $tab->active = false;
         $tabs['thankyou'] = $tab;
     }
     if ($showUnapproved) {
         $params = array('embedded' => 1, 'topics_categories' => 0, 'topics_catselection' => 1, 'userid' => $this->profile->userid, 'mode' => 'unapproved', 'sel' => -1, 'limit' => 10, 'filter_order' => 'time', 'limitstart' => 0, 'filter_order_Dir' => 'desc');
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_MESSAGE_ADMINISTRATION');
         $tab->content = $this->subRequest('Message/List/Recent', new JInput($params), $params);
         $tab->active = false;
         $tabs['unapproved'] = $tab;
     }
     if ($showAttachments) {
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
         $tab->content = $this->subRequest('User/Attachments');
         $tab->active = false;
         $tabs['attachments'] = $tab;
     }
     if ($showBanManager) {
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_BAN_BANMANAGER');
         $tab->content = $this->subRequest('User/Ban/Manager');
         $tab->active = false;
         $tabs['banmanager'] = $tab;
     }
     if ($showBanHistory) {
         $tab = new stdClass();
         $tab->title = JText::_('COM_KUNENA_BAN_BANHISTORY');
         $tab->content = $this->subRequest('User/Ban/History');
         $tab->active = false;
         $tabs['banhistory'] = $tab;
     }
     if ($showBanUser) {
         $tab = new stdClass();
         $tab->title = $banInfo->exists() ? JText::_('COM_KUNENA_BAN_EDIT') : JText::_('COM_KUNENA_BAN_NEW');
         $tab->content = $this->subRequest('User/Ban/Form');
         $tab->active = false;
         $tabs['banuser'] = $tab;
     }
     return $tabs;
 }
Example #19
0
/**
 * Kunena Component
 * @package     Kunena.Template.Crypsis
 * @subpackage  Layout.User
 *
 * @copyright   (C) 2008 - 2015 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        http://www.kunena.org
 **/
defined('_JEXEC') or die;
// @var KunenaUser $profile
$profile = $this->profile;
$me = KunenaUserHelper::getMyself();
$this->ktemplate = KunenaFactory::getTemplate();
$avatar = $profile->getAvatarImage($this->ktemplate->params->get('avatarType'), 'post');
$banInfo = $this->config->showbannedreason ? KunenaUserBan::getInstanceByUserid($profile->userid) : null;
$private = $profile->getPrivateMsgURL();
$privateLabel = $profile->getPrivateMsgLabel();
$websiteURL = $profile->getWebsiteURL();
$websiteName = $profile->getWebsiteName();
$personalText = $profile->getPersonalText();
$signature = $profile->getSignature();
$email = $profile->email && !$profile->hideEmail && $this->config->showemail || $me->isModerator() || $profile->userid == $me->userid;
$activityIntegration = KunenaFactory::getActivityIntegration();
$points = $activityIntegration->getUserPoints($profile->userid);
$medals = $activityIntegration->getUserMedals($profile->userid);
if ($this->config->showuserstats) {
    $rankImage = $profile->getRank(0, 'image');
    $rankTitle = $profile->getRank(0, 'title');
}
?>
Example #20
0
	function displayBanManager() {
		kimport('kunena.user.ban');
		$this->bannedusers = KunenaUserBan::getBannedUsers();
		echo $this->loadTemplate('banmanager');
	}
Example #21
0
	function unblock() {
		$app = JFactory::getApplication ();
		kimport('kunena.user.ban');
		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$cid = JRequest::getVar ( 'cid', array (), 'post', 'array' );
		$userid = (int)array_shift($cid);

		if ($userid < 0 ) {
			$app->enqueueMessage ( JText::_('COM_KUNENA_PROFILE_NO_USER'), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$ban = KunenaUserBan::getInstanceByUserid ( $userid, true );
		if (! $ban->id) {
			$ban->ban ( $userid, null, 1 );
			$success = $ban->save ();
		} else {
			jimport ('joomla.utilities.date');
			$now = new JDate();
			$ban->setExpiration ( $now );
			$success = $ban->save ();
		}

		$message = JText::_ ( 'COM_KUNENA_USER_UNBLOCK_DONE' );

		if (! $success) {
			$app->enqueueMessage ( $ban->getError (), 'error' );
		} else {
			$app->enqueueMessage ( $message );
		}

		$app->redirect ( KunenaRoute::_($this->baseurl, false) );
	}
Example #22
0
 protected function isIPBanned()
 {
     // Disabled for now..
     return false;
     kimport('userban');
     $banned = KunenaUserBan::getInstanceByIP($_SERVER['REMOTE_ADDR']);
     if ($banned) {
         if (!$banned->isLifetime()) {
             require_once KPATH_SITE . '/lib/kunena.timeformat.class.php';
             $this->_app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_IP_BANNED_NOACCESS_EXPIRY', CKunenaTimeformat::showDate($banned->expiration)), 'error');
             $this->redirectBack();
             return true;
         } else {
             $this->_app->enqueueMessage(JText::_('COM_KUNENA_POST_ERROR_IP_BANNED_NOACCESS'), 'error');
             $this->redirectBack();
             return true;
         }
     }
     return false;
 }
Example #23
0
	function ban() {
		$app = JFactory::getApplication();
		$user = KunenaFactory::getUser(JRequest::getInt ( 'userid', 0 ));
		if(!$user->exists() || !JRequest::checkToken()) {
			$app->redirect ( CKunenaLink::GetProfileURL($user->userid, false), COM_KUNENA_ERROR_TOKEN, 'error' );
			return;
		}

		$ip = JRequest::getVar ( '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', '' );

		kimport ( 'kunena.user.ban' );
		$ban = KunenaUserBan::getInstanceByUserid ( $user->userid, true );
		if (! $ban->id) {
			$ban->ban ( $user->userid, $ip, $block, $expiration, $reason_private, $reason_public, $comment );
			$success = $ban->save ();
		} else {
			$delban = JRequest::getString ( 'delban', '' );

			if ( $delban ) {
				$ban->unBan($comment);
				$success = $ban->save ();
			} else {
				$ban->blocked = $block;
				$ban->setExpiration ( $expiration, $comment );
				$ban->setReason ( $reason_private, $reason_public );
				$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) {
			$app->enqueueMessage ( $ban->getError (), 'error' );
		} else {
			$app->enqueueMessage ( $message );
		}

		$banDelPosts = JRequest::getVar ( 'bandelposts', '' );
		$DelAvatar = JRequest::getVar ( 'delavatar', '' );
		$DelSignature = JRequest::getVar ( 'delsignature', '' );
		$DelProfileInfo = JRequest::getVar ( 'delprofileinfo', '' );

		$db = JFactory::getDBO();
		if (! empty ( $DelAvatar ) || ! empty ( $DelProfileInfo )) {
			jimport ( 'joomla.filesystem.file' );
			$avatar_deleted = '';
			// Delete avatar from file system
			if (JFile::exists ( JPATH_ROOT . '/media/kunena/avatars/' . $userprofile->avatar ) && !stristr($userprofile->avatar,'gallery/')) {
				JFile::delete ( JPATH_ROOT . '/media/kunena/avatars/' . $userprofile->avatar );
				$avatar_deleted = $app->enqueueMessage ( JText::_('COM_KUNENA_MODERATE_DELETED_BAD_AVATAR_FILESYSTEM') );
			}
			$user->avatar = '';
			$user->save();
			$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();
			$app->enqueueMessage ( JText::_('COM_KUNENA_MODERATE_DELETED_BAD_PROFILEINFO') );
		} elseif (! empty ( $DelSignature )) {
			$user->signature = '';
			$user->save();
			$app->enqueueMessage ( JText::_('COM_KUNENA_MODERATE_DELETED_BAD_SIGNATURE') );
		}

		if (! empty ( $banDelPosts )) {
			// FIXME: delete user posts needs new logic (not here)
			//select only the messages which aren't already in the trash
/*			$db->setQuery ( "UPDATE #__kunena_messages SET hold=2 WHERE hold!=2 AND userid={$db->Quote($user->userid)}" );
			$idusermessages = $db->loadObjectList ();
			KunenaError::checkDatabaseError();
			$app->enqueueMessage ( JText::_('COM_KUNENA_MODERATE_DELETED_BAD_MESSAGES') );*/
		}

		$app->redirect ( CKunenaLink::GetProfileURL($user->userid, false) );
	}
Example #24
0
 * @package     Kunena.Template.Crypsis
 * @subpackage  Layout.User
 *
 * @copyright   (C) 2008 - 2016 Kunena Team. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link        https://www.kunena.org
 **/
defined('_JEXEC') or die;

// @var KunenaUser $profile

$profile = $this->profile;
$me = KunenaUserHelper::getMyself();
$avatar = $profile->getAvatarImage('img-polaroid', 'post');
$banInfo = $this->config->showbannedreason
	? KunenaUserBan::getInstanceByUserid($profile->userid)
	: null;
$private = KunenaFactory::getPrivateMessaging();
$websiteURL = $profile->getWebsiteURL();
$websiteName = $profile->getWebsiteName();
$personalText = $profile->getPersonalText();
$signature = $profile->getSignature();
$email = $profile->email && !$profile->hideEmail && $this->config->showemail || $me->isModerator() || $profile->userid == $me->userid;
$activityIntegration = KunenaFactory::getActivityIntegration();
$points = $activityIntegration->getUserPoints($profile->userid);
$medals = $activityIntegration->getUserMedals($profile->userid);

if ($this->config->showuserstats)
{
	$rankImage = $profile->getRank(0, 'image');
	$rankTitle = $profile->getRank(0, 'title');