From: Deepak Srivastava Date: Wed, 17 Apr 2013 14:03:36 +0000 (+0530) Subject: Fix for CRM-12362 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1e2f5f2500d1f7ddcc89a3c53fea17902ef825d4;p=civicrm-core.git Fix for CRM-12362 --- diff --git a/CRM/SMS/Form/Schedule.php b/CRM/SMS/Form/Schedule.php index 555973d5eb..ab7384c0af 100644 --- a/CRM/SMS/Form/Schedule.php +++ b/CRM/SMS/Form/Schedule.php @@ -162,42 +162,39 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { 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 - ); + 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(); + if ($params['now']) { + $params['scheduled_date'] = date('YmdHis'); + } + else { + $params['scheduled_date'] = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']); + } + + $session = CRM_Core_Session::singleton(); + // set the scheduled_id + $params['scheduled_id'] = $session->get('userID'); + $params['scheduled_date'] = date('YmdHis'); + + // set approval details if workflow is not enabled + if (!CRM_Mailing_Info::workflowEnabled()) { + $params['approver_id'] = $session->get('userID'); + $params['approval_date'] = date('YmdHis'); + $params['approval_status_id'] = 1; } + if ($params['now']) { + $params['scheduled_date'] = date('YmdHis'); + } + else { + $params['scheduled_date'] = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']); + } + + /* Build the mailing object */ + 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&sms=1' diff --git a/CRM/SMS/Provider.php b/CRM/SMS/Provider.php index f72ec43f9e..ae9cbeaee6 100644 --- a/CRM/SMS/Provider.php +++ b/CRM/SMS/Provider.php @@ -291,5 +291,17 @@ INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1"; return $phone; } } + + function urlEncode($values) { + $uri = ''; + foreach ($values as $key => $value) { + $value = urlencode($value); + $uri .= "&{$key}={$value}"; + } + if (!empty($uri)) { + $uri = substr($uri, 1); + } + return $uri; + } } diff --git a/tools/extensions/org.civicrm.sms.clickatell.zip b/tools/extensions/org.civicrm.sms.clickatell.zip index c64f100796..6d8308ce37 100644 Binary files a/tools/extensions/org.civicrm.sms.clickatell.zip and b/tools/extensions/org.civicrm.sms.clickatell.zip differ diff --git a/tools/extensions/org.civicrm.sms.clickatell/org_civicrm_sms_clickatell.php b/tools/extensions/org.civicrm.sms.clickatell/org_civicrm_sms_clickatell.php index 1eeac0664d..6aeeb5d23e 100644 --- a/tools/extensions/org.civicrm.sms.clickatell/org_civicrm_sms_clickatell.php +++ b/tools/extensions/org.civicrm.sms.clickatell/org_civicrm_sms_clickatell.php @@ -184,8 +184,8 @@ class org_civicrm_sms_clickatell extends CRM_SMS_Provider { $this->_providerInfo['api_params']['is_test'] == 1 ) { $response = array('data' => 'OK:' . rand()); } else { - $postData = CRM_Utils_Array::urlEncode($postDataArray); - $response = $this->curl($url, $postData); + $postData = $this->urlEncode($postDataArray); + $response = $this->curl($url, $postData); } if (PEAR::isError($response)) { return $response; @@ -271,7 +271,7 @@ class org_civicrm_sms_clickatell extends CRM_SMS_Provider { $response = array('data' => 'ID:' . rand()); } else { - $postData = CRM_Utils_Array::urlEncode($postDataArray); + $postData = $this->urlEncode($postDataArray); $response = $this->curl($url, $postData); } if (PEAR::isError($response)) {