Example #1
0
 public function projectsAction()
 {
     $this->view->noAJmanpro = true;
     $task = $this->_getParam("task");
     $targetActionID = $this->_getParam("t");
     switch ($task) {
         case "attach":
             $this->view->dis = "attach";
             $cu = new Application_Model_DbTable_Users();
             $projectA = new Application_Model_DbTable_Projects();
             $pInfo = $projectA->getById($targetActionID);
             $cRes = $cu->getClients();
             $this->view->clients = $cRes;
             $this->view->projectID = $targetActionID;
             $this->view->projectName = $pInfo->projectName;
             break;
         case "new":
             $this->view->dis = "new";
             break;
         case "del":
             $this->view->dis = "del";
             $t = $this->_request->getPost('target-id');
             if ($this->getRequest()->isPost() && !empty($t)) {
                 $this->_helper->layout()->disableLayout();
                 $p = new Application_Model_DbTable_Projects();
                 $p->delete("id = " . $t);
             }
             break;
         default:
             $this->view->dis = "list";
             $pObj = new Application_Model_DbTable_Projects();
             $res = $pObj->getProjects();
             $this->view->projectList = $res;
     }
 }
Example #2
0
 public function readAction()
 {
     $targetID = $this->_getParam('t');
     $getWhat = $this->_getParam('g');
     if (!empty($targetID) && !empty($getWhat)) {
         $rObj = new Application_Model_DbTable_Reviews();
         switch ($getWhat) {
             case "client":
                 $userOBJ = new Application_Model_DbTable_Users();
                 $userInfo = $userOBJ->getUser($targetID);
                 $pRes = $rObj->getReviews($targetID, 'user_ID');
                 if ($pRes) {
                     $this->view->projectsReviews = $pRes;
                 }
                 $this->view->success = 1;
                 $this->view->targetName = $userInfo->fullName . " - " . $userInfo->email;
                 $this->view->targetType = "client";
                 break;
             case "project":
                 $projectObj = new Application_Model_DbTable_Projects();
                 $pinfo = $projectObj->getById($targetID);
                 $pRes = $rObj->getReviews($targetID, 'project_ID');
                 if ($pRes) {
                     $this->view->projectsReviews = $pRes;
                 }
                 $this->view->success = 1;
                 $this->view->targetName = $pinfo->projectName;
                 break;
             default:
                 $this->view->success = 0;
         }
     }
 }
Example #3
0
 public function testUpdate()
 {
     $table = new Application_Model_DbTable_Users();
     $users = $table->find(1);
     $user = $users->current();
     Zend_Debug::dump($user);
     $this->assertSame($user->username, 'admin');
     $this->assertSame($user->id, '1');
     $list = $user->toArray();
     Zend_Debug::dump($list);
 }
 public function grantAction()
 {
     if (!$this->admin_is_on) {
         die('ACCESS DENIED!');
     }
     $request = $this->getRequest();
     $user_data = $request->getPost();
     //$authAdapter = $this->getAuthAdapter();
     # get the username and password from the form
     $username = trim($user_data['username']);
     $password = '******';
     if (!strlen($username)) {
         echo $this->view->lang->_('MISSING USERNAME');
         die;
     }
     # pass to the adapter the submitted username and password
     $authAdapter = $this->getAuthAdapter();
     $authAdapter->setIdentity($username)->setCredential($password);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     # is the user a valid one?
     if ($this->admin_is_on) {
         # all info about this user from the login table
         # ommit only the password, we don't need that
         $user = new Application_Model_DbTable_Users();
         $userInfo = $user->getUserInfo($username);
         # the default storage is a session with namespace Zend_Auth
         $authStorage = $auth->getStorage();
         $authStorage->write($userInfo);
         if ($userInfo->role == Application_Model_DbTable_Users::$EMPLOYER) {
             $jobs = $user->getEmpJobs($userInfo->user_id);
             //        print_r ($jobs);die;
             $user_jobs = new Zend_Session_Namespace('jobs');
             foreach ($jobs as $id) {
                 $user_jobs->jobs[] = $id->job_id;
             }
             $this->_redirect('/empconsole/');
         }
         if ($userInfo->role == Application_Model_DbTable_Users::$SEEKER) {
             $this->_redirect('/sekconsole/');
         }
         if ($userInfo->role == Application_Model_DbTable_Users::$ADMIN) {
             $this->_redirect('/addmin/');
         }
         die('Invalid user account!');
     } else {
         echo Zend_Json::encode(array('status' => false, 'msg' => $this->view->lang->_('WRONG LOGIN')));
         die;
     }
 }
Example #5
0
 /**
  * New user registration
  */
 public function registerAction()
 {
     $form = new Application_Form_Register();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         var_dump($formData);
         if ($form->isValid($formData)) {
             $user = $formData['username'];
             $password = $formData['password'];
             $users = new Application_Model_DbTable_Users();
             $users->addUser($user, $password);
             $this->redirect("index/index");
         } else {
             $form->populate($formData);
         }
     }
 }
Example #6
0
 public function signupAction()
 {
     $users = new Application_Model_DbTable_Users();
     $form = new Application_Form_RegistrationForm();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             if ($formData['password'] != $formData['password2']) {
                 $this->view->errorMsg = "Password and Confirm Password must match.";
                 $this->render('signup');
                 return;
             }
             unset($formData['password2']);
             unset($formData['register']);
             $users->insert($formData);
             $this->_redirect('auth/login');
         }
     }
 }
