public function getUserListURL($action='', $xhtml = true) { $config = KunenaFactory::getConfig (); $my = JFactory::getUser(); if ( $config->userlist_allowed == 1 && $my->id == 0 ) return false; return CRoute::_('index.php?option=com_community&view=search&task=browse', $xhtml); }
public function getQueryWhere() { $where = ''; // Hide super admins from the list if (!KunenaFactory::getConfig()->superadmin_userlist) { $db = JFactory::getDBO(); $query = "SELECT user_id FROM `#__user_usergroup_map` WHERE group_id =8"; $db->setQuery($query); $superadmins = (array) $db->loadColumn(); if (!$superadmins) { $superadmins = array(0); } $this->setState('list.exclude', implode(',', $superadmins)); $where = ' u.id NOT IN (' . $this->getState('list.exclude') . ') AND '; } if ($this->config->userlist_count_users == '1') { $where .= '(u.block=0 OR u.activation="")'; } elseif ($this->config->userlist_count_users == '2') { $where .= '(u.block=0 AND u.activation="")'; } elseif ($this->config->userlist_count_users == '3') { $where .= 'u.block=0'; } else { $where .= '1'; } return $where; }
public function __construct($config = array()) { parent::__construct($config); $this->app = JFactory::getApplication(); $this->me = KunenaUserHelper::getMyself(); $this->config = KunenaFactory::getConfig(); }
/** * 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; }
public function __construct() { $this->config = KunenaFactory::getConfig(); $this->publickey = $this->config->recaptcha_publickey; $this->privatekey = $this->config->recaptcha_privatekey; $this->host = JRequest::getVar('REMOTE_ADDR', null, 'server'); }
/** * Test getInstance() * * @param KunenaForumCategoryUser $categoryuser * @return KunenaForumCategoryUser * @depends testCreate */ public function testGetInstance(KunenaForumCategoryUser $categoryuser) { $admin = KunenaFactory::getUser('admin'); $categoryuser2 = KunenaForumCategoryUser::getInstance($categoryuser->category_id, $admin->userid); $this->assertSame($categoryuser, $categoryuser2); return $categoryuser; }
/** * Display module contents. */ public final function display() { // Load CSS only once if (static::$css) { $this->document->addStyleSheet(JURI::root(true) . static::$css); static::$css = null; } // Use caching also for registered users if enabled. if ($this->params->get('owncache', 0)) { /** @var $cache JCacheControllerOutput */ $cache = JFactory::getCache('com_kunena', 'output'); $me = KunenaFactory::getUser(); $cache->setLifeTime($this->params->get('cache_time', 180)); $hash = md5(serialize($this->params)); if ($cache->start("display.{$me->userid}.{$hash}", 'mod_kunenalatest')) { return; } } // Initialize Kunena. KunenaForum::setup(); // Display module. $this->_display(); // Store cached page. if (isset($cache)) { $cache->end(); } }
/** * Test get() */ public function testGet() { $admin = KunenaFactory::getUser('admin'); $categoryuser = KunenaForumCategoryUserHelper::get(0, $admin->userid); $this->assertEquals(0, $categoryuser->category_id); $this->assertEquals($admin->userid, $categoryuser->user_id); }
/** * @param $user * @param $sizex * @param $sizey * * @return string */ protected function _getURL($user, $sizex, $sizey) { $user = KunenaFactory::getUser($user); $avatar = $user->avatar; $config = KunenaFactory::getConfig(); $path = KPATH_MEDIA . "/avatars"; $origPath = "{$path}/{$avatar}"; if (!is_file($origPath)) { // If avatar does not exist use default image. if ($sizex <= 90) { $avatar = 's_nophoto.jpg'; } else { $avatar = 'nophoto.jpg'; } // Search from the template. $template = KunenaFactory::getTemplate(); $origPath = JPATH_SITE . '/' . $template->getAvatarPath($avatar); $avatar = $template->name . '/' . $avatar; } $dir = dirname($avatar); $file = basename($avatar); if ($sizex == $sizey) { $resized = "resized/size{$sizex}/{$dir}"; } else { $resized = "resized/size{$sizex}x{$sizey}/{$dir}"; } // TODO: make timestamp configurable? $timestamp = ''; if (!is_file("{$path}/{$resized}/{$file}")) { KunenaImageHelper::version($origPath, "{$path}/{$resized}", $file, $sizex, $sizey, intval($config->avatarquality), KunenaImage::SCALE_INSIDE, intval($config->avatarcrop)); $timestamp = '?' . round(microtime(true)); } return KURL_MEDIA . "avatars/{$resized}/{$file}{$timestamp}"; }
function kunena_upgrade_200_configuration($parent) { $config = KunenaFactory::getConfig (); if ($config->allowimageupload >= 0) { $config->image_upload = 'nobody'; if ($config->allowimageregupload == 1) { $config->image_upload = 'registered'; } if ($config->allowimageupload == 1) { $config->image_upload = 'everybody'; } $config->allowimageupload = $config->allowimageregupload = -1; } if ($config->allowfileupload >= 0) { $config->file_upload = 'nobody'; if ($config->allowfileregupload == 1) { $config->file_upload = 'registered'; } if ($config->allowfileupload == 1) { $config->file_upload = 'everybody'; } $config->allowfileupload = $config->allowfileregupload = -1; } // Save configuration $config->remove (); $config->create (); return array ('action' => '', 'name' => JText::_ ( 'COM_KUNENA_INSTALL_200_CONFIGURATION' ), 'success' => true ); }
protected function _getURL($user, $sizex, $sizey) { $user = KunenaFactory::getUser($user); // Get CUser object $avatar=AwdwallHelperUser::getBigAvatar51($user->userid); return $avatar; }
function displayDefault() { JToolBarHelper::title ( ' ', 'kunena.png' ); $this->config = KunenaFactory::getConfig (); $this->versioncheck = $this->get('latestversion'); $this->display (); }
function displayList($tpl = null) { $this->app = JFactory::getApplication(); $this->config = KunenaFactory::getConfig(); $this->assignRef ( 'announcements', $this->get ( 'Announcements' ) ); $this->assignRef ( 'canEdit', $this->get ( 'CanEdit' ) ); $this->display(); }
protected function _getURL($user, $sizex, $sizey) { $user = KunenaFactory::getUser($user); $user = FD::user($user->userid); $avatar = $user->getAvatar(SOCIAL_AVATAR_LARGE); return $avatar; }
/** * 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)); }
/** * Test getInstance() * * @param KunenaForumTopicUser $topicuser * @return KunenaForumTopicUser * @depends testCreate */ public function testGetInstance(KunenaForumTopicUser $topicuser) { $admin = KunenaFactory::getUser('admin'); $topicuser2 = KunenaForumTopicUser::getInstance($topicuser->topic_id, $admin->userid); $this->assertSame($topicuser, $topicuser2); return $topicuser; }
function kunena_160_2010_05_30_timezone($parent) { $result = null; $config = KunenaFactory::getConfig(); $db = JFactory::getDbo(); // We need to fix all timestamps to UTC (if not already done) if ($config->get('board_ofset', '0.00') != '0.00') { $timeshift = (double) date('Z') + (double) $config->get('board_ofset') * 3600; $db->setQuery("UPDATE #__kunena_categories SET time_last_msg = time_last_msg - {$timeshift}"); $db->query(); if ($db->getErrorNum()) { throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum()); } $db->setQuery("UPDATE #__kunena_sessions SET lasttime = lasttime - {$timeshift}, currvisit = currvisit - {$timeshift}"); $db->query(); if ($db->getErrorNum()) { throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum()); } $db->setQuery("UPDATE #__kunena_whoisonline SET time = time - {$timeshift}"); $db->query(); if ($db->getErrorNum()) { throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum()); } $db->setQuery("UPDATE #__kunena_messages SET time = time - {$timeshift}, modified_time = modified_time - {$timeshift}"); $db->query(); if ($db->getErrorNum()) { throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum()); } unset($config->board_ofset); $result = array('action' => '', 'name' => JText::sprintf('COM_KUNENA_INSTALL_160_TIMEZONE', sprintf('%+d:%02d', $timeshift / 3600, $timeshift / 60 % 60)), 'success' => true); } // Save configuration $config->save(); return $result; }
public function displayEdit() { $this->setToolBarEdit(); $this->user = $this->get('user'); $this->sub = $this->get('subscriptions'); $this->subscatslist = $this->get('catsubcriptions'); $this->ipslist = $this->get('IPlist'); $avatarint = KunenaFactory::getAvatarIntegration(); $this->editavatar = ($avatarint instanceof KunenaAvatarKunena) ? true : false; $this->avatar = $avatarint->getLink($this->user, '', 'users'); // make the select list for the moderator flag $yesnoMod [] = JHtml::_('select.option', '1', JText::_('COM_KUNENA_YES')); $yesnoMod [] = JHtml::_('select.option', '0', JText::_('COM_KUNENA_NO')); // build the html select list $this->selectMod = JHtml::_('select.genericlist', $yesnoMod, 'moderator', 'class="inputbox" size="2"', 'value', 'text', $this->user->moderator); // make the select list for the moderator flag $yesnoOrder [] = JHtml::_('select.option', '0', JText::_('COM_KUNENA_USER_ORDER_ASC')); $yesnoOrder [] = JHtml::_('select.option', '1', JText::_('COM_KUNENA_USER_ORDER_DESC')); // build the html select list $this->selectOrder = JHtml::_('select.genericlist', $yesnoOrder, 'neworder', 'class="inputbox" size="2"', 'value', 'text', $this->user->ordering); $this->modCats = $this->get('listmodcats'); $this->selectRank = $this->get('listuserranks'); $this->display(); }
public function onUserAfterSave($user, $isnew, $success, $msg) { //Don't continue if the user wasn't stored succesfully if (! $success) { return false; } if ($isnew) { $user = KunenaFactory::getUser(intval($user ['id'])); $user->save(); } /* // See: http://www.kunena.org/forum/159-k-16-common-questions/63438-category-subscriptions-default-subscribed#63554 // TODO: Subscribe user to every category if he is new and Kunena is configured to do so if ($isnew) { $subscribedCategories = '1,2,3,4,5,6,7,8,9,10'; $db = Jfactory::getDBO(); $query = "INSERT INTO #__kunena_user_categories (user_id,category_id) SELECT {$user->userid} AS user_id, c.id as category_id FROM #__kunena_categories AS c LEFT JOIN #__kunena_user_categories AS s ON c.id=s.category_id AND s.user_id={$user->userid} WHERE c.parent>0 AND c.id IN ({$subscribedCategories}) AND s.user_id IS NULL"; $db->setQuery ( $query ); $db->query (); KunenaError::checkDatabaseError(); // Here's also query to subscribe all users (including blocked) to all existing cats: $query = "INSERT INTO #__kunena_user_categories (user_id,category_id) SELECT u.id AS user_id, c.id AS category_id FROM #__users AS u JOIN #__kunena_categories AS c ON c.parent>0 LEFT JOIN #__kunena_user_categories AS s ON u.id=s.user_id WHERE c.id IN ({$subscribedCategories}) AND s.user_id IS NULL"; } */ }
/** * Test get() */ public function testGet() { $admin = KunenaFactory::getUser('admin'); $topicuser = KunenaForumTopicUserHelper::get(); $this->assertEquals(null, $topicuser->topic_id); $this->assertEquals(0, $topicuser->user_id); }
function displayDefault($tpl = null) { if (!$this->config->enablerss) { JError::raiseError(404, JText::_('COM_KUNENA_RSS_DISABLED')); } KunenaHtmlParser::$relative = false; $this->category = $this->get('Category'); if (!$this->category->authorise('read')) { JError::raiseError(404, $this->category->getError()); } $this->topics = $this->get('Topics'); $title = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name; $this->setTitle($title); $metaDesc = $this->document->getDescription() . '. ' . $this->escape("{$this->category->name} - {$this->config->board_title}"); $this->document->setDescription($metaDesc); // Create image for feed $image = new JFeedImage(); $image->title = $this->document->getTitle(); $image->url = $this->ktemplate->getImagePath('icons/rss.png'); $image->description = $this->document->getDescription(); $this->document->image = $image; foreach ($this->topics as $topic) { $description = $topic->last_post_message; $date = new JDate($topic->last_post_time); $userid = $topic->last_post_userid; $username = KunenaFactory::getUser($userid)->getName($topic->last_post_guest_name); $title = $topic->subject; $category = $topic->getCategory(); $url = $topic->getUrl($category, true, 'last'); $this->createItem($title, $url, $description, $category->name, $date, $userid, $username); } }
function permdel() { if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $message = ''; $ids = array_keys(JRequest::getVar('topics', array(), 'post', 'array')); // Array of integer keys JArrayHelper::toInteger($ids); $topics = KunenaForumTopicHelper::getTopics($ids); if (!$topics) { $message = JText::_('COM_KUNENA_NO_TOPICS_SELECTED'); } else { foreach ($topics as $topic) { if ($topic->authorise('permdelete') && $topic->delete()) { // Activity integration $activity = KunenaFactory::getActivityIntegration(); $activity->onAfterDeleteTopic($topic); $message = JText::_('COM_KUNENA_BULKMSG_DELETED'); } else { $this->app->enqueueMessage($topic->getError(), 'notice'); } } } if ($message) { $this->app->enqueueMessage($message); } $this->setRedirectBack(); }
public function __construct() { $this->integration = KunenaIntegration::getInstance ( 'jomsocial' ); if (! $this->integration || ! $this->integration->isLoaded ()) return; $this->priority = 40; $this->_config = KunenaFactory::getConfig (); }
/** * 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'); }
public function getSmileyspaths() { $template = KunenaFactory::getTemplate(); $selected = $this->getSmiley(); $smileypath = $template->getSmileyPath(); $files1 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html')); $files1 = (array) array_flip($files1); foreach ($files1 as $key => &$path) { $path = $smileypath . $key; } $smileypath = 'media/kunena/emoticons/'; $files2 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html')); $files2 = (array) array_flip($files2); foreach ($files2 as $key => &$path) { $path = $smileypath . $key; } $smiley_images = $files1 + $files2; ksort($smiley_images); $smiley_list = array(); foreach ($smiley_images as $file => $path) { $smiley_list[] = JHtml::_('select.option', $path, $file); } $list = JHtml::_('select.genericlist', $smiley_list, 'smiley_url', 'class="inputbox" onchange="update_smiley(this.options[selectedIndex].value);" onmousemove="update_smiley(this.options[selectedIndex].value);"', 'value', 'text', !empty($selected->location) ? $smiley_images[$selected->location] : ''); return $list; }
protected function _getURL($user, $sizex, $sizey) { $user = KunenaFactory::getUser($user); $avatar = $user->avatar; $config = KunenaFactory::getConfig(); $path = KPATH_MEDIA . "/avatars"; if (!is_file("{$path}/{$avatar}")) { // If avatar does not exist use default image if ($sizex <= 90) { $avatar = 's_nophoto.jpg'; } else { $avatar = 'nophoto.jpg'; } } $dir = dirname($avatar); $file = basename($avatar); if ($sizex == $sizey) { $resized = "resized/size{$sizex}/{$dir}"; } else { $resized = "resized/size{$sizex}x{$sizey}/{$dir}"; } if (!is_file("{$path}/{$resized}/{$file}")) { require_once KPATH_SITE . '/lib/kunena.image.class.php'; CKunenaImageHelper::version("{$path}/{$avatar}", "{$path}/{$resized}", $file, $sizex, $sizey, intval($config->avatarquality)); } return KURL_MEDIA . "avatars/{$resized}/{$file}"; }
public function getRankspaths() { $template = KunenaFactory::getTemplate(); $selected = $this->getRank(); $rankpath = $template->getRankPath(); $files1 = (array) JFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html')); $files1 = (array) array_flip($files1); foreach ($files1 as $key => &$path) { $path = $rankpath . $key; } $rankpath = 'media/kunena/ranks/'; $files2 = (array) JFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html')); $files2 = (array) array_flip($files2); foreach ($files2 as $key => &$path) { $path = $rankpath . $key; } $rank_images = $files1 + $files2; ksort($rank_images); $rank_list = array(); foreach ($rank_images as $file => $path) { $rank_list[] = JHtml::_('select.option', $path, $file); } $list = JHtml::_('select.genericlist', $rank_list, 'rank_image', 'class="inputbox" onchange="update_rank(this.options[selectedIndex].value);" onmousemove="update_rank(this.options[selectedIndex].value);"', 'value', 'text', isset($selected->rank_image) ? $rank_images[$selected->rank_image] : ''); return $list; }
/** * @return string */ protected function getInput() { if (!class_exists('KunenaForum') || !KunenaForum::installed()) { echo '<a href="index.php?option=com_kunena">PLEASE COMPLETE KUNENA INSTALLATION</a>'; return ''; } KunenaFactory::loadLanguage('com_kunena'); $size = $this->element['size']; $class = $this->element['class']; $attribs = ' '; if ($size) { $attribs .= 'size="' . $size . '"'; } if ($class) { $attribs .= 'class="' . $class . '"'; } else { $attribs .= 'class="inputbox"'; } if (!empty($this->element['multiple'])) { $attribs .= ' multiple="multiple"'; } // Get the field options. $options = $this->getOptions(); return JHtml::_('kunenaforum.categorylist', $this->name, 0, $options, $this->element, $attribs, 'value', 'text', $this->value); }
public function getTopHits($limit = 0) { if (!$limit) { $limit = KunenaFactory::getConfig()->popusercount; } return (array) $this->_getTopHits($limit); }
/** * Method to retrieve small category icon * * @param KunenaSubCategory $subcategory The KunenaCategory object * * @return string */ public function getSmallCategoryIcon($subcategory) { $this->ktemplate = KunenaFactory::getTemplate(); $defaultcategoryicon = $this->ktemplate->params->get('DefaultCategoryicon'); if ($subcategory->getNewCount()) { if (!empty($subcategory->icon)) { return '<i class="' . $subcategory->icon . ' icon-knewchar" alt="' . JText::_('COM_KUNENA_GEN_FORUM_NEWPOST') . '"> </i>'; } else { return '<i class="' . $defaultcategoryicon . ' icon-knewchar" alt="' . JText::_('COM_KUNENA_GEN_FORUM_NEWPOST') . '"> </i>'; } } else { if (!empty($subcategory->icon)) { return '<i class="' . $subcategory->icon . '" alt="' . JText::_('COM_KUNENA_GEN_FORUM_NEWPOST') . '"> </i>'; } else { return '<i class="' . $defaultcategoryicon . '" alt="' . JText::_('COM_KUNENA_GEN_FORUM_NEWPOST') . '"> </i>'; } } }