Ejemplo n.º 1
0
 /**
  * returns the column headers as an array of tuples:
  * (name, sortName (key to the sort array))
  *
  * @param string $action the action being performed
  * @param enum   $output what should the result set include (web/email/csv)
  *
  * @return array the column headers that need to be displayed
  * @access public
  */
 function &getColumnHeaders($action = null, $output = null)
 {
     require_once 'CRM/Mailing/BAO/Mailing.php';
     require_once 'CRM/Mailing/BAO/Job.php';
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     if (!isset(self::$_columnHeaders)) {
         self::$_columnHeaders = array(array('name' => ts('Mailing Name'), 'sort' => 'name', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Status'), 'sort' => 'status', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Created By'), 'sort' => 'created_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Sent By'), 'sort' => 'scheduled_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Scheduled'), 'sort' => 'scheduled_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Started'), 'sort' => 'start_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Completed'), 'sort' => 'end_date', 'direction' => CRM_Utils_Sort::DESCENDING));
         if ($output != CRM_Core_Selector_Controller::EXPORT) {
             self::$_columnHeaders[] = array('name' => ts('Action'));
         }
     }
     return self::$_columnHeaders;
 }
Ejemplo n.º 2
0
 /** 
  * run this page (figure out the action needed and perform it). 
  * 
  * @return void 
  */
 function run($newArgs)
 {
     $this->preProcess();
     if (isset($_GET['runJobs']) || CRM_Utils_Array::value('2', $newArgs) == 'queue') {
         require_once 'CRM/Mailing/BAO/Job.php';
         $config =& CRM_Core_Config::singleton();
         CRM_Mailing_BAO_Job::runJobs_pre($config->mailerJobSize);
         CRM_Mailing_BAO_Job::runJobs();
         CRM_Mailing_BAO_Job::runJobs_post();
     }
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
         $this->set('sortByCharacter', '');
     }
     if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
         $this->_unscheduled = true;
     }
     $this->set('unscheduled', $this->_unscheduled);
     if (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
         $this->_archived = true;
     }
     $this->set('archived', $this->_archived);
     if (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
         $this->_scheduled = true;
     }
     $this->set('scheduled', $this->_scheduled);
     $this->_createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, 0);
     if ($this->_createdId) {
         $this->set('createdId', $this->_createdId);
     }
     $session = CRM_Core_Session::singleton();
     $context = $session->readUserContext();
     if ($this->_action & CRM_Core_Action::DISABLE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
             require_once 'CRM/Mailing/BAO/Job.php';
             CRM_Mailing_BAO_Job::cancel($this->_mailingId);
             CRM_Utils_System::redirect($context);
         } else {
             $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Cancel Mailing'), $this->_action);
             $controller->setEmbedded(true);
             $controller->run();
         }
     } else {
         if ($this->_action & CRM_Core_Action::DELETE) {
             if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
                 // check for action permissions.
                 if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
                     CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
                 }
                 require_once 'CRM/Mailing/BAO/Mailing.php';
                 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
                 CRM_Utils_System::redirect($context);
             } else {
                 $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Delete Mailing'), $this->_action);
                 $controller->setEmbedded(true);
                 $controller->run();
             }
         } else {
             if ($this->_action & CRM_Core_Action::RENEW) {
                 //archive this mailing, CRM-3752.
                 if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
                     //set is_archived to 1
                     CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', true);
                     CRM_Utils_System::redirect($context);
                 } else {
                     $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Archive Mailing'), $this->_action);
                     $controller->setEmbedded(true);
                     $controller->run();
                 }
             }
         }
     }
     $selector = new CRM_Mailing_Selector_Browse();
     $selector->setParent($this);
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID) . $this->get(CRM_Utils_Sort::SORT_DIRECTION), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE);
     $controller->setEmbedded(true);
     $controller->run();
     //hack to display results as per search
     $rows = $controller->getRows($controller);
     $this->assign('rows', $rows);
     $urlParams = 'reset=1';
     $urlString = 'civicrm/mailing/browse';
     if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
         $urlString .= '/unscheduled';
         $urlParams .= '&scheduled=false';
         $this->assign('unscheduled', true);
         CRM_Utils_System::setTitle(ts('Draft and Unscheduled Mailings'));
     } else {
         if (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
             $urlString .= '/archived';
             $this->assign('archived', true);
             CRM_Utils_System::setTitle(ts('Archived Mailings'));
         } else {
             if (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
                 $urlString .= '/scheduled';
                 $urlParams .= '&scheduled=true';
                 CRM_Utils_System::setTitle(ts('Scheduled and Sent Mailings'));
             } else {
                 CRM_Utils_System::setTitle(ts('Find Mailings'));
             }
         }
     }
     $crmRowCount = CRM_Utils_Request::retrieve('crmRowCount', 'Integer', CRM_Core_DAO::$_nullObject);
     $crmPID = CRM_Utils_Request::retrieve('crmPID', 'Integer', CRM_Core_DAO::$_nullObject);
     if ($crmRowCount || $crmPID) {
         $urlParams .= '&force=1';
         $urlParams .= $crmRowCount ? '&crmRowCount=' . $crmRowCount : '';
         $urlParams .= $crmPID ? '&crmPID=' . $crmPID : '';
     }
     $crmSID = CRM_Utils_Request::retrieve('crmSID', 'Integer', CRM_Core_DAO::$_nullObject);
     if ($crmSID) {
         $urlParams .= '&crmSID=' . $crmSID;
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url($urlString, $urlParams);
     $session->pushUserContext($url);
     //CRM-6862 -run form cotroller after
     //selector, since it erase $_POST
     $this->search();
     return parent::run();
 }
