Esempio n. 1
0
 /**
  * Get session user/client info sololy based on session key.
  *
  * @return array Array of user and client array.
  */
 public function getSessionInfo()
 {
     $sessionKey = $this->_request->getParam('session');
     $keyRow = Repo_UserApiSessionKeys::getInstance()->getRow(array(array('where' => 'session_key = ?', 'bind' => $sessionKey)));
     if (!$keyRow || time() > $keyRow->modified + $keyRow->lifetime) {
         return false;
     }
     $user = new Object_User($keyRow->user_id);
     $client = new Object_Client($user->client_id);
     return array('user' => $user->getBasicInfo(), 'client' => $client->getDataArray());
 }
 /**
  * Bulk upload multiple pages with a zip file.
  *
  */
 public function uploadPagesAction()
 {
     $id = $this->_request->getParam('id');
     $client = new Object_Client($id);
     $clientId = $client->getId();
     if (empty($clientId)) {
         // No client defined, redirec to list users.
         $this->_redirect('/admin/client');
         return false;
     }
     $this->view->client = $client;
     $form = new Form_Admin_Client_Page_BulkUpload(false, array('clientId' => $id));
     if ($this->_request->isPost()) {
         $params = $this->_request->getPost();
         if ($form->isValid($params)) {
             $pages = $form->generatePages($id);
             if (!empty($pages)) {
                 // Redirect to client page list
                 $this->_helper->getHelper('FlashMessenger')->addMessage(count($pages) . ' pages have been created/updated.');
                 $titleId = $params['title'];
                 if (!empty($titleId) && (int) $titleId > 0) {
                     $titlePages = array();
                     // Added to a title if title is available
                     $title = new Object_Title($titleId);
                     $existingPages = Repo_TitlePage::getInstance()->getTitlePages($title->getId());
                     if ($existingPages) {
                         foreach ($existingPages as $_p) {
                             $titlePages[] = $_p->id;
                         }
                     }
                     $titlePages = array_merge($titlePages, $pages);
                     $title->savePages($titlePages);
                     $this->_helper->getHelper('FlashMessenger')->addMessage('Pages have been added to title: <a href="/admin/client/title-detail/id/' . $title->id . '">' . $title->name . '</a>.');
                 }
                 $this->_redirect('/admin/client/page/client/' . $id);
             }
             $form->populate($params);
         } else {
             $form->populate($params);
         }
     }
     $this->view->form = $form;
 }