コード例 #1
0
/**
 * A PHP cron script to run the outstanding and scheduled CiviMail jobs
 * initiated by Owen Barton from a mailing sent by Lobo to crm-mail
 *
 * The structure of the file is set to mimiic soap.php which is a stand-alone
 * script and hence does not have any UF issues. You should be able to run
 * this script using a web url or from the command line
 */
function processQueue($batch_size)
{
    require_once 'CRM/Mailing/BAO/Job.php';
    // Split up the parent jobs into multiple child jobs
    CRM_Mailing_BAO_Job::runJobs_pre($batch_size);
    CRM_Mailing_BAO_Job::runJobs();
    CRM_Mailing_BAO_Job::runJobs_post();
}
コード例 #2
0
ファイル: Approve.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * Process the posted form values.  Approve /reject a mailing.
  *
  * @param
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $ids = array();
     if (isset($this->_mailingID)) {
         $ids['mailing_id'] = $this->_mailingID;
     } else {
         $ids['mailing_id'] = $this->get('mailing_id');
     }
     if (!$ids['mailing_id']) {
         CRM_Core_Error::fatal();
     }
     $params['approver_id'] = $this->_contactID;
     $params['approval_date'] = date('YmdHis');
     // if rejected, then we need to reset the scheduled date and scheduled id
     require_once 'CRM/Core/OptionGroup.php';
     $rejectOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'Rejected', 'name');
     if ($rejectOptionID && $params['approval_status_id'] == $rejectOptionID) {
         $params['scheduled_id'] = 'null';
         $params['scheduled_date'] = 'null';
         // also delete any jobs associated with this mailing
         $job = new CRM_Mailing_BAO_Job();
         $job->mailing_id = $ids['mailing_id'];
         $job->delete();
     }
     CRM_Mailing_BAO_Mailing::create($params, $ids);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
 }
コード例 #3
0
ファイル: Browse.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /** 
  * 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();
 }
コード例 #4
0
ファイル: Unsubscribe.php プロジェクト: ksecor/civicrm
 /**
  * Get rows for the event browser
  *
  * @param int $mailing_id       ID of the mailing
  * @param int $job_id           optional ID of the job
  * @param boolean $is_distinct  Group by queue id?
  * @param int $offset           Offset
  * @param int $rowCount         Number of rows
  * @param array $sort           sort array
  * @return array                Result set
  * @access public
  * @static
  */
 public static function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
 {
     $dao =& new CRM_Core_Dao();
     $unsub = self::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $query = "\n            SELECT      {$contact}.display_name as display_name,\n                        {$contact}.id as contact_id,\n                        {$email}.email as email,\n                        {$unsub}.time_stamp as date,\n                        {$unsub}.org_unsubscribe as org_unsubscribe\n            FROM        {$contact}\n            INNER JOIN  {$queue}\n                    ON  {$queue}.contact_id = {$contact}.id\n            INNER JOIN  {$email}\n                    ON  {$queue}.email_id = {$email}.id\n            INNER JOIN  {$unsub}\n                    ON  {$unsub}.event_queue_id = {$queue}.id\n            INNER JOIN  {$job}\n                    ON  {$queue}.job_id = {$job}.id\n            INNER JOIN  {$mailing}\n                    ON  {$job}.mailing_id = {$mailing}.id\n                    AND {$job}.is_test = 0\n            WHERE       {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
     if (!empty($job_id)) {
         $query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
     if ($is_distinct) {
         $query .= " GROUP BY {$queue}.id ";
     }
     $query .= " ORDER BY {$contact}.sort_name, {$unsub}.time_stamp DESC ";
     if ($offset) {
         $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
     $dao->query($query);
     $results = array();
     while ($dao->fetch()) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}");
         $results[] = array('name' => "<a href=\"{$url}\">{$dao->display_name}</a>", 'email' => $dao->email, 'org' => $dao->org_unsubscribe ? ts('Yes') : ts('No'), 'date' => CRM_Utils_Date::customFormat($dao->date));
     }
     return $results;
 }
