Example #1
0
 public function load($chatId, $editorialId = null, $portal = null)
 {
     $sql = 'CALL `admin_editorial_fetch`(:chatId, :editorialId, :portalId)';
     $stmt = Zend_Registry::get('dbh')->prepare($sql);
     $stmt->bindParam(':chatId', $chatId, PDO::PARAM_INT);
     $stmt->bindParam(':editorialId', $editorialId, PDO::PARAM_INT);
     $stmt->bindParam(':portalId', $portal->id, PDO::PARAM_INT);
     try {
         $stmt->execute();
         $result = $stmt->fetchAll(Zend_Db::FETCH_OBJ);
         $stmt->closeCursor();
         $editorials = array();
         foreach ($result as $row) {
             $editorial = new Showcase_Content_Editorial();
             $editorial->unlock(Showcase_Admin::getInstance());
             $editorial->id = $row->editorial;
             $editorial->chatId = $row->chat;
             $editorial->headline = $row->headline;
             $editorial->alias = $row->alias;
             $editorial->sponsor = Showcase_Sponsor::factory($row->sponsorId, $row->sponsorName, $row->sponsorUrl);
             $editorial->channel = Showcase_Channel::factory($portal, $row->channel);
             $editorial->lock();
             $editorials[$editorial->id] = $editorial;
         }
         return $editorials;
     } catch (Zend_Db_Statement_Exception $e) {
         echo $e->getMessage();
     }
 }
Example #2
0
 public function __construct()
 {
     // check that the Admin object exists.  This is the thing with all the save power so it's pretty uber
     if (!Showcase_Admin::getInstance()) {
         die("You cannot instantiate an admin helper without the appropriate permissions.  Which you don't have!");
     }
 }
Example #3
0
 public function save($editorialId, array $post = array())
 {
     $user = $this->getRequest()->getParam('User');
     if ($articleId = Showcase_Admin::saveArticle($user, $editorialId, $post)) {
         return true;
     }
 }
Example #4
0
 public function save($chatId, array $post = array())
 {
     $user = $this->getRequest()->getParam('User');
     if ($showId = Showcase_Admin::saveShow($user, $chatId, $post)) {
         $this->getRequest()->setParam('showId', $showId);
         return $showId;
     }
 }
Example #5
0
 public static function fetchCache()
 {
     if (!self::$_cache instanceof Zend_Cache) {
         $cacheSettings = Zend_Registry::get('site_cache_settings');
         self::$_cache = Zend_Cache::factory('Core', $cacheSettings['BACKEND']['TYPE'], $cacheSettings['FRONTEND']['OPTIONS'], $cacheSettings['BACKEND']['OPTIONS']);
     }
     return self::$_cache;
 }
Example #6
0
 public function init()
 {
     $mainMenu = new Showcase_Admin_Menus();
     $this->view->assign('mainMenu', $mainMenu->mainMenu);
     $this->_contentId = $this->_getParam('contentId');
     $this->_status = Showcase_Admin::getStatus();
     $this->_categories = Showcase_Admin::getCategories();
     $this->_types = Showcase_Admin::getTypes();
 }
Example #7
0
 public function save($chatId, array $post = array())
 {
     // first, parse out the sections into different areas
     $user = $this->getRequest()->getParam('User');
     if ($chatId = Showcase_Admin::saveChat($user, $chatId, $post)) {
         $this->getRequest()->setParam('chatId', $chatId);
         return $chatId;
     }
 }
Example #8
0
 public function newAction()
 {
     $this->view->assign('requestUri', $this->getRequest()->getRequestUri());
     $this->view->assign('jobId', $this->_jobId);
     $this->view->assign('title', 'Add a phase');
     //fetch all the status available in the db
     $this->view->assign('status', $this->_status);
     //if save is submitted
     if ($this->getRequest()->isPost()) {
         if ($post = $this->getRequest()->getPost('addContent')) {
             //put the files into the main post
             if ($_FILES['image']) {
                 $post['image'] = $_FILES['image'];
                 $post['image']['description'] = $post['description'];
                 unset($post['imageAlt']);
             }
             // jobId and clientId in the post
             $post['jobId'] = $this->_jobId;
             $post['clientId'] = $this->_clientId;
             //Turn client into an array with id and name
             $clientName = Showcase_Admin::seekName($this->_clients, $post['clientId']);
             $post['client'] = array('name' => $clientName, 'id' => $post['clientId']);
             unset($post['clientId']);
             //specify the operation type
             $post['operationType'] = 'save';
             //validate, upload and saveDB
             $oContent = new Showcase_Admin_Content($post);
             $return = $oContent->processContent();
             //print errors
             if (isset($return['Error'])) {
                 $this->view->assign('errorMessages', $return['Error']);
                 $this->view->assign('posted', $return['post']);
                 return false;
             }
             //if successful
             $this->_redirect('/admin/content/success');
         }
         $this->view->assign('errorMessage', 'There was a problem with your form, please submit again.');
     }
 }
