コード例 #1
0
ファイル: view.html.php プロジェクト: sansandeep143/av
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->params = $app->getParams();
     /* Default Page fallback*/
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
     }
     $this->currentItemid = $active->id;
     $entriesPerPage = $this->params->get('max_events_per_page', 12);
     $model = $this->getModel('events');
     $eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel');
     $recursive = $this->params->get('show_items_per_category_recursive', false);
     $user = JFactory::getUser();
     $usergroups = JUserHelper::getUserGroups($user->id);
     $entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->params->get('catid', null), $recursive);
     $this->pageNav = $model->getPagination();
     $this->entries = $entries;
     $this->eventModel = $eventModel;
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #2
0
ファイル: temakorok.php プロジェクト: madcsaba/li-de
 /**
  * the user is admin?
  * @param JUser $user
  * @return boolean      
  */
 public function isAdmin($user = false)
 {
     jimport('joomla.user.helper');
     if ($user == false) {
         $user = JFactory::getUser();
     }
     $result = false;
     if ($user) {
         $groups = JUserHelper::getUserGroups($user->id);
         //DBG foreach($groups as $fn => $fv) echo '<p>'.$fn.'='.$fv.'</p>'; exit();
         $admin_groups = array();
         //put all the groups that you consider to be admins
         $admin_groups[] = "Super Users";
         $admin_groups[] = "Administrator";
         $admin_groups[] = "Manager";
         $admin_groups[] = "8";
         $admin_groups[] = "7";
         $admin_groups[] = "6";
         foreach ($admin_groups as $temp) {
             if (!empty($groups[$temp])) {
                 $result = true;
             }
         }
     }
     return $result;
 }
コード例 #3
0
 function display($tpl = null)
 {
     $option = JRequest::getCMD('option');
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($user->get('guest')) {
         // Redirect to login
         $uri = JFactory::getURI();
         $mainframe->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), null);
         return;
     } else {
         $groups = JUserHelper::getUserGroups($user->get('id'));
         if (!in_array(4, $groups)) {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return;
         }
     }
     $document =& JFactory::getDocument();
     //$document->addScript( '/media/system/js/viewutils.js');
     //$document->addScript('/media/system/js/mootools1.js');
     //$document->addStyleSheet('/media/system/css/global.css');
     //$document->addStyleSheet('/media/system/css/content.css');
     $document->addStylesheet('/media/system/css/ZoneStyle.css');
     $helper = new comZonalesHelper();
     $this->assignRef('template', $mainframe->getTemplate());
     $this->assignRef('user', $user);
     $host = 'localhost';
     $this->assignRef('tomcat_host', $host);
     $port = '38080';
     $this->assignRef('tomcat_port', $port);
     $this->assignRef('zonal_id', ucwords(str_replace("_", "+", $helper->getZonalActual())));
     parent::display($tpl);
 }
コード例 #4
0
ファイル: acl.php プロジェクト: joomlacorner/citruscart
 /**
  * Checks if the current user, or userID passed to function is an administrator
  *
  * @param INT
  */
 public static function isAdmin($userid = NULL, $admin_groups = array("7", "8"), $group_ids_passed = true)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         jimport('joomla.user.helper');
         $user = JFactory::getUser($userid);
         $groups = JUserHelper::getUserGroups($user->id);
         //var_dump($admin_groups);
         if ($group_ids_passed) {
             foreach ($groups as $temp) {
                 if (in_array($temp, $admin_groups)) {
                     return true;
                 }
             }
         } else {
             foreach ($admin_groups as $temp) {
                 if (!empty($groups[$temp])) {
                     return true;
                 }
             }
         }
         return false;
     } else {
         // Joomla! 1.5 code here
         jimport('joomla.user.helper');
         $user = JFactory::getUser($userid);
         // Note: in practice I'd use $user->gid here
         if (in_array($user->usertype, array("Super Administrator", "Administrator"))) {
             return true;
         } else {
             return false;
         }
     }
 }
コード例 #5
0
ファイル: nonewadmins.php プロジェクト: knigherrant/decopatio
 /**
  * Disables creating new admins or updating new ones
  */
 public function onAfterInitialise()
 {
     $input = $this->input;
     $option = $input->getCmd('option', '');
     $task = $input->getCmd('task', '');
     $gid = $input->getInt('gid', 0);
     if ($option != 'com_users' && $option != 'com_admin') {
         return;
     }
     $jform = $this->input->get('jform', array(), 'array');
     $allowedTasks = array('save', 'apply', 'user.apply', 'user.save', 'user.save2new', 'profile.apply', 'profile.save');
     if (!in_array($task, $allowedTasks)) {
         return;
     }
     // Not editing, just core devs using the same task throughout the component, dammit
     if (empty($jform)) {
         return;
     }
     $groups = array();
     if (isset($jform['groups'])) {
         $groups = $jform['groups'];
     }
     $user = JFactory::getUser((int) $jform['id']);
     // Sometimes $user->groups is null... let's be 100% sure that we loaded all the groups of the user
     if (empty($user->groups)) {
         $user->groups = JUserHelper::getUserGroups($user->id);
     }
     if (!empty($user->groups)) {
         foreach ($user->groups as $title => $gid) {
             if (!in_array($gid, $groups)) {
                 $groups[] = $gid;
             }
         }
     }
     $isAdmin = false;
     if (!empty($groups)) {
         foreach ($groups as $group) {
             // First try to see if the group has explicit backend login privileges
             $backend = JAccess::checkGroup($group, 'core.login.admin', 1);
             // If not, is it a Super Admin (ergo inherited privileges)?
             if (is_null($backend)) {
                 $backend = JAccess::checkGroup($group, 'core.admin', 1);
             }
             $isAdmin |= $backend;
         }
     }
     if ($isAdmin) {
         $jlang = JFactory::getLanguage();
         $jlang->load('joomla', JPATH_ROOT, 'en-GB', true);
         $jlang->load('joomla', JPATH_ROOT, $jlang->getDefault(), true);
         $jlang->load('joomla', JPATH_ROOT, null, true);
         if (version_compare(JVERSION, '3.0', 'ge')) {
             throw new Exception(JText::_('JGLOBAL_AUTH_ACCESS_DENIED'), '403');
         } else {
             JError::raiseError(403, JText::_('JGLOBAL_AUTH_ACCESS_DENIED'));
         }
     }
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: sansandeep143/av
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->params = $app->getParams();
     /* Default Page fallback*/
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
     }
     $this->currentItemid = $active->id;
     $this->catid = JRequest::getInt('catid', 0);
     if ($this->catid == 0) {
         $this->catid = 'root';
     }
     $options = array();
     $options['countItems'] = $this->params->get('show_items_per_category_count', 0);
     /**
      * @var JCategories $categories
      */
     $categories = JCategories::getInstance('Eventgallery', $options);
     /**
      * @var JCategoryNode $root
      */
     if (null != $this->catid) {
         $this->category = $categories->get($this->catid);
     }
     if ($this->category == null || $this->category->published != 1) {
         return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
     }
     $entriesPerPage = $this->params->get('max_events_per_page', 12);
     $model = $this->getModel('categories');
     $eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel');
     $user = JFactory::getUser();
     $usergroups = JUserHelper::getUserGroups($user->id);
     $entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->catid);
     $this->pageNav = $model->getPagination();
     $this->entries = $entries;
     $this->eventModel = $eventModel;
     $this->_prepareDocument();
     /**
      * @var JPathway $pathway
      */
     $pathway = $app->getPathway();
     $rootCategoryId = 0;
     if (isset($active->query['catid'])) {
         $rootCategoryId = $active->query['catid'];
     }
     EventgalleryHelpersCategories::addCategoryPathToPathway($pathway, $rootCategoryId, JRequest::getInt('catid', 0), $this->currentItemid);
     parent::display($tpl);
 }
