function getAdmins() { $db = DiscussHelper::getDBO(); $query = 'SELECT `id`'; $query .= ' FROM #__users'; if (DiscussHelper::getJoomlaVersion() >= '1.6') { $saUsersIds = DiscussHelper::getSAUsersIds(); $query .= ' WHERE id IN (' . implode(',', $saUsersIds) . ')'; } else { $query .= ' WHERE LOWER( `usertype` ) = ' . $db->Quote('super administrator'); } $query .= ' AND `sendEmail` = ' . $db->Quote('1'); $db->setQuery($query); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $result = $db->loadObjectList(); return $result; }
public static function getDefaultSAIds() { $saUserId = '62'; if (DiscussHelper::getJoomlaVersion() >= '1.6') { $saUsers = DiscussHelper::getSAUsersIds(); $saUserId = $saUsers[0]; } return $saUserId; }
function _verifyOnwerShip($id) { $db = DiscussHelper::getDBO(); $query = 'SELECT `id` FROM `#__users` WHERE `id` = ' . $db->Quote($id); $db->setQuery($query); $result = $db->loadResult(); if (empty($result)) { if (DiscussHelper::getJoomlaVersion() >= '1.6') { $saUsersId = DiscussHelper::getSAUsersIds(); $result = $saUsersId[0]; } else { $result = $this->_getSuperAdminId(); } } return $result; }
private function _removeUser16($id) { $db = DiscussHelper::getDBO(); $currentUser = JFactory::getUser(); $user = JFactory::getUser($id); $isUserSA = $user->authorise('core.admin'); if ($isUserSA) { $msg = JText::_('You cannot delete a Super Administrator'); } else { if ($id == $currentUser->get('id')) { $msg = JText::_('You cannot delete Yourself!'); } else { $count = 2; if ($isUserSA) { $saUsers = DiscussHelper::getSAUsersIds(); $count = count($saUsers); } if ($count <= 1 && $isUserSA) { // cannot delete Super Admin where it is the only one that exists $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; } else { // delete user $user->delete(); $msg = JText::_('User Deleted.'); JRequest::setVar('task', 'remove'); JRequest::setVar('cid', $id); // delete user acounts active sessions $this->logout(); $success = true; } } } $result['success'] = $success; $result['msg'] = $msg; return $result; }
public static function getModeratorsDropdownOld($categoryId) { $category = DiscussHelper::getTable('Category'); if (!$category->load($categoryId)) { return ''; } $moderators = array(); $moderators[0] = JText::_('COM_EASYDISCUSS_MODERATOR_OPTION_NONE'); $list = $category->getModerators(); if ($list) { foreach ($list as $userId) { $profile = DiscussHelper::getTable('Profile'); $profile->load($userId); $moderators[$profile->id] = $profile->getName(); } } // Find super admins. $siteAdmins = DiscussHelper::getSAUsersIds(); $ids = array_keys($moderators); foreach ($siteAdmins as $id) { if (!in_array($id, $ids)) { $profile = DiscussHelper::getTable('Profile'); $profile->load($id); $moderators[$id] = $profile->getName(); } } return $moderators; }
/** * Includes admins, custom admins, moderators, custom moderators * unique these emails */ private static function _getAdministratorsEmails($catId, $notifyAdmins = false, $notifyModerators = false) { $config = DiscussHelper::getConfig(); $db = DiscussHelper::getDBO(); $admins = array(); $customAdmins = array(); $mods = array(); $customMods = array(); if ($notifyAdmins) { $query = 'SELECT `email` FROM `#__users`'; if (DiscussHelper::getJoomlaVersion() >= '1.6') { $saUsersIds = DiscussHelper::getSAUsersIds(); $query .= ' WHERE id IN (' . implode(',', $saUsersIds) . ')'; } else { $query .= ' WHERE LOWER( `usertype` ) = ' . $db->Quote('super administrator'); } $query .= ' AND `sendEmail` = ' . $db->Quote('1'); $db->setQuery($query); $admins = $db->loadResultArray(); $customAdmins = explode(',', $config->get('notify_custom')); } if ($notifyModerators) { $mods = DiscussHelper::getHelper('Moderator')->getModeratorsEmails($catId); $customMods = array(); if ($catId) { $category = DiscussHelper::getTable('Category'); $category->load($catId); $customMods = explode(',', $category->getParam('cat_notify_custom')); } } $emails = array_unique(array_merge($admins, $customAdmins, $mods, $customMods)); return $emails; }
* to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.filesystem.file'); // Load constants require_once JPATH_ROOT . '/components/com_easydiscuss/constants.php'; require_once JPATH_ROOT . '/components/com_easydiscuss/helpers/helper.php'; // Require the base controller require_once JPATH_COMPONENT . '/controllers/controller.php'; // Call ajax library require_once DISCUSS_CLASSES . '/disjax.php'; require_once DISCUSS_CLASSES . '/themes.php'; DiscussHelper::getSAUsersIds(); // Process AJAX calls here DiscussHelper::getHelper('Ajax')->process(); DiscussHelper::getUserGids(); // Load up config object. $config = DiscussHelper::getConfig(); require_once dirname(__FILE__) . '/services.php'; // Compile javascripts DiscussHelper::compileJS(); // Get the task $task = JRequest::getCmd('task', 'display'); // We treat the view as the controller. Load other controller if there is any. $controller = JRequest::getWord('controller', ''); if (!empty($controller)) { $controller = JString::strtolower($controller); $path = JPATH_COMPONENT . '/controllers/' . $controller . '.php';