コード例 #1
0
ファイル: BasecampController.php プロジェクト: hettema/Stages
 /**
  * Initial connect function to get the user details and also to check the user tocken
  */
 public function connectAction()
 {
     $this->_getSession()->unsSignup();
     $token = $this->getRequest()->getParam('token');
     $host = $this->getRequest()->getParam('host');
     //Load the user object with the bc-token
     $user = App_Main::getModel('stages/user')->load($token, 'bc_auth_token');
     //login and redirect to homepage if the user is already registered
     if ($user->getId()) {
         $user->setSessionUser($user);
         echo Zend_Json::encode(array('redirect' => App_Main::getUrl('')));
         return;
     }
     //Get the Basecamp connect object
     $bcConnect = new Connect_Basecamp($host, $token, 'X', 'xml');
     $userXml = $bcConnect->getMe();
     if (!empty($userXml['body']) && $userXml['status'] == '200 OK') {
         $userArray = App_Main::getHelper('stages')->XMLToArray($userXml['body']);
         $return = array('success' => 1, 'username' => $userArray['user-name'], 'firstname' => $userArray['first-name'], 'lastname' => $userArray['last-name'], 'avatar' => $userArray['avatar-url'], 'token' => $userArray['token']);
         $signUp = App_Main::getModel('core/object');
         $signUp->setMode('bc_token_connect');
         $signUp->setToken($token);
         $signUp->setHost($host);
         $this->_getSession()->setSignup($signUp);
     } else {
         $return = array('success' => 0);
     }
     echo Zend_Json::encode($return);
 }
コード例 #2
0
ファイル: IndexController.php プロジェクト: hettema/Stages
 /**
  * Load the project view block
  * 
  * @return type 
  */
 public function viewAction()
 {
     if (!$this->isUserLoggedIn()) {
         echo Zend_Json::encode(array('success' => 0, 'redirect' => App_Main::getUrl('')));
         return;
     }
     $title = 'View Project';
     $projectId = $this->getRequestParam('id');
     if ($projectId) {
         $project = $this->_getSession()->getUser()->getProjectById($projectId, 'bc_id');
         $title = 'View Project - ' . $project->getTitle();
     } else {
         $project = false;
     }
     $this->getLayout()->getBlock('head')->setTitle($title, true);
     $this->getLayout()->getBlock('root')->addBodyClass('view-project logged-in');
     $contentMain = $this->getLayout()->createBlock('core/template', 'content-main', array('template' => 'stages/project/view.phtml', 'project' => $project));
     $this->getLayout()->getBlock('content')->append($contentMain, 'content-main');
     $this->renderLayout();
 }
コード例 #3
0
ファイル: Action.php プロジェクト: hettema/Stages
 /**
  * Set redirect into responce
  *
  * @param   string $path
  * @param   array $arguments
  */
 protected function _redirect($path, $arguments = array())
 {
     $this->getResponse()->setRedirect(App_Main::getUrl($path, $arguments));
     return $this;
 }
コード例 #4
0
ファイル: CreateController.php プロジェクト: hettema/Stages
 /**
  * Save the milestone under the loaded project
  * called via ajax request
  * 
  * @return type 
  */
 public function save_milestoneAction()
 {
     if (!$this->isUserLoggedIn()) {
         echo Zend_Json::encode(array('redirect' => App_Main::getUrl('')));
         return;
     }
     $success = 0;
     $projectId = $this->getRequestParam('project_id');
     if ($projectId) {
         $project = $this->_getSession()->getUser()->getProjectById($projectId);
         if ($project && $project->getId()) {
             $title = $this->getRequestParam('title');
             $date = $this->getRequestParam('date');
             $user = $this->getRequestParam('user');
             $type = $this->getRequestParam('type');
             $bcId = $this->getRequestParam('bc_id');
             $milestone = $project->saveMilestone($title, $date, $user, $type, $bcId);
             if ($milestone) {
                 $success = 1;
                 echo Zend_Json::encode(array('success' => $success, 'milestone' => $milestone->prepareDataForJson()));
                 return;
             }
         }
     }
     echo Zend_Json::encode(array('success' => $success));
 }
コード例 #5
0
ファイル: UserController.php プロジェクト: hettema/Stages
 /**
  * Get the milestone title index formatted in JSON
  * @return type 
  */
 public function milestone_indexAction()
 {
     if (!$this->isUserLoggedIn()) {
         echo Zend_Json::encode(array('redirect' => App_Main::getUrl('')));
         return;
     }
     $refreshBc = $this->getRequestParam('refresh');
     $bcMsIndex = $this->_getSession()->getUser()->getMilestoneIndex($refreshBc);
     if (!empty($bcMsIndex)) {
         echo Zend_Json::encode(array('success' => 1, 'ms_index' => $bcMsIndex));
     } else {
         echo Zend_Json::encode(array('success' => 1));
     }
 }
コード例 #6
0
ファイル: Abstract.php プロジェクト: hettema/Stages
 /**
  * Get url
  * Wraper function for Core_Model_Url::getUrl
  *
  * @param   string $route
  * @param   array $params
  * @return  string
  */
 protected function _getUrl($route, $params = array())
 {
     return App_Main::getUrl($route, $params);
 }