Ejemplo n.º 1
0
 public function indexAction()
 {
     try {
         $user_form = new Application_Form_UserForm();
         $this->view->form = $user_form;
         $usersMapper = new Application_Model_UsersMapper();
         $users = new Application_Model_Users();
         $request = $this->getRequest();
         if ($request->isPost()) {
             $request_type = $request->getParam("request_type", false);
             if ($request_type) {
                 if ($request_type == "add") {
                     $params = $request->getParams();
                     if ($user_form->isValid($params)) {
                         foreach ($params as $param => $value) {
                             if ($param == "hashed_password") {
                                 $value = sha1($value);
                             }
                             $users->__set($param, $value);
                         }
                         $users->__set("user_fb_id", "");
                         if ($usersMapper->addNewUser($users)) {
                             $this->view->message = "User added successfully";
                             $this->view->hasMessage = true;
                             $this->view->messageType = "success";
                         } else {
                             $this->view->message = "Error occured while adding. Please try again";
                             $this->view->hasMessage = true;
                             $this->view->messageType = "danger";
                         }
                     } else {
                         $this->view->message = "Error occured while Adding. Please fill form correctly";
                         $this->view->hasMessage = true;
                         $this->view->messageType = "danger";
                     }
                 } elseif ($request_type == "delete") {
                     $id = $request->getParam("id");
                     if ($usersMapper->deleteUserById($id)) {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "success";
                         $this->view->message = "User deleted successfully.";
                     } else {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "danger";
                         $this->view->message = "Error occured while deleting. Please try again.";
                     }
                 }
             }
         }
         $user = $usersMapper->getAllUsers();
         $this->view->users = $user;
         $this->authorised = true;
     } catch (Exception $ex) {
         $this->authorised = false;
         $this->view->hasMessage = true;
         $this->view->messageType = "danger";
         $this->view->message = $ex->getMessage();
     }
 }
Ejemplo n.º 2
0
 public function buildusersAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     if ($this->auth->hasIdentity()) {
         $build = new Application_Model_Users($this->registry['DB']);
         $this->view->results = $build->buildusers();
     }
 }
Ejemplo n.º 3
0
 public function checkmailAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $email = $this->getRequest()->getParam('email');
     $user = new Application_Model_Users($this->registry['DB']);
     if ($user->checkmail($email)) {
         $this->getResponse()->setBody(json_encode(array('status' => 'true')));
     } else {
         $this->getResponse()->setBody(json_encode(array('status' => 'false')));
     }
 }
Ejemplo n.º 4
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $fields = array("email" => $request->getParam('email', ""));
     /**
      * a post action has occured, validate data
      */
     if ($request->isPost()) {
         $hasError = false;
         $email = trim($request->getPost('email', ""));
         $fields["email"] = $email;
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $hasError = true;
             $fields["email_error"] = "Not a valid email.";
         }
         $password = $request->getPost('password', "");
         $fields["password"] = "";
         if (strlen($password) < 4) {
             $hasError = true;
             $fields["password_error"] = "Password must be at least 4 characters!";
         }
         if (!$hasError) {
             $member = new Application_Model_Users();
             if ($member->exists($email)) {
                 $user = $member->getUser($email);
                 $sha = new Application_Model_NanoSha256();
                 if ($sha->getSaltedHash($email, $password) == $user->pass) {
                     $groups = array(99 => "Physician", 59 => "Family Member", 10 => "Patient");
                     $authNamespace = new Zend_Session_Namespace('Zend_Auth');
                     $authNamespace->id = $user->id;
                     $authNamespace->email = $user->email;
                     $authNamespace->name_first = $user->name_first;
                     $authNamespace->name_last = $user->name_last;
                     $authNamespace->account_type = $user->account_type;
                     $authNamespace->name = $user['name_first'] . " " . $user['name_last'];
                     $authNamespace->title_name = $user->title . " " . $authNamespace->name;
                     $authNamespace->account_type_print = $groups[$user->account_type];
                     $authNamespace->relationship = $user->relationship;
                     return $this->_redirect('/portal');
                 } else {
                     $hasError = true;
                     $fields["error"] = "Invalid email/password combination!";
                 }
             } else {
                 $hasError = true;
                 $fields["error"] = "Invalid email/password combination!";
             }
         }
         if ($hasError) {
             $fields["has_error"] = true;
         }
         $this->view->fields = $fields;
     }
 }
Ejemplo n.º 5
0
 public function listAction()
 {
     echo "hgh";
     if ($this->view->identity) {
         echo "jjjj";
         var_dump($this->view->identity->username);
     }
     echo "kkk";
     // if($this->view->identity)            {
     $model = new Application_Model_Requests();
     $requests = $model->listRequests();
     //$page=$this->_getParam('page',1);
     //$paginator = Zend_Paginator::factory($courses);
     // $paginator->setItemCountPerPage(10);
     //$paginator->setCurrentPageNumber($page);
     $this->view->requests = $requests;
     $course_request_form = new Application_Form_CourseReuest();
     $material_request_form = new Application_Form_MaterialReuest();
     $user_model = new Application_Model_Users();
     $users = $user_model->listUsers();
     for ($i = 0; $i < count($users); $i++) {
         $options[$users[$i]['id']] = $users[$i]['username'];
     }
     $course_request_form->getElement('uid')->setMultiOptions($options);
     $material_request_form->getElement('uid')->setMultiOptions($options);
     $options = NULL;
     $course_model = new Application_Model_Courses();
     $courses = $course_model->listCourses();
     for ($i = 0; $i < count($courses); $i++) {
         $options[$courses[$i]['id']] = $courses[$i]['name'];
     }
     $course_request_form->getElement('cid')->setMultiOptions($options);
     $options = NULL;
     $material_model = new Application_Model_Materials();
     $materials = $material_model->listMaterials();
     for ($i = 0; $i < count($materials); $i++) {
         $options[$materials[$i]['id']] = $materials[$i]['name'];
     }
     $material_request_form->getElement('mid')->setMultiOptions($options);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $model = new Application_Model_Requests();
             $form->getElement("uid")->setValue(2);
             //session
             $form->getElement("rdate")->setValue(date('Y-m-d'));
             $form->reset();
         }
     }
     $this->view->course_request_form = $course_request_form;
     $this->view->material_request_form = $material_request_form;
     //}
     //else { $this->_redirect("/user/login"); }
 }