コード例 #7
0
 function __construct($config, $sitemap)
 {
     jimport('joomla.utilities.date');
     jimport('joomla.user.helper');
     $user = JFactory::getUser();
     $groups = array_keys(JUserHelper::getUserGroups($user->get('id')));
     $date = new JDate();
     $this->userLevels = (array) $user->getAuthorisedViewLevels();
     // Deprecated: should use userLevels from now on
     // $this->gid	= $user->gid;
     $this->now = $date->toUnix();
     $this->config = $config;
     $this->sitemap = $sitemap;
     $this->isNews = false;
     $this->count = 0;
     $this->canEdit = false;
 }
コード例 #8
0
ファイル: defview.php プロジェクト: madcsaba/li-de
 /**
  * the user is admin?
  * @param JUser $user
  * @return boolean      
  */
 protected function isAdmin($user)
 {
     jimport('joomla.user.helper');
     $result = false;
     if ($user) {
         $groups = JUserHelper::getUserGroups($user->id);
         $admin_groups = array();
         //put all the groups that you consider to be admins
         $admin_groups[] = "Super Users";
         $admin_groups[] = "Administrator";
         foreach ($admin_groups as $temp) {
             if (!empty($groups[$temp])) {
                 $result = true;
             }
         }
     }
     return $result;
 }
コード例 #9
0
 function onUserAfterSave($user, $isnew, $success, $msg)
 {
     jimport('joomla.user.helper');
     //if 'latitude' key exists, event triggered from within JomSocial
     if (array_key_exists('latitude', $user)) {
         return;
     }
     $app = JFactory::getApplication();
     // Instantiate JomSocial
     require_once JPATH_ROOT . '/administrator/components/com_community/defines.php';
     require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
     // Get sync mappings
     $mappings = self::getJomSocialGroupSyncMappings();
     if (empty($mappings)) {
         return;
     }
     // create JomSocial objects needed to manage group members
     $group =& JTable::getInstance('Group', 'CTable');
     $model = CFactory::getModel('Groups');
     // create
     $data = new stdClass();
     $data->memberid = $user['id'];
     $data->approved = 1;
     $data->permissions = 0;
     //get the users ACL groups; retrieve using helper if not set in user object
     if (empty($user['groups'])) {
         $jUserGroups = JUserHelper::getUserGroups($user['id']);
     } else {
         $jUserGroups = $user['groups'];
     }
     // Cycle through mappings and add to/remove from JomSocial groups
     foreach ($mappings as $mapping) {
         $data->groupid = $mapping['jsgroup_id'];
         if (in_array($mapping['jgroup_id'], $jUserGroups)) {
             // Add user to group members table
             if (!$model->isMember($data->memberid, $data->groupid)) {
                 $addResult = $group->addMember($data);
             }
         } else {
             $model->removeMember($data);
         }
     }
     return;
 }
コード例 #10
0
ファイル: ajax.json.php プロジェクト: 01J/topm
 public function editElement()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     jimport('joomla.utilities.date');
     jimport('joomla.user.helper');
     $user = JFactory::getUser();
     $groups = array_keys(JUserHelper::getUserGroups($user->get('id')));
     $result = new JRegistry('_default');
     $sitemapId = JREquest::getInt('id');
     if (!$user->authorise('core.edit', 'com_xmap.sitemap.' . $sitemapId)) {
         $result->setValue('result', 'KO');
         $result->setValue('message', 'You are not authorized to perform this action!');
     } else {
         $model = $this->getModel('sitemap');
         if ($model->getItem()) {
             $action = JRequest::getCmd('action', '');
             $uid = JRequest::getCmd('uid', '');
             $itemid = JRequest::getInt('itemid', '');
             switch ($action) {
                 case 'toggleElement':
                     if ($uid && $itemid) {
                         $state = $model->toggleItem($uid, $itemid);
                     }
                     break;
                 case 'changeProperty':
                     $uid = JRequest::getCmd('uid', '');
                     $property = JRequest::getCmd('property', '');
                     $value = JRequest::getCmd('value', '');
                     if ($uid && $itemid && $uid && $property) {
                         $state = $model->chageItemPropery($uid, $itemid, 'xml', $property, $value);
                     }
                     break;
             }
         }
         $result->set('result', 'OK');
         $result->set('state', $state);
         $result->set('message', '');
     }
     echo $result->toString();
 }
