예제 #1
0
파일: Abstract.php 프로젝트: hettema/Stages
 /** 
  * Get the session user or load the user bu the id passed the request query
  *
  * @return type 
  */
 public function getUser()
 {
     if ($this->_user) {
         return $this->_user;
     }
     if (App_Main::getRequest()->getParam('user') && App_Main::hasSingleton('stages/user')) {
         $user = App_Main::getSingleton('stages/user');
     } else {
         if (App_Main::hasSingleton('stages/user')) {
             $user = App_Main::getSingleton('stages/user');
         }
     }
     if (!empty($user)) {
         $this->_user = $user;
         return $this->_user;
     }
     //else load the user with the fbid or from the session
     if ($userId = App_Main::getRequest()->getParam('user')) {
         $user = App_Main::getSession()->getUser()->getId() == $userId ? App_Main::getSession()->getUser() : App_Main::getSingleton('stages/user')->load($userId);
     } else {
         if (App_Main::getSession()->getUser()) {
             $user = App_Main::getSession()->getUser();
         }
     }
     if ($user->getId()) {
         $this->_user = $user;
         return $this->_user;
     }
     return false;
 }
예제 #2
0
파일: List.php 프로젝트: hettema/Stages
 /**
  * Get the visitor list
  * 
  * @return type Core_Model_Object
  */
 public function getResultCollection()
 {
     if (!empty($this->_collection)) {
         return $this->_collection;
     }
     $_resultCollection = App_Main::getSingleton('visitor/visitor')->getCollection()->getResultCollection();
     if (empty($_resultCollection)) {
         $_resultCollection = array();
     }
     $this->_collection = $_resultCollection;
     return $this->_collection;
 }
예제 #3
0
 /**
  * Edit selected admin user
  */
 public function editAction()
 {
     $this->updateLayout();
     $user = App_Main::getSingleton('admin/user');
     $user->load($this->getRequest()->getparam('id'));
     if (!$user || !$user->getId()) {
         $this->_redirect('page_notfound.html');
         return false;
     }
     $this->getLayout()->getBlock('head')->setTitle('Edit Admin User :: ' . $user->getFirstname(), false);
     $contentMain = $this->getLayout()->createBlock('backend/template', 'user_edit', array('template' => 'admin/user/edit.phtml'));
     $this->getLayout()->getBlock('content')->append($contentMain, 'user_edit');
     $this->renderLayout();
 }
예제 #4
0
파일: Session.php 프로젝트: hettema/Stages
 /**
  * Try to login user in admin
  *
  * @param  string $username
  * @param  string $password
  * @param  Core_Controller_Request_Http $request
  * @return Admin_Model_User|null
  */
 public function login($username, $password, $request = null)
 {
     if (empty($username) || empty($password)) {
         return;
     }
     try {
         /* @var $user Admin_Model_User */
         $user = App_Main::getModel('admin/user');
         $user->login($username, $password);
         if ($user->getId()) {
             $session = App_Main::getSingleton('admin/session');
             $session->setIsFirstVisit(true);
             $session->setUser($user);
         } else {
             throw App_Main::exception('Core', 'Invalid Username or Password.');
         }
     } catch (Core_Exception $e) {
         if ($request && !$request->getParam('messageSent')) {
             App_Main::getSingleton('core/session')->addError($e->getMessage());
             $request->setParam('messageSent', true);
         }
     }
     return $user;
 }
예제 #5
0
파일: Action.php 프로젝트: hettema/Stages
 protected function postDispatch()
 {
     $this->_getSession()->setLastUrl(App_Main::getUrl('*/*/*', array('_current' => true)));
     if ($this->_currentArea == 'frontend') {
         if ($this->_getWebsite()->getConfig('session-log-visitors')) {
             App_Main::getSingleton('visitor/visitor')->saveByRequest();
         }
     }
     return $this;
 }
예제 #6
0
파일: Messages.php 프로젝트: hettema/Stages
 /**
  * Add new success message
  * 
  * @param string $message
  * @return Core_Block_Messages
  */
 public function addSuccess($message)
 {
     $this->addMessage(App_Main::getSingleton('core/message')->success($message));
     return $this;
 }
예제 #7
0
파일: Abstract.php 프로젝트: hettema/Stages
 /**
  * Retrieve cookie object
  *
  * @return Core_Model_Cookie
  */
 public function getCookie()
 {
     return App_Main::getSingleton('core/cookie');
 }
예제 #8
0
 /** 
  * Edit the user profile 
  */
 public function edit_profileAction()
 {
     $userId = App_Main::getSingleton('admin/session')->getUser()->getUserId();
     $user = App_Main::getModel('admin/user')->load($userId);
     $contentMain = $this->getLayout()->createBlock('core/template', 'user_edit', array('template' => 'admin/edit_user_profile.phtml', 'user' => $user));
     $this->getLayout()->getBlock('content')->append($contentMain, 'user_edit');
     $this->renderLayout();
 }
예제 #9
0
파일: Visitor.php 프로젝트: hettema/Stages
 /**
  * get the session object
  *
  * @return Core_Model_Session
  */
 protected function _getSession()
 {
     return App_Main::getSingleton('core/session');
 }
예제 #10
0
 /**
  * View the user profile
  */
 public function view_profileAction()
 {
     $userId = $this->getRequest()->getParam('user');
     if ($this->_getSession()->getUser() && $this->_getSession()->getUser()->getId() == $userId) {
         $this->getLayout()->getBlock('root')->addBodyClass('dashboard');
         $user = $this->_getSession()->getUser();
     } else {
         $this->getLayout()->getBlock('root')->addBodyClass('profile');
         $user = App_Main::getSingleton('stages/user')->load($userId);
     }
     $contentMain = $this->getLayout()->createBlock('stages/user/profile', 'content-main', array('template' => 'stages/user/profile.phtml'));
     $this->getLayout()->getBlock('content')->append($contentMain, 'content-main');
     $this->renderLayout();
 }
예제 #11
0
파일: User.php 프로젝트: hettema/Stages
 /**
  * Get the basecamp projects to whom the user have got acces to
  * If the $reload flag is true the projects will be loaded directly from BC
  * insted of loading from the local DB cache
  * 
  * @todo add a flag to reload projects based on the last load time 
  * 
  * @param bool $reload
  * @return array $projects array of basecamp project each instances of Project_Model_Project
  */
 public function getProjects($reload = false)
 {
     if (empty($this->_bcProjects) || $reload) {
         $this->_bcProjects = App_Main::getSingleton('project/project')->loadProjectsFromBc();
     }
     $this->_bcProjects = empty($this->_bcProjects) ? array() : $this->_bcProjects;
     return $this->_bcProjects;
 }
예제 #12
0
파일: Abstract.php 프로젝트: hettema/Stages
 /**
  * Update already existing url rewrite path identified by idPath
  * 
  * @param string $idPath
  * @param string $requestPath
  * @return Core_Model_Abstract 
  */
 protected function _updateUrlRewrite($idPath, $requestPath)
 {
     App_Main::getSingleton('core/url_rewrite')->updateUrlRewite($idPath, $requestPath);
     return $this;
 }