Example #1
0
 /**
  * read permission data and fill in array
  * @param  [type] $_list [description]
  * @return [type]        [description]
  */
 public function permModuleFill()
 {
     $permResult = [];
     // 1. get the name of permission
     $myChild = $this->child();
     if ($myChild === 'edit') {
         $myChild = $this->childparam('edit');
     }
     // 2. get perm data from table
     $qry = $this->sql()->table('options')->where('user_id', 'IS', 'NULL')->and('post_id', 'IS', "NULL")->and('option_cat', 'permissions')->and('option_value', $myChild)->and('option_status', "enable");
     $datarow = $qry->select()->assoc('option_meta');
     if (substr($datarow, 0, 1) == '{') {
         $datarow = json_decode($datarow, true);
     }
     // 3. fill the result
     foreach (\lib\utility\option::contentList() as $myContent) {
         // 3.1 fill null
         $permResult[$myContent] = ['enable' => null, 'modules' => null, 'roles' => null];
         // 3.2 set enable status
         if (isset($datarow[$myContent]['enable']) && $datarow[$myContent]['enable']) {
             $permResult[$myContent]['enable'] = true;
         }
         // 3.3 get modules list of specefic content and fill it with db values
         foreach (\lib\utility\permission::moduleList($myContent) as $myLoc => $value) {
             if (isset($datarow[$myContent]['modules'][$myLoc]) && is_array($datarow[$myContent]['modules'][$myLoc])) {
                 $permResult[$myContent]['modules'][$myLoc] = $datarow[$myContent]['modules'][$myLoc];
                 // if user set specefic value for this location add it to db values
                 if (is_array($value)) {
                     $permResult[$myContent]['modules'][$myLoc] += $value;
                 }
             } else {
                 $permResult[$myContent]['modules'][$myLoc] = $value;
             }
         }
     }
     return $permResult;
 }
Example #2
0
 /**
  * call permission access func
  * @return [type] [description]
  */
 public function access()
 {
     return \lib\utility\permission::access(...func_get_args());
 }