コード例 #11
0
ファイル: edit.php プロジェクト: kevinwojo/hubzero-cms
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$user = User::getInstance();
$unknown = true;
$name = '';
$usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
$notify = array();
if ($this->row->get('login')) {
    if ($this->row->get('name')) {
        jimport('joomla.user.helper');
        $usertype = implode(', ', JUserHelper::getUserGroups($this->row->submitter()->get('id')));
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&task=edit&id=' . $this->row->submitter()->get('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = false;
        $notify[] = $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')';
    }
}
if (!$name) {
    if ($this->row->get('name')) {
        $name = $this->escape($this->row->get('name')) . ' (' . $this->escape($this->row->get('email')) . ')';
    } else {
        $name = $this->escape($this->row->get('email'));
    }
    $notify[] = $name;
}
if ($this->row->isOwned()) {
    if ($this->row->owner()->get('name')) {
コード例 #12
0
ファイル: socialconnect.php プロジェクト: juanferden/adoperp
 public function getAssignedGroups($userId = null)
 {
     $userId = !empty($userId) ? $userId : (int) $this->getState('socialconnect.id');
     if (empty($userId)) {
         $result = array();
         $config = JComponentHelper::getParams('com_users');
         if ($groupId = $config->get('new_usertype')) {
             $result[] = $groupId;
         }
     } else {
         $result = JUserHelper::getUserGroups($userId);
     }
     return $result;
 }
コード例 #13
0
ファイル: ticket.php プロジェクト: kevinwojo/hubzero-cms
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$this->css()->css('jquery.ui.css', 'system')->js('jquery.timepicker.js', 'system')->js();
$status = $this->row->status('text');
$unknown = 1;
//$name     = Lang::txt('COM_SUPPORT_UNKNOWN');
$usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
if ($this->row->get('login')) {
    $submitter = $this->row->submitter();
    if ($submitter->get('id')) {
        $usertype = implode(', ', \JUserHelper::getUserGroups($submitter->get('id')));
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&id=' . $submitter->get('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = 0;
    } else {
        $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">';
        $name .= $this->row->get('login') ? $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')' : $this->escape(stripslashes($this->row->get('name')));
        $name .= '</a>';
    }
} else {
    $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">' . $this->escape(stripslashes($this->row->get('name'))) . '</a>';
}
$prev = null;
$next = null;
$sq = new \Components\Support\Tables\Query($this->database);
$sq->load($this->filters['show']);
if ($sq->conditions) {
コード例 #14
0
 /**
  * Return the full user directory path. Create if required
  *
  * @param string  The base path
  * @access public
  * @return Full path to folder
  */
 public function getRootDir()
 {
     static $root;
     if (!isset($root)) {
         $user = JFactory::getUser();
         $wf = WFEditor::getInstance();
         $profile = $wf->getProfile();
         // Get base directory as shared parameter
         $root = $this->get('dir', '');
         // Remove whitespace
         $root = trim($root);
         if (!empty($root)) {
             // Convert slashes / Strip double slashes
             $root = preg_replace('/[\\\\]+/', '/', $root);
             // Remove first leading slash
             $root = ltrim($root, '/');
             // Force default directory if base param starts with a variable or a . eg $id
             if (preg_match('/[\\.\\$]/', $root[0])) {
                 $root = 'images';
             }
             jimport('joomla.user.helper');
             // Joomla! 1.6+
             if (method_exists('JUserHelper', 'getUserGroups')) {
                 $groups = JUserHelper::getUserGroups($user->id);
                 // get the first group
                 $group_id = array_shift(array_keys($groups));
                 // Joomla! 2.5?
                 if (is_int($group_id)) {
                     // usergroup table
                     $group = JTable::getInstance('Usergroup');
                     $group->load($group_id);
                     // usertype
                     $usertype = $group->title;
                 } else {
                     $usertype = $group_id;
                 }
             } else {
                 $usertype = $user->usertype;
             }
             // Replace any path variables
             $pattern = array('/\\$id/', '/\\$username/', '/\\$user(group|type)/', '/\\$(group|profile)/', '/\\$day/', '/\\$month/', '/\\$year/');
             $replace = array($user->id, $user->username, $usertype, $profile->name, date('d'), date('m'), date('Y'));
             $root = preg_replace($pattern, $replace, $root);
             // split into path parts to preserve /
             $parts = explode('/', $root);
             $textcase = $wf->getParam('editor.websafe_textcase');
             if (!empty($textcase)) {
                 $textcase = array_shift($textcase);
             }
             // clean path parts
             $parts = WFUtility::makeSafe($parts, $wf->getParam('editor.websafe_mode', 'utf-8'), $wf->getParam('editor.websafe_allow_spaces', 0), $textcase);
             //join path parts
             $root = implode('/', $parts);
         }
     }
     return $root;
 }
コード例 #15
0
ファイル: helper.php プロジェクト: adjaika/J3Base
 /**
  * Helper wrapper method for getUserGroups
  *
  * @param   integer  $userId  The id of the user.
  *
  * @return  array    List of groups
  *
  * @see     JUserHelper::addUserToGroup()
  * @since   3.4
  */
 public function getUserGroups($userId)
 {
     return JUserHelper::getUserGroups($userId);
 }
コード例 #16
0
ファイル: user.php プロジェクト: Caojunkai/working
 /**
  * Gets the groups this object is assigned to
  *
  * @param   integer  $userId  The user ID to retrieve the groups for
  *
  * @return  array  An array of assigned groups
  *
  * @since   1.6
  */
 public function getAssignedGroups($userId = null)
 {
     $userId = !empty($userId) ? $userId : (int) $this->getState('user.id');
     if (empty($userId)) {
         $result = array();
         $groupsIDs = $this->getForm()->getValue('groups');
         if (!empty($groupsIDs)) {
             $result = $groupsIDs;
         } else {
             $config = JComponentHelper::getParams('com_users');
             if ($groupId = $config->get('new_usertype')) {
                 $result[] = $groupId;
             }
         }
     } else {
         $result = JUserHelper::getUserGroups($userId);
     }
     return $result;
 }
コード例 #17
0
    $this->ticket = new \Components\Support\Models\Ticket($this->ticket);
}
$base = rtrim(Request::base(), '/');
if (substr($base, -13) == 'administrator') {
    $base = rtrim(substr($base, 0, strlen($base) - 13), '/');
    $sef = 'support/ticket/' . $this->ticket->get('id');
} else {
    $sef = Route::url($this->ticket->link());
}
$link = $base . '/' . trim($sef, '/');
$message = '';
if (!$this->config->get('email_terse')) {
    $usertype = Lang::txt('COM_SUPPORT_UNKNOWN');
    if ($this->ticket->submitter('id')) {
        jimport('joomla.user.helper');
        $usertype = implode(', ', \JUserHelper::getUserGroups($this->ticket->submitter('id')));
    }
    if ($this->delimiter) {
        $message .= $this->delimiter . "\n";
        $message .= Lang::txt('COM_SUPPORT_EMAIL_REPLY_ABOVE') . "\n";
        $message .= 'Message from ' . rtrim(Request::base(), '/') . '/support / Ticket #' . $this->ticket->get('id') . "\n";
    }
    $message .= '----------------------------' . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_TICKET')) . ': ' . $this->ticket->get('id') . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_TICKET_DETAILS_SUMMARY')) . ': ' . $this->ticket->get('summary') . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_TICKET_DETAILS_CREATED')) . ': ' . $this->ticket->get('created') . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_TICKET_DETAILS_CREATED_BY')) . ': ' . $this->ticket->submitter('name') . ($this->ticket->get('login') ? ' (' . $this->ticket->get('login') . ')' : '') . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_TICKET_DETAILS_USERTYPE')) . ': ' . $usertype . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_EMAIL')) . ': ' . $this->ticket->get('email') . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_IP_HOSTNAME')) . ': ' . $this->ticket->get('ip') . ' (' . $this->ticket->get('hostname') . ')' . "\n";
    $message .= strtoupper(Lang::txt('COM_SUPPORT_OS')) . ': ' . $this->ticket->get('os') . "\n";
