Esempio n. 1
0
 function update($p)
 {
     $permSet = array();
     if (!empty($p['pm'])) {
         foreach ($p['pm'] as $k => $v) {
             $permSet[$k] = $v == 'on' ? true : cInt($v);
         }
     }
     $this->id = isPostor('id');
     $this->acr = cInt(isPostor('acr', 0));
     $this->acw = cInt(isPostor('acw', 0));
     if (!isset($permSet['esv.def']) && !isset($permSet['ews.def'])) {
         $permSet['esv.def'] = true;
     }
     if ($this->id == 1) {
         $this->acr = 99;
         $this->acw = 99;
         $adm = array('esv.def' => issetor($permSet['esv.def'], false), 'ews.def' => issetor($permSet['ews.def'], false));
         $permSet = $adm;
     }
     $this->name = trim(isPostor('name'));
     $this->desc = isPostor('desc');
     $this->props["pm"] = $permSet;
     if (empty($this->name)) {
         gzClient::begin()->eAlert("Error:!Name is not empty...")->send();
     }
     $data = array('userg_name' => $this->name, 'userg_description' => $this->desc, 'userg_acr' => $this->acr, 'userg_acw' => $this->acw, 'rec_update' => NOW, 'userg_props' => json_encode($this->props));
     if (empty($this->id)) {
         $data['rec_update'] = NOW;
         $data['rec_create'] = NOW;
         g::DB()->aInsert($data, 'sg_user_group');
     } else {
         g::DB()->aUpdate($data, 'sg_user_group', 'userg_id', $this->id);
         g::cacheSet('UGROUP' . $this->id, $this);
     }
     //gzData::uGroupInfo(true);
     gzClient::begin()->redirect("cpanel.usergroup")->endSend();
 }