Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * 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');
 }
Exemple #3
0
	/**
	 * 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
		);
	}
Exemple #4
0
	/**
	 * 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;
	}
Exemple #5
0
 /**
  * Method to get moderation actions for announcements
  *
  * @return string
  */
 public function getActions()
 {
     $this->buttons = array();
     if ($this->announcement->authorise('edit')) {
         $this->buttons['edit'] = $this->getButton($this->announcement->getUri('edit'), 'edit', 'announcement', 'moderation');
     }
     if ($this->announcement->authorise('delete')) {
         $this->buttons['delete'] = $this->getButton($this->announcement->getTaskUri('delete'), 'delete', 'announcement', 'permanent');
     }
     if ($this->buttons) {
         $this->buttons['cpanel'] = $this->getButton(KunenaForumAnnouncementHelper::getUri('list'), 'list', 'announcement', 'communication');
     }
     return $this->buttons;
 }
Exemple #6
0
 function getAnnouncements()
 {
     $start = $this->getState('list.start');
     $limit = $this->getState('list.limit');
     $this->total = KunenaForumAnnouncementHelper::getCount(!$this->me->isModerator());
     // If out of range, use last page
     if ($limit && $this->total < $start) {
         $start = intval($this->total / $limit) * $limit;
     }
     $announces = KunenaForumAnnouncementHelper::getAnnouncements($start, $limit, !$this->me->isModerator());
     if ($this->total < $start) {
         $this->setState('list.start', intval($this->total / $limit) * $limit);
     }
     return $announces;
 }
Exemple #7
0
 public static function getAnnouncements($start = 0, $limit = 1, $filter = true)
 {
     $db = JFactory::getDBO();
     $where = $filter ? "WHERE published=1" : '';
     $query = "SELECT * FROM #__kunena_announcement {$where} ORDER BY created DESC";
     $db->setQuery($query, $start, $limit);
     $results = (array) $db->loadAssocList();
     KunenaError::checkDatabaseError();
     self::$_instances = array();
     $list = array();
     foreach ($results as $announcement) {
         if (isset(self::$_instances[$announcement['id']])) {
             continue;
         }
         $instance = new KunenaForumAnnouncement($announcement);
         $instance->exists(true);
         self::$_instances[$instance->id] = $instance;
         $list[] = $instance;
     }
     unset($results);
     return $list;
 }
Exemple #8
0
 public function save()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $now = new JDate();
     $fields = array();
     $fields['title'] = JRequest::getString('title', '', 'post', JREQUEST_ALLOWRAW);
     $fields['description'] = JRequest::getString('description', '', 'post', JREQUEST_ALLOWRAW);
     $fields['sdescription'] = JRequest::getString('sdescription', '', 'post', JREQUEST_ALLOWRAW);
     $fields['created'] = JRequest::getString('created', $now->toSql());
     $fields['published'] = JRequest::getInt('published', 1);
     $fields['showdate'] = JRequest::getInt('showdate', 1);
     $id = JRequest::getInt('id');
     $announcement = KunenaForumAnnouncementHelper::get($id);
     $announcement->bind($fields);
     if (!$announcement->authorise($id ? 'edit' : 'create') || !$announcement->save()) {
         $this->app->enqueueMessage($announcement->getError(), 'error');
         $this->redirectBack();
     }
     $this->app->enqueueMessage(JText::_($id ? 'COM_KUNENA_ANN_SUCCESS_EDIT' : 'COM_KUNENA_ANN_SUCCESS_ADD'));
     $this->setRedirect($announcement->getUrl('default', false));
 }
Exemple #9
0
	/**
	 * Free up memory by cleaning up all cached items.
	 */
	public static function cleanup() {
		self::$_instances = array();
	}
Exemple #10
0
	function displayActions()
	{
		$this->buttons = array();

		if ($this->announcement->authorise('edit'))
		{
			$this->buttons['edit'] = $this->getButton($this->announcement->getUri('edit'), 'edit', 'announcement', 'moderation');
		}

		if ($this->announcement->authorise('delete'))
		{
			$this->buttons['delete'] = $this->getButton($this->announcement->getTaskUri('delete'), 'delete', 'announcement', 'permanent');
		}

		if ($this->buttons)
		{
			$this->buttons['cpanel'] = $this->getButton(KunenaForumAnnouncementHelper::getUri('list'), 'list', 'announcement', 'communication');
		}

		$contents = $this->loadTemplateFile('actions');

		return $contents;
	}
 /**
  * Returns the global KunenaForumAnnouncement object.
  *
  * @param   int  $id  The announcement id to load.
  *
  * @return  KunenaForumAnnouncement
  */
 public static function getInstance($identifier = null, $reload = false)
 {
     return KunenaForumAnnouncementHelper::get($identifier, $reload);
 }
Exemple #12
0
	function displayLoginBox($tpl = null)
	{
		if ($this->offline)
		{
			return;
		}

		$my         = JFactory::getUser();
		$cache      = JFactory::getCache('com_kunena', 'output');
		$cachekey   = "{$this->ktemplate->name}.common.loginbox.u{$my->id}";
		$cachegroup = 'com_kunena.template';

		// FIXME: enable caching after fixing the issues
		$contents = false; //$cache->get($cachekey, $cachegroup);

		if (!$contents)
		{
			$this->moduleHtml = $this->getModulePosition('kunena_profilebox');

			$login = KunenaLogin::getInstance();

			if ($my->get('guest'))
			{
				$this->setLayout('login');

				if ($login)
				{
					$this->login           = $login;
					$this->registerUrl     = $login->getRegistrationUrl();
					$this->lostPasswordUrl = $login->getResetUrl();
					$this->lostUsernameUrl = $login->getRemindUrl();
					$this->remember        = $login->getRememberMe();
				}
			}
			else
			{
				$this->setLayout('logout');

				if ($login)
				{
					$this->logout = $login;
				}

				$this->lastvisitDate = KunenaDate::getInstance($this->me->lastvisitDate);

				// Private messages
				$this->getPrivateMessageLink();

				// TODO: Edit profile (need to get link to edit page, even with integration)
				//$this->editProfileLink = '<a href="' . $url.'">'. JText::_('COM_KUNENA_PROFILE_EDIT').'</a>';

				// Announcements
				if ($this->me->isModerator())
				{
					$this->announcementsLink = '<a href="' . KunenaForumAnnouncementHelper::getUrl('list') . '">' . JText::_('COM_KUNENA_ANN_ANNOUNCEMENTS') . '</a>';
				}

			}
			$contents = $this->loadTemplateFile($tpl);

			if (JError::isError($contents))
			{
				return $contents;
			}
			// FIXME: enable caching after fixing the issues
			//$cache->store($contents, $cachekey, $cachegroup);
		}

		$contents = preg_replace_callback('|\[K=(\w+)(?:\:([\w-_]+))?\]|', array($this, 'fillLoginBoxInfo'), $contents);
		echo $contents;
	}
 function getAnnouncements()
 {
     return KunenaForumAnnouncementHelper::getAnnouncements($this->getState('list.start'), $this->getState('list.limit'), !$this->me->isModerator());
 }