コード例 #5
0
 /**
  * Process the posted form values.  Create and schedule a mailing.
  *
  * @param
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
     if (empty($params['mailing_id'])) {
         CRM_Core_Error::fatal(ts('Could not find a mailing id'));
     }
     foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
         $params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $ids['mailing_id'];
     if ($mailing->find(TRUE)) {
         $job = new CRM_Mailing_BAO_Job();
         $job->mailing_id = $mailing->id;
         $job->is_test = 0;
         if ($job->find(TRUE)) {
             CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
         }
         if (empty($mailing->is_template)) {
             $job->status = 'Scheduled';
             if ($params['now']) {
                 $job->scheduled_date = date('YmdHis');
             } else {
                 $job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
             }
             $job->save();
         }
         // set approval details if workflow is not enabled
         if (!CRM_Mailing_Info::workflowEnabled()) {
             $session = CRM_Core_Session::singleton();
             $mailing->approver_id = $session->get('userID');
             $mailing->approval_date = date('YmdHis');
             $mailing->approval_status_id = 1;
         } else {
             // reset them in case this mailing was rejected
             $mailing->approver_id = 'null';
             $mailing->approval_date = 'null';
             $mailing->approval_status_id = 'null';
         }
         if ($mailing->approval_date) {
             $mailing->approval_date = CRM_Utils_Date::isoToMysql($mailing->approval_date);
         }
         // also set the scheduled_id
         $session = CRM_Core_Session::singleton();
         $mailing->scheduled_id = $session->get('userID');
         $mailing->scheduled_date = date('YmdHis');
         $mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
         $mailing->save();
     }
     //when user perform mailing from search context
     //redirect it to search result CRM-3711.
     $ssID = $this->get('ssID');
     if ($ssID && $this->_searchBasedMailing && !CRM_Mailing_Info::workflowEnabled()) {
         if ($this->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($this->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($this->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $context = $this->get('context');
         if (!CRM_Contact_Form_Search::isSearchContext($context)) {
             $context = 'search';
         }
         $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
         return $this->controller->setDestination($url);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
 }
コード例 #6
0
ファイル: Browse.php プロジェクト: bhirsch/voipdev
 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     static $actionLinks = null;
     if (empty($actionLinks)) {
         $cancelExtra = ts('Are you sure you want to cancel this mailing?');
         $deleteExtra = ts('Are you sure you want to delete this mailing?');
         $archiveExtra = ts('Are you sure you want to archive this mailing?');
         $actionLinks = array(CRM_Core_Action::VIEW => array('name' => ts('Report'), 'url' => 'civicrm/mailing/report', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('View Mailing Report')), CRM_Core_Action::UPDATE => array('name' => ts('Re-Use'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('Re-Send Mailing')), CRM_Core_Action::DISABLE => array('name' => ts('Cancel'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=disable&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $cancelExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Cancel Mailing')), CRM_Core_Action::PREVIEW => array('name' => ts('Continue'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&continue=true&reset=1', 'title' => ts('Continue Mailing')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=delete&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $deleteExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Delete Mailing')), CRM_Core_Action::RENEW => array('name' => ts('Archive'), 'url' => 'civicrm/mailing/browse/archived', 'qs' => 'action=renew&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $archiveExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Archive Mailing')));
     }
     $mailing =& new CRM_Mailing_BAO_Mailing();
     $params = array();
     $whereClause = ' AND ' . $this->whereClause($params);
     if (empty($params)) {
         $this->_parent->assign('isSearch', 0);
     } else {
         $this->_parent->assign('isSearch', 1);
     }
     $rows =& $mailing->getRows($offset, $rowCount, $sort, $whereClause, $params);
     //get the search base mailing Ids, CRM-3711.
     $searchMailings = $mailing->searchMailingIDs();
     //check for delete CRM-4418
     require_once 'CRM/Core/Permission.php';
     $allowToDelete = CRM_Core_Permission::check('delete in CiviMail');
     if ($output != CRM_Core_Selector_Controller::EXPORT) {
         foreach ($rows as $key => $row) {
             $actionMask = null;
             if (!($row['status'] == 'Not scheduled')) {
                 $actionMask = CRM_Core_Action::VIEW;
                 if (!in_array($row['id'], $searchMailings)) {
                     $actionMask |= CRM_Core_Action::UPDATE;
                 }
             } else {
                 //FIXME : currently we are hiding continue action for
                 //search base mailing, we should handle it when we fix CRM-3876
                 if (!in_array($row['id'], $searchMailings)) {
                     $actionMask = CRM_Core_Action::PREVIEW;
                 }
             }
             if (in_array($row['status'], array('Scheduled', 'Running', 'Paused'))) {
                 $actionMask |= CRM_Core_Action::DISABLE;
             }
             if ($row['status'] == 'Complete' && !$row['archived']) {
                 $actionMask |= CRM_Core_Action::RENEW;
             }
             //check for delete permission.
             if ($allowToDelete) {
                 $actionMask |= CRM_Core_Action::DELETE;
             }
             //get status strings as per locale settings CRM-4411.
             $rows[$key]['status'] = CRM_Mailing_BAO_Job::status($row['status']);
             $rows[$key]['action'] = CRM_Core_Action::formLink($actionLinks, $actionMask, array('mid' => $row['id']));
             //unset($rows[$key]['id']);
             // if the scheduled date is 0, replace it with an empty string
             if ($rows[$key]['scheduled_iso'] == '0000-00-00 00:00:00') {
                 $rows[$key]['scheduled'] = '';
             }
             unset($rows[$key]['scheduled_iso']);
         }
     }
     // also initialize the AtoZ pager
     $this->pagerAtoZ();
     return $rows;
 }
コード例 #7
0
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the Affero General Public License for more details.            |
 |                                                                    |
 | You should have received a copy of the Affero General Public       |
 | License along with this program; if not, contact the Social Source |
 | Foundation at info[AT]socialsourcefoundation[DOT]org.  If you have |
 | questions about the Affero General Public License or the licensing |
 | of CiviCRM, see the Social Source Foundation CiviCRM license FAQ   |
 | at http://www.openngo.org/faqs/licensing.html                       |
 +--------------------------------------------------------------------+
*/
/**
 * A PHP cron script to run the outstanding and scheduled CiviMail jobs
 * initiated by Owen Barton from a mailing sent by Lobo to crm-mail
 *
 * The structure of the file is set to mimiic soap.php which is a stand-alone
 * script and hence does not have any UF issues. You should be able to run
 * this script using a web url or from the command line
 */
session_start();
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config =& CRM_Core_Config::singleton();
$config->userFramework = 'Soap';
$config->userFrameworkClass = 'CRM_Utils_System_Soap';
$config->userHookClass = 'CRM_Utils_Hook_Soap';
require_once 'CRM/Mailing/BAO/Job.php';
CRM_Mailing_BAO_Job::runJobs();
コード例 #8
0
ファイル: Event.php プロジェクト: bhirsch/voipdev
 /**
  * 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';
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     require_once 'CRM/Mailing/BAO/Job.php';
     $job = CRM_Mailing_BAO_Job::getTableName();
     if (!isset($this->_columnHeaders)) {
         $this->_columnHeaders = array(array('name' => ts('Contact')), array('name' => ts('Email Address')));
         if ($this->_event_type == 'bounce') {
             $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Bounce Type')), array('name' => ts('Bounce Reason'))));
         } elseif ($this->_event_type == 'unsubscribe') {
             $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Opt-Out'))));
         } elseif ($this->_event_type == 'click') {
             $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('URL'))));
         } elseif ($this->_event_type == 'forward') {
             $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Forwarded Email'))));
         }
         $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Date'))));
     }
     return $this->_columnHeaders;
 }
コード例 #9
0
ファイル: Job.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * cancel a mailing
  *
  * @param int $mailingId  the id of the mailing to be canceled
  * @static
  */
 public static function cancel($mailingId)
 {
     $job = new CRM_Mailing_BAO_Job();
     $job->mailing_id = $mailingId;
     // test mailing should not be included during Cancellation
     $job->is_test = 0;
     if ($job->find(true) and in_array($job->status, array('Scheduled', 'Running', 'Paused'))) {
         // fix MySQL dates...
         $job->scheduled_date = CRM_Utils_Date::isoToMysql($job->scheduled_date);
         $job->start_date = CRM_Utils_Date::isoToMysql($job->start_date);
         $job->end_date = CRM_Utils_Date::isoToMysql($job->end_date);
         $job->status = 'Canceled';
         $job->save();
         CRM_Core_Session::setStatus(ts('The mailing has been canceled.'));
     }
 }
コード例 #10
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)
 {
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     if (!isset($this->_columnHeaders)) {
         $this->_columnHeaders = array(array('name' => ts('Contact'), 'sort' => $contact . '.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING), array('name' => ts('Email Address'), 'sort' => $email . '.email', 'direction' => CRM_Utils_Sort::DONTCARE));
         switch ($this->_event_type) {
             case 'queue':
                 $dateSort = $job . '.start_date';
                 break;
             case 'delivered':
                 $dateSort = CRM_Mailing_Event_BAO_Delivered::getTableName() . '.time_stamp';
                 break;
             case 'opened':
                 $dateSort = CRM_Mailing_Event_BAO_Opened::getTableName() . '.time_stamp';
                 break;
             case 'bounce':
                 $dateSort = CRM_Mailing_Event_BAO_Bounce::getTableName() . '.time_stamp';
                 $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Bounce Type')), array('name' => ts('Bounce Reason'))));
                 break;
             case 'forward':
                 $dateSort = CRM_Mailing_Event_BAO_Forward::getTableName() . '.time_stamp';
                 $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Forwarded Email'))));
                 break;
             case 'reply':
                 $dateSort = CRM_Mailing_Event_BAO_Reply::getTableName() . '.time_stamp';
                 break;
             case 'unsubscribe':
                 $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp';
                 $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Unsubscribe'))));
                 break;
             case 'optout':
                 $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp';
                 $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Opt-Out'))));
                 break;
             case 'click':
                 $dateSort = CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName() . '.time_stamp';
                 $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('URL'))));
                 break;
             default:
                 return 0;
         }
         $this->_columnHeaders = array_merge($this->_columnHeaders, array(array('name' => ts('Date'), 'sort' => $dateSort, 'direction' => CRM_Utils_Sort::DESCENDING)));
     }
     return $this->_columnHeaders;
 }
