コード例 #1
0
 /**
  * Register Edit / New group form data
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function editing($_post)
 {
     $msg = null;
     // check permission
     $msg = $_post['id'] ? AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'menus', $_post['id'], 2) : AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_group_creation', 0, 4);
     if (is_null($msg)) {
         // handle _post
         $post = array('name' => $_post['name'], 'id_area' => $_post['id_area'], 'description' => $_post['description']);
         // update or insert
         $group = new Group_model();
         if ($_post['id']) {
             $result = $group->update($_post['id'], $post);
         } else {
             $result = $group->insert($post);
             // add permission
             if ($result[1]) {
                 $perm = new Permission_model();
                 $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
                 $res = $perm->pexec('groups', $array, $_post['id_area']);
             }
         }
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // set what update
         if ($result[1]) {
             $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'users', 'title' => null);
         }
     }
     $this->response($msg);
 }