Ejemplo n.º 6
0
 public function emailExistsAction()
 {
     if ($email = $this->getRequest()->getParam('email')) {
         $users = new Application_Model_Users();
         $user = $users->getUserBy('email', $email);
         if ($user) {
             $result = true;
         }
     }
     $this->view->result = isset($result) ? $result : false;
     $this->render('boolean-result');
 }
Ejemplo n.º 7
0
 public function displayAction()
 {
     if (isset($this->authIdentity)) {
         $id = $this->getRequest()->getParam('name');
         if (!empty($this->authIdentity->intrestedlists[$id])) {
             $userids = explode(',', $this->authIdentity->interestedlists[$id]);
             $activityModel = new Application_Model_Activity($this->registry->DB);
             $this->view->results = $activityModel->getStreams($userids);
             $userModel = new Application_Model_Users($this->registry->DB);
             $this->view->users = $userModel->getminiprofile($userids);
         }
     }
 }
Ejemplo n.º 8
0
 public function createleafaccountAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     //$username=$this->getRequest()->getParam('username');
     $password = $this->getRequest()->getParam('password');
     $email = $this->getRequest()->getParam('email');
     $dd = $this->getRequest()->getParam('dd');
     $dm = $this->getRequest()->getParam('dm');
     $dy = $this->getRequest()->getParam('dy');
     $dob = $dy . '-' . $dm . '-' . $dd;
     $create = new Application_Model_Users($this->registry['DB']);
     $finis = $create->CreateUserAccount(null, $password, null, null, $email, null, $dob, 'none');
     echo json_encode($finis);
 }
Ejemplo n.º 9
0
 public static function getInstance()
 {
     if (!is_object(self::$_instance)) {
         self::$_instance = new Application_Model_Users();
     }
     return self::$_instance;
 }
Ejemplo n.º 10
0
 public function registerAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $db = Zend_Db_Table::getDefaultAdapter();
     $users = new Application_Model_Users();
     $registerForm = new Application_Form_Registration();
     if ($this->_request->isPost()) {
         foreach ($this->_request->getPost('dataPost') as $dataArray) {
             $name = $dataArray['name'];
             $formDataForValidation["{$name}"] = $dataArray['value'];
         }
         if ($formDataForValidation['driverCheck'] === "1") {
             $carModel = $registerForm->getElement('carModel');
             $carModel->setRequired(true)->addErrorMessage('Required');
             $carMake = $registerForm->getElement('carMake');
             $carMake->setRequired(true)->addErrorMessage('Required');
             $driverLicense = $registerForm->getElement('driverLicense');
             $driverLicense->setRequired(true)->addErrorMessage('Required');
         }
         if ($registerForm->isValid($formDataForValidation)) {
             $userDataInsert = array('id' => null, 'email' => $formDataForValidation['emailRegister'], 'password' => $formDataForValidation['passwordRegister'], 'last_name' => $formDataForValidation['lastName'], 'first_name' => $formDataForValidation['firstName'], 'driver_flag' => $formDataForValidation['driverCheck'], 'telephone' => $formDataForValidation['telephone']);
             try {
                 $db->insert($users->getTableName(), $userDataInsert);
                 $last_id = $users->getAdapter()->lastInsertId();
             } catch (Zend_Exception $e) {
                 $this->redirect('/error/error');
             }
             if ($formDataForValidation['driverCheck']) {
                 //if the user is a driver => need to update driver data
                 $driver = new Application_Model_Driver();
                 $driverDataInsert = array('id' => null, 'user_id' => $last_id, 'make' => $formDataForValidation['carMake'], 'model' => $formDataForValidation['carModel'], 'license' => $formDataForValidation['driverLicense'], 'completed' => 0);
                 try {
                     $db->insert($driver->getTableName(), $driverDataInsert);
                 } catch (Zend_Exception $e) {
                     $this->redirect('/error/error');
                 }
             }
             $this->_helper->json(0);
         } else {
             $errorMessages = $registerForm->getMessages();
             $this->_helper->json($errorMessages);
         }
     }
 }
Ejemplo n.º 11
0
 public function registerAction()
 {
     $form = new Application_Form_RegistrationForm();
     $users = new Application_Model_Users();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             if ($data['password'] != $data['confirmPassword']) {
                 $this->view->errorMessage = "Password and confirm password don't match.";
                 return;
             }
             unset($data['confirmPassword']);
             $users->insert($data);
             $this->_redirect('authentification/login');
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 12
0
 public static function login($login, $senha)
 {
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     //Inicia o adaptador Zend_Auth para banco de dados
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('users')->setIdentityColumn('login')->setCredentialColumn('password')->setCredentialTreatment('SHA1(?)');
     //Define os dados para processar o login
     $authAdapter->setIdentity($login)->setCredential($senha);
     //Faz inner join dos dados do perfil no SELECT do Auth_Adapter
     $select = $authAdapter->getDbSelect();
     $select->join('roles', 'roles.id_role = users.id_role', array('role_roles' => 'role', 'id_role'));
     //Efetua o login
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     //Verifica se o login foi efetuado com sucesso
     if ($result->isValid()) {
         //Recupera o objeto do usuário, sem a senha
         $info = $authAdapter->getResultRowObject(null, 'password');
         $usuario = new Application_Model_Users();
         $usuario->setFullName($info->nome);
         $usuario->setUserName($info->login);
         $usuario->setRoleId($info->role_roles);
         $usuario->setRoleCod($info->id_role);
         $storage = $auth->getStorage();
         $storage->write($usuario);
         return true;
     }
     throw new Exception('Nome de usuário ou senha inválida');
 }
Ejemplo n.º 13
0
 public function edituserAction()
 {
     if ($role != 2) {
         $this->_redirect('/');
     }
     $ID = $this->_getParam('i');
     $db = new Application_Model_Users();
     $user = $db->find(intval($ID))[0];
     $this->view->user = $user;
     $form = new Application_Form_EditUserForm();
     $this->view->form = $form;
     $form->populate(array('email' => $user->email, 'role' => Application_Model_Users::getRole($user->role)));
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $where = $db->getAdapter()->quoteInto('ID = ?', $user->ID);
             $db->update($data, $where);
             $this->_redirect('/pages/dashboard');
             $this->view->message = "Successfully updated";
         }
     }
 }