コード例 #11
0
 /**
  * Get the rows for a browse operation
  *
  * @param int $offset       The row number to start from
  * @param int $rowCount     The nmber of rows to return
  * @param string $sort      The sql string that describes the sort order
  * 
  * @return array            The rows
  * @access public
  */
 function &getRows($offset, $rowCount, $sort)
 {
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $session =& CRM_Core_Session::singleton();
     $domain_id = $session->get('domainID');
     $query = "\n            SELECT      {$mailing}.id,\n                        {$mailing}.name, \n                        {$job}.status, \n                        MIN({$job}.scheduled_date) as scheduled_date, \n                        MIN({$job}.start_date) as start_date,\n                        MAX({$job}.end_date) as end_date\n            FROM        {$mailing}\n            INNER JOIN  {$job}\n                    ON  {$job}.mailing_id = {$mailing}.id\n            WHERE       {$mailing}.domain_id = {$domain_id}\n            GROUP BY    {$mailing}.id\n            ORDER BY    {$mailing}.id, {$job}.end_date";
     if ($rowCount) {
         $query .= " LIMIT {$offset}, {$rowCount} ";
     }
     $this->query($query);
     $rows = array();
     while ($this->fetch()) {
         $rows[] = array('id' => $this->id, 'name' => $this->name, 'status' => CRM_Mailing_BAO_Job::status($this->status), 'scheduled' => CRM_Utils_Date::customFormat($this->scheduled_date), 'scheduled_iso' => $this->scheduled_date, 'start' => CRM_Utils_Date::customFormat($this->start_date), 'end' => CRM_Utils_Date::customFormat($this->end_date));
     }
     return $rows;
 }