コード例 #18
0
ファイル: JUserHelperTest.php プロジェクト: Rai-Ka/joomla-cms
 /**
  * TestingGetUserGroups().
  *
  * @param   integer  $userid    User ID
  * @param   mixed    $expected  User object or empty array if unknown
  * @param   array    $error     Expected error info
  *
  * @dataProvider casesGetUserGroups
  * @covers  JUserHelper::getUserGroups
  * @return  void
  */
 public function testGetUserGroups($userid, $expected, $error)
 {
     $this->assertEquals($expected, JUserHelper::getUserGroups($userid));
 }
コード例 #19
0
ファイル: trinity.php プロジェクト: Jougito/DynWeb
 protected function updateUser($userinfo)
 {
     $locked = 0;
     if (!empty($userinfo['block']) || !empty($userinfo['activation'])) {
         if ($userinfo['block'] == 1 || $userinfo['activation'] == 1) {
             $locked = 1;
         }
     }
     $password = sha1(strtoupper($userinfo['username']) . ':' . strtoupper($userinfo['password_clear']));
     $sql = "UPDATE " . $this->dbaccount . ".account SET email='" . $userinfo['email'] . "', locked=" . $locked . ", sha_pass_hash='" . $password . "' WHERE UPPER(username)=UPPER('" . $userinfo['username'] . "')";
     $db = JTrinityCoreDBHelper::getDB();
     $db->setQuery($sql);
     if (!$db->query()) {
         JLog::add('Error updating account in trinity db. SQL= ' . $sql, JLog::ERROR, $this->logcat);
         return false;
     } else {
         // Get joomla user groups
         $jgroups = JUserHelper::getUserGroups($userinfo['id']);
         $dbo = JFactory::getDbo();
         $query = $dbo->getQuery(true);
         $query->select($dbo->quoteName('id') . ', ' . $dbo->quoteName('title'));
         $query->from($dbo->quoteName('#__usergroups'));
         $query->where($dbo->quoteName('id') . ' = ' . implode(' OR ' . $dbo->quoteName('id') . ' = ', $jgroups));
         $dbo->setQuery($query);
         $results = $dbo->loadObjectList();
         // Update account_access table
         $groups = JTrinityCoreDBHelper::getWowGroups();
         $gmlevel = 0;
         foreach ($groups as $v) {
             foreach ($results as $g) {
                 if (strtoupper($g->title) == strtoupper($v['name'])) {
                     $gmlevel = $v['id'];
                 }
             }
         }
         $sql = "UPDATE " . $this->dbaccount . ".account_access SET gmlevel=" . $gmlevel;
         $db->setQuery($sql);
         if (!$db->query()) {
             JLog::add('Error updating account_access in trinity db. SQL= ' . $sql, JLog::ERROR, $this->logcat);
             return false;
         }
     }
     return true;
 }
コード例 #20
0
 /**
  * Return the full user directory path. Create if required
  *
  * @param string  The base path
  * @access public
  * @return Full path to folder
  */
 function getRootDir()
 {
     static $root;
     if (!$root) {
         $user = JFactory::getUser();
         $wf = WFEditorPlugin::getInstance();
         $profile = $wf->getProfile();
         // Get base directory as shared parameter
         $root = $this->get('dir', 'images');
         // Remove whitespace
         $root = trim($root);
         // Convert slashes / Strip double slashes
         $root = preg_replace('/[\\\\]+/', '/', $root);
         // Remove first leading slash
         $root = ltrim($root, '/');
         // Force default directory if base param starts with a variable or a . eg $id
         if (preg_match('/[\\.\\$]/', $root[0])) {
             $root = 'images';
         }
         jimport('joomla.user.helper');
         // Joomla! 1.6+
         if (method_exists('JUserHelper', 'getUserGroups')) {
             $groups = JUserHelper::getUserGroups($user->id);
             $usertype = array_shift(array_keys($groups));
         } else {
             $usertype = $user->usertype;
         }
         // Replace any path variables
         $pattern = array('/\\$id/', '/\\$username/', '/\\$usertype/', '/\\$(group|profile)/', '/\\$day/', '/\\$month/', '/\\$year/');
         $replace = array($user->id, strtolower($user->username), strtolower($usertype), strtolower($profile->name), date('d'), date('m'), date('Y'));
         $root = preg_replace($pattern, $replace, $root);
         // Clean
         $root = preg_replace(array('/$\\w+\\b/', '/(\\.) {2,}/', '/[^A-Za-z0-9:\\.\\_\\-\\/]/'), '', $root);
     }
     return $root;
 }
