Exemplo n.º 1
0
 /**
  * [getData get data at the status data is ture]
  * @return [array] [return set of data status is true]
  */
 public static function getData()
 {
     $user_role = new Usernhc();
     $role_id = $user_role->getRoleName()->role_id;
     //Get role id
     $rs_policy = RolePolicy::where('role_id', '=', $role_id)->select('policy_id')->get()->toArray();
     //Get relate policy
     $policy_id = $rs_policy[0]['policy_id'];
     //Policy id
     $data_id = DataPolicy::where('policy_id', '=', $policy_id)->select('data_id')->get()->toArray();
     $data_id = array_flatten($data_id);
     // Data id that relate with policy
     $rs_dataid = DataPrivacy::where('status', '=', true)->whereIn('data_id', $data_id)->distinct()->get(array('data_id'));
     foreach ($rs_dataid->toArray() as $key => $value) {
         $id[] = $value['data_id'];
     }
     //$dataid_set = implode("','", $id); //Displays 'A', 'B', 'C'
     return $id;
 }
Exemplo n.º 2
0
 /**
  * [policyRBACSaveAction for save each policy and rbac option]
  * @param  [integer] $id [policy id]
  * @return [none]     [redirect to rbac-policy page]
  */
 public function policyRBACSaveAction($id)
 {
     $data = Input::all();
     $rules = array('rbac_role' => array('required'), 'rbac_data' => array('required'), 'rbac_action' => array('required'), 'rbac_condition' => array('required'));
     // Build the custom messages array.
     $messages = array('rbac_role.required' => 'กรุณาระบุชื่อบทบาท', 'rbac_data.required' => 'กรุณาระบุชื่อข้อมูล', 'rbac_action.required' => 'กรุณาระบุชื่อการกระทำ', 'rbac_condition.required' => 'กรุณาระบุชื่อเงื่อนไข');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         //For Role
         RolePolicy::where('policy_id', '=', $id)->delete();
         foreach ($data['rbac_role'] as $key => $value) {
             $role_data['role_id'] = $value;
             $role_data['policy_id'] = $id;
             $datas_role[] = $role_data;
         }
         // var_dump($datas_role);exit;
         RolePolicy::insert($datas_role);
         //For Data
         DataPolicy::where('policy_id', '=', $id)->delete();
         foreach ($data['rbac_data'] as $key => $value) {
             $_data['data_id'] = $value;
             $_data['policy_id'] = $id;
             $datas[] = $_data;
         }
         DataPolicy::insert($datas);
         //For Condition
         ConditionPolicy::where('policy_id', '=', $id)->delete();
         foreach ($data['rbac_condition'] as $key => $value) {
             $cond_data['cond_id'] = $value;
             $cond_data['policy_id'] = $id;
             $datas_cond[] = $cond_data;
         }
         //var_dump($datas_cond);exit;
         ConditionPolicy::insert($datas_cond);
         //For Purpose
         PurposePolicy::where('policy_id', '=', $id)->delete();
         if (isset($data['rbac_purpose'])) {
             foreach ($data['rbac_purpose'] as $key => $value) {
                 $purp_data['purp_id'] = $value;
                 $purp_data['policy_id'] = $id;
                 $datas_purp[] = $purp_data;
             }
             PurposePolicy::insert($datas_purp);
         }
         //For Obligation
         ObligationPolicy::where('policy_id', '=', $id)->delete();
         if (isset($data['rbac_obligation'])) {
             foreach ($data['rbac_obligation'] as $key => $value) {
                 $obl_data['obl_id'] = $value;
                 $obl_data['policy_id'] = $id;
                 $datas_obl[] = $obl_data;
             }
             ObligationPolicy::insert($datas_obl);
         }
         //For Action
         ActionPolicy::where('policy_id', '=', $id)->delete();
         foreach ($data['rbac_action'] as $key => $value) {
             $action_data['action_id'] = $value;
             $action_data['policy_id'] = $id;
             $datas_action[] = $action_data;
         }
         ActionPolicy::insert($datas_action);
         return Redirect::to('/policy-rbac/' . $id)->with('success', 'อาร์บีเอซี:มีนโยบายคลังฯรหัส = ' . $id . ' บันทึกสำเร็จ')->with('rbac_data', self::policyRBACEditAction($id));
     } else {
         return Redirect::to('/policy-rbac/' . $id)->withErrors($validator);
     }
 }
Exemplo n.º 3
0
 /**
  * [delDataById description]
  * @param  integer 	$id 	policy id
  * @return array 	$datas  data id information and count
  */
 public function delDataById($id)
 {
     $data = DataPolicy::where('policy_id', '=', $id)->delete();
 }