コード例 #12
0
ファイル: GenerateMailing.php プロジェクト: ksecor/civicrm
foreach ($tables as $t) {
    $query = "DELETE FROM {$t}";
    CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
$prefix = 'Automated Mailing Gen: ';
$numGroups = 153;
$status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
for ($i = 1; $i <= $numGroups; $i++) {
    $mailing = new CRM_Mailing_BAO_Mailing();
    $alphabet = mt_rand(97, 122);
    $cnt = sprintf('%05d', $i);
    $mailing->name = chr($alphabet) . ": {$prefix} {$cnt}";
    $mailing->header_id = $mailing->footer_id = $mailing->reply_id = $mailing->unsubscribe_id = $mailing->optout_id = 1;
    $mailing->is_completed = 1;
    $mailing->save();
    $job = new CRM_Mailing_BAO_Job();
    $job->mailing_id = $mailing->id;
    $job->scheduled_date = generateRandomDate();
    $job->start_date = generateRandomDate();
    $job->end_date = generateRandomDate();
    $job->status = 'Complete';
    $job->save();
    $group = new CRM_Mailing_DAO_Group();
    $group->mailing_id = $mailing->id;
    $group->group_type = 'Include';
    $group->entity_table = 'civicrm_group';
    $group->entity_id = 1;
    $group->save();
}
function generateRandomDate()
{
コード例 #13
0
 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
 {
     static $actionLinks = NULL;
     if (empty($actionLinks)) {
         $cancelExtra = ts('Are you sure you want to cancel this mailing?');
         $deleteExtra = ts('Are you sure you want to delete this mailing?');
         $archiveExtra = ts('Are you sure you want to archive this mailing?');
         $actionLinks = array(CRM_Core_Action::ENABLE => array('name' => ts('Approve/Reject'), 'url' => 'civicrm/mailing/approve', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('Approve/Reject Mailing')), CRM_Core_Action::VIEW => array('name' => ts('Report'), 'url' => 'civicrm/mailing/report', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('View Mailing Report')), CRM_Core_Action::UPDATE => array('name' => ts('Re-Use'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('Re-Send Mailing')), CRM_Core_Action::DISABLE => array('name' => ts('Cancel'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=disable&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $cancelExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Cancel Mailing')), CRM_Core_Action::PREVIEW => array('name' => ts('Continue'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&continue=true&reset=1', 'title' => ts('Continue Mailing')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=delete&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $deleteExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Delete Mailing')), CRM_Core_Action::RENEW => array('name' => ts('Archive'), 'url' => 'civicrm/mailing/browse/archived', 'qs' => 'action=renew&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $archiveExtra . '\')) this.href+=\'&amp;confirmed=1\'; else return false;"', 'title' => ts('Archive Mailing')));
     }
     $allAccess = TRUE;
     $workFlow = $showApprovalLinks = $showScheduleLinks = $showCreateLinks = FALSE;
     if (CRM_Mailing_Info::workflowEnabled()) {
         $allAccess = FALSE;
         $workFlow = TRUE;
         //supercedes all permission
         if (CRM_Core_Permission::check('access CiviMail')) {
             $allAccess = TRUE;
         }
         if (CRM_Core_Permission::check('approve mailings')) {
             $showApprovalLinks = TRUE;
         }
         if (CRM_Core_Permission::check('create mailings')) {
             $showCreateLinks = TRUE;
         }
         if (CRM_Core_Permission::check('schedule mailings')) {
             $showScheduleLinks = TRUE;
         }
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $params = array();
     $whereClause = ' AND ' . $this->whereClause($params);
     if (empty($params)) {
         $this->_parent->assign('isSearch', 0);
     } else {
         $this->_parent->assign('isSearch', 1);
     }
     $rows =& $mailing->getRows($offset, $rowCount, $sort, $whereClause, $params);
     //get the search base mailing Ids, CRM-3711.
     $searchMailings = $mailing->searchMailingIDs();
     //check for delete CRM-4418
     $allowToDelete = CRM_Core_Permission::check('delete in CiviMail');
     if ($output != CRM_Core_Selector_Controller::EXPORT) {
         //create the appropriate $op to use for hook_civicrm_links
         $pageTypes = array('view', 'mailing', 'browse');
         if ($this->_parent->_unscheduled) {
             $pageTypes[] = 'unscheduled';
         }
         if ($this->_parent->_scheduled) {
             $pageTypes[] = 'scheduled';
         }
         if ($this->_parent->_archived) {
             $pageTypes[] = 'archived';
         }
         $opString = implode('.', $pageTypes);
         foreach ($rows as $key => $row) {
             $actionMask = NULL;
             if ($row['sms_provider_id']) {
                 $actionLinks[CRM_Core_Action::PREVIEW]['url'] = 'civicrm/sms/send';
             }
             if (!($row['status'] == 'Not scheduled') && !$row['sms_provider_id']) {
                 if ($allAccess || $showCreateLinks) {
                     $actionMask = CRM_Core_Action::VIEW;
                 }
                 if (!in_array($row['id'], $searchMailings)) {
                     if ($allAccess || $showCreateLinks) {
                         $actionMask |= CRM_Core_Action::UPDATE;
                     }
                 }
             } else {
                 //FIXME : currently we are hiding continue action for
                 //search base mailing, we should handle it when we fix CRM-3876
                 if (!in_array($row['id'], $searchMailings)) {
                     if ($allAccess || ($showCreateLinks || $showScheduleLinks)) {
                         $actionMask = CRM_Core_Action::PREVIEW;
                     }
                 }
             }
             if (in_array($row['status'], array('Scheduled', 'Running', 'Paused'))) {
                 if ($allAccess || $showApprovalLinks && $showCreateLinks && $showScheduleLinks) {
                     $actionMask |= CRM_Core_Action::DISABLE;
                 }
                 if ($row['status'] == 'Scheduled' && empty($row['approval_status_id'])) {
                     if ($workFlow && ($allAccess || $showApprovalLinks)) {
                         $actionMask |= CRM_Core_Action::ENABLE;
                     }
                 }
             }
             if ($row['status'] == 'Complete' && !$row['archived']) {
                 if ($allAccess || $showCreateLinks) {
                     $actionMask |= CRM_Core_Action::RENEW;
                 }
             }
             //check for delete permission.
             if ($allowToDelete) {
                 $actionMask |= CRM_Core_Action::DELETE;
             }
             if ($actionMask == NULL) {
                 $actionMask = CRM_Core_Action::ADD;
             }
             //get status strings as per locale settings CRM-4411.
             $rows[$key]['status'] = CRM_Mailing_BAO_Job::status($row['status']);
             $rows[$key]['action'] = CRM_Core_Action::formLink($actionLinks, $actionMask, array('mid' => $row['id']), "more", FALSE, $opString, "Mailing", $row['id']);
             //unset($rows[$key]['id']);
             // if the scheduled date is 0, replace it with an empty string
             if ($rows[$key]['scheduled_iso'] == '0000-00-00 00:00:00') {
                 $rows[$key]['scheduled'] = '';
             }
             unset($rows[$key]['scheduled_iso']);
         }
     }
     // also initialize the AtoZ pager
     $this->pagerAtoZ();
     return $rows;
 }
コード例 #14
0
ファイル: Browse.php プロジェクト: bhirsch/voipdrupal-4.7-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($GLOBALS['_CRM_MAILING_SELECTOR_BROWSE']['_columnHeaders'])) {
         $GLOBALS['_CRM_MAILING_SELECTOR_BROWSE']['_columnHeaders'] = array(array('name' => ts('Mailing Name')), array('name' => ts('Status')), array('name' => ts('Scheduled Date')), array('name' => ts('Start Date')), array('name' => ts('Completed Date')));
         if ($output != CRM_CORE_SELECTOR_CONTROLLER_EXPORT) {
             $GLOBALS['_CRM_MAILING_SELECTOR_BROWSE']['_columnHeaders'][] = array('name' => ts('Action'));
         }
     }
     return $GLOBALS['_CRM_MAILING_SELECTOR_BROWSE']['_columnHeaders'];
 }
コード例 #15
0
 /**
  * Process the posted form values.  Approve /reject a mailing.
  *
  * @param
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $ids = array();
     if (isset($this->_mailingID)) {
         $ids['mailing_id'] = $this->_mailingID;
     } else {
         $ids['mailing_id'] = $this->get('mailing_id');
     }
     if (!$ids['mailing_id']) {
         CRM_Core_Error::fatal();
     }
     $params['approver_id'] = $this->_contactID;
     $params['approval_date'] = date('YmdHis');
     // if rejected, then we need to reset the scheduled date and scheduled id
     $rejectOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'Rejected', 'name');
     if ($rejectOptionID && $params['approval_status_id'] == $rejectOptionID) {
         $params['scheduled_id'] = 'null';
         $params['scheduled_date'] = 'null';
         // also delete any jobs associated with this mailing
         $job = new CRM_Mailing_BAO_Job();
         $job->mailing_id = $ids['mailing_id'];
         $job->delete();
     }
     CRM_Mailing_BAO_Mailing::create($params, $ids);
     //when user perform mailing from search context
     //redirect it to search result CRM-3711
     $ssID = $this->get('ssID');
     if ($ssID && $this->_searchBasedMailing) {
         if ($this->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($this->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($this->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $context = $this->get('context');
         if (!CRM_Contact_Form_Search::isSearchContext($context)) {
             $context = 'search';
         }
         $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
         return $this->controller->setDestination($url);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
 }
コード例 #16
0
 /**
  * cancel a mailing
  *
  * @param int $mailingId  the id of the mailing to be canceled
  * @static
  */
 public static function cancel($mailingId)
 {
     $sql = "\nSELECT *\nFROM   civicrm_mailing_job\nWHERE  mailing_id = %1\nAND    is_test = 0\nAND    ( ( job_type IS NULL ) OR\n           job_type <> 'child' )\n";
     $params = array(1 => array($mailingId, 'Integer'));
     $job = CRM_Core_DAO::executeQuery($sql, $params);
     if ($job->fetch() && in_array($job->status, array('Scheduled', 'Running', 'Paused'))) {
         $newJob = new CRM_Mailing_BAO_Job();
         $newJob->id = $job->id;
         $newJob->end_date = date('YmdHis');
         $newJob->status = 'Canceled';
         $newJob->save();
         // also cancel all child jobs
         $sql = "\nUPDATE civicrm_mailing_job\nSET    status = 'Canceled',\n       end_date = %2\nWHERE  parent_id = %1\nAND    is_test = 0\nAND    job_type = 'child'\nAND    status IN ( 'Scheduled', 'Running', 'Paused' )\n";
         $params = array(1 => array($job->id, 'Integer'), 2 => array(date('YmdHis'), 'Timestamp'));
         CRM_Core_DAO::executeQuery($sql, $params);
         CRM_Core_Session::setStatus(ts('The mailing has been canceled.'));
     }
 }
コード例 #17
0
 static function processQueue($mode = NULL)
 {
     $config =& CRM_Core_Config::singleton();
     CRM_Core_Error::debug_log_message("Beginning processQueue run: {$config->mailerJobsMax}, {$config->mailerJobSize}");
     if ($mode == NULL && CRM_Core_BAO_MailSettings::defaultDomain() == "FIXME.ORG") {
         CRM_Core_Error::fatal(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in the online user and administrator guide</a>', array(1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'), 2 => "http://book.civicrm.org/user/initial-set-up/email-system-configuration")));
     }
     // check if we are enforcing number of parallel cron jobs
     // CRM-8460
     $gotCronLock = FALSE;
     if ($config->mailerJobsMax && $config->mailerJobsMax > 1) {
         $lockArray = range(1, $config->mailerJobsMax);
         shuffle($lockArray);
         // check if we are using global locks
         $serverWideLock = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'civimail_server_wide_lock');
         foreach ($lockArray as $lockID) {
             $cronLock = new CRM_Core_Lock("civimail.cronjob.{$lockID}", NULL, $serverWideLock);
             if ($cronLock->isAcquired()) {
                 $gotCronLock = TRUE;
                 break;
             }
         }
         // exit here since we have enuf cronjobs running
         if (!$gotCronLock) {
             CRM_Core_Error::debug_log_message('Returning early, since max number of cronjobs running');
             return TRUE;
         }
     }
     // load bootstrap to call hooks
     // Split up the parent jobs into multiple child jobs
     CRM_Mailing_BAO_Job::runJobs_pre($config->mailerJobSize, $mode);
     CRM_Mailing_BAO_Job::runJobs(NULL, $mode);
     CRM_Mailing_BAO_Job::runJobs_post($mode);
     // lets release the global cron lock if we do have one
     if ($gotCronLock) {
         $cronLock->release();
     }
     CRM_Core_Error::debug_log_message('Ending processQueue run');
     return TRUE;
 }