Ejemplo n.º 3
0
 /**
  * Returns the column headers as an array of tuples:
  * (name, sortName (key to the sort array))
  *
  * @param string $action
  *   The action being performed.
  * @param string $output
  *   What should the result set include (web/email/csv).
  *
  * @return array
  *   the column headers that need to be displayed
  */
 public function &getColumnHeaders($action = NULL, $output = NULL)
 {
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_MailingJob::getTableName();
     if (!isset(self::$_columnHeaders)) {
         $completedOrder = NULL;
         // Set different default sort depending on type of mailings (CRM-7652)
         $unscheduledOrder = $scheduledOrder = $archivedOrder = CRM_Utils_Sort::DONTCARE;
         if ($this->_parent->get('unscheduled')) {
             $unscheduledOrder = CRM_Utils_Sort::DESCENDING;
         } elseif ($this->_parent->get('scheduled')) {
             $scheduledOrder = CRM_Utils_Sort::DESCENDING;
         } else {
             // sort by completed date for archived and undefined get
             $completedOrder = CRM_Utils_Sort::DESCENDING;
         }
         $nameHeaderLabel = $this->_parent->get('sms') ? ts('SMS Name') : ts('Mailing Name');
         self::$_columnHeaders = array(array('name' => $nameHeaderLabel, 'sort' => 'name', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Status'), 'sort' => 'status', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Created By'), 'sort' => 'created_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Created Date'), 'sort' => 'created_date', 'direction' => $unscheduledOrder), array('name' => ts('Sent By'), 'sort' => 'scheduled_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Scheduled'), 'sort' => 'scheduled_date', 'direction' => $scheduledOrder), array('name' => ts('Started'), 'sort' => 'start_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Completed'), 'sort' => 'end_date', 'direction' => $completedOrder));
         if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
             self::$_columnHeaders[] = array('name' => ts('Campaign'), 'sort' => 'campaign_id', 'direction' => CRM_Utils_Sort::DONTCARE);
         }
         if ($output != CRM_Core_Selector_Controller::EXPORT) {
             self::$_columnHeaders[] = array('name' => ts('Action'));
         }
     }
     return self::$_columnHeaders;
 }