Example #7
0
 public function deleteAction()
 {
     if ($this->getRequest()->isPost()) {
         $id = intval($this->getRequest()->getPost('id'));
         $users = new Application_Model_DbTable_Users();
         $where = 'id = ' . $id;
         $users->delete($where);
         $this->_helper->redirector('index');
     }
 }
 protected function _getAuthAdapter($treatment = true)
 {
     $users = new Application_Model_DbTable_Users();
     $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter());
     if ($treatment) {
         $authAdapter->setTableName('users')->setIdentityColumn('user_email')->setCredentialColumn('hashed_password')->setCredentialTreatment('SHA1(?)');
     } else {
         $authAdapter->setTableName('users')->setIdentityColumn('user_email')->setCredentialColumn('hashed_password');
     }
     return $authAdapter;
 }
Example #9
0
 /**
  * This action check the user login 
  * 
  */
 public function checkAction()
 {
     $request = $this->getRequest();
     $user_data = $request->getPost();
     //$authAdapter = $this->getAuthAdapter();
     # get the username and password from the form
     $username = trim($user_data['username']);
     $password = trim($user_data['password']);
     $remember_me = isset($user_data['rememberme']) && $user_data['rememberme'];
     if (!strlen($username)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('MISSING_USERNAME') . '</div>');
         $this->_redirect('/');
     }
     if (!strlen($password)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('MISSING_PASSWORD') . '</div>');
         $this->_redirect('/');
     }
     # pass to the adapter the submitted username and password
     //        $authAdapter = $this->getAuthAdapter();
     //        $authAdapter->setIdentity($username)
     //                    ->setCredential($password);
     $auth = Zend_Auth::getInstance();
     //        $result = $auth->authenticate($authAdapter);
     $user_DB = new Application_Model_DbTable_Users();
     $user_Info = $user_DB->getUserInfo($username);
     if (!$user_Info) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('NOT_VERIFIED') . '</div>');
         $this->_redirect('/');
     }
     $hashed_password = $user_DB->getPassword($username);
     if ($this->hashequals($hashed_password, crypt($user_data['password'], $hashed_password))) {
         //        # is the user a valid one?
         //        if($result->isValid())
         //        {
         //            # all info about this user from the login table
         //            # ommit only the password, we don't need that
         //            $userInfo = $authAdapter->getResultRowObject(null, 'password');
         # the default storage is a session with namespace Zend_Auth
         $authStorage = $auth->getStorage();
         $authStorage->write($user_Info);
         // print_r ($userInfo);die;
         // Throw signin event
         //            topxiteHooksRegistry::dispatchEvent('onSignIn', $userInfo);
         # remeber me
         // $seconds  = 6048000; // 70 days
         // if ($remember_me) {
         //  Zend_Session::RememberMe($seconds);
         //}
         // else {
         //   Zend_Session::ForgetMe();
         //}
         //            topxiteHooksRegistry::dispatchEvent('lastLogin', $userInfo);
         //$user = new Application_Model_DbTable_Users();
         //$user->setLastLogin($userInfo->user_id);
         #check if user is admin
         $role = (string) $user_DB->getRole($username);
         $_SESSION['Default']['role'] = $role;
         if ($role == 'admin') {
             $_SESSION['Default']['entry'] = true;
             $this->_redirect('/entry');
         } else {
             $this->_redirect('/fields');
         }
     } else {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('WRONG_LOGIN') . '</div>');
         $this->_redirect('/');
     }
 }
Example #10
0
 public function deleteuserAction()
 {
     $userID = $this->_request->getParam('u');
     $ganID = $this->_request->getParam('g');
     $users_DB = new Application_Model_DbTable_Users();
     $users_DB->delete("userID = {$userID}");
     $this->_redirect("/admin/editgan/g/" . $ganID);
 }
Example #11
0
 private function newClient($fName, $emailAdd)
 {
     $userOBJ = new Application_Model_DbTable_Users();
     $upass = substr(md5(date('Y-m-d H:i:s')), 0, 8);
     $userID = $userOBJ->insert(array("fullName" => $fName, "email" => $emailAdd, "level" => "client", "password" => md5($upass), "dateCreated" => date('Y-m-d H:i:s')));
     $mail = new Zend_Mail();
     $mail->setFrom("*****@*****.**");
     $mail->addTo($emailAdd);
     $mail->setSubject("Confidential: Access details from Okapi ");
     $emailBody = "\n\t\t\nDear Client,\n\nOkapi Project Preview System \n\nIn order to serve you better with your projects, we have created a Project Viewing System that you can access for collaboration. Please find below your login credentials to access the System.\n\nLogin Credentials:\n\nWeb Address: http://www.dev45.net\n\nRegistered E-Mail: " . $emailAdd . "\n\nPassword : "******"\n(You can choose a new password when you login) \n\nIf you have any questions please email info@dev45.net\n\n\nRegards,\nThe Okapi Development Team.\n\t\t";
     $mail->setBodyText($emailBody);
     $mail->send();
     return $userID;
 }
Example #12
0
 /**
  * 批量从角色组删除员工
  */
 public function remRoleHave($UserIDs)
 {
     $ids = $this->formatID($UserIDs);
     if (empty($ids)) {
         return false;
     }
     $staffTable = new Application_Model_DbTable_Users();
     foreach ($ids as $UserID) {
         $staff = $staffTable->getUser($UserID);
         //删除,可以非空检测
         if (!empty($staff->RoleIDs)) {
             $temp = explode(',', $staff->RoleIDs);
             $roles = array();
             foreach ($temp as $rid) {
                 $roles[$rid] = $rid;
             }
             if (isset($roles[$this->relatedid])) {
                 unset($roles[$this->relatedid]);
             }
             $staff->RoleIDs = implode(',', $roles);
             $staff->save();
         }
     }
     return false;
 }