コード例 #18
0
 /**
  * Form rule to send out a test mailing.
  *
  * @param array $params     Array of the form values
  * @param array $files      Any files posted to the form
  * @param array $self       an current this object
  *
  * @return boolean          true on succesful SMTP handoff
  * @access public
  */
 static function &testMail($testParams, $files, $self)
 {
     $error = NULL;
     $urlString = 'civicrm/mailing/send';
     $urlParams = "_qf_Test_display=true&qfKey={$testParams['qfKey']}";
     $ssID = $self->get('ssID');
     if ($ssID && $self->_searchBasedMailing) {
         if ($self->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($self->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($self->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $urlString = 'civicrm/contact/' . $fragment;
     }
     $emails = NULL;
     if (CRM_Utils_Array::value('sendtest', $testParams)) {
         if (!($testParams['test_group'] || $testParams['test_email'])) {
             CRM_Core_Session::setStatus(ts('Your did not provided any email address or selected any group. No test mail is sent.'));
             $error = TRUE;
         }
         if ($testParams['test_email']) {
             $emailAdd = explode(',', $testParams['test_email']);
             foreach ($emailAdd as $key => $value) {
                 $email = trim($value);
                 $testParams['emails'][] = $email;
                 $emails .= $emails ? ",'{$email}'" : "'{$email}'";
                 if (!CRM_Utils_Rule::email($email)) {
                     CRM_Core_Session::setStatus(ts('Please enter valid email addresses only.'));
                     $error = TRUE;
                 }
             }
         }
         if ($error) {
             $url = CRM_Utils_System::url($urlString, $urlParams);
             CRM_Utils_System::redirect($url);
             return $error;
         }
     }
     if (CRM_Utils_Array::value('_qf_Test_submit', $testParams)) {
         //when user perform mailing from search context
         //redirect it to search result CRM-3711.
         if ($ssID && $self->_searchBasedMailing) {
             $draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             $status = ts("Your mailing has been saved. You can continue later by clicking the 'Continue' action to resume working on it.<br /> From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
             CRM_Core_Session::setStatus($status);
             //replace user context to search.
             $context = $self->get('context');
             if (!CRM_Contact_Form_Search::isSearchContext($context)) {
                 $context = 'search';
             }
             $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}&qfKey={$testParams['qfKey']}";
             $url = CRM_Utils_System::url($urlString, $urlParams);
             CRM_Utils_System::redirect($url);
         } else {
             $status = ts("Your mailing has been saved. Click the 'Continue' action to resume working on it.");
             CRM_Core_Session::setStatus($status);
             $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             CRM_Utils_System::redirect($url);
         }
     }
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
             CRM_Utils_System::redirect($url);
         }
     }
     if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST) || CRM_Utils_Array::value('_qf_Test_next', $testParams) || !CRM_Utils_Array::value('sendtest', $testParams)) {
         $error = TRUE;
         return $error;
     }
     $job = new CRM_Mailing_BAO_Job();
     $job->mailing_id = $self->get('mailing_id');
     $job->is_test = TRUE;
     $job->save();
     $newEmails = NULL;
     $session = CRM_Core_Session::singleton();
     if (!empty($testParams['emails'])) {
         $query = "\n                      SELECT id, contact_id, email  \n                      FROM civicrm_email  \n                      WHERE civicrm_email.email IN ({$emails})";
         $dao = CRM_Core_DAO::executeQuery($query);
         $emailDetail = array();
         // fetch contact_id and email id for all existing emails
         while ($dao->fetch()) {
             $emailDetail[$dao->email] = array('contact_id' => $dao->contact_id, 'email_id' => $dao->id);
         }
         $dao->free();
         foreach ($testParams['emails'] as $key => $email) {
             $email = trim($email);
             $contactId = $emailId = NULL;
             if (array_key_exists($email, $emailDetail)) {
                 $emailId = $emailDetail[$email]['email_id'];
                 $contactId = $emailDetail[$email]['contact_id'];
             }
             if (!$contactId) {
                 //create new contact.
                 $params = array('contact_type' => 'Individual', 'email' => array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => 1)));
                 $contact = CRM_Contact_BAO_Contact::create($params);
                 $emailId = $contact->email[0]->id;
                 $contactId = $contact->id;
                 $contact->free();
             }
             $params = array('job_id' => $job->id, 'email_id' => $emailId, 'contact_id' => $contactId);
             CRM_Mailing_Event_BAO_Queue::create($params);
         }
     }
     $testParams['job_id'] = $job->id;
     $isComplete = FALSE;
     while (!$isComplete) {
         $isComplete = CRM_Mailing_BAO_Job::runJobs($testParams);
     }
     if (CRM_Utils_Array::value('sendtest', $testParams)) {
         $status = ts('Your test message has been sent.');
         if (CRM_Mailing_Info::workflowEnabled()) {
             if (CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings') || CRM_Core_Permission::check('access CiviMail')) {
                 $status .= ts(" Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
             }
         } else {
             $status .= ts(" Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
         }
         CRM_Core_Session::setStatus($status);
         $url = CRM_Utils_System::url($urlString, $urlParams);
         CRM_Utils_System::redirect($url);
     }
     $error = TRUE;
     return $error;
 }
コード例 #19
0
 /**
  * Send a reponse email informing the contact of the groups to which he/she
  * has been resubscribed.
  *
  * @param string $queue_id      The queue event ID
  * @param array $groups         List of group IDs
  * @param bool $is_domain       Is this domain-level?
  * @param int $job              The job ID
  * @return void
  * @access public
  * @static
  */
 public static function send_resub_response($queue_id, $groups, $is_domain = false, $job)
 {
     // param is_domain is not supported as of now.
     $config = CRM_Core_Config::singleton();
     $domain =& CRM_Core_BAO_Domain::getDomain();
     $jobTable = CRM_Mailing_BAO_Job::getTableName();
     $mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
     $contacts = CRM_Contact_DAO_Contact::getTableName();
     $email = CRM_Core_DAO_Email::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     $dao = new CRM_Mailing_BAO_Mailing();
     $dao->query("   SELECT * FROM {$mailingTable} \n                        INNER JOIN {$jobTable} ON\n                            {$jobTable}.mailing_id = {$mailingTable}.id \n                        WHERE {$jobTable}.id = {$job}");
     $dao->fetch();
     $component = new CRM_Mailing_BAO_Component();
     $component->id = $dao->resubscribe_id;
     $component->find(true);
     $html = $component->body_html;
     if ($component->body_text) {
         $text = $component->body_text;
     } else {
         $text = CRM_Utils_String::htmlToText($component->body_html);
     }
     $eq = new CRM_Core_DAO();
     $eq->query("SELECT     {$contacts}.preferred_mail_format as format,\n                    {$contacts}.id as contact_id,\n                    {$email}.email as email,\n                    {$queue}.hash as hash\n        FROM        {$contacts}\n        INNER JOIN  {$queue} ON {$queue}.contact_id = {$contacts}.id\n        INNER JOIN  {$email} ON {$queue}.email_id = {$email}.id\n        WHERE       {$queue}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer'));
     $eq->fetch();
     foreach ($groups as $key => $value) {
         if (!$value) {
             unset($groups[$key]);
         }
     }
     $message = new Mail_mime("\n");
     list($addresses, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls($job, $queue_id, $eq->hash, $eq->email);
     $bao = new CRM_Mailing_BAO_Mailing();
     $bao->body_text = $text;
     $bao->body_html = $html;
     $tokens = $bao->getTokens();
     require_once 'CRM/Utils/Token.php';
     if ($eq->format == 'HTML' || $eq->format == 'Both') {
         $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, true, $tokens['html']);
         $html = CRM_Utils_Token::replaceResubscribeTokens($html, $domain, $groups, true, $eq->contact_id, $eq->hash);
         $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, true, $tokens['html']);
         $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, null, $tokens['html']);
         $message->setHTMLBody($html);
     }
     if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
         $text = CRM_Utils_Token::replaceDomainTokens($html, $domain, true, $tokens['text']);
         $text = CRM_Utils_Token::replaceResubscribeTokens($text, $domain, $groups, false, $eq->contact_id, $eq->hash);
         $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, false, $tokens['text']);
         $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, null, $tokens['text']);
         $message->setTxtBody($text);
     }
     require_once 'CRM/Core/BAO/MailSettings.php';
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $headers = array('Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'To' => $eq->email, 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}");
     $b =& CRM_Utils_Mail::setMimeParams($message);
     $h =& $message->headers($headers);
     $mailer =& $config->getMailer();
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler'));
     if (is_object($mailer)) {
         $mailer->send($eq->email, $h, $b);
         CRM_Core_Error::setCallback();
     }
 }