Ejemplo n.º 14
0
 public function myroutesAction()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $routes = new Application_Model_Routes();
     $users = new Application_Model_Users();
     $bind = new Application_Model_Bind();
     $query = $db->select()->from($routes->getTableName());
     $query->join($users->getTableName(), $routes->getTableName() . '.driver_id = ' . $users->getTableName() . '.id');
     //        $query->join($drivers->getTableName(),
     //                $users->getTableName().'.id = '.$drivers->getTableName().'.user_id');
     $query->where($users->getTableName() . '.id = ?', $this->user->id);
     $results = $db->fetchAll($query);
     $this->view->results = $results;
     $query2 = $db->select()->from($users->getTableName(), array('driver_flag'));
     $query2->where($users->getTableName() . '.id = ?', $this->user->id);
     $driver = $db->fetchOne($query2);
     $query3 = $db->select()->from($routes->getTableName());
     $query3->join($bind->getTableName(), $routes->getTableName() . '.route_id = ' . $bind->getTableName() . '.route_id');
     $query3->where($bind->getTableName() . '.user_id = ?', $this->user->id);
     $passangers = $db->fetchAll($query3);
     $this->view->results = $results;
     $this->view->driver = $driver;
     $this->view->passangerResults = $passangers;
 }
Ejemplo n.º 15
0
 public function settings(Application_Model_Users $user)
 {
     $data = array('user' => $user->getUser(), 'key' => base64_encode($user->getKey()), 'secret' => base64_encode($user->getSecret()), 'cid' => $user->getCid());
     $this->getDbTable()->update($data, array('user = ?' => $user->getUser()));
 }
Ejemplo n.º 16
0
 public function createLeaf($pagename, $type, $category, $subcategory, $songurl = null)
 {
     $types = array('default', 'basic', 'standard', 'premium', 'songs', 'video');
     if (isset($this->authIdentity) && in_array($type, $types) && !empty($pagename) && !empty($category) && !empty($subcategory)) {
         $rand = mt_rand() . "_" . mt_rand();
         $a = array();
         if (strlen($rand) > 25) {
             $rand = substr($rand, 0, 25);
         }
         $admins = array($this->authIdentity->userid);
         $votes = array($this->authIdentity->userid);
         $creator = $this->authIdentity->userid;
         if ($type == 'default' || $type == 'places') {
             $creator = 'default';
             $admins = array('default');
         }
         $admins = serialize($admins);
         $votes = serialize($votes);
         switch ($category) {
             case 'musics':
                 $propic = 3;
                 break;
             case 'movies':
                 $propic = 13;
                 break;
             case 'celebrities':
                 $propic = 12;
                 break;
             case 'books':
                 $propic = 5;
                 break;
             case 'sports':
                 $propic = 6;
                 break;
             case 'games':
                 $propic = 7;
                 break;
             default:
                 $propic = 8;
         }
         $freniz_data = array('userid' => 'leaf_' . $rand, 'type' => 'page', 'url' => 'leaf_' . $rand, 'adminpages' => 'a:0:{}', 'username' => $pagename, 'propic' => $propic);
         $pages_data = array('pageid' => 'leaf_' . $rand, 'pagename' => $pagename, 'type' => $type, 'category' => $category, 'subcategory' => $subcategory, 'creator' => $creator, 'admins' => $admins, 'vote' => $votes, 'date' => new Zend_Db_Expr('now()'), 'url' => 'leaf_' . $rand, 'bannedusers' => 'a:0:{}', 'pagepic' => $propic);
         $pagesinfo_data = array('pageid' => 'leaf_' . $rand, 'info' => 'a:0:{}', 'tabs' => 'a:0:{}', 'tags' => 'a:0:{}', 'ratings' => 'a:0:{}');
         if ($type == 'songs' && isset($songurl)) {
             $pagesinfo_data['songurl'] = $songurl;
         }
         $this->_db->insert('freniz', $freniz_data);
         $this->_db->insert('pages', $pages_data);
         if (!($type == 'default' || $type == 'places')) {
             array_push($this->authIdentity->adminpages, 'leaf_' . $rand);
             $this->_db->update('freniz', array('adminpages' => serialize($this->authIdentity->adminpages)), array('userid=?' => $this->authIdentity->userid));
             $this->_db->update('user_info', array('adminpages' => serialize($this->authIdentity->adminpages)), array('userid=?' => $this->authIdentity->userid));
             $this->_db->insert('pages_info', $pagesinfo_data);
             $AlbumModel = new Application_Model_Album($this->_db);
             $UserModel = new Application_Model_Users($this->_db);
             $pagepicalbum = $UserModel->createAlbumData('leaf_' . $rand, 'Page Pics');
             $banners = $UserModel->createAlbumData('leaf_' . $rand, 'Banners');
             $chartpic = $UserModel->createAlbumData('leaf_' . $rand, 'Chart Pics', true, true);
             $pagepicAlbumid = $AlbumModel->insert($pagepicalbum);
             $bannersAlbum = $AlbumModel->insert($banners);
             $chartpicAlbum = $AlbumModel->insert($chartpic);
             $this->update(array('pagepicalbum' => $pagepicAlbumid, 'banners' => $bannersAlbum), array('pageid=?' => 'leaf_' . $rand));
         }
         //$user=array('userid'=>'leaf_'.$rand,'type'=>'page','username'=>$pagename,'user_url'=>'leaf_'.$rand,'pagepic_url'=>'default_page.jpg','page_vote'=>$votes,'category'=>$category,'subcategory'=>$subcategory,'bids'=>0);
         //$usersModel=new Application_Model_Users($this->_db);
         $search = array('userid' => 'leaf_' . $rand, 'type' => 'page', 'username' => $pagename);
         $this->_db->insert('searchtable', $search);
         //$usersModel->buildusers(array('leaf_'.$rand=>$user));
         return 'leaf_' . $rand;
     } else {
         return false;
     }
 }