コード例 #21
0
ファイル: filespro.php プロジェクト: knigherrant/decopatio
 public function getDirectory($allowroot = false, $item = false)
 {
     if (!$this->_directory) {
         $user = JFactory::getUser();
         $item = $item ? $item : $this->getItem();
         // Get base directory as shared parameter
         $root = $this->config->find('files._source_dir', $this->_joomla_file_path);
         // if item is new and the path is using dynamic yet unknown vars, return temporal path
         $pattern = '/\\[zooprimarycat\\]|\\[zooprimarycatid\\]|\\[zooitemid\\]|\\[zooitemalias\\]/';
         if (!$item->id && preg_match($pattern, $root)) {
             return 'tmp/zl_' . $this->identifier . '_' . $this->getUniqid();
         }
         // Restricted Joomla! folders
         $restricted = explode(',', 'administrator,cache,components,includes,language,libraries,logs,media,modules,plugins,templates,xmlrpc');
         // Remove whitespace
         $root = trim($root);
         // Convert slashes / Strip double slashes
         $root = preg_replace('/[\\\\]+/', '/', $root);
         // Remove first leading slash
         $root = ltrim($root, '/');
         // Split in parts to better manage
         $parts = explode('/', $root);
         // abort if path starts with a variable, a . or is empty
         if (preg_match('/[\\.\\[]/', $parts[0]) || empty($root) && !$allowroot) {
             return false;
         }
         // abort if path not allowed
         if (!$allowroot && in_array(strtolower($parts[0]), $restricted)) {
             return false;
         }
         // join back
         $root = implode('/', $parts);
         // set path variables
         jimport('joomla.user.helper');
         // user
         $groups = JUserHelper::getUserGroups($user->id);
         $groups = array_keys($groups);
         // get the first group
         $usergroupid = array_shift($groups);
         // usergroup table
         $group = JTable::getInstance('Usergroup', 'JTable');
         $group->load($usergroupid);
         // usertype
         $usergroup = $group->title;
         // author
         $author = $this->app->user->get($item->created_by);
         $author = $author ? $author : $user;
         // if no author set use current user
         $groups = JUserHelper::getUserGroups($author->id);
         $groups = array_keys($groups);
         // get the first group
         $authorgroupid = array_shift($groups);
         // usergroup table
         $group = JTable::getInstance('Usergroup', 'JTable');
         $group->load($authorgroupid);
         // usertype
         $authorgroup = $group->title;
         // zoo
         $zooapp = strtolower($item->getApplication()->name);
         $zooprimarycat = $item->getPrimaryCategory() ? $item->getPrimaryCategory()->alias : 'none';
         $zooprimarycatid = $item->getPrimaryCategoryId();
         // Replace variables
         $pattern = array('/\\[userid\\]/', '/\\[username\\]/', '/\\[usergroup\\]/', '/\\[usergroupid\\]/', '/\\[authorid\\]/', '/\\[authorname\\]/', '/\\[authorgroup\\]/', '/\\[authorgroupid\\]/', '/\\[zooapp\\]/', '/\\[zooprimarycat\\]/', '/\\[zooprimarycatid\\]/', '/\\[zooitemtype\\]/', '/\\[zooitemid\\]/', '/\\[zooitemalias\\]/', '/\\[day\\]/', '/\\[month\\]/', '/\\[year\\]/');
         $replace = array($user->id, $user->username, $usergroup, $usergroupid, $author->id, $author->username, $authorgroup, $authorgroupid, $zooapp, $zooprimarycat, $zooprimarycatid, $item->type, $item->id, $item->alias, date('d'), date('m'), date('Y'));
         $root = preg_replace($pattern, $replace, $root);
         // split into path parts to preserve /
         $parts = explode('/', $root);
         // clean path parts
         $parts = $this->app->zlfw->filesystem->makeSafe($parts, 'ascii');
         // join path parts
         $root = implode('/', $parts);
         // return the result
         $this->_directory = $root;
     }
     return $this->_directory;
 }
コード例 #22
0
ファイル: users.php プロジェクト: proyectoseb/University
 function remove()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     if (empty($cid)) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_PROFILE_NO_USER'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $users = KunenaUserHelper::loadUsers($cid);
     $my = JFactory::getUser();
     $usernames = array();
     foreach ($users as $user) {
         $groups = JUserHelper::getUserGroups($user->userid);
         if ($my->id == $user->userid) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_USER_ERROR_CANNOT_DELETE_YOURSELF'), 'notice');
             continue;
         }
         $instance = JUser::getInstance($user->userid);
         if ($instance->authorise('core.admin')) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_USER_ERROR_CANNOT_DELETE_ADMINS'), 'notice');
             continue;
         }
         $result = $user->delete();
         if (!$result) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_USER_DELETE_KUNENA_USER_TABLE_FAILED', $user->userid), 'notice');
             continue;
         }
         // Delete the user too from Joomla!
         $jresult = $instance->delete();
         if (!$jresult) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_USER_DELETE_JOOMLA_USER_TABLE_FAILED', $user->userid), 'notice');
             continue;
         }
         $usernames[] = $user->username;
     }
     if (!empty($usernames)) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_USER_DELETE_DONE_SUCCESSFULLY', implode(', ', $usernames)));
     }
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
コード例 #23
0
 /**
  * TestingGetUserGroups().
  *
  * @param   integer  $userid    User ID
  * @param   mixed    $expected  User object or empty array if unknown
  * @param   array    $error     Expected error info
  *
  * @dataProvider casesGetUserGroups
  * @covers  JUserHelper::getUserGroups
  * @return  void
  */
 public function testGetUserGroups($userid, $expected, $error)
 {
     $this->assertThat(JUserHelper::getUserGroups($userid), $this->equalTo($expected));
 }
コード例 #24
0
ファイル: path.php プロジェクト: knigherrant/decopatio
 public function getDirectory($root, $allowroot = false)
 {
     $user = JFactory::getUser();
     // Restricted Joomla! folders
     $restricted = explode(',', 'administrator,cache,components,includes,language,libraries,logs,media,modules,plugins,templates,xmlrpc');
     // Remove whitespace
     $root = trim($root);
     // Convert slashes / Strip double slashes
     $root = preg_replace('/[\\\\]+/', '/', $root);
     // Remove first leading slash
     $root = ltrim($root, '/');
     // Split in parts to better manage
     $parts = explode('/', $root);
     // abort if path starts with a variable, a . or is empty
     if (preg_match('/[\\.\\[]/', $parts[0]) || empty($root) && !$allowroot) {
         return false;
     }
     // abort if path not allowed
     if (!$allowroot && in_array(strtolower($parts[0]), $restricted)) {
         return false;
     }
     // join back
     $root = implode('/', $parts);
     // set path variables
     jimport('joomla.user.helper');
     // user
     $groups = JUserHelper::getUserGroups($user->id);
     $groups = array_keys($groups);
     // get the first group
     $usergroupid = array_shift($groups);
     // usergroup table
     $group = JTable::getInstance('Usergroup', 'JTable');
     $group->load($usergroupid);
     // usertype
     $usergroup = $group->title;
     // Replace any path variables
     $pattern = array('/\\[userid\\]/', '/\\[username\\]/', '/\\[usergroup\\]/', '/\\[usergroupid\\]/', '/\\[day\\]/', '/\\[month\\]/', '/\\[year\\]/');
     $replace = array($user->id, $user->username, $usergroup, $usergroupid, date('d'), date('m'), date('Y'));
     $root = preg_replace($pattern, $replace, $root);
     // split into path parts to preserve /
     $parts = explode('/', $root);
     // clean path parts
     $parts = $this->app->zlfw->filesystem->makeSafe($parts, 'utf-8');
     // join path parts
     $root = implode('/', $parts);
     return $root;
 }
コード例 #25
0
ファイル: user.php プロジェクト: kosmosby/medicine-prof
	/**
	 * Gets the groups this object is assigned to
	 *
	 * @return	array
	 * @since	1.6
	 */
	public function getAssignedGroups($userId = null)
	{
		// Initialise variables.
		$userId = (!empty($userId)) ? $userId : (int)$this->getState('user.id');

		if (empty($userId)) {
			$result = array();
			$config = JComponentHelper::getParams('com_users');
			if ($groupId = $config->get('new_usertype')) {
				$result[] = $groupId;
			}
		}
		else {
			jimport('joomla.user.helper');
			$result = JUserHelper::getUserGroups($userId);
		}

		return $result;
	}
