Пример #1
0
 public static function set_public_user()
 {
     $p_gs = self::get_public_groups();
     $infos = \GCore\Admin\Models\Group::getInstance()->find('list', array('fields' => array('Group.id', 'Group.path'), 'conditions' => array('Group.id' => $p_gs)));
     $d_inh = array();
     foreach ($infos as $info) {
         $d_inh = $d_inh + explode('.', $info);
     }
     $inheritance = array_values(array_filter(array_unique($d_inh)));
     $user = array('id' => 0, 'logged_in' => 0, 'guest' => 1, 'groups' => $p_gs, 'inheritance' => $inheritance);
     $session = Base::getSession();
     $session->set('user', $user);
     return $user;
 }
Пример #2
0
 public static function config()
 {
     //permissions groups
     $groups = \GCore\Admin\Models\Group::getInstance()->find('flat');
     $rules = array();
     foreach ($groups as $k => $group) {
         $rules[$group['Group']['id']] = $group['Group']['title'];
     }
     $rules['owner'] = 'Owner';
     echo \GCore\Helpers\Html::formStart('action_config authenticator_action_config', 'authenticator_action_config_{N}');
     echo \GCore\Helpers\Html::formSecStart();
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][owner_id_index]', array('type' => 'text', 'label' => l_('CF_OWNER_ID_INDEX'), 'default' => '', 'sublabel' => l_('CF_OWNER_ID_INDEX_DESC')));
     foreach ($rules as $g_id => $g_name) {
         echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][access][' . $g_id . ']', array('type' => 'dropdown', 'label' => $g_name, 'class' => 'M', 'options' => array(0 => l_('INHERITED'), '' => l_('NOT_SET'), 1 => l_('ALLOWED'), -1 => l_('DENIED'))));
     }
     echo \GCore\Helpers\Html::formSecEnd();
     echo \GCore\Helpers\Html::formEnd();
 }
Пример #3
0
 public static function config()
 {
     //permissions groups
     $groups = \GCore\Admin\Models\Group::getInstance()->find('flat');
     $rules = array();
     foreach ($groups as $k => $group) {
         $rules[$group['Group']['id']] = $group['Group']['title'];
     }
     echo \GCore\Helpers\Html::formStart('action_config check_captcha_action_config', 'check_captcha_action_config_{N}');
     echo \GCore\Helpers\Html::formSecStart();
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][name]', array('type' => 'text', 'label' => l_('CF_JOOMLA_REG_NAME'), 'class' => 'M', 'sublabel' => l_('CF_JOOMLA_REG_NAME_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][username]', array('type' => 'text', 'label' => l_('CF_JOOMLA_REG_USERNAME'), 'class' => 'M', 'sublabel' => l_('CF_JOOMLA_REG_USERNAME_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][email]', array('type' => 'text', 'label' => l_('CF_JOOMLA_REG_EMAIL'), 'class' => 'M', 'sublabel' => l_('CF_JOOMLA_REG_EMAIL_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][password]', array('type' => 'text', 'label' => l_('CF_JOOMLA_REG_PASSWORD'), 'class' => 'M', 'sublabel' => l_('CF_JOOMLA_REG_PASSWORD_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][password2]', array('type' => 'text', 'label' => l_('CF_JOOMLA_REG_CONFIRM_PASSWORD'), 'class' => 'M', 'sublabel' => l_('CF_JOOMLA_REG_CONFIRM_PASSWORD_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][new_usertype][]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_USER_GROUPS'), 'multiple' => 'multiple', 'size' => 7, 'options' => $rules, 'sublabel' => l_('CF_JOOMLA_REG_USER_GROUPS_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][useractivation]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_USER_ACTIVATION'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_JOOMLA_REG_USER_ACTIVATION_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][random_password]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_RANDOM_PASS'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_JOOMLA_REG_RANDOM_PASS_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][auto_login]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_AUTO_LOGIN'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_JOOMLA_REG_AUTO_LOGIN_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][send_joo_activation]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_SEND_JOO_ACTIVATION'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_JOOMLA_REG_SEND_JOO_ACTIVATION_DESC')));
     echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][enable_cb_support]', array('type' => 'dropdown', 'label' => l_('CF_JOOMLA_REG_ENABLE_CB_SUPPORT'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_JOOMLA_REG_ENABLE_CB_SUPPORT_DESC')));
     echo \GCore\Helpers\Html::formSecEnd();
     echo \GCore\Helpers\Html::formEnd();
 }
