Esempio n. 1
0
 public function actionDeleteModule()
 {
     if (isset($_POST['module_id'])) {
         $module_id = $_POST['module_id'];
         $module = Modules::model()->findByPk($module_id);
         if ($module->delete()) {
             $definePermission = DefinePermission::model()->deleteAll('module_id = ' . intval($module_id));
             $roleBasic = RolesBasicPermission::model()->deleteAll('module_id = ' . intval($module_id));
             $roleDefine = RolesDefinePermission::model()->deleteAll('module_id = ' . intval($module_id));
             $accountBasic = AccountBasicPermission::model()->deleteAll('module_id = ' . intval($module_id));
             $accountDefine = AccountDefinePermission::model()->deleteAll('module_id = ' . intval($module_id));
             echo '{"status":"success"}';
         } else {
             echo '{"status":"fail"}';
         }
     }
 }
Esempio n. 2
0
 /**
  * Hàm này lấy quyền của user
  * @param type $module_name
  * @param type $per_value
  * @param type $user_id
  * @return boolean
  */
 public function checkPerModule($module_name, $per_value, $user_id = FALSE)
 {
     if (!$user_id) {
         $user_id = Yii::app()->user->id;
     }
     $result_per = false;
     $modules = Modules::model()->getOneModules($module_name);
     $permission = BasicPermission::model()->find('basic_permission_name = "' . $per_value . '"');
     if ($modules && $permission) {
         // Kiểm tra quyền user được gán vào roles
         $roles = AccountRoles::model()->findAll('accout_id = ' . intval($user_id));
         foreach ($roles as $roleItem) {
             $check_permisson_roles = RolesBasicPermission::model()->find('role_id = ' . intval($roleItem->role_id) . ' AND module_id = ' . intval($modules->lb_record_primary_key) . ' AND basic_permission_id = ' . intval($permission->basic_permission_id) . ' AND basic_permission_status = 1');
             if (count($check_permisson_roles) > 0) {
                 $result_per = true;
             }
         }
         // END Roles
         // Kiểm tra gan quyền trực tiếp cho user
         $check_permisson = AccountBasicPermission::model()->find('account_id = ' . intval($user_id) . ' AND module_id = ' . intval($modules->lb_record_primary_key) . ' AND basic_permission_id = ' . intval($permission->basic_permission_id));
         if ($check_permisson) {
             if ($check_permisson->basic_permission_status == 1) {
                 $result_per = true;
             } else {
                 $result_per = false;
             }
         }
         //End modules
     }
     return $result_per;
 }
Esempio n. 3
0
 public function checkHiddenModule($mod_directory)
 {
     $user_id = YII::app()->user->id;
     // Kiểm tra tai khoản admin
     $ownSub = AccountSubscription::model()->checkIsSubscriptionOwner(LBApplication::getCurrentlySelectedSubscription());
     //END
     $criteria = new CDbCriteria();
     $criteria->condition = 'module_directory = "' . $mod_directory . '" AND module_hidden = 1';
     $module = $this->getOneRecords($criteria);
     $basic_account = array();
     if ($module) {
         // Kierm tra user da duoc gan module nay chua
         $checkModule = false;
         $basic_account = AccountBasicPermission::model()->findAll('module_id = "' . $module->lb_record_primary_key . '" AND account_id = ' . intval($user_id));
         if (count($basic_account) > 0) {
             $checkModule = true;
         }
         // Kiem tra uer da duoc gan role ma co module nay chua
         $checkModuleRole = false;
         $role = AccountRoles::model()->findAll('accout_id=' . intval($user_id));
         foreach ($role as $roleItem) {
             $basic_role = RolesBasicPermission::model()->findAll('role_id=' . intval($roleItem->role_id) . ' AND module_id = ' . intval($module->lb_record_primary_key));
             if (count($basic_role) > 0) {
                 $checkModuleRole = true;
             }
         }
     }
     // Kiem tra user co dc xem modules nay ko
     //            $assignModulesUser = AccountBasicPermission::model()->findAll('account_id = '.intval($user_id).' AND module_id='.intval($dataProvider->data->module_id));
     if (count($module) > 0 && $ownSub) {
         return true;
     } else {
         if (count($module) > 0 && ($checkModule == true || $checkModuleRole == true)) {
             return true;
         }
     }
     return false;
 }
                <td width="8%">Add</td>
                <td width="8%">View Own</td>
                <td width="8%">View All</td>
                <td width="8%">Update Own</td>
                <td width="8%">Update All</td>
                <td width="8%">Delete Own</td>
                <td width="8%">Delete All</td>
                <td width="8%">List Own</td>
                <td width="8%">List All</td>
                <td width="5%">&nbsp;</td>
            </tr>
          </thead>
          <tbody>
          <?php 
foreach ($moduleRoles->data as $moduleRolesItem) {
    $permissionRoles = RolesBasicPermission::model()->getPermissionByRoles($model->lb_record_primary_key, $moduleRolesItem->module_id);
    ?>
            <tr>
                <td style="text-align: left"><?php 
    echo $moduleRolesItem->module->module_name;
    ?>
</td>
                <?php 
    foreach ($permissionRoles->data as $permissionRolesItem) {
        ?>
                <td><?php 
        $checked = false;
        $status = 1;
        if ($permissionRolesItem->basic_permission_status == 1) {
            $checked = true;
            $status = 0;
Esempio n. 5
0
 public function actionDeleteModuleRole()
 {
     if (isset($_POST['module_id']) && isset($_POST['role_id'])) {
         $module_id = $_POST['module_id'];
         $role_id = $_POST['role_id'];
         $delete = $modelModuleRole = RolesBasicPermission::model()->deleteAll('module_id = ' . intval($module_id) . ' AND role_id = ' . intval($role_id));
         if ($delete) {
             echo '{"status":"success"}';
         } else {
             echo '{"status":"fail"}';
         }
     }
 }