コード例 #26
0
 /**
  * Utility method to act on a user after it has been saved.
  *
  * @param   array    $user     Holds the new user data.
  * @param   boolean  $isnew    True if a new user is stored.
  * @param   boolean  $success  True if user was succesfully stored in the database.
  * @param   string   $msg      Message.
  * @return  void
  */
 public function onUserAfterSave($user, $isnew, $success, $msg)
 {
     $userId = \Hubzero\Utility\Arr::getValue($user, 'id', 0, 'int');
     if ($userId && $success) {
         try {
             $gids = JUserHelper::getUserGroups($userId);
             $db = App::get('db');
             //
             // Quota class
             //
             require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'quotas_classes.php';
             require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php';
             $row = new \Components\Members\Tables\UsersQuotas($db);
             // Check for an existing quota record
             $db->setQuery("SELECT * FROM `#__users_quotas` WHERE `user_id`=" . $userId);
             if ($quota = $db->loadObject()) {
                 $row->bind($quota);
             } else {
                 $row->user_id = $userId;
             }
             // If (no quota record OR a record and a quota class [e.g., not custom]) ...
             if (!$row->id || $row->id && $row->class_id) {
                 $val = array('hard_files' => 0, 'soft_files' => 0, 'hard_blocks' => 0, 'soft_blocks' => 0);
                 $db->setQuery("SELECT c.* FROM `#__users_quotas_classes` AS c LEFT JOIN `#__users_quotas_classes_groups` AS g ON g.`class_id`=c.`id` WHERE g.`group_id` IN (" . implode(',', $gids) . ")");
                 $cids = $db->loadObjectList();
                 if (count($cids) <= 0) {
                     $db->setQuery("SELECT c.* FROM `#__users_quotas_classes` AS c WHERE c.`alias`=" . $db->quote('default'));
                     $cids = $db->loadObjectList();
                 }
                 // Loop through each usergroup and find the highest quota values
                 foreach ($cids as $cls) {
                     $cls->hard_blocks = intval($cls->hard_blocks);
                     $cls->soft_blocks = intval($cls->soft_blocks);
                     if ($cls->hard_blocks > $val['hard_blocks'] && $cls->soft_blocks > $val['soft_blocks']) {
                         $row->class_id = $cls->id;
                     }
                     //$val['hard_files']  = ($val['hard_files']  > $cls->hard_files  ?: $cls->hard_files);
                     //$val['soft_files']  = ($val['soft_files']  > $cls->soft_files  ?: $cls->soft_files);
                     $val['hard_blocks'] = $val['hard_blocks'] > $cls->hard_blocks ? $val['hard_blocks'] : $cls->hard_blocks;
                     $val['soft_blocks'] = $val['soft_blocks'] > $cls->soft_blocks ? $val['soft_blocks'] : $cls->soft_blocks;
                 }
                 $row->hard_files = $val['hard_files'];
                 $row->soft_files = $val['soft_files'];
                 $row->hard_blocks = $val['hard_blocks'];
                 $row->soft_blocks = $val['soft_blocks'];
                 if (!$row->check()) {
                     throw new Exception($row->getError());
                 }
                 if (!$row->store()) {
                     throw new Exception($row->getError());
                 }
             }
             //
             // Session limits
             //
             require_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'tables' . DS . 'sessionclass.php';
             require_once PATH_CORE . DS . 'components' . DS . 'com_tools' . DS . 'tables' . DS . 'preferences.php';
             $row = new \Components\Tools\Tables\Preferences($db);
             // Check for an existing quota record
             $db->setQuery("SELECT * FROM `#__users_tool_preferences` WHERE `user_id`=" . $userId);
             if ($quota = $db->loadObject()) {
                 $row->bind($quota);
             } else {
                 $row->user_id = $userId;
             }
             // If (no quota record OR a record and a quota class [e.g., not custom]) ...
             if (!$row->id || $row->id && $row->class_id) {
                 $val = array('jobs' => 0);
                 $db->setQuery("SELECT c.* FROM `#__tool_session_classes` AS c LEFT JOIN `#__tool_session_class_groups` AS g ON g.`class_id`=c.`id` WHERE g.`group_id` IN (" . implode(',', $gids) . ")");
                 $cids = $db->loadObjectList();
                 if (count($cids) <= 0) {
                     $db->setQuery("SELECT c.* FROM `#__tool_session_classes` AS c WHERE c.`alias`=" . $db->quote('default'));
                     $cids = $db->loadObjectList();
                 }
                 // Loop through each usergroup and find the highest 'jobs allowed' value
                 foreach ($cids as $cls) {
                 }
                 $cls->jobs = intval($cls->jobs);
                 if ($cls->jobs > $val['jobs']) {
                     $row->class_id = $cls->id;
                 }
                 $val['jobs'] = $val['jobs'] > $cls->jobs ? $val['jobs'] : $cls->jobs;
                 $row->jobs = $val['jobs'];
                 if (!$row->check()) {
                     throw new Exception($row->getError());
                 }
                 if (!$row->store()) {
                     throw new Exception($row->getError());
                 }
             }
         } catch (Exception $e) {
             $this->_subject->setError($e->getMessage());
             return false;
         }
     }
     return true;
 }
コード例 #27
0
ファイル: user.php プロジェクト: rich20/Kunena
	protected function saveUser()
	{
		$app = JFactory::getApplication();
		$user = $this->user; //new JUser ( $this->user->get('id') );

		// we don't want users to edit certain fields so we will ignore them
		$ignore = array('id', 'gid', 'block', 'usertype', 'registerDate', 'activation');

		//clean request
		$post = JRequest::get( 'post' );
		$post['password']	= JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
		$post['password2']	= JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
		if (empty($post['password']) || empty($post['password2'])) {
			unset($post['password'], $post['password2']);
		}
		if ($this->config->usernamechange) $post['username'] = JRequest::getVar('username', '', 'post', 'username');
		else $ignore[] = 'username';
		foreach ($ignore as $field) {
			if (isset($post[$field]))
				unset($post[$field]);
		}

		jimport ( 'joomla.version' );
		$jversion = new JVersion ();
		if ( $jversion->RELEASE == '1.6' ) {
			jimport('joomla.user.helper');
			$result = JUserHelper::getUserGroups($user->id);

			$groups = array();
			foreach ( $result as $key => $value ) {
				$groups[]= $key;
			}

			$post['groups'] = $groups;
		}

		// get the redirect
		$return = CKunenaLink::GetMyProfileURL($user->id, '', false);
		$err_return = CKunenaLink::GetMyProfileURL($user->id, 'edit', false);

		// do a password safety check
		if ( !empty($post['password']) && !empty($post['password2']) ) {
			if(strlen($post['password']) < 5 && strlen($post['password2']) < 5 ) {
				if($post['password'] != $post['password2']) {
					$msg = JText::_('COM_KUNENA_PROFILE_PASSWORD_MISMATCH');
					$app->redirect ( $err_return, $msg, 'error' );
				}
				$msg = JText::_('COM_KUNENA_PROFILE_PASSWORD_NOT_MINIMUM');
				$app->redirect ( $err_return, $msg, 'error' );
			}
		}

		$username = $this->user->username;

		// Bind the form fields to the user table
		if (!$user->bind($post)) {
			$app->enqueueMessage ( $user->getError(), 'error' );
			return false;
		}

		// Store user to the database
		if (!$user->save(true)) {
			$app->enqueueMessage ( $user->getError(), 'error' );
			return false;
		}

		$session = JFactory::getSession();
		$session->set('user', $user);

		// update session if username has been changed
		if ( $username && $username != $user->username )
		{
			$table = JTable::getInstance('session', 'JTable' );
			$table->load($session->getId());
			$table->username = $user->username;
			$table->store();
		}
	}