コード例 #20
0
 /**
  * Get rows for the event browser
  *
  * @param int $mailing_id       ID of the mailing
  * @param int $job_id           optional ID of the job
  * @param boolean $is_distinct  Group by queue id?
  * @param int $url_id           optional ID of a trackable URL to filter on
  * @param int $offset           Offset
  * @param int $rowCount         Number of rows
  * @param array $sort           sort array
  * @return array                Result set
  * @access public
  * @static
  */
 public static function &getRows($mailing_id, $job_id = null, $is_distinct = false, $url_id, $offset = null, $rowCount = null, $sort = null)
 {
     $dao = new CRM_Core_Dao();
     $click = self::getTableName();
     $url = CRM_Mailing_BAO_TrackableURL::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $query = "\n            SELECT      {$contact}.display_name as display_name,\n                        {$contact}.id as contact_id,\n                        {$email}.email as email,\n                        {$click}.time_stamp as date,\n                        {$url}.url as url\n            FROM        {$contact}\n            INNER JOIN  {$queue}\n                    ON  {$queue}.contact_id = {$contact}.id\n            INNER JOIN  {$email}\n                    ON  {$queue}.email_id = {$email}.id\n            INNER JOIN  {$click}\n                    ON  {$click}.event_queue_id = {$queue}.id\n            INNER JOIN  {$url}\n                    ON  {$click}.trackable_url_id = {$url}.id\n            INNER JOIN  {$job}\n                    ON  {$queue}.job_id = {$job}.id\n            INNER JOIN  {$mailing}\n                    ON  {$job}.mailing_id = {$mailing}.id\n                    AND {$job}.is_test = 0\n            WHERE       {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
     if (!empty($job_id)) {
         $query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
     if (!empty($url_id)) {
         $query .= " AND {$url}.id = " . CRM_Utils_Type::escape($url_id, 'Integer');
     }
     if ($is_distinct) {
         $query .= " GROUP BY {$queue}.id ";
     }
     $orderBy = "sort_name ASC, {$click}.time_stamp DESC";
     if ($sort) {
         if (is_string($sort)) {
             $orderBy = $sort;
         } else {
             $orderBy = trim($sort->orderBy());
         }
     }
     $query .= " ORDER BY {$orderBy} ";
     if ($offset || $rowCount) {
         //Added "||$rowCount" to avoid displaying all records on first page
         $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
     $dao->query($query);
     $results = array();
     while ($dao->fetch()) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}");
         $results[] = array('name' => "<a href=\"{$url}\">{$dao->display_name}</a>", 'email' => $dao->email, 'url' => $dao->url, 'date' => CRM_Utils_Date::customFormat($dao->date));
     }
     return $results;
 }
コード例 #21
0
ファイル: Retry.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 function postProcess()
 {
     $mailing_id = $this->get('mailing_id');
     $mailing_name = $this->get('mailing_name');
     $start_date = $this->controller->exportValue($this->_name, 'start_date');
     $now = $this->controller->exportValue($this->_name, 'now');
     if ($now) {
         $start_date = date('YmdHis');
     } else {
         $start_date = CRM_Utils_Date::format($start_date);
     }
     require_once 'CRM/Mailing/BAO/Job.php';
     CRM_Mailing_BAO_Job::retry($mailing_id, $start_date);
     CRM_Core_Session::setStatus(ts('Retry scheduled for mailing: %1', array(1 => $mailing_name)));
 }
