コード例 #1
0
ファイル: User.php プロジェクト: swastikit/devotees
 public function updateAceessList($id, $data)
 {
     $bootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
     $db = $bootstrap->getPluginResource('db')->getDbAdapter();
     $db->beginTransaction();
     $mstUser = new Application_Model_DbTable_Mstuser();
     $prevUser = $mstUser->getActionList($id, 'CHECKED');
     $logObj = Zend_Json::encode($prevUser);
     try {
         if ($data) {
             //-Delete Database-------------
             $uVsMethod = new Application_Model_DbTable_MstUserMethodVsUser();
             $where = $uVsMethod->getAdapter()->quoteInto('user_id = ?', $id);
             $uVsMethod->delete($where);
             //Insert Now
             foreach ($data as $r) {
                 if ($r['checked'] == 'checked') {
                     //insert
                     $data = array('user_id' => $id, 'method_id' => $r['id']);
                     $uVsMethod->insert($data);
                 }
             }
             Rgm_UserServices::log($id, 'mst_user', 'Access list changed', $logObj);
             $db->commit();
             $return = "";
         }
     } catch (Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     }
     return $return;
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: swastikit/devotees
 public function editmoreinfoAction()
 {
     //info=ACCESSES;MENTORS;GURUS;DBS;COUNSELORS;CENTERS;
     $id = $this->_getParam('id');
     $info = $this->_getParam('info');
     $result = new stdClass();
     $result->info = $info;
     $this->view->info = $info;
     $message = '';
     $htmlStringBg = '';
     $error = '';
     if (!$id || !$info) {
         $error = 'Invalid request';
         //*********************************************************************
         return 1;
     }
     $this->view->id = $id;
     $u = new Application_Model_DbTable_Mstuser();
     $htmlString = '';
     /*
      *********************ACTION ASSIGNED TO THE USER*****************************
      */
     if ($info == 'ACCESSES') {
         $do = $this->_getParam('do');
         if ($do == null) {
             //Display the edit actions page
             $list = $u->getActionList($id, 'ALL');
             $this->view->list = $list;
             $menuTbl = new Application_Model_DbTable_MstUserMenuMain();
             $lstModules = $menuTbl->getKeyValues();
             $lstModules = array(0 => 'All') + $lstModules;
             $this->view->lstModules = $lstModules;
             $htmlString = $this->view->render('user/editaccesses.phtml');
         } else {
             if ($do == 'SAVE') {
                 $jSelectedIds = $this->_getParam('jSelectedIds');
                 $actionIds = Zend_Json::decode($jSelectedIds);
                 if ($actionIds != null) {
                     $userModel = new Admin_Model_User();
                     $message = $userModel->updateAceessList($id, $actionIds);
                     if ($message == '') {
                         //Successfull
                         $message = 'Successfully updated.';
                         //Refresh the background page
                         $this->view->actionList = $u->getActionList($id, 'CHECKED');
                         $htmlStringBg = $this->view->render('user/viewaccesses.ajax.phtml');
                     }
                 } else {
                     $message = 'Error:: list of selected action found blank.';
                 }
             }
         }
         /**********************CENTER ASSIGNED TO THE USER******************************/
     } else {
         if ($info == 'CENTERS') {
             $do = $this->_getParam('do');
             if ($do == null) {
                 //Display the edit actions page
                 $list = $u->getCenterList($id, 'ALL');
                 $this->view->list = $list;
                 $countryTbl = new Application_Model_DbTable_MstCountry();
                 $lstCountry = $countryTbl->getKeyValues();
                 $lstCountry = array(0 => 'All') + $lstCountry;
                 $this->view->lstCountries = $lstCountry;
                 $htmlString = $this->view->render('user/editcenters.phtml');
             } else {
                 if ($do == 'SAVE') {
                     $jSelectedIds = $this->_getParam('jSelectedIds');
                     $centerIds = Zend_Json::decode($jSelectedIds);
                     if ($centerIds != null) {
                         $userModel = new Admin_Model_User();
                         $message = $userModel->updateCenterList($id, $centerIds);
                         if ($message == '') {
                             //Successfull
                             $message = 'Successfully updated.';
                             //Refresh the background page
                             $this->view->centerList = $u->getCenterList($id, 'CHECKED');
                             $htmlStringBg = $this->view->render('user/viewcenters.ajax.phtml');
                         }
                     } else {
                         $message = 'Error:: list of selected centers found blank.';
                     }
                 }
             }
             /**********************COUNSELORS ASSIGNED TO THE USER******************************/
         } else {
             if ($info == 'COUNSELORS') {
                 $do = $this->_getParam('do');
                 if ($do == null) {
                     //Display the edit actions page
                     $list = $u->getCounselorList($id, 'ALL');
                     $this->view->list = $list;
                     $centerTbl = new Application_Model_DbTable_MstCenter();
                     $lstCenter = $centerTbl->getKeyValues('counselor');
                     $lstCenter = array(0 => 'All') + $lstCenter;
                     $this->view->lstCenters = $lstCenter;
                     $htmlString = $this->view->render('user/editcounselors.phtml');
                 } else {
                     if ($do == 'SAVE') {
                         $jSelectedIds = $this->_getParam('jSelectedIds');
                         $counselorIds = Zend_Json::decode($jSelectedIds);
                         if ($counselorIds != null) {
                             $userModel = new Admin_Model_User();
                             $message = $userModel->updateCounselorList($id, $counselorIds);
                             if ($message == '') {
                                 //Successfull
                                 $message = 'Successfully updated.';
                                 //Refresh the background page
                                 $this->view->counselorList = $u->getCounselorList($id, 'CHECKED');
                                 $htmlStringBg = $this->view->render('user/viewcounselors.ajax.phtml');
                             }
                         } else {
                             $message = 'Error:: list of selected counselor found blank.';
                         }
                     }
                 }
                 /**********************MENTORS ASSIGNED TO THE USER******************************/
             } else {
                 if ($info == 'MENTORS') {
                     $do = $this->_getParam('do');
                     if ($do == null) {
                         //Display the edit MENTORS page
                         $list = $u->getMentorList($id, 'ALL');
                         $this->view->list = $list;
                         $centerTbl = new Application_Model_DbTable_MstCenter();
                         $lstCenter = $centerTbl->getKeyValues('mentor');
                         $lstCenter = array(0 => 'All') + $lstCenter;
                         $this->view->lstCenters = $lstCenter;
                         $htmlString = $this->view->render('user/editmentors.phtml');
                     } else {
                         if ($do == 'SAVE') {
                             $jSelectedIds = $this->_getParam('jSelectedIds');
                             $mentorIds = Zend_Json::decode($jSelectedIds);
                             if ($mentorIds != null) {
                                 $userModel = new Admin_Model_User();
                                 $message = $userModel->updateMentorList($id, $mentorIds);
                                 if ($message == '') {
                                     //Successfull
                                     $message = 'Successfully updated.';
                                     //Refresh the background page
                                     $this->view->mentorList = $u->getMentorList($id, 'CHECKED');
                                     $htmlStringBg = $this->view->render('user/viewmentors.ajax.phtml');
                                 }
                             } else {
                                 $message = 'Error:: list of selected mentor found blank.';
                             }
                         }
                     }
                     /**********************GURUS ASSIGNED TO THE USER******************************/
                 } else {
                     if ($info == 'GURUS') {
                         $do = $this->_getParam('do');
                         if ($do == null) {
                             //Display the edit GURUS page
                             $list = $u->getGuruList($id, 'ALL');
                             $this->view->list = $list;
                             $htmlString = $this->view->render('user/editgurus.phtml');
                         } else {
                             if ($do == 'SAVE') {
                                 $jSelectedIds = $this->_getParam('jSelectedIds');
                                 $guruIds = Zend_Json::decode($jSelectedIds);
                                 if ($guruIds != null) {
                                     $userModel = new Admin_Model_User();
                                     $message = $userModel->updateGuruList($id, $guruIds);
                                     if ($message == '') {
                                         //Successfull
                                         $message = 'Successfully updated.';
                                         //Refresh the background page
                                         $this->view->guruList = $u->getGuruList($id, 'CHECKED');
                                         $htmlStringBg = $this->view->render('user/viewgurus.ajax.phtml');
                                     }
                                 } else {
                                     $message = 'Error:: list of selected spiritual master found blank.';
                                 }
                             }
                         }
                         /**********************Dbs ASSIGNED TO THE USER******************************/
                     } else {
                         if ($info == 'DBS') {
                             $do = $this->_getParam('do');
                             if ($do == null) {
                                 //Display the edit DB page
                                 $list = $u->getDbList($id, 'ALL');
                                 $this->view->list = $list;
                                 $htmlString = $this->view->render('user/editdbs.phtml');
                             } else {
                                 if ($do == 'SAVE') {
                                     $jSelectedIds = $this->_getParam('jSelectedIds');
                                     $dbIds = Zend_Json::decode($jSelectedIds);
                                     if ($dbIds != null) {
                                         $userModel = new Admin_Model_User();
                                         $message = $userModel->updateDbList($id, $dbIds);
                                         if ($message == '') {
                                             //Successfull
                                             $message = 'Successfully updated.';
                                             //Refresh the background page
                                             $this->view->dbList = $u->getDbList($id, 'CHECKED');
                                             $htmlStringBg = $this->view->render('user/viewdbs.ajax.phtml');
                                         }
                                     } else {
                                         $message = 'Error:: list of selected database found blank.';
                                     }
                                 }
                             }
                             /**********************DEVOTEES ASSIGNED TO THE USER******************************/
                         } else {
                             if ($info == 'DEVOTEES') {
                                 $do = $this->_getParam('do');
                                 if ($do == null) {
                                     //Display the edit UserVsDevotee page
                                     $this->view->devoteeList = $u->getDevoteeList($id, 'CHECKED');
                                     $htmlString = $this->view->render('user/editdevotees.phtml');
                                 } else {
                                     if ($do == 'SAVE') {
                                         $jSelectedIds = $this->_getParam('jSelectedIds');
                                         $DIDs = Zend_Json::decode($jSelectedIds);
                                         if ($DIDs != null) {
                                             $userModel = new Admin_Model_User();
                                             $message = $userModel->updateDevoteesList($id, $DIDs);
                                             if ($message == '') {
                                                 //Successfull
                                                 $message = 'Successfully updated.';
                                                 //Refresh the background page
                                                 $this->view->devoteeList = $u->getDevoteeList($id, 'CHECKED');
                                                 $htmlStringBg = $this->view->render('user/viewdevotee.ajax.phtml');
                                             }
                                         } else {
                                             $message = 'Error:: list of selected database found blank.';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $result->message = $message;
     $result->htmlBody = $htmlString;
     $result->htmlBodyBg = $htmlStringBg;
     $this->_helper->json($result);
 }