예제 #1
0
 public function logout()
 {
     $owner = UserMap::getUser();
     $dataToLog["owner_name"] = $owner["first_name"] . " " . $owner["last_name"];
     $dataToLog["owner_id"] = $owner["owner_id"];
     Mongo_Logger::logEvent($dataToLog, Mongo_Logs_LogFactory::LogoutOwer, Mongo_Interface::LOGS);
     $session = new Zend_Session_Namespace("LeadsChat_Owner_Auth");
     $session->unsetAll();
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public static function GetKeyMaps()
 {
     if (self::$KM == null) {
         self::$KM = array();
         self::$KM["fk_contact_user"] = new KeyMap("fk_contact_user", "Iduser", "Contact", "User", KM_TYPE_ONETOMANY, KM_LOAD_LAZY);
         // use KM_LOAD_EAGER with caution here (one-to-one relationships only)
         self::$KM["fk_search_user1"] = new KeyMap("fk_search_user1", "Iduser", "Search", "User", KM_TYPE_ONETOMANY, KM_LOAD_LAZY);
         // use KM_LOAD_EAGER with caution here (one-to-one relationships only)
         self::$KM["fk_user_has_role_user1"] = new KeyMap("fk_user_has_role_user1", "Iduser", "Userrole", "User", KM_TYPE_ONETOMANY, KM_LOAD_LAZY);
         // use KM_LOAD_EAGER with caution here (one-to-one relationships only)
         self::$KM["fk_user_institution1"] = new KeyMap("fk_user_institution1", "Institution", "Institution", "Idinstitution", KM_TYPE_MANYTOONE, KM_LOAD_LAZY);
         // you change to KM_LOAD_EAGER here or (preferrably) make the change in _config.php
         self::$KM["fk_user_timezone"] = new KeyMap("fk_user_timezone", "Timezone", "Timezones", "Idtimezone", KM_TYPE_MANYTOONE, KM_LOAD_LAZY);
         // you change to KM_LOAD_EAGER here or (preferrably) make the change in _config.php
     }
     return self::$KM;
 }
예제 #3
0
 /**
  * (non-PHPdoc)
  * @see Zend_Controller_Action::preDispatch()
  */
 public function preDispatch()
 {
     $controllerName = $this->getRequest()->getControllerName();
     $controllerAction = $this->getRequest()->getActionName();
     $acl = Zend_Registry::get("Zend_Acl");
     $role = UserMap::getRole();
     if (!$this->getRequest()->isXmlHttpRequest()) {
         if (!$acl->isAllowed(UserMap::getRole(), $controllerName, $controllerAction) && $controllerAction != "logout") {
             if ($role == "guest") {
                 header("Location:/");
             } else {
                 if ($role == "owner" || $role == "member") {
                     header("Location:/owners/login");
                 } else {
                     if ($role == "agent" || $role == "admin") {
                         header("Location:/agents/login");
                     }
                 }
             }
             exit;
         }
     }
     parent::preDispatch();
 }
예제 #4
0
 /**
  * @Post('/DeleteGroup/{user_id:[0-9]{1,10}}')
  */
 public function deleteGroupAction($user_id)
 {
     $ans = [];
     try {
         $group_id = $this->request->getPost('group_id');
         if (!is_int($group_id)) {
             throw new Exception('please give us a number', 1301);
         }
         $map = UserMap::findFirst('user_id=' . $user_id . ' and user_group_id=' . $group_id);
         $succeed = $map->delete();
         if ($succeed) {
             $ans['ret'] = 0;
         } else {
             foreach ($map->getMessages() as $message) {
                 throw new Exception($message, 100);
             }
         }
     } catch (Exception $e) {
         $ans['ret'] = -1;
         Utils::makeError($e, $ans);
     } finally {
         echo json_encode($ans);
     }
 }
예제 #5
0
 protected function _initAcl()
 {
     $acl = new Acl();
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(UserMap::getRole());
     Zend_Registry::set('Zend_Acl', $acl);
     return $acl;
 }
예제 #6
0
 /**
  * Bootstrap dashboard Action
  */
 public function bootstrapDashboardAction()
 {
     $owner = UserMap::getUser();
     if ($owner) {
         //load all notifications
         /*
         //load all leads per date of owner
         $today = date("Y-m-d");
         $yesterday = date("Y-m-d", strtotime("-1 days", strtotime($today)));
         $last2Days = date("Y-m-d", strtotime("-2 days", strtotime($today)));
         $allLeads = array();
         $todayLeads = $this->leadModel->getReadyToBuyLeads($today, $owner["owner_id"]);
         $yesterdayLeads = $this->leadModel->getReadyToBuyLeads($yesterday, $owner["owner_id"]);
         $last2DaysLeads = $this->leadModel->getReadyToBuyLeads($last2Days, $owner["owner_id"]);
         	
         
         //load group and members
         if (!is_null($owner["has_member"])){
         	$members = $this->memberModel->loadMembers($owner["owner_id"]);
         }
         */
     }
     $this->view->result = array("success" => true, "owner" => $owner);
     $this->_helper->layout->setLayout("plain");
     $this->_helper->viewRenderer("json");
 }
예제 #7
0
 function findGroup($user_id)
 {
     $maps = UserMap::find('user_id=' . $user_id);
     if (is_null($maps)) {
         return null;
     }
     $ans = [];
     $i = 0;
     foreach ($maps as $map) {
         $ans[$i] = $map->user_group_id;
         $i++;
     }
     return $ans;
 }
예제 #8
0
 public function processLoginAction()
 {
     $sessionAgent = new Zend_Session_Namespace("LeadsChat_Auth");
     if (!$sessionAgent->agent_id && $this->_request->isXmlHttpRequest()) {
         if ($this->auth->authenticate()) {
             $this->view->result = array("result" => true, "message" => "Successful logged in", "level" => UserMap::getRole());
         } else {
             $this->view->result = array("result" => false, "message" => "Invalid Username/Password");
         }
     } else {
         if ($sessionAgent->agent_id) {
             $this->view->result = array("result" => true, "message" => "Already logged in");
         } else {
             $this->view->result = array("result" => false, "message" => "Invalid request method");
         }
     }
     $this->_helper->layout->setLayout("plain");
     $this->_helper->viewRenderer("json");
 }