Ejemplo n.º 17
0
 public function saveAction()
 {
     //read the json format post from angularjs
     $postdata = file_get_contents("php://input");
     $post = json_decode($postdata, true);
     $map = $post['map'];
     $target = $post['target'];
     $password = $post['password'];
     $status = $post['status'];
     //read file from the upload directory
     //send 'true' as all entries should be processed
     $data = $this->readFile($target);
     if (array_key_exists('error', $data) || !array_key_exists('data', $data)) {
         $error = ['error' => 'File is corrupted'];
         $this->_helper->json($error);
         exit;
     }
     $data = $this->sanitize($data['data']);
     $pointer = 0;
     $counter = 0;
     try {
         foreach ($data as $user) {
             //combine with keys from mapping
             $user = array_combine($map, $user);
             //set up doctrine model
             $model = new Application_Model_Users();
             //if required data is missing, return error
             if (empty($user['firstname']) || empty($user['lastname']) || empty($user['email'])) {
                 $error = ['error' => 'Required Field is missing from data'];
                 $this->_helper->json($error);
                 exit;
             }
             //populate required field
             $model->setFirstname($user['firstname']);
             $model->setLastname($user['lastname']);
             $model->setEmail($user['email']);
             //fillup password and status. If not found, enter with default value
             if (!empty($user['password'])) {
                 $model->setPassword($user['password']);
             } else {
                 $model->setPassword($password);
             }
             if (!empty($user['status'])) {
                 $model->setStatus($user['status']);
             } else {
                 $model->setStatus($status);
             }
             //populate optional fields: optional fields. check both keys and values
             if (array_key_exists('country', $user) && $user['country']) {
                 $model->setCountry($user['country']);
             }
             if (array_key_exists('city', $user) && $user['city']) {
                 $model->setCity($user['city']);
             }
             if (array_key_exists('address', $user) && $user['address']) {
                 $model->setAddress($user['address']);
             }
             //persist the data
             $this->em->persist($model);
             $pointer++;
             $counter++;
             //bulk saving by 20
             if ($pointer == 20) {
                 $pointer = 0;
                 $this->em->flush();
             }
         }
         //final batch save
         $this->em->flush();
     } catch (Exception $e) {
         $error = ['error' => 'Database entry failed'];
         $this->_helper->json($error);
         exit;
     }
     $this->_helper->json(['success' => $counter]);
     exit;
 }
