public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.settings', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $config = DiscussHelper::getConfig(); $jconfig = DiscussHelper::getJConfig(); $defaultSAId = DiscussHelper::getDefaultSAIds(); $joomlaVersion = DiscussHelper::getJoomlaVersion(); $joomlaGroups = DiscussHelper::getJoomlaUserGroups(); $this->assignRef('config', $config); $this->assignRef('jconfig', $jconfig); $this->assignRef('defaultSAId', $defaultSAId); $this->assignRef('defaultLength', $defaultLength); $this->assignRef('joomlaversion', $joomlaVersion); $this->assignRef('joomlaGroups', $joomlaGroups); if ($this->getLayout() == 'default') { $app = JFactory::getApplication(); $app->redirect('index.php?option=com_easydiscuss&view=settings&layout=default_main_workflow&child=general'); } parent::display($tpl); }
function _getnewOwnerShip($curUserId) { $econfig = DiscussHelper::getConfig(); // this should get from backend. If backend not defined, get the default superadmin. $defaultSAid = DiscussHelper::getDefaultSAIds(); $newOwnerShipId = $econfig->get('main_orphanitem_ownership', $defaultSAid); /** * we check if the tobe deleted user is the same user id as the saved user id in config. * if yes, we try to get a next SA id. */ if ($curUserId == $newOwnerShipId) { // this is no no a big no! try to get the next admin. if (DiscussHelper::getJoomlaVersion() >= '1.6') { $saUsersId = DiscussHelper::getSAUsersIds(); if (count($saUsersId) > 0) { for ($i = 0; $i < count($saUsersId); $i++) { if ($saUsersId[$i] != $curUserId) { $newOwnerShip = $saUsersId[$i]; break; } } } } else { $newOwnerShip = $this->_getSuperAdminId($curUserId); } } $newOwnerShipId = $this->_verifyOnwerShip($newOwnerShipId); $db = DiscussHelper::getDBO(); $query = 'SELECT a.`id`, a.`name`, a.`username`, b.`nickname`, a.`email` ' . ' FROM ' . $db->nameQuote('#__users') . ' as a ' . ' INNER JOIN ' . $db->nameQuote('#__discuss_users') . ' as b on a.`id` = b.`id` ' . ' WHERE a.`id` = ' . $db->Quote($newOwnerShipId); $db->setQuery($query); $result = $db->loadAssoc(); $displayFormat = $econfig->get('layout_nameformat', 'name'); $displayName = ''; switch ($displayFormat) { case "name": $displayName = $result['name']; break; case "username": $displayName = $result['username']; break; case "nickname": default: $displayName = empty($result['nickname']) ? $result['name'] : $result['nickname']; break; } $newOwnerShip = new stdClass(); $newOwnerShip->id = $result['id']; $newOwnerShip->name = $displayName; $newOwnerShip->email = $result['email']; return $newOwnerShip; }
private function mapVBulletinCategory($vCategory, &$category, $parentId = 0) { $parentId = $parentId ? $parentId : 0; // @task: Since vBulletin does not store the creator of the category, we'll need to assign a default owner. $category->set('created_by', DiscussHelper::getDefaultSAIds()); $category->set('title', strip_tags($vCategory->title)); $category->set('description', $vCategory->description); $category->set('published', 1); $category->set('parent_id', $parentId); // @TODO: Detect if it has a parent id and migrate according to the category tree. $category->store(true); $this->added('vBulletin', $category->id, $vCategory->forumid, 'category'); }