コード例 #22
0
ファイル: civimail.cronjob.php プロジェクト: ksecor/civicrm
/**
 * A PHP cron script to run the outstanding and scheduled CiviMail jobs
 * initiated by Owen Barton from a mailing sent by Lobo to crm-mail
 *
 * The structure of the file is set to mimiic soap.php which is a stand-alone
 * script and hence does not have any UF issues. You should be able to run
 * this script using a web url or from the command line
 */
function processQueue()
{
    require_once 'CRM/Mailing/BAO/Job.php';
    CRM_Mailing_BAO_Job::runJobs();
}
コード例 #23
0
 /**
  * Process the posted form values.  Create and schedule a Mass SMS.
  *
  * @param
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
     if (empty($params['mailing_id'])) {
         CRM_Core_Error::fatal(ts('Could not find a mailing id'));
     }
     foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
         $params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $ids['mailing_id'];
     if ($mailing->find(TRUE)) {
         $job = new CRM_Mailing_BAO_Job();
         $job->mailing_id = $mailing->id;
         $job->is_test = 0;
         if ($job->find(TRUE)) {
             CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
         }
         if (empty($mailing->is_template)) {
             $job->status = 'Scheduled';
             if ($params['now']) {
                 $job->scheduled_date = date('YmdHis');
             } else {
                 $job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
             }
             $job->save();
         }
         // also set the scheduled_id
         $session = CRM_Core_Session::singleton();
         $mailing->scheduled_id = $session->get('userID');
         $mailing->scheduled_date = date('YmdHis');
         $mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
         $mailing->save();
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true&sms=1'));
 }
コード例 #24
0
ファイル: Browse.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Mailing_BAO_Mailing::del($this->_mailingId);
     } elseif ($this->_action & CRM_Core_Action::DISABLE) {
         CRM_Mailing_BAO_Job::cancel($this->_mailingId);
     } elseif ($this->_action & CRM_Core_Action::RENEW) {
         //set is_archived to 1
         CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', true);
     }
 }
コード例 #25
0
ファイル: Forward.php プロジェクト: bhirsch/voipdev
 /**
  * Get rows for the event browser
  *
  * @param int $mailing_id       ID of the mailing
  * @param int $job_id           optional ID of the job
  * @param boolean $is_distinct  Group by queue id?
  * @param int $offset           Offset
  * @param int $rowCount         Number of rows
  * @param array $sort           sort array
  * @return array                Result set
  * @access public
  * @static
  */
 public static function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
 {
     $dao =& new CRM_Core_Dao();
     $forward = self::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $query = "\n            SELECT      {$contact}.display_name as from_name,\n                        {$contact}.id as from_id,\n                        {$email}.email as from_email,\n                        dest_contact.id as dest_id,\n                        dest_email.email as dest_email,\n                        {$forward}.time_stamp as date\n            FROM        {$contact}\n            INNER JOIN  {$queue}\n                    ON  {$queue}.contact_id = {$contact}.id\n            INNER JOIN  {$email}\n                    ON  {$queue}.email_id = {$email}.id\n            INNER JOIN  {$forward}\n                    ON  {$forward}.event_queue_id = {$queue}.id\n            INNER JOIN  {$queue} as dest_queue\n                    ON  {$forward}.dest_queue_id = dest_queue.id\n            INNER JOIN  {$contact} as dest_contact\n                    ON  dest_queue.contact_id = dest_contact.id\n            INNER JOIN  {$email} as dest_email\n                    ON  dest_queue.email_id = dest_email.id\n            INNER JOIN  {$job}\n                    ON  {$queue}.job_id = {$job}.id\n            INNER JOIN  {$mailing}\n                    ON  {$job}.mailing_id = {$mailing}.id\n                    AND {$job}.is_test = 0\n            WHERE       {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
     if (!empty($job_id)) {
         $query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
     if ($is_distinct) {
         $query .= " GROUP BY {$queue}.id ";
     }
     $query .= " ORDER BY {$contact}.sort_name, {$forward}.time_stamp DESC ";
     if ($offset || $rowCount) {
         //Added "||$rowCount" to avoid displaying all records on first page
         $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
     $dao->query($query);
     $results = array();
     while ($dao->fetch()) {
         $from_url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->from_id}");
         $dest_url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->dest_id}");
         $results[] = array('from_name' => "<a href=\"{$from_url}\">{$dao->from_name}</a>", 'from_email' => $dao->from_email, 'dest_email' => "<a href=\"{$dest_url}\">{$dao->dest_email}</a>", 'date' => CRM_Utils_Date::customFormat($dao->date));
     }
     return $results;
 }
コード例 #26
0
ファイル: Mailing.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * Delete Jobss and all its associated records 
  * related to test Mailings
  *
  * @param  int  $id id of the Job to delete
  *
  * @return void
  * @access public
  * @static
  */
 public static function delJob($id)
 {
     if (empty($id)) {
         CRM_Core_Error::fatal();
     }
     $dao = new CRM_Mailing_BAO_Job();
     $dao->id = $id;
     $dao->delete();
 }
コード例 #27
0
ファイル: Bounce.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * Get rows for the event browser
  *
  * @param int $mailing_id       ID of the mailing
  * @param int $job_id           optional ID of the job
  * @param boolean $is_distinct  Group by queue id?
  * @param int $offset           Offset
  * @param int $rowCount         Number of rows
  * @param array $sort           sort array
  * @return array                Result set
  * @access public
  * @static
  */
 function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
 {
     $dao =& new CRM_Core_Dao();
     $bounce = CRM_Mailing_Event_BAO_Bounce::getTableName();
     $bounceType = CRM_Mailing_DAO_BounceType::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $query = "\n            SELECT      {$contact}.display_name as display_name,\n                        {$contact}.id as contact_id,\n                        {$email}.email as email,\n                        {$bounce}.time_stamp as date,\n                        {$bounce}.bounce_reason as reason,\n                        {$bounceType}.name as bounce_type\n            FROM        {$contact}\n            INNER JOIN  {$queue}\n                    ON  {$queue}.contact_id = {$contact}.id\n            INNER JOIN  {$email}\n                    ON  {$queue}.email_id = {$email}.id\n            INNER JOIN  {$bounce}\n                    ON  {$bounce}.event_queue_id = {$queue}.id\n            LEFT JOIN   {$bounceType}\n                    ON  {$bounce}.bounce_type_id = {$bounceType}.id\n            INNER JOIN  {$job}\n                    ON  {$queue}.job_id = {$job}.id\n            INNER JOIN  {$mailing}\n                    ON  {$job}.mailing_id = {$mailing}.id\n            WHERE       {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
     if (!empty($job_id)) {
         $query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
     if ($is_distinct) {
         $query .= " GROUP BY {$queue}.id ";
     }
     $query .= " ORDER BY {$contact}.sort_name, {$bounce}.time_stamp ";
     if ($offset) {
         $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
     $dao->query($query);
     $results = array();
     while ($dao->fetch()) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}");
         $results[] = array('name' => "<a href=\"{$url}\">{$dao->display_name}</a>", 'email' => $dao->email, 'type' => empty($dao->bounce_type) ? ts('Unknown') : $dao->bounce_type, 'reason' => $dao->reason, 'date' => CRM_Utils_Date::customFormat($dao->date));
     }
     return $results;
 }