Ejemplo n.º 18
0
 public function switchAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $id = trim($this->getRequest()->getParam('id'));
     if (isset($this->authidentity) && $this->authidentity->userid != $id) {
         $userModel = new Application_Model_Users($this->registry->DB);
         $userModel->switchUser($id);
         echo json_encode(array('status' => 'success'));
     } else {
         echo json_encode(array('status' => 'error'));
     }
 }
 public function registerAction()
 {
     $request = $this->getRequest();
     $usersMapper = new Application_Model_UsersMapper();
     $userWalletMapper = new Application_Model_UserWalletMapper();
     $userWallet = new Application_Model_UserWallet();
     $request_type = $request->getParam("request_type", FALSE);
     $referred_by = $request->getParam("refer", FALSE);
     if ($referred_by) {
         $user = $usersMapper->getUserByEmail($referred_by);
         $user_id = $user->__get("user_id");
     } else {
         $user_id = 0;
     }
     $this->view->user_id = $user_id;
     $usersMapper = new Application_Model_UsersMapper();
     $users = new Application_Model_Users();
     if ($request_type) {
         if ($request_type == "register") {
             $user_fname = $request->getParam("user_fname");
             $user_lname = $request->getParam("user_lname");
             $user_email = $request->getParam("user_email");
             $password = $request->getParam("hashed_password");
             $cpassword = $request->getParam("cpassword");
             $user_number = $request->getParam("user_number");
             $user_address = $request->getParam("user_address");
             $user_locality = $request->getParam("user_locality");
             $user_landmark = $request->getParam("user_landmark");
             $user_city = $request->getParam("user_city");
             $user_state = $request->getParam("user_state");
             $user_country = $request->getParam("user_country");
             $reference_email = $request->getParam("refer");
             $errors = array();
             if (empty($user_fname)) {
                 $errors[] = "First Name Should Not Be Empty";
             }
             if (empty($user_lname)) {
                 $errors[] = "Last Name Should Not Be Empty";
             }
             if (empty($user_email)) {
                 $errors[] = "Email Should Not Be Empty";
             }
             if (empty($password)) {
                 $errors[] = "Password Should Not Be EMpty";
             }
             if (empty($cpassword)) {
                 $errors[] = "Confirm Password Should Not Be Empty";
             }
             if (empty($user_number)) {
                 $errors[] = "Number Should Not Be Empty";
             }
             if (empty($user_address)) {
                 $errors[] = "Address Should Not Be Empty";
             }
             if (empty($user_city)) {
                 $errors[] = "City Should Not Be Empty";
             }
             if (empty($user_state)) {
                 $errors[] = "State Should Not Be Empty";
             }
             if (empty($user_country)) {
                 $errors[] = "Country Should Not Be Empty";
             }
             if ($password != $cpassword) {
                 $errors[] = "Password Did Not Match";
             }
             if ($user_number < 10 && $user_number > 10) {
                 $errors[] = "Phone Number Should Be of 10 Digits";
             }
             $emailValidator = new Zend_Validate_EmailAddress();
             if (!$emailValidator->isValid($user_email)) {
                 $errors[] = "Email address not valid";
             }
             $options = array("table" => "users", "field" => "user_email");
             $recordValidation = new Zend_Validate_Db_RecordExists($options);
             if ($recordValidation->isValid($user_email)) {
                 $errors[] = "Email address already in use";
             }
             $hashed_password = sha1($password);
             if (count($errors) == 0) {
                 $users->__set("user_fname", $user_fname);
                 $users->__set("user_lname", $user_lname);
                 $users->__set("user_email", $user_email);
                 $users->__set("user_number", $user_number);
                 $users->__set("hashed_password", $hashed_password);
                 $users->__set("user_address", $user_address);
                 if ($user_locality) {
                     $users->__set("user_locality", $user_locality);
                 } else {
                     $users->__set("user_locality", "");
                 }
                 if ($user_landmark) {
                     $users->__set("user_landmark", $user_landmark);
                 } else {
                     $users->__set("user_landmark", "");
                 }
                 $users->__set("user_city", $user_city);
                 $users->__set("user_state", $user_state);
                 $users->__set("user_country", $user_country);
                 $users->__set("user_fb_id", "");
                 if ($reference_email) {
                     $new_user = $usersMapper->getUserByEmail($reference_email);
                     if ($new_user) {
                         $users->__set("referred_by", $new_user->__get("user_id"));
                     }
                 }
                 $user_id = $usersMapper->addNewUser($users);
                 if ($reference_email) {
                     $new_user = $usersMapper->getUserByEmail($reference_email);
                     if ($new_user) {
                         $reference_by = $new_user->__get("user_id");
                         $userWallet->__set("user_id", $reference_by);
                         $userWallet->__set("entry_type", "CREDIT");
                         $userWallet->__set("entry_amount", "100");
                         $userWalletMapper->addNewUserWallet($userWallet);
                         $userWallet->__set("user_id", $user_id);
                         $userWalletMapper->addNewUserWallet($userWallet);
                     }
                 }
                 $subject = "Hi " . $user_fname . " " . $user_lname . ", Welcome to Laundry Wala";
                 $message = "Dear " . $user_fname . " " . $user_lname . ",<br/><br/>\n                            Greetings From LaundryWala.<br/><br/>\n                            Thanks for registering with us and choosing us as your preferred laundry service.</strong><br/><br/>\n                            We offer affordable and professional laundry service at the convenience of your doorstep.<br/><br/>\n                            Do login to our website www.laundrywala.co.in for more details about us.<br/><br/>\n                            Look forward to being of service to you.<br/><br/>\n                            Best regards,<br/><br/>\n                            Customer Care Team<br/><br/>\n                            LaundryWala<br/><br/>";
                 $result = $this->_newForgotPasswordNotification($user_email, $subject, $message);
                 $result1 = $this->_newForgotPasswordNotification("*****@*****.**", $subject, $message);
                 $sms = "Dear " . $user_fname . ", Welcome to LaundryWala. Do login to our website www.laundrywala.co.in for more details. Look forward to being of service to you. Regards, LaundryWala";
                 $sms_result = $this->_smsNotification($user_number, $sms);
                 if ($user_id && $result && $result1) {
                     $this->view->hasMessage = true;
                     $this->view->messageType = "success";
                     $this->view->message = "User has been added successfully";
                 } else {
                     $this->view->hasMessage = true;
                     $this->view->messageType = "danger";
                     $this->view->message = "Error while adding user";
                 }
             } else {
                 $errorString = "";
                 foreach ($errors as $error) {
                     $errorString .= $error . "<br/>";
                 }
                 $this->view->hasMessage = true;
                 $this->view->messageType = "danger";
                 $this->view->message = $errorString;
             }
         }
     }
 }