Пример #4
0
 function dispatch($content_only = false)
 {
     Event::trigger('on_before_dispatch', $this);
     $session = Base::getSession();
     reset:
     //if no action set, set it to index
     if (strlen(trim($this->action)) == 0) {
         $this->action = 'index';
     }
     //set admin path
     $site = '';
     if ($this->site == 'admin') {
         $site = '\\Admin';
     }
     //load the extension class
     $controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
     $extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
     $classname = '\\GCore' . $site . $extension . $controller;
     $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
     //set referer
     if (!$content_only) {
         if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
             //$session->set('_referer', Url::current());
         } else {
             //$session->set('_referer', 'index.php');
         }
     }
     $G_User = $session->get('user', array());
     //check permissions
     $J_User = \JFactory::getUser();
     if (empty($J_User->groups) or empty($G_User['groups']) or array_values($J_User->groups) !== $G_User['groups'] or empty($G_User['inheritance'])) {
         $user_session = array();
         $user_session['id'] = $J_User->id;
         $user_session['name'] = $J_User->name;
         $user_session['username'] = $J_User->username;
         $user_session['email'] = $J_User->email;
         $user_session['last_login'] = $J_User->lastvisitDate;
         $user_session['logged_in'] = !$J_User->guest;
         $user_session['guest'] = $J_User->guest;
         $user_session['groups'] = empty($J_User->groups) ? array(1) : array_values($J_User->groups);
         $user_session['inheritance'] = array();
         if (!empty($J_User->groups)) {
             //sort groups
             $groups = \GCore\Admin\Models\Group::getInstance()->find('all', array('order' => 'Group.parent_id ASC'));
             $valid_groups = array_intersect($user_session['groups'], \GCore\Libs\Arr::getVal($groups, array('[n]', 'Group', 'id')));
             if (!empty($groups) and $valid_groups) {
                 reloop:
                 foreach ($groups as $group) {
                     //if this group exists in the user's groups or its inheitance then add its parent_id
                     if (in_array($group['Group']['id'], $user_session['groups']) or in_array($group['Group']['id'], $user_session['inheritance'])) {
                         $user_session['inheritance'][] = $group['Group']['parent_id'];
                     }
                 }
                 //find the number of occurances of each group in the inheritane
                 $groups_counted = array_count_values($user_session['inheritance']);
                 //if the count of root parent (0 parent_id) is less than the count of user's groups then not all pathes have been found, reloop
                 if (count($user_session['groups']) and !isset($groups_counted[0]) or $groups_counted[0] < count($user_session['groups'])) {
                     goto reloop;
                 } else {
                     $user_session['inheritance'] = array_unique($user_session['inheritance']);
                 }
             }
         }
         if ($session->get('user', array()) !== $user_session) {
             $session->clear('acos_permissions');
         }
         $session->set('user', array_merge($session->get('user', array()), $user_session));
     }
     //copy some config
     $mainframe = \JFactory::getApplication();
     //set timezone
     date_default_timezone_set($mainframe->getCfg('offset'));
     //site title
     \GCore\Libs\Base::setConfig('site_title', $mainframe->getCfg('sitename'));
     //$lang = \JFactory::getLanguage();
     //\GCore\Libs\Base::setConfig('site_language', $lang->getTag());
     /*if(!Authorize::authorized($classname, $this->action)){
     			if($content_only){
     				return;
     			}
     			$this->redirect(r_('index.php?cont=users&act=login'));
     		}*/
     //if the extension class not found or the action function not found then load an error
     if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
         $this->controller = 'errors';
         $this->action = 'e404';
         //reset the controller
         //$classname = '\GCore\Controllers\Errors';
         $this->buffer = 'Page not found';
         \GCore\Libs\Env::e404();
         \JError::raiseError(404, $this->buffer);
         //we need the rendered content only
         if ($content_only) {
             return;
         }
     }
     //load language file
     if (!empty($extension)) {
         Lang::load($site . $extension);
     }
     //set theme
     $doc = Document::getInstance($this->site, $this->thread);
     $doc->theme = 'bootstrap3';
     $theme = \GCore\Helpers\Theme::getInstance();
     //load class and run the action
     ${$classname} = new $classname($this->site, $this->thread);
     ob_start();
     $continue = ${$classname}->_initialize();
     //check and read cache
     if (!empty(${$classname}->cache)) {
         if (!is_array(${$classname}->cache)) {
             ${$classname}->cache = array();
         }
         if (empty(${$classname}->cache['time'])) {
             ${$classname}->cache['time'] = Base::getConfig('app_cache_expiry', 900);
         }
         if (empty(${$classname}->cache['title'])) {
             ${$classname}->cache['title'] = File::makeSafe($classname . '_' . $this->action);
         } else {
             ${$classname}->cache['title'] = File::makeSafe(${$classname}->cache['title']);
         }
         if (empty(${$classname}->cache['key'])) {
             ${$classname}->cache['key'] = 'cached_view';
         } else {
             ${$classname}->cache['key'] = 'cached_view_' . ${$classname}->cache['key'];
         }
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cached_view = $cache->get(${$classname}->cache['key']);
         $cached = false;
         if (!empty($cached_view)) {
             $cached = true;
             $continue = false;
             echo $cached_view;
         }
     }
     if ($continue !== false) {
         ${$classname}->{$this->action}();
         if ($this->reset === true) {
             $this->reset = false;
             goto reset;
         }
         //initialize and render view
         $view = new View();
         $view->initialize(${$classname});
         $view->renderView($this->action);
     }
     //get the action output buffer
     $this->buffer = ob_get_clean();
     //check and save cache
     if (!empty(${$classname}->cache) and !$cached) {
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cache->set(${$classname}->cache['key'], $this->buffer);
     }
     //finalize
     ob_start();
     ${$classname}->_finalize();
     $this->buffer .= ob_get_clean();
     if ($this->tvout != 'ajax' and $doc->theme == 'bootstrap3') {
         $this->buffer = '<div class="gbs3">' . $this->buffer . '</div>';
     }
     //Event::trigger('on_after_dispatch');
 }