Author: Fred (mconyango@gmail.com)
Inheritance: extends CWebModule
 /**
  * @return AuthModule
  */
 public function newAuthModule()
 {
     $result = null;
     $configKey = 'authModule';
     $moduleConfig = $this->_getModuleConfigItemByKey($configKey);
     $moduleInstance = new AuthModule();
     // initialize module ....
     $moduleInstance->init();
     $moduleInstance->applyConfig($moduleConfig['config']);
     return $moduleInstance;
 }
Esempio n. 2
0
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
0
 public function before()
 {
     parent::before();
     $this->is_logged = Auth::check();
     $this->current_user = null;
     $this->lang = Session::instance()->get('language', 'en');
     if ($this->is_logged) {
         $this->current_user = Auth::get_profile_fields();
         $this->current_user['id'] = Auth::get('id');
         $this->current_user['username'] = Auth::get('username');
         if (!empty($this->current_user['is_deleted'])) {
             Auth::logout();
             die(json_encode(['status' => 'error', 'message' => 'error_msg_1'], JSON_UNESCAPED_UNICODE));
         }
         if (!empty($this->current_user['is_blocked'])) {
             Auth::logout();
             die(json_encode(['status' => 'error', 'message' => 'User is blocked'], JSON_UNESCAPED_UNICODE));
         }
     }
     if (!AuthModule::accessGuard(\Request::active()->controller, \Request::active()->action, $this->current_user)) {
         die(json_encode(['status' => 'error', 'message' => 'Access denied'], JSON_UNESCAPED_UNICODE));
     }
 }
Esempio n. 4
0
File: Base.php Progetto: FTTA/devels
 public function before()
 {
     parent::before();
     $this->template = View::forge('main_template');
     $this->template->styles = ['bootstrap.css'];
     $this->template->scripts = ['jquery-1.9.0.min.js', 'sys_func.js', 'users_logout.js', 'form_getter.js', 'users_login.js', 'page.js'];
     $lSession = Session::instance();
     $this->lang = $lSession->get('language', 'en');
     $this->template->i18n = Model_Translations::getAll($this->lang);
     $this->is_logged = Auth::check();
     $this->current_user = null;
     $lSession->set('translation', $this->template->i18n);
     if ($this->is_logged) {
         $this->current_user = Auth::get_profile_fields();
         $this->current_user['id'] = Auth::get('id');
         $this->current_user['username'] = Auth::get('username');
         if (!empty($this->current_user['avatar_id'])) {
             $this->current_user['avatar'] = Model_Avatars::getById($this->current_user['avatar_id']);
         }
         if (!empty($this->current_user['is_deleted'])) {
             Auth::logout();
             HTTP::redirect('/main/accessDenied?msg=error_msg_1');
         }
         if (!empty($this->current_user['is_blocked'])) {
             Auth::logout();
             HTTP::redirect('/main/accessDenied?msg=User is blocked');
         }
     }
     if (!AuthModule::accessGuard(\Request::active()->controller, \Request::active()->action, $this->current_user)) {
         //Request::forge('/main/accessDenied')->execute();
         Response::redirect('/main/accessDenied');
     }
     View::set_global('is_logged', $this->is_logged, false);
     View::set_global('current_user', $this->current_user, false);
     $this->template->header = View::forge('header');
 }
Esempio n. 5
0
        </div>
    </div>

<?php 
if (!empty($admin_mode)) {
    ?>
    <div class="form-group">
        <label class="col-sm-2 control-label">
            <?php 
    echo DifferentFunc::translation('role');
    ?>
        </label>
        <div class="col-sm-4">
            <select class="form_field validate" name="user[role_id]">
            <?php 
    foreach (AuthModule::rolesList() as $lKey => $lVal) {
        $lSelected = $lVal == $user_data['role_id'] ? 'selected="selected"' : '';
        echo '<option value="' . $lVal . '"' . $lSelected . '>' . DifferentFunc::translation($lKey) . '</option>';
    }
    ?>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">
            <?php 
    echo DifferentFunc::translation('block');
    ?>
        </label>
        <div class="col-sm-4">
Esempio n. 6
0
    <div class="col-md-2"><b><?php 
echo DifferentFunc::translation('deleted');
?>
 </b></div>
    <div class="col-md-2"><b><?php 
echo DifferentFunc::translation('blocked');
?>
 </b></div>
    <div class="col-md-2"><b><?php 
echo DifferentFunc::translation('action');
?>
 </b></div>
</div>

<?php 
$lRolesNames = AuthModule::rolesNames();
$lMarcks['yes'] = DifferentFunc::translation('yes');
$lMarcks['no'] = DifferentFunc::translation('no');
foreach ($users as $lVal) {
    $lRoleName = $lRolesNames[$lVal['profile_fields']['role_id']];
    ?>
<div class="row">
    <div class="col-md-2"><?php 
    echo $lVal['username'];
    ?>
</div>
    <div class="col-md-2"><?php 
    echo $lVal['email'];
    ?>
</div>
    <div class="col-md-2"><?php