Ejemplo n.º 20
0
 public function resendActivationAction()
 {
     $form = new Application_Form_ResendActivation(array('action' => '/sso/account/resend-activation', 'method' => 'post'));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if (!$form->isValid($this->getRequest()->getPost())) {
             // Did not pass validation...
             $this->view->form = $form;
             return $this->render('resend-activation');
         }
         $users = new Application_Model_Users();
         try {
             $user = $users->getUserBy('email', $form->getValue('email'));
         } catch (Exception $e) {
             if (!($error = $e->getMessage())) {
                 $error = 'Sorry, an error occurred while finding your account. Please try again.';
             }
             $this->view->messages = array($error);
             return $this->render('resend-activation');
         }
         //print_r((array) $user->toArray());exit;
         if ($user) {
             if ($user->email_confirmed) {
                 $form->addError('Your account has already been activated.');
             } else {
                 $this->sendActivationEmail($user);
                 return $this->render('resent-activation');
             }
         } else {
             $form->addError('There is no account with this email address.');
         }
         return $this->render('resend-activation');
     } else {
         $this->render('resend-activation');
     }
 }
 public function forgotPasswordAction()
 {
     $response = new stdClass();
     if ($this->getRequest()->isPost()) {
         $users = Application_Model_Users::getInstance();
         $mailer = Engine_Mailer_MandrillApp_Mailer::getInstance();
         $method = $this->getRequest()->getPost('method');
         switch ($method) {
             case "EnterEmailId":
                 if ($this->getRequest()->isPost()) {
                     $postData = $this->getRequest()->getParams();
                     $fpwemail = '';
                     if (isset($postData['EmailId'])) {
                         $fpwemail = $postData['EmailId'];
                     }
                     if ($fpwemail != '') {
                         $resetcode = mt_rand(100000, 999999);
                         $exists = $users->checkMail($fpwemail, $resetcode);
                         $uname = $exists['uname'];
                         if ($exists) {
                             //Mandrill mail
                             $template_name = 'ResetPW';
                             $to = $fpwemail;
                             $username = "******";
                             $subject = "Ziingo Reset password";
                             $mergevars = array(array('name' => 'resetcode', 'content' => $resetcode), array('name' => 'usermail', 'content' => $fpwemail), array('name' => 'support', 'content' => "Ziingo Support"));
                             $result = $mailer->sendtemplate($template_name, $to, $username, $subject, $mergevars);
                             //Mandrill mail ends
                             if ($result[0]['status'] == "sent") {
                                 //                                if (true) {
                                 $response->code = 200;
                                 $response->message = "Mail Sent with Reset code";
                                 $response->data = 1;
                             }
                         } else {
                             $response->code = 100;
                             $response->message = "Email Doesnt Exist. Enter correct Email.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 100;
                         $response->message = "You missed something";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             case "verifyResetCode":
                 if ($this->getRequest()->isPost()) {
                     $postData = $this->getRequest()->getParams();
                     $fpwemail = '';
                     if (isset($postData['EmailId'])) {
                         $fpwemail = $postData['EmailId'];
                     }
                     $resetcode = '';
                     if (isset($postData['resetcode'])) {
                         $resetcode = $postData['resetcode'];
                     }
                     if ($fpwemail != '' && $resetcode != '') {
                         $exists = $users->verifyResetCode($fpwemail, $resetcode);
                         if ($exists) {
                             $response->code = 200;
                             $response->message = "Reset Code Verified Successfully.";
                             $response->data = $exists;
                         } else {
                             $response->code = 100;
                             $response->message = "Reset Code Didnt Matched, Enter Correct Reset Code.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 100;
                         $response->message = "You missed something";
                         $response->data = null;
                     }
                     //                        } else {
                     //                            $response->code = 401;
                     //                            $response->message = "Access Denied";
                     //                            $response->data = null;
                     //                        }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             case "resetPassword":
                 if ($this->getRequest()->isPost()) {
                     $postData = $this->getRequest()->getParams();
                     $fpwemail = '';
                     if (isset($postData['EmailId'])) {
                         $fpwemail = $postData['EmailId'];
                     }
                     $resetcode = '';
                     if (isset($postData['resetcode'])) {
                         $resetcode = $postData['resetcode'];
                     }
                     $password = '';
                     //Send Password in md5 format
                     if (isset($postData['Password'])) {
                         $password = $postData['Password'];
                     }
                     $re_password = '';
                     if (isset($postData['rePassword'])) {
                         $re_password = $postData['rePassword'];
                     }
                     if ($fpwemail != '' && $resetcode != '' && $password != '' && $re_password != '') {
                         if ($password == $re_password) {
                             $updated = $users->resetPassword($fpwemail, $resetcode, $password);
                             if ($updated) {
                                 $response->code = 200;
                                 $response->message = "Password Changed Successfully.";
                                 $response->data = $updated;
                             } else {
                                 $response->code = 100;
                                 $response->message = "Something went Wrong. Provide Correct Input.";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 100;
                             $response->message = "Password Didnt match";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 100;
                         $response->message = "You missed something";
                         $response->data = null;
                     }
                     //                        } else {
                     //                            $response->code = 401;
                     //                            $response->message = "Access Denied";
                     //                            $response->data = null;
                     //                        }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             default:
                 break;
         }
     }
 }
Ejemplo n.º 22
0
 public function getListsDetail($id)
 {
     $result = $this->find($id);
     if ($result[0]) {
         $result = $result[0]->toArray();
         if ($result['userid'] == $this->authIdentity->userid) {
             $usersList = unserialize($result['listitems']);
             $result['listitems'] = $usersList;
             if (!empty($usersList)) {
                 $users = new Application_Model_Users($this->_db);
                 $result['userpro'] = $users->getminiprofile($usersList);
             }
             return $result;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function userAccountSettingsAction()
 {
     $users = Application_Model_Users::getInstance();
     $response = new stdClass();
     $method = $this->getRequest()->getParam('method');
     if ($method) {
         switch ($method) {
             case 'changepassword':
                 if ($this->getRequest()->isPost()) {
                     $postData = $this->getRequest()->getParams();
                     $userId = "";
                     if (isset($postData['user_id'])) {
                         $userId = $postData['user_id'];
                     }
                     $oldpassword = "";
                     //SEND ALL 3 PASSWORDS WITH MD5 FORMAT WHILE HITTING URL
                     if (isset($postData['oldPassword'])) {
                         $oldpassword = $postData['oldPassword'];
                     }
                     $newpassword = "";
                     if (isset($postData['newPassword'])) {
                         $newpassword = $postData['newPassword'];
                     }
                     $renewpassword = "";
                     if (isset($postData['reNewPassword'])) {
                         $renewpassword = $postData['reNewPassword'];
                     }
                     if ($userId != '') {
                         $checkoldPassword = $users->authenticateByUserID($userId, md5(sha1($oldpassword)));
                         if ($checkoldPassword) {
                             if ($oldpassword != '' && $newpassword != '' && $renewpassword != '') {
                                 if ($newpassword == $renewpassword) {
                                     if ($oldpassword != $newpassword) {
                                         $Updatepassword = $users->updateUserCreds($userId, $newpassword);
                                         if ($Updatepassword) {
                                             $response->code = 200;
                                             $response->message = "Update Successful";
                                             $response->data = $Updatepassword;
                                         } else {
                                             $response->code = 100;
                                             $response->message = "Invalid Password format";
                                             $response->data = null;
                                         }
                                     } else {
                                         $response->code = 100;
                                         $response->message = "New password cannot be same as old password";
                                         $response->data = null;
                                     }
                                 } else {
                                     $response->code = 100;
                                     $response->message = "Password didnot match";
                                     $response->data = null;
                                 }
                             } else {
                                 $response->code = 100;
                                 $response->message = "You missed something";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 401;
                             $response->message = "Your old Passowrd is incorrect";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "You need to login to change password";
                         $response->data = null;
                     }
                     echo json_encode($response, true);
                     break;
                 }
         }
     }
 }
Ejemplo n.º 24
0
 private function getUsersForDept($workgroup_id, $format = 'FMIL')
 {
     $users = Application_Model_Users::getWorkgroupUsers($workgroup_id);
     return ProNav_Utils::getSelectOptions($users, 'user_id', $format);
 }
Ejemplo n.º 25
0
 public function createFromExternalAction()
 {
     //@todo check if the user isn't already logged in with a local account - redirect to account home if so
     $auth = Zend_Auth::getInstance();
     $authSess = new Zend_Session_Namespace('Auth');
     $identity = $auth->getIdentity();
     $external = $authSess->external;
     $users = new Application_Model_Users();
     //if(!isset($authData['identity']) || !isset($authData['properties']) || !isset($authData['properties']['email']) || !isset($authData['provider']))
     //	throw Exception('Invalid auth data');
     $form = new Application_Form_RegisterFromExternal();
     $form->setAction($this->_helper->url('create-from-external'));
     if ($this->getRequest()->isPost()) {
         if (!$form->isValid($this->getRequest()->getPost())) {
             // Did not pass validation...
             $this->view->form = $form;
             return $this->render();
         }
         $values = $form->getValues();
         /*array_merge(
          		$form->getValues(),
          		array(
          			'email'=>$external['properties']['email']
          		)
          	);*/
         //if(!isset($values['email']) || !isset($values['username']))
         //  throw new Exception('Email or username not supplied');
         if (!isset($external['provider']) || !isset($external['identity'])) {
             throw new Exception('Email or username not supplied');
         }
         //check for local with matching email
         if (!($user = $users->getUserBy('email', $values['email']))) {
             //no local user with matching email, create new local user
             try {
                 //create new user
                 $user = $users->createUser($values);
                 //email user their password
                 if (isset($user->email)) {
                     $email = $user->email;
                     $email_to = $user->display_name ?: $user->username;
                     $password = $values['password'];
                     $subject = $email_to . ', you logged in to Practical Plants';
                     $html = '<h1>Hello ' . $email_to . ', thanks for logging in to Practical Plants</h1>' . '<p>You logged in using ' . $external['provider'] . '</p>' . '<p>Next time you log in, either use ' . $external['provider'] . ', or you can login using the account details you just chose: </p>' . '<blockquote><p>Email: ' . $email . '</p>' . '<p>Password: '******'</p></blockquote>' . '<p>If you have any questions, drop by the <a href="http://practicalplants.org/community">Community Forums</a> or email us: hello@practicalplants.org</p>';
                     $text = "Hello {$email_to}, thanks for logging in to Practical Plants\n" . "You logged in using {$external['provider']}.\n" . "Next time you log in, either use {$external['provider']}, or you can login using the account details you just chose: \n" . "\tEmail: {$email}\n" . "\tPassword: {$password}\n" . "If you have any questions, drop by the Community Forums (http://practicalplants.org/community) or email us: hello@practicalplants.org";
                     $this->sendMail($email_to, $email, $html, $text, $subject);
                 }
                 $users->setUserActive($user);
                 //set email confirmed and active, we trust the external authentication service
                 $auths = new Application_Model_User_Authentications();
                 //associate the users external authentication with the local user
                 $auths->addAuthentication($user, $external['provider'], $external['identity']);
                 //add local user to session
                 $authSess->user = $user->toArray();
                 //update auth identity to email address (used for local auth)
                 $auth->getStorage()->write($user->email);
                 //tell integrated services we've logged in
                 $integrations = new Application_Model_Integrations();
                 $integrations->onAuthenticate();
                 //show success message
                 $this->view->external_provider = $authSess->external['provider'];
                 return $this->render('external-user-created');
             } catch (Exception $e) {
                 //print_r($values);
                 if (!($error = $e->getMessage())) {
                     $error = 'Sorry, an error occurred while creating your account. Please try again.';
                 }
                 $this->view->message = $error;
                 return $this->render('error');
             }
         } else {
             $this->view->message = 'Cannot create user. User with the email address ' . $values['email'] . ' already exists.';
             return $this->render('error');
         }
     } else {
         if (isset($authSess->external)) {
             $props = $authSess->external['properties'];
             if (isset($props['name'])) {
                 $props['display_name'] = $props['name'];
             }
             if (isset($props['screen_name'])) {
                 $props['username'] = $props['screen_name'];
             }
             $fields = array_keys($form->getValues());
             $populate = array();
             foreach ($props as $k => $v) {
                 if (in_array($k, $fields)) {
                     $populate[$k] = $v;
                 }
             }
             $form->populate($populate);
             $this->view->form = $form;
         } else {
             throw Exception('No external authentication data.');
         }
     }
 }
Ejemplo n.º 26
0
 public function listAction()
 {
     $authorization = Zend_Auth::getInstance();
     $identity = $authorization->getIdentity();
     if ($identity->user_type == "admin") {
         $user_model = new Application_Model_Users();
         $users = $user_model->listUsers();
         //$page=$this->_getParam('page',1);
         //$paginator = Zend_Paginator::factory($courses);
         // $paginator->setItemCountPerPage(10);
         //$paginator->setCurrentPageNumber($page);
         $this->view->users = $users;
     } else {
         $this->view->user_msg = "The page not allowed for normal user.";
         $this->_redirect("/users/login");
     }
 }
 public function hotelsReviewsAction()
 {
     $users = Application_Model_Users::getInstance();
     $reviewsratings = Application_Model_Reviews::getInstance();
     $hotelssummaryModel = Application_Model_HotelDetails::getInstance();
     $response = new stdClass();
     $method = $this->getRequest()->getParam('method');
     if ($method) {
         switch ($method) {
             case 'AddReviews':
                 if ($this->getRequest()->isPost()) {
                     $userid = $this->getRequest()->getPost('user_id');
                     $starratings = $this->getRequest()->getPost('star_rating');
                     $reviewdesc = $this->getRequest()->getPost('review_desc');
                     $hotelid = $this->getRequest()->getPost('hotel_id');
                     if ($userid != '') {
                         $Userscredentials = $users->validateByUserId($userid);
                         if ($Userscredentials) {
                             if ($hotelid != '' && $reviewdesc != '' && $starratings != '') {
                                 $addReview = $reviewsratings->isavailablereview($hotelid, $userid);
                                 if (empty($addReview)) {
                                     $data['user_id'] = $userid;
                                     $data['review_type'] = 0;
                                     $data['review_for_id'] = $hotelid;
                                     $data['review_rating'] = $starratings;
                                     $data['review_description'] = $reviewdesc;
                                     $data['review_status'] = 0;
                                     $addReview = $reviewsratings->addReview($data);
                                     if ($addReview) {
                                         $avgofStarRatings = $reviewsratings->getavgratingsofindividualHotel($hotelid);
                                         if ($avgofStarRatings) {
                                             $addavgRatetoindividualshotels = $hotelssummaryModel->updatehotels($hotelid, $avgofStarRatings);
                                             $Admincredentials = $users->validateByAdminId(2);
                                             if ($Admincredentials != '') {
                                                 $admin_id = $Admincredentials['user_id'];
                                                 $objNotification = Engine_Plugins_Functions::getInstance();
                                                 $sent_by = $userid;
                                                 $sent_to = $admin_id;
                                                 $noti_url = "/admin/notification";
                                                 $Noti_message = "New Review for Product is pending for You";
                                                 $addNotification = $objNotification->sendNotificationWithUrl($sent_by, $sent_to, $Noti_message, $noti_url);
                                             }
                                             $response->code = 200;
                                             $response->message = "Review Successfully Added";
                                             $response->data = $addReview;
                                         } else {
                                             $response->code = 100;
                                             $response->message = "Something went wrong";
                                             $response->data = null;
                                         }
                                     } else {
                                         $response->code = 100;
                                         $response->message = "Something went wrong..Review Not added, Try again.";
                                         $response->data = null;
                                     }
                                 } else {
                                     $response->code = 100;
                                     $response->message = "Review Already Added, You can add one review to one product.";
                                     $response->data = $addReview;
                                 }
                             } else {
                                 $response->code = 100;
                                 $response->message = "You missed something.";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 100;
                             $response->message = "Their is No user for this ID.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 100;
                         $response->message = "You need to login to Add Review.";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Access Denied";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 die;
                 break;
             case 'getReviews':
                 if ($this->getRequest()->isPost()) {
                     $hotelid = $this->getRequest()->getPost('hotel_id');
                     if ($hotelid != '') {
                         $hotelReviewDetails = $reviewsratings->gethotelsReviewsWithLimit($hotelid);
                         if ($hotelReviewDetails) {
                             $response->code = 200;
                             $response->message = "Suiccessful";
                             $response->data = $hotelReviewDetails;
                         } else {
                             $response->code = 200;
                             $response->message = "Something went wrong";
                         }
                     } else {
                         $response->code = 200;
                         $response->message = "Hotel ID should not be Null";
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 die;
                 break;
         }
     }
 }
Ejemplo n.º 28
0
 public function updateUser(Application_Model_Users $user)
 {
     $data = array("user_fname" => $user->__get("user_fname"), "user_lname" => $user->__get("user_lname"), "user_email" => $user->__get("user_email"), "hashed_password" => $user->__get("hashed_password"), "user_fb_id" => $user->__get("user_fb_id"), "user_address" => $user->__get("user_address"), "user_address_additional" => $user->__get("user_address_additional"), "user_number" => $user->__get("user_number"), "user_locality" => $user->__get("user_locality"), "user_landmark" => $user->__get("user_landmark"), "user_city" => $user->__get("user_city"), "user_state" => $user->__get("user_state"), "user_country" => $user->__get("user_country"), "reset_code" => $user->__get("reset_code"), "referred_by" => $user->__get("referred_by"));
     $where = array("user_id = ?" => $user->__get("user_id"));
     try {
         $updated_records = $this->_db_table->update($data, $where);
         return (object) array("success" => true, "error" => false, "message" => "Record Successfully Updated", "row_affected" => $updated_records);
     } catch (Zend_Exception $e) {
         /* Handle Exception Here  */
         return (object) array("success" => false, "error" => true, "message" => $e->getMessage(), "exception" => true, "exception_code" => $e->getCode());
     }
 }
Ejemplo n.º 29
0
 public function getminiprofileAction()
 {
     if ($this->auth->hasIdentity()) {
         $getmini = new Application_Model_Users($this->registry['DB']);
         $ids = $this->getRequest()->getParam('ids');
         $this->view->results = $getmini->getminiprofile($ids);
     }
 }
Ejemplo n.º 30
0
 public function setLocationAction()
 {
     // die("ok");
     $objUserModel = Application_Model_Users::getInstance();
     if ($this->getRequest()->isPost()) {
         $userId = $this->getRequest()->getPost('uid');
         $lat = $this->getRequest()->getPost('lat');
         $lng = $this->getRequest()->getPost('lon');
         $result = $objUserModel->setUserLocation($userId, $lat, $lng);
         if ($result) {
             echo json_encode($result);
         } else {
             return 0;
         }
     } else {
         die("not a post");
     }
 }