コード例 #28
0
 /**
  * Get rows for the event browser
  *
  * @param int $mailing_id       ID of the mailing
  * @param int $job_id           optional ID of the job
  * @param boolean $is_distinct  Group by queue id?
  * @param int $offset           Offset
  * @param int $rowCount         Number of rows
  * @param array $sort           sort array
  *
  * @return array                Result set
  * @access public
  * @static
  */
 public static function &getRows($mailing_id, $job_id = NULL, $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $org_unsubscribe = NULL)
 {
     $dao = new CRM_Core_Dao();
     $unsub = self::$_tableName;
     $queueObject = new CRM_Mailing_Event_BAO_Queue();
     $queue = $queueObject->getTableName();
     $mailingObject = new CRM_Mailing_BAO_Mailing();
     $mailing = $mailingObject->getTableName();
     $jobObject = new CRM_Mailing_BAO_Job();
     $job = $jobObject->getTableName();
     $contactObject = new CRM_Contact_BAO_Contact();
     $contact = $contactObject->getTableName();
     $emailObject = new CRM_Core_BAO_Email();
     $email = $emailObject->getTableName();
     $query = "\n            SELECT      {$contact}.display_name as display_name,\n                        {$contact}.id as contact_id,\n                        {$email}.email as email,\n                        {$unsub}.time_stamp as date,\n                        {$unsub}.org_unsubscribe as org_unsubscribe\n            FROM        {$contact}\n            INNER JOIN  {$queue}\n                    ON  {$queue}.contact_id = {$contact}.id\n            INNER JOIN  {$email}\n                    ON  {$queue}.email_id = {$email}.id\n            INNER JOIN  {$unsub}\n                    ON  {$unsub}.event_queue_id = {$queue}.id\n            INNER JOIN  {$job}\n                    ON  {$queue}.job_id = {$job}.id\n            INNER JOIN  {$mailing}\n                    ON  {$job}.mailing_id = {$mailing}.id\n                    AND {$job}.is_test = 0\n            WHERE       {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
     if (!empty($job_id)) {
         $query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
     if ($org_unsubscribe !== NULL) {
         $query .= " AND {$unsub}.org_unsubscribe = " . ($org_unsubscribe ? 0 : 1);
     }
     if ($is_distinct) {
         $query .= " GROUP BY {$queue}.id ";
     }
     $orderBy = "sort_name ASC, {$unsub}.time_stamp DESC";
     if ($sort) {
         if (is_string($sort)) {
             $orderBy = $sort;
         } else {
             $orderBy = trim($sort->orderBy());
         }
     }
     $query .= " ORDER BY {$orderBy} ";
     if ($offset || $rowCount) {
         //Added "||$rowCount" to avoid displaying all records on first page
         $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
     $dao->query($query);
     $results = array();
     while ($dao->fetch()) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}");
         $results[] = array('name' => "<a href=\"{$url}\">{$dao->display_name}</a>", 'email' => $dao->email, 'org' => $dao->org_unsubscribe ? ts('Yes') : ts('No'), 'date' => CRM_Utils_Date::customFormat($dao->date));
     }
     return $results;
 }
コード例 #29
0
ファイル: Queue.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /**
  * Get the mailing object for this queue event instance
  * 
  * @param
  * @return object           Mailing BAO
  * @access public
  */
 function &getMailing()
 {
     $mailing =& new CRM_Mailing_BAO_Mailing();
     $jobs = CRM_Mailing_BAO_Job::getTableName();
     $mailings = CRM_Mailing_BAO_Mailing::getTableName();
     $queue = CRM_Mailing_Event_BAO_Queue::getTableName();
     $mailing->query("\n                SELECT      {$mailings}.*\n                FROM        {$mailings}\n                INNER JOIN  {$jobs}\n                        ON  {$jobs}.mailing_id = {$mailings}.id\n                INNER JOIN  {$queue}\n                        ON  {$queue}.job_id = {$jobs}.id\n                WHERE       {$queue}.id = {$this->id}");
     $mailing->fetch();
     return $mailing;
 }
コード例 #30
0
ファイル: Invoke.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 function main(&$args)
 {
     if ($args[1] !== 'mailing') {
         return;
     }
     require_once 'CRM/Mailing/Controller/Send.php';
     require_once 'CRM/Mailing/Page/Browse.php';
     require_once 'CRM/Mailing/BAO/Job.php';
     if ($args[2] == 'forward') {
         $session =& CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::baseURL());
         $wrapper =& new CRM_Utils_Wrapper();
         return $wrapper->run('CRM_Profile_Form_ForwardMailing', ts('Forward Mailing'), null);
     }
     if ($args[2] == 'retry') {
         $session =& CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse'));
         CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
         CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/report') . '">' . ts('Report') . '</a>');
         $wrapper =& new CRM_Utils_Wrapper();
         return $wrapper->run('CRM_Mailing_Form_Retry', ts('Retry Mailing'), null);
     }
     if ($args[2] == 'component') {
         require_once 'CRM/Mailing/Page/Component.php';
         $view =& new CRM_Mailing_Page_Component();
         return $view->run();
     }
     if ($args[2] == 'browse') {
         require_once 'CRM/Mailing/Page/Browse.php';
         $view =& new CRM_Mailing_Page_Browse();
         return $view->run();
     }
     if ($args[2] == 'event') {
         CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
         CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/report') . '">' . ts('Report') . '</a>');
         require_once 'CRM/Mailing/Page/Event.php';
         $view =& new CRM_Mailing_Page_Event();
         return $view->run();
     }
     if ($args[2] == 'report') {
         CRM_Utils_System::appendBreadCrumb('<a href="' . CRM_Utils_System::url('civicrm/mailing/browse') . '">' . ts('Mailings') . '</a>');
         require_once 'CRM/Mailing/Page/Report.php';
         $view =& new CRM_Mailing_Page_Report();
         return $view->run();
     }
     if ($args[2] == 'send') {
         $session =& CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1'));
         require_once 'CRM/Mailing/Controller/Send.php';
         $controller =& new CRM_Mailing_Controller_Send(ts('Send Mailing'));
         return $controller->run();
     }
     if ($args[2] == 'queue') {
         $session =& CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse', 'reset=1'));
         require_once 'CRM/Mailing/BAO/Job.php';
         CRM_Mailing_BAO_Job::runJobs();
         CRM_Core_Session::setStatus(ts('The mailing queue has been processed.'));
     }
     require_once 'CRM/Mailing/Page/Browse.php';
     $view =& new CRM_Mailing_Page_Browse();
     return $view->run();
 }