Example #9
0
 public function deleteJob()
 {
     //prepare the files for db insertion (add paths(full and db), identifier ...)
     $this->_prepareFilesForDb($this->_post['media']);
     //Delete the files
     //TODO: move to bin and if errors put'em back
     foreach ($this->_post['media'] as $aFiles) {
         $this->_deleteFiles($aFiles);
     }
     //delete job in db
     $oJob = new Showcase_Controller_Action_Helper_Admin_Job();
     $return = $oJob->deleteJob($this->_post['jobId']);
     if ($return == true) {
         //flush cache
         Showcase_Admin::flushCache();
         return true;
     } else {
         return false;
     }
 }
Example #10
0
 public function editAction()
 {
     $title = 'Edit a Job';
     $this->view->assign('title', $title);
     //populate the list of clients
     $this->view->assign('clients', $this->_clients);
     // if the form has come back...
     if ($this->getRequest()->isPost()) {
         //After selecting the client
         if ($client = $this->getRequest()->getPost('selectClient')) {
             // if the user sets an empty user
             if ($client == '') {
                 $this->view->assign('errorMessages', array('Please select a client.'));
                 return false;
             }
             //set the action and error
             $this->view->assign('requestUri', $this->getRequest()->getRequestUri());
             $this->view->assign('errorMessages', array());
             //Turn client into an array with id and name
             $clientName = Showcase_Admin::seekName($this->_clients, $client['client']);
             $posted = array('client' => array('name' => $clientName, 'id' => $client['client']));
             //keeping the selected client open correctly
             $this->view->assign('posted', $client);
             //then load and update the jobNumber list
             $jobNumbers = $this->_helper->Job->getJobsNumbers($posted['client']['id']);
             //open the second select in the form and populate with jobs
             $this->view->assign('selectJob', 1);
             $this->view->assign('errorMessages', array());
             $this->view->assign('jobNumbers', $jobNumbers);
         }
         // after selecting a job number
         if ($posted = $this->getRequest()->getPost('selectJob')) {
             //print_r($posted); die;
             //Turn client into an array with id and name
             $clientName = Showcase_Admin::seekName($this->_clients, $posted['client']);
             $posted['client'] = array('name' => $clientName, 'id' => $posted['client']);
             //load and update the jobNumber list
             $this->_jobNumbers = $this->_helper->Job->getJobsNumbers($posted['client']['id']);
             $this->view->assign('jobNumbers', $this->_jobNumbers);
             //fetch all the status available in the db
             $this->view->assign('status', $this->_status);
             //keep the job number selection form open
             $this->view->assign('selectJob', 1);
             //open the 3rd and last form
             $this->view->assign('jobChosen', $posted['jobId']);
             //get job using a already built frontend helper with a twist
             //that we pass the name for a similar proc without the status requirement
             $dbJob = new Showcase_Controller_Action_Helper_Jobs();
             $posted['job'] = $dbJob->loadJob($posted['client']['id'], $posted['jobId'], 'NULL', 'get_job_all_status');
             //instantiate the job object
             $oJob = new Showcase_Admin_Job($posted);
             //strip the old frontend object for admin
             $posted = $oJob->prepareObject($posted);
             //populate the form
             $this->view->assign('posted', $posted);
             //print_r($posted); die;
         }
         //if it was SUBMITTED for update
         if ($posted = $this->getRequest()->getPost('editJob')) {
             //print_r($posted); die;
             //Turn client into an array with id and name
             $clientName = Showcase_Admin::seekName($this->_clients, $posted['client']);
             $posted['client'] = array('name' => $clientName, 'id' => $posted['client']);
             if (!empty($_FILES['image']['name']) || !empty($_FILES['thumb']['name'])) {
                 //put the files into the main post
                 $this->getFilesIntoPost('image', $posted, 'images', 'imageAlt');
                 $this->getFilesIntoPost('thumb', $posted, 'thumbs', 'thumbAlt');
             }
             if (!empty($_FILES['document']['name'])) {
                 $this->getFilesIntoPost('document', $posted, 'documents', 'docdescription');
             }
             //go!
             $oJob = new Showcase_Admin_Job($posted);
             $return = $oJob->updateJob();
             //print the errors returned with the sanitized post
             if (isset($return['Error'])) {
                 //keep the job number selection form open
                 $this->view->assign('selectJob', 1);
                 //open the 3rd and last form
                 $this->view->assign('jobChosen', $posted['jobId']);
                 // TODO: should be an array of messages
                 $this->view->assign('errorMessages', $return['Error']);
                 $this->view->assign('posted', $return['post']);
                 return false;
             }
             $this->_redirect('/admin/job/success');
         }
     }
 }