Exemplo n.º 1
0
 public function changepassAction()
 {
     if ($this->getRequest()->isPost()) {
         $currpassword = $this->_request->getPost('currpassword');
         $password = $this->_request->getPost('password');
         $confirmpassword = $this->_request->getPost('confirmpassword');
         $model_user = new AdminReportHandler();
         $auth = Zing_Admin_Auth::getInstance();
         $userId = $auth->getIdentity()->userid;
         try {
             if ($currpassword == '' || $password == '' || $confirmpassword == "") {
                 $result['error'][] = "Enter required fields!";
             } else {
                 if ($password != $confirmpassword) {
                     $result['error'][] = "Password and confirm password do not match";
                 } else {
                     $user = $model_user->getAdmin($userId, $currpassword);
                     if (count($user) != 1) {
                         $result['error'][] = "Current password is wrong";
                     } else {
                         $resultChangePass = $model_user->changePass($userId, $currpassword, $password);
                         $result['success'] = true;
                     }
                 }
             }
         } catch (Exception $e) {
             $result['error'][] = "Unknown error";
         }
         echo json_encode($result);
         die;
     } else {
         $this->view->container = $this->view->render("index/changepass.phtml");
     }
 }
Exemplo n.º 2
0
 public function authenticate($username, $password)
 {
     $modelUser = new AdminReportHandler();
     $result = $modelUser->getAdmin($username, $password);
     if (count($result) == 1) {
         $result = $result[0];
         //Identity from DB is object
         $this->_identity = new stdClass();
         $this->_identity->userid = $result['adminID'];
         $this->_identity->username = $result['adminID'];
         $this->_identity->name = $result['adminName'];
         $this->_identity->adminflg = $result['adminflg'];
         $storage = $this->getStorage();
         $zadmin_auth = $storage->create();
         $storage->write($this->_identity);
         Zing_Cookies::createCookies(self::COOKIE_ADMIN_AUTH_KEY, $zadmin_auth, 0);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 public function edituserAction()
 {
     try {
         $array_of_params = $this->_request->getParams();
         if (isset($array_of_params['validate'])) {
             $this->view->validate = $array_of_params['validate'];
         }
         $adminReportHandler = new AdminReportHandler();
         $admin = $adminReportHandler->getAdmin($array_of_params['userId']);
         $adminApps = $adminReportHandler->getAllAdminApp($array_of_params['userId']);
         $adminAppsMap = array();
         foreach ($adminApps as $adminApp) {
             $adminAppsMap['' . $adminApp['adminAppID']] = '1';
         }
         $userData["txtUserName"] = $admin["adminID"];
         $userData["appid"] = $adminAppsMap;
         $userData["txtName"] = $admin["adminName"];
         $userData["adminflg"] = $admin["adminflg"];
         $this->view->userData = $userData;
         $appserver = new AppInfo();
         $allApps = $appserver->getAllAppInfo();
         $allApps = $this->sortAppByID($allApps);
         $this->view->allApps = $allApps;
         $this->view->frmSearch = $this->view->render('index/edituser.phtml');
         $this->view->container = $this->view->render('index/index.phtml');
     } catch (Exception $e) {
         var_dump($e);
         die;
     }
 }