Ejemplo n.º 1
0
 public function updateDevoteesList($id, $data)
 {
     $return = "";
     $bootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
     $db = $bootstrap->getPluginResource('db')->getDbAdapter();
     $db->beginTransaction();
     $mstUser = new Application_Model_DbTable_Mstuser();
     $prevUser = $mstUser->getDevoteeList($id, 'CHECKED');
     $logObj = Zend_Json::encode($prevUser);
     try {
         if ($data) {
             //-Delete Devotees-------------
             $uVsDevotees = new Application_Model_DbTable_MstUserVsDevotee();
             $where = $uVsDevotees->getAdapter()->quoteInto('user_id = ?', $id);
             $uVsDevotees->delete($where);
             //-Insert Now
             foreach ($data as $r) {
                 if ($r != 0) {
                     $data = array('user_id' => $id, 'did' => $r);
                     $uVsDevotees->insert($data);
                 }
             }
             Rgm_UserServices::log($id, 'mst_user', 'Devotees list changed', $logObj);
             $db->commit();
             $return = "";
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     } catch (Zend_Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     } catch (Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     }
     return $return;
 }
Ejemplo n.º 2
0
 public function accountsettingsAction()
 {
     $this->getHelper("layout")->setLayout('layout_no_sidebar');
     $messages = '';
     $form = new Application_Form_AccountSetings();
     $form->setAction('accountsettings');
     $form->setMethod('post');
     $this->view->form = $form;
     //Save button pushed in accountsetting page
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('pageId') == 'accountsetings') {
         $valid = true;
         //Validate the form
         if (!$form->isValid($this->getRequest()->getPost())) {
             return;
         }
         //Validate the Security Question
         $country = $this->getRequest()->getPost('country');
         if ($country == 0 || $country == '') {
             $form->getElement('country')->addError('Select country');
             $valid = false;
         }
         $securityQ01 = $this->getRequest()->getPost('securityQ01');
         if ($securityQ01 == 0 || $securityQ01 == '') {
             $form->getElement('securityQ01')->addError('Select a security question');
             $valid = false;
         }
         $securityQ02 = $this->getRequest()->getPost('securityQ02');
         if ($securityQ02 == 0 || $securityQ02 == '') {
             $form->getElement('securityQ02')->addError('Select a security question');
             $valid = false;
         }
         if ($securityQ01 != 0 && $securityQ01 != '' && $securityQ01 == $securityQ02) {
             $form->getElement('securityQ01')->addError('Both security questions are identical. Select different one');
             $form->getElement('securityQ02')->addError('Both security questions are identical. Select different one');
             $valid = false;
         }
         if (!$valid) {
             return;
         }
         //Update the useraccount now
         $fName = $this->getRequest()->getPost('fName');
         $mName = $this->getRequest()->getPost('mName');
         $lName = $this->getRequest()->getPost('lName');
         $email = $this->getRequest()->getPost('email');
         $mobile = $this->getRequest()->getPost('mobile');
         $userName = $this->getRequest()->getPost('userName');
         $securityA01 = $this->getRequest()->getPost('securityA01');
         $securityA02 = $this->getRequest()->getPost('securityA02');
         $auth = Zend_Auth::getInstance();
         $authArray = $auth->getIdentity();
         $userid = $authArray['user_id'];
         $mstUser = new Application_Model_DbTable_Mstuser();
         $prevData = Zend_Json::encode($mstUser->findById($userid));
         $data = array('fName' => $fName, 'mName' => $mName, 'lName' => $lName, 'email' => $email, 'country_id' => $country, 'login' => $userName, 'mobile' => $mobile, 'security_question_id01' => $securityQ01, 'security_answer01' => $securityA01, 'security_question_id02' => $securityQ02, 'security_answer02' => $securityA02);
         $result = $mstUser->updatePreliminaryInfo($userid, $data);
         if ($result) {
             if ($result['result'] == 'ok') {
                 $messages = 'Changes saved successfully.';
             } else {
                 if ($result['result'] == 'DUPLICATE_LOGIN') {
                     $messages = 'User id already exists in the database.';
                     $form->getElement('userName')->addError($messages);
                 } else {
                     $messages = 'Error occured while saveing the changes.';
                 }
             }
         }
         Rgm_UserServices::log($userid, 'mst_user', 'Preliminary Information Changed', $prevData);
     } else {
         //Populate the form with default values
         $auth = Zend_Auth::getInstance();
         $authArray = $auth->getIdentity();
         $userid = $authArray['user_id'];
         $mstUser = new Application_Model_DbTable_Mstuser();
         if ($user = $mstUser->findById($userid)) {
             $form->getElement('fName')->setValue($user->first_name);
             $form->getElement('mName')->setValue($user->middle_name);
             $form->getElement('lName')->setValue($user->last_name);
             $form->getElement('userName')->setValue($user->login);
             $form->getElement('email')->setValue($user->email);
             $form->getElement('country')->setValue($user->country_id);
             $form->getElement('mobile')->setValue($user->mobile);
             $form->getElement('securityQ01')->setValue($user->security_question_id01);
             $form->getElement('securityA01')->setValue($user->security_answer01);
             $form->getElement('securityQ02')->setValue($user->security_question_id02);
             $form->getElement('securityA02')->setValue($user->security_answer02);
         }
     }
     $this->view->messages = $messages;
 }