Пример #1
0
 public function actionEdit()
 {
     $data['login'] = "";
     $data['email'] = "";
     $data['password'] = "";
     $this->get();
     $this->post();
     $error = "";
     //print_r($this->post);
     try {
         if (empty($this->get['id'])) {
             throw new Exception("EMPTY_ID");
         }
         $id = $this->get['id'];
         $edit_user = new myUser($this->db, $id);
         $data = $edit_user->data;
         $data_arr['id'] = $this->get['id'];
         if (!empty($this->post)) {
             if (empty($this->post['email'])) {
                 throw new Exception("NOT_ENTERED_EMAIL");
             }
             if (!empty($this->post['password']) && !empty($this->post['password2'])) {
                 if ($this->post['password'] !== $this->post['password2']) {
                     throw new Exception("PASSWORDS_NOT_IDENTICAL");
                 }
             }
             if (!empty($this->post['role'])) {
                 $data_arr['role'] = $this->post['role'];
             }
             $data_arr['email'] = $this->post['email'];
             $data_arr['login'] = $this->post['login'];
             $data_arr['original_pass'] = "";
             if (SAVE_ORIGINAL_PASS) {
                 $data_arr['original_pass'] = $this->post['password'];
             }
             $edit_user->saveFields($data_arr);
             $edit_user->changePass($this->post['password']);
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
     $this->assign('role_options', $this->user->roles);
     $this->assign("error", $error);
     $this->assign("data", $data);
     $this->render("admin/user/item.tpl");
 }