コード例 #28
0
ファイル: helper.php プロジェクト: madcsaba/li-de
 /**
  * Test to see if user can add events from the front end
  *
  * @return boolean
  */
 public static function isEventCreator()
 {
     static $isEventCreator;
     if (!isset($isEventCreator)) {
         //+ 2li-de integráció 015.04.02 FT.
         /* li-de integráció
         			$isEventCreator = false;
         			$user = JEVHelper::getAuthorisedUser();
         			if (is_null($user))
         			{
         				$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         				$authorisedonly = $params->get("authorisedonly", 0);
         				if (!$authorisedonly)
         				{
         					$juser = JFactory::getUser();
         					$isEventCreator = $juser->authorise('core.create', 'com_jevents');
         					// this is too heavy on database queries - keep this in the file so that sites that want to use this approach can uncomment this block
         					if (false)
         					{
         						if (!$isEventCreator)
         						{
         							$cats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
         							if (count($cats) > 0)
         							{
         								$isEventCreator = true;
         							}
         						}
         					}
         					else
         					{
         						if ($isEventCreator)
         						{
         							$okcats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
         							if (count($okcats) > 0)
         							{
         								$juser = JFactory::getUser();
         								$dataModel = new JEventsDataModel();
         								$dataModel->setupComponentCatids();
         
         								$allowedcats = explode(",", $dataModel->accessibleCategoryList());
         								$intersect = array_intersect($okcats, $allowedcats);
         
         								if (count($intersect) == 0)
         								{
         									$isEventCreator = false;
         								}
         							}
         							else
         							{
         								$isEventCreator = false;
         							}
         						}
         					}
         				}
         			}
         			else if ($user->cancreate)
         			{
         				// Check maxevent count
         				if ($user->eventslimit > 0)
         				{
         					$db = JFactory::getDBO();
         					$db->setQuery("SELECT count(*) FROM #__jevents_vevent where created_by=" . $user->user_id);
         					$eventcount = intval($db->loadResult());
         					if ($eventcount < $user->eventslimit)
         					{
         						$isEventCreator = true;
         					}
         					else
         					{
         						$isEventCreator = false;
         					}
         				}
         				else
         				{
         					$isEventCreator = true;
         				}
         				// are we blocked by category or calendar constraints
         				if ($isEventCreator && $user->categories != "" && $user->categories != "all")
         				{
         					$okcats = explode("|", $user->categories);
         
         					$juser = JFactory::getUser();
         					$dataModel = new JEventsDataModel();
         					$dataModel->setupComponentCatids();
         
         					$allowedcats = explode(",", $dataModel->accessibleCategoryList());
         					$intersect = array_intersect($okcats, $allowedcats);
         
         					if (count($intersect) == 0)
         					{
         						$isEventCreator = false;
         					}
         				}
         			}
         
         			JPluginHelper::importPlugin("jevents");
         			$dispatcher = JDispatcher::getInstance();
         			$dispatcher->trigger('isEventCreator', array(& $isEventCreator));
                     $isEventCreator = fallback;
                     */
         // li-de integráció JRequest::getVar('catids') --> #__categories record
         //       ennek alias adata "t###"  --> temakor_id
         //       user->id + temakor_id + #__tagok recod --> $isEventCreator
         $isEventCreator = false;
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $db->setQuery('select alias 
         from #__categories 
         where id="' . JRequest::getVar('catids') . '"');
         $categoryRec = $db->loadObject();
         if ($categoryRec) {
             $temakor_id = substr($categoryRec->alias, 1, 20);
             $db->setQuery('select * 
             from #__tagok 
             where temakor_id="' . $temakor_id . '" and user_id="' . $user->id . '"');
             $tagokRec = $db->loadObject();
             if ($tagokRec) {
                 if ($tagokRec->admin == 1) {
                     $isEventCreator = true;
                 }
             }
         }
         // sadmin userek is felvihetnek eseményeket
         if ($isEventCreator == false) {
             $groups = JUserHelper::getUserGroups($user->id);
             $admin_groups = array();
             //put all the groups that you consider to be admins
             $admin_groups[] = "Super Users";
             $admin_groups[] = "Administrator";
             $admin_groups[] = "Manager";
             $admin_groups[] = "8";
             $admin_groups[] = "7";
             $admin_groups[] = "6";
             foreach ($admin_groups as $temp) {
                 if (!empty($groups[$temp])) {
                     $isEventCreator = true;
                 }
             }
         }
     }
     //- li-de integráció
     return $isEventCreator;
 }
コード例 #29
0
/templates/z20/js/swfobject.js"></script>
        <script type="text/javascript" src="<?php 
echo $this->baseurl;
?>
/templates/z20/js/zonales.js"></script>
        <script language="javascript" type="text/javascript" src="components/com_zonales/utils.js"></script>
        <script language="javascript" type="text/javascript" src="components/com_zonales/solr.js"></script>
        <script language="javascript" type="text/javascript" src="components/com_zonales/vistas.js"></script>
        <script language="javascript" type="text/javascript" src="components/com_zonales/ZContext.js"></script>
        <script language="javascript" type="text/javascript" src="http://<?php 
echo gethostbyname('g2p2-node');
?>
:4000/socket.io/socket.io.js"></script>
        <script language="javascript" type="text/javascript">
            var loguedUser = ['<?php 
echo implode("','", JUserHelper::getUserGroups(JFactory::getUser()->get('id')));
?>
'];
        </script>
    </head>

    <body>

        <div id="wrapper-web">

            <div id="topBar">
                <jdoc:include type="modules" name="header"/>
            </div><!-- #topBar -->
            <form name="ver_portada" action="/" method="post" style="display:none">
                <input type="hidden" name="task" value="clearZonal" />
                <input type="hidden" name="option" value="com_zonales" />
コード例 #30
0
ファイル: helper.php プロジェクト: q0821/esportshop
 public static function checkChangeLevel($referrerid, $newtotal)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $ok = 0;
     $lang = JFactory::getLanguage();
     $lang->load('com_alphauserpoints', JPATH_SITE);
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'tables');
     $resultChangeLevel1 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel1', 0, $referrerid);
     $resultChangeLevel2 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel2', 0, $referrerid);
     $resultChangeLevel3 = AlphaUserPointsHelper::checkRuleEnabled('sysplgaup_changelevel3', 0, $referrerid);
     if ($resultChangeLevel1) {
         $checkAlreadyDone1 = explode(',', $resultChangeLevel1[0]->exclude_items);
     }
     if ($resultChangeLevel2) {
         $checkAlreadyDone2 = explode(',', $resultChangeLevel2[0]->exclude_items);
     }
     if ($resultChangeLevel3) {
         $checkAlreadyDone3 = explode(',', $resultChangeLevel3[0]->exclude_items);
     }
     $userid = AlphaUserPointsHelper::getUserID($referrerid);
     // get actual group fot this user
     jimport('joomla.user.helper');
     $authorizedLevels = JAccess::getAuthorisedViewLevels($userid);
     $result = array_keys(JUserHelper::getUserGroups($userid));
     $actualgroup = end($result);
     if ($resultChangeLevel1 && $newtotal >= $resultChangeLevel1[0]->points2 && !in_array(intval($resultChangeLevel1[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone1)) {
         // delete old group
         $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'";
         $db->setQuery($query);
         $db->query();
         JUserHelper::addUserToGroup($userid, intval($resultChangeLevel1[0]->content_items));
         $user = JUser::getInstance((int) $userid);
         $ok = 1;
         $resultChangeLevel = $resultChangeLevel1;
         $result = JUserHelper::getUserGroups($userid);
         $actualnamegroup = end($result);
         // insert done for this user in this rule
         if ($resultChangeLevel1[0]->exclude_items != '') {
             $insertUserId = $resultChangeLevel1[0]->exclude_items . ',' . $userid;
         } else {
             $insertUserId = $userid;
         }
         $row = JTable::getInstance('rules');
         $row->load(intval($resultChangeLevel1[0]->id));
         $row->exclude_items = $insertUserId;
         $db->updateObject('#__alpha_userpoints_rules', $row, 'id');
     }
     if ($resultChangeLevel2 && $newtotal >= $resultChangeLevel2[0]->points2 && !in_array(intval($resultChangeLevel2[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone2)) {
         $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'";
         $db->setQuery($query);
         $db->query();
         JUserHelper::addUserToGroup($userid, intval($resultChangeLevel2[0]->content_items));
         $user = JUser::getInstance((int) $userid);
         $ok = 1;
         $resultChangeLevel = $resultChangeLevel2;
         $result = JUserHelper::getUserGroups($userid);
         $actualnamegroup = end($result);
         $row = JTable::getInstance('rules');
         $row->load(intval($resultChangeLevel2[0]->id));
         $row->exclude_items = $insertUserId;
         $db->updateObject('#__alpha_userpoints_rules', $row, 'id');
     }
     if ($resultChangeLevel3 && $newtotal >= $resultChangeLevel3[0]->points2 && !in_array(intval($resultChangeLevel3[0]->content_items), $authorizedLevels) && !in_array($userid, $checkAlreadyDone3)) {
         $query = "DELETE FROM `#__user_usergroup_map` WHERE `user_id`='{$userid}'";
         $db->setQuery($query);
         $db->query();
         JUserHelper::addUserToGroup($userid, intval($resultChangeLevel3[0]->content_items));
         $user = JUser::getInstance((int) $userid);
         $ok = 1;
         $resultChangeLevel = $resultChangeLevel3;
         $result = JUserHelper::getUserGroups($userid);
         $actualnamegroup = end($result);
         $row = JTable::getInstance('rules');
         $row->load(intval($resultChangeLevel3[0]->id));
         $row->exclude_items = $insertUserId;
         $db->updateObject('#__alpha_userpoints_rules', $row, 'id');
     }
     if ($ok) {
         // refresh session if user online
         $temp = JFactory::getUser((int) $userid);
         $temp->groups = $user->groups;
         $temp = JFactory::getUser((int) $userid);
         if ($temp->id == $userid) {
             $temp->groups = $user->groups;
         }
     }
     // show message only for current user and if frontend site
     if ($referrerid == @$_SESSION['referrerid'] && $app->isSite() && $ok) {
         // display message for the current user
         if ($resultChangeLevel[0]->displaymsg && $resultChangeLevel[0]->msg != '') {
             $msg = str_replace('{username}', $user->username, $resultChangeLevel[0]->msg);
             $msg = str_replace('{points}', AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points), $msg);
             $msg = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $msg);
             AlphaUserPointsHelper::displayMessageSystem($msg);
         } elseif ($resultChangeLevel[0]->displaymsg && $resultChangeLevel[0]->msg == '') {
             AlphaUserPointsHelper::displayMessageSystem(sprintf(JText::_('AUP_MSG_YOUHAVENEWUSERRIGHTS'), AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points2), $actualnamegroup));
         }
     }
     if ($ok) {
         // insert this new activity in database
         $datareference = sprintf(JText::_('AUP_DESCRIPTIONACTIVITYONCHANGELEVEL'), AlphaUserPointsHelper::getFPoints($resultChangeLevel[0]->points2), $actualnamegroup);
         //AlphaUserPointsHelper::insertUserPoints( $referrerid, $resultChangeLevel[0], 0, '', $datareference );
         //Send notification
         if ($resultChangeLevel[0]->notification) {
             AlphaUserPointsHelper::sendnotification($referrerid, $resultChangeLevel[0]->points2, $newtotal, $resultChangeLevel[0]);
             // load external plugins
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('alphauserpoints');
             $rule_name = JText::_($resultChangeLevel[0]->rule_name);
             $results = $dispatcher->trigger('onSendNotificationAlphaUserPoints', array(&$resultChangeLevel[0], $rule_name, $resultChangeLevel[0]->points2, $newtotal, $referrerid, $userid));
         }
         // load external plugins
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('alphauserpoints');
         $results = $dispatcher->trigger('onChangeLevelAlphaUserPoints', array(&$resultChangeLevel[0], $actualnamegroup, $userid, $referrerid));
     }
 }