First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,78 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class contains all the function that are called using AJAX
*/
class CRM_Mailing_Page_AJAX {
/**
* Fetch the template text/html messages
*/
public static function template() {
$templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer');
$messageTemplate = new CRM_Core_DAO_MessageTemplate();
$messageTemplate->id = $templateId;
$messageTemplate->selectAdd();
$messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id');
$messageTemplate->find(TRUE);
$messages = array(
'subject' => $messageTemplate->msg_subject,
'msg_text' => $messageTemplate->msg_text,
'msg_html' => $messageTemplate->msg_html,
'pdf_format_id' => $messageTemplate->pdf_format_id,
);
$documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId);
foreach ((array) $documentInfo as $info) {
list($messages['document_body']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
}
CRM_Utils_JSON::output($messages);
}
/**
* Retrieve contact mailings.
*/
public static function getContactMailings() {
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
$params += CRM_Core_Page_AJAX::validateParams(array('contact_id' => 'Integer'));
// get the contact mailings
$mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
CRM_Utils_JSON::output($mailings);
}
}

View file

@ -0,0 +1,339 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This implements the profile page for all contacts. It uses a selector
* object to do the actual dispay. The fields displayd are controlled by
* the admin
*/
class CRM_Mailing_Page_Browse extends CRM_Core_Page {
/**
* All the fields that are listings related.
*
* @var array
*/
protected $_fields;
/**
* The mailing id of the mailing we're operating on
*
* @var int
*/
protected $_mailingId;
/**
* The action that we are performing (in CRM_Core_Action terms)
*
* @var int
*/
protected $_action;
public $_sortByCharacter;
public $_unscheduled;
public $_archived;
/**
* Scheduled mailing.
*
* @var boolean
*/
public $_scheduled;
public $_sms;
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*/
public function preProcess() {
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_unscheduled = $this->_archived = $archiveLinks = FALSE;
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
$this->_sms = CRM_Utils_Request::retrieve('sms', 'Positive', $this);
$this->assign('sms', $this->_sms);
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->assign('action', $this->_action);
$showLinks = TRUE;
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('create mailings')) {
$archiveLinks = TRUE;
}
if (!CRM_Core_Permission::check('access CiviMail') &&
!CRM_Core_Permission::check('create mailings')
) {
$showLinks = FALSE;
}
}
$this->assign('showLinks', $showLinks);
if (CRM_Core_Permission::check('access CiviMail')) {
$archiveLinks = TRUE;
}
if ($archiveLinks == TRUE) {
$this->assign('archiveLinks', $archiveLinks);
}
}
/**
* Run this page (figure out the action needed and perform it).
*/
public function run() {
$this->preProcess();
$newArgs = func_get_args();
// since we want only first function argument
$newArgs = $newArgs[0];
if (isset($_GET['runJobs']) || CRM_Utils_Array::value('2', $newArgs) == 'queue') {
$mailerJobSize = Civi::settings()->get('mailerJobSize');
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize);
CRM_Mailing_BAO_MailingJob::runJobs();
CRM_Mailing_BAO_MailingJob::runJobs_post();
}
$this->_sortByCharacter
= CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
// CRM-11920 all should set sortByCharacter to null, not empty string
if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) {
$this->_sortByCharacter = NULL;
$this->set('sortByCharacter', NULL);
}
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);
}
if ($this->_sms) {
$this->set('sms', $this->_sms);
}
$session = CRM_Core_Session::singleton();
$context = $session->readUserContext();
if ($this->_action & CRM_Core_Action::DISABLE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
CRM_Mailing_BAO_MailingJob::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();
}
}
elseif ($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.'));
}
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();
}
}
elseif ($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 ($this->get('sms')) {
$urlParams .= '&sms=1';
}
if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
$urlString .= '/unscheduled';
$urlParams .= '&scheduled=false';
$this->assign('unscheduled', TRUE);
}
elseif (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
$urlString .= '/archived';
$this->assign('archived', TRUE);
}
elseif (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
$urlString .= '/scheduled';
$urlParams .= '&scheduled=true';
}
if ($this->get('sms')) {
CRM_Utils_System::setTitle(ts('Find Mass SMS'));
}
$crmRowCount = CRM_Utils_Request::retrieve('crmRowCount', 'Integer');
$crmPID = CRM_Utils_Request::retrieve('crmPID', 'Integer');
if ($crmRowCount || $crmPID) {
$urlParams .= '&force=1';
$urlParams .= $crmRowCount ? '&crmRowCount=' . $crmRowCount : '';
$urlParams .= $crmPID ? '&crmPID=' . $crmPID : '';
}
$crmSID = CRM_Utils_Request::retrieve('crmSID', 'Integer');
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();
}
public function search() {
if ($this->_action & (CRM_Core_Action::ADD |
CRM_Core_Action::UPDATE
)
) {
return;
}
$form = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Search',
ts('Search Mailings'),
CRM_Core_Action::ADD
);
$form->setEmbedded(TRUE);
$form->setParent($this);
$form->process();
$form->run();
}
/**
* @param array $params
* @param bool $sortBy
*
* @return string
*/
public function whereClause(&$params, $sortBy = TRUE) {
$values = array();
$clauses = array();
$title = $this->get('mailing_name');
// echo " name=$title ";
if ($title) {
$clauses[] = 'name LIKE %1';
if (strpos($title, '%') !== FALSE) {
$params[1] = array($title, 'String', FALSE);
}
else {
$params[1] = array($title, 'String', TRUE);
}
}
if ($sortBy &&
$this->_sortByCharacter !== NULL
) {
$clauses[] = "name LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
}
$campainIds = $this->get('campaign_id');
if (!CRM_Utils_System::isNull($campainIds)) {
if (!is_array($campainIds)) {
$campaignIds = array($campaignIds);
}
$clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )';
}
return implode(' AND ', $clauses);
}
}

View file

@ -0,0 +1,130 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Mailing_Page_Common extends CRM_Core_Page {
protected $_type = NULL;
/**
* Run page.
*
* This includes assigning smarty variables and other page processing.
*
* @return string
* @throws Exception
*/
public function run() {
$job_id = CRM_Utils_Request::retrieve('jid', 'Integer');
$queue_id = CRM_Utils_Request::retrieve('qid', 'Integer');
$hash = CRM_Utils_Request::retrieve('h', 'String');
if (!$job_id ||
!$queue_id ||
!$hash
) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
// verify that the three numbers above match
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
CRM_Core_Error::fatal(ts("There was an error in your request"));
}
$cancel = CRM_Utils_Request::retrieve("_qf_{$this->_type}_cancel", 'String', CRM_Core_DAO::$_nullObject,
FALSE, NULL, $_REQUEST
);
if ($cancel) {
$config = CRM_Core_Config::singleton();
CRM_Utils_System::redirect($config->userFrameworkBaseURL);
}
$confirm = CRM_Utils_Request::retrieve('confirm', 'Boolean', CRM_Core_DAO::$_nullObject,
FALSE, NULL, $_REQUEST
);
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
$this->assign('confirm', $confirm);
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
$this->assign('groups', $groups);
$groupExist = NULL;
foreach ($groups as $key => $value) {
if ($value) {
$groupExist = TRUE;
}
}
$this->assign('groupExist', $groupExist);
if ($confirm) {
if ($this->_type == 'unsubscribe') {
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash);
if (count($groups)) {
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, $groups, FALSE, $job_id);
}
else {
// should we indicate an error, or just ignore?
}
}
elseif ($this->_type == 'resubscribe') {
$groups = CRM_Mailing_Event_BAO_Resubscribe::resub_to_mailing($job_id, $queue_id, $hash);
if (count($groups)) {
CRM_Mailing_Event_BAO_Resubscribe::send_resub_response($queue_id, $groups, FALSE, $job_id);
}
else {
// should we indicate an error, or just ignore?
}
}
else {
if (CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_domain($job_id, $queue_id, $hash)) {
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, NULL, TRUE, $job_id);
}
else {
// should we indicate an error, or just ignore?
}
}
}
else {
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}",
"reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1"
);
$this->assign('confirmURL', $confirmURL);
// push context for further process CRM-4431
$session = CRM_Core_Session::singleton();
$session->pushUserContext($confirmURL);
}
return parent::run();
}
}

View file

@ -0,0 +1,128 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* Page to display / edit the header / footer of a mailing
*
*/
class CRM_Mailing_Page_Component extends CRM_Core_Page_Basic {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO.
*/
public function getBAOName() {
return 'CRM_Mailing_BAO_Component';
}
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => CRM_Utils_System::currentPath(),
'qs' => 'action=update&id=%%id%%',
'title' => ts('Edit Mailing Component'),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Mailing Component'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Mailing Component'),
),
);
}
return self::$_links;
}
/**
* Get name of edit form.
*
* @return string
* Classname of edit form.
*/
public function editForm() {
return 'CRM_Mailing_Form_Component';
}
/**
* Get edit form name.
*
* @return string
* name of this page.
*/
public function editName() {
return 'Mailing Components';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return CRM_Utils_System::currentPath();
}
/**
* @param null $args
* @param null $pageArgs
* @param null $sort
*/
public function run($args = NULL, $pageArgs = NULL, $sort = NULL) {
return parent::run($args, $pageArgs, "component_type, is_default desc, name");
}
}

View file

@ -0,0 +1,68 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Mailing_Page_Confirm extends CRM_Core_Page {
/**
* @return string
* @throws Exception
*/
public function run() {
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
$contact_id = CRM_Utils_Request::retrieve('cid', 'Integer');
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer');
$hash = CRM_Utils_Request::retrieve('h', 'String');
if (!$contact_id ||
!$subscribe_id ||
!$hash
) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
$result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash);
if ($result === FALSE) {
$this->assign('success', $result);
}
else {
$this->assign('success', TRUE);
$this->assign('group', $result);
}
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id);
$this->assign('display_name', $displayName);
$this->assign('email', $email);
return parent::run();
}
}

View file

@ -0,0 +1,120 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This implements the profile page for all contacts.
*
* It uses a selector object to do the actual display. The fields displayed are controlled by
* the admin
*/
class CRM_Mailing_Page_Event extends CRM_Core_Page {
/**
* All the fields that are listings related.
*
* @var array
*/
protected $_fields;
/**
* Run this page (figure out the action needed and perform it).
*/
public function run() {
$selector = new CRM_Mailing_Selector_Event(
CRM_Utils_Request::retrieve('event', 'String', $this),
CRM_Utils_Request::retrieve('distinct', 'Boolean', $this),
CRM_Utils_Request::retrieve('mid', 'Positive', $this),
CRM_Utils_Request::retrieve('jid', 'Positive', $this),
CRM_Utils_Request::retrieve('uid', 'Positive', $this)
);
$mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($mailing_id);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
if ($context == 'activitySelector') {
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
$backUrlTitle = ts('Back to Activities');
}
elseif ($context == 'mailing') {
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
$backUrlTitle = ts('Back to Mailing');
}
elseif ($context == 'angPage') {
$angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this);
if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) {
CRM_Core_Error::fatal('Malformed return URL');
}
$backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage);
$backUrlTitle = ts('Back to Report');
}
else {
$backUrl = CRM_Utils_System::url('civicrm/mailing/report', "reset=1&mid={$mailing_id}");
$backUrlTitle = ts('Back to Report');
}
$this->assign('backUrl', $backUrl);
$this->assign('backUrlTitle', $backUrlTitle);
CRM_Utils_System::setTitle($selector->getTitle());
$this->assign('title', $selector->getTitle());
$this->assign('mailing_id', $mailing_id);
$sortID = NULL;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
);
}
$controller = new CRM_Core_Selector_Controller(
$selector,
$this->get(CRM_Utils_Pager::PAGE_ID),
$sortID,
CRM_Core_Action::VIEW,
$this,
CRM_Core_Selector_Controller::TEMPLATE
);
$controller->setEmbedded(TRUE);
$controller->run();
return parent::run();
}
}

View file

@ -0,0 +1,47 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Mailing_Page_Optout extends CRM_Mailing_Page_Common {
/**
* Run page.
*
* This includes assigning smarty variables and other page processing.
*
* @return string
* @throws Exception
*/
public function run() {
$this->_type = 'optout';
return parent::run();
}
}

View file

@ -0,0 +1,101 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* a page for mailing preview
*/
class CRM_Mailing_Page_Preview extends CRM_Core_Page {
/**
* Run this page (figure out the action needed and perform it).
*/
public function run() {
$session = CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
$type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
$options = array();
$session->getVars($options, "CRM_Mailing_Controller_Send_$qfKey");
// get the options if control come from search context, CRM-3711
if (empty($options)) {
$session->getVars($options, "CRM_Contact_Controller_Search_$qfKey");
}
// FIXME: the below and CRM_Mailing_Form_Test::testMail()
// should be refactored
$fromEmail = NULL;
$mailing = new CRM_Mailing_BAO_Mailing();
if (!empty($options)) {
$mailing->id = $options['mailing_id'];
$fromEmail = CRM_Utils_Array::value('from_email', $options);
}
$mailing->find(TRUE);
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
// get and format attachments
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
$mailing->id
);
// get details of contact with token value including Custom Field Token Values.CRM-3734
$returnProperties = $mailing->getReturnProperties();
$params = array('contact_id' => $session->get('userID'));
$details = CRM_Utils_Token::getTokenDetails($params,
$returnProperties,
TRUE, TRUE, NULL,
$mailing->getFlattenedTokens(),
get_class($this)
);
$mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
TRUE, $details[0][$session->get('userID')], $attachments
);
if ($type == 'html') {
CRM_Utils_System::setHttpHeader('Content-Type', 'text/html; charset=utf-8');
print $mime->getHTMLBody();
}
else {
CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain; charset=utf-8');
print $mime->getTXTBody();
}
CRM_Utils_System::civiExit();
}
}

View file

@ -0,0 +1,149 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* Page to display / edit the header / footer of a mailing.
*/
class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
public $_mailing_id;
/**
* Get BAO Name.
*
* @return string
* Classname of BAO
*/
public function getBAOName() {
return 'CRM_Mailing_BAO_Mailing';
}
/**
* An array of action links.
*
* @return null
*/
public function &links() {
return CRM_Core_DAO::$_nullObject;
}
/**
* @return null
*/
public function editForm() {
return NULL;
}
/**
* @return string
*/
public function editName() {
return 'CiviMail Report';
}
/**
* Get user context.
*
* @param null $mode
*
* @return string
* user context.
*/
public function userContext($mode = NULL) {
return 'civicrm/mailing/report';
}
/**
* @param null $mode
*
* @return string
*/
public function userContextParams($mode = NULL) {
return 'reset=1&mid=' . $this->_mailing_id;
}
/**
* @return string
*/
public function run() {
$this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
//CRM-15979 - check if abtest exist for mailing then redirect accordingly
$abtest = CRM_Mailing_BAO_MailingAB::getABTest($this->_mailing_id);
if (!empty($abtest) && !empty($abtest->id)) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id));
}
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id);
$report = CRM_Mailing_BAO_Mailing::report($this->_mailing_id);
// get contents of mailing
CRM_Mailing_BAO_Mailing::getMailingContent($report, $this);
// assign backurl
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($context == 'activitySelector') {
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
$backUrlTitle = ts('Back to Activities');
}
elseif ($context == 'activity') {
$atype = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
$aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this);
$backUrl = CRM_Utils_System::url('civicrm/activity/view',
"atype={$atype}&action=view&reset=1&id={$aid}&cid={$cid}&context=activity"
);
$backUrlTitle = ts('Back to Activity');
}
elseif ($context == 'mailing') {
$backUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=mailing");
$backUrlTitle = ts('Back to Mailing');
}
else {
$backUrl = CRM_Utils_System::url('civicrm/mailing', 'reset=1');
$backUrlTitle = ts('Back to CiviMail');
}
$this->assign('backUrl', $backUrl);
$this->assign('backUrlTitle', $backUrlTitle);
$this->assign('report', $report);
CRM_Utils_System::setTitle(ts('CiviMail Report: %1',
array(1 => $report['mailing']['name'])
));
$this->assign('public_url', CRM_Mailing_BAO_Mailing::getPublicViewUrl($this->_mailing_id));
return CRM_Core_Page::run();
}
}

View file

@ -0,0 +1,42 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Mailing_Page_Resubscribe extends CRM_Mailing_Page_Common {
/**
* @return string
*/
public function run() {
$this->_type = 'resubscribe';
return parent::run();
}
}

View file

@ -0,0 +1,83 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class handle mailing and contact related functions
*/
class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_links = NULL;
public $_permission = NULL;
public $_contactId = NULL;
/**
* Called when action is browse.
*/
public function browse() {
}
/**
* Build all the data structures needed to build the form.
*/
public function preProcess() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('contactId', $this->_contactId);
$this->assign('displayName', $displayName);
// Check logged in url permission.
CRM_Contact_Page_View::checkUserPermission($this);
CRM_Utils_System::setTitle(ts('Mailings sent to %1', array(1 => $displayName)));
}
/**
* The main function that is called when the page loads.
*
* It decides the which action has to be taken for the page.
*/
public function run() {
$this->preProcess();
$this->browse();
parent::run();
}
}

View file

@ -0,0 +1,48 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Mailing_Page_Unsubscribe extends CRM_Mailing_Page_Common {
/**
* Run page.
*
* This includes assigning smarty variables and other page processing.
*
* @return string
* @throws Exception
*/
public function run() {
$this->_type = 'unsubscribe';
return parent::run();
}
}

View file

@ -0,0 +1,203 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| 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 GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* A page for mailing preview.
*/
class CRM_Mailing_Page_View extends CRM_Core_Page {
protected $_mailingID;
protected $_mailing;
protected $_contactID;
/**
* Lets do permission checking here.
* First check for valid mailing, if false return fatal.
* Second check for visibility.
* Call a hook to see if hook wants to override visibility setting.
*/
public function checkPermission() {
if (!$this->_mailing) {
return FALSE;
}
// check for visibility, if visibility is Public Pages and they have the permission
// return true
if ($this->_mailing->visibility == 'Public Pages' &&
CRM_Core_Permission::check('view public CiviMail content')
) {
return TRUE;
}
// if user is an admin, return true
if (CRM_Core_Permission::check('administer CiviCRM') ||
CRM_Core_Permission::check('approve mailings') ||
CRM_Core_Permission::check('access CiviMail')
) {
return TRUE;
}
return FALSE;
}
/**
* Run this page (figure out the action needed and perform it).
*
* @param int $id
* @param int $contactID
* @param bool $print
* @param bool $allowID
*
* @return null|string
* Not really sure if anything should be returned - parent doesn't
*/
public function run($id = NULL, $contactID = NULL, $print = TRUE, $allowID = FALSE) {
if (is_numeric($id)) {
$this->_mailingID = $id;
}
else {
$print = TRUE;
$this->_mailingID = CRM_Utils_Request::retrieve('id', 'String', CRM_Core_DAO::$_nullObject, TRUE);
}
// # CRM-7651
// override contactID from the function level if passed in
if (isset($contactID) &&
is_numeric($contactID)
) {
$this->_contactID = $contactID;
}
else {
$this->_contactID = CRM_Core_Session::getLoggedInContactID();
}
// mailing key check
if (Civi::settings()->get('hash_mailing_url')) {
$this->_mailing = new CRM_Mailing_BAO_Mailing();
if (!is_numeric($this->_mailingID)) {
$this->_mailing->hash = $this->_mailingID;
}
elseif (is_numeric($this->_mailingID)) {
$this->_mailing->id = $this->_mailingID;
// if mailing is present and associated hash is present
// while 'hash' is not been used for mailing view : throw 'permissionDenied'
if ($this->_mailing->find() &&
CRM_Core_DAO::getFieldValue('CRM_Mailing_BAO_Mailing', $this->_mailingID, 'hash', 'id') &&
!$allowID
) {
CRM_Utils_System::permissionDenied();
return NULL;
}
}
}
else {
$this->_mailing = new CRM_Mailing_BAO_Mailing();
$this->_mailing->id = $this->_mailingID;
}
if (!$this->_mailing->find(TRUE) ||
!$this->checkPermission()
) {
CRM_Utils_System::permissionDenied();
return NULL;
}
CRM_Mailing_BAO_Mailing::tokenReplace($this->_mailing);
// get and format attachments
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing',
$this->_mailing->id
);
// get contact detail and compose if contact id exists
$returnProperties = $this->_mailing->getReturnProperties();
if (isset($this->_contactID)) {
// get details of contact with token value including Custom Field Token Values.CRM-3734
$params = array('contact_id' => $this->_contactID);
$details = CRM_Utils_Token::getTokenDetails($params,
$returnProperties,
FALSE, TRUE, NULL,
$this->_mailing->getFlattenedTokens(),
get_class($this)
);
$details = $details[0][$this->_contactID];
$contactId = $this->_contactID;
}
else {
// get tokens that are not contact specific resolved
$params = array('contact_id' => 0);
$details = CRM_Utils_Token::getAnonymousTokenDetails($params,
$returnProperties,
TRUE, TRUE, NULL,
$this->_mailing->getFlattenedTokens(),
get_class($this)
);
$details = CRM_Utils_Array::value(0, $details[0]);
$contactId = 0;
}
$mime = $this->_mailing->compose(NULL, NULL, NULL, $contactId,
$this->_mailing->from_email,
$this->_mailing->from_email,
TRUE, $details, $attachments
);
$title = NULL;
if (isset($this->_mailing->body_html) && empty($_GET['text'])) {
$header = 'text/html; charset=utf-8';
$content = $mime->getHTMLBody();
if (strpos($content, '<head>') === FALSE && strpos($content, '<title>') === FALSE) {
$title = '<head><title>' . $this->_mailing->subject . '</title></head>';
}
}
else {
$header = 'text/plain; charset=utf-8';
$content = $mime->getTXTBody();
}
CRM_Utils_System::setTitle($this->_mailing->subject);
if (CRM_Utils_Array::value('snippet', $_GET) === 'json') {
CRM_Core_Page_AJAX::returnJsonResponse($content);
}
if ($print) {
CRM_Utils_System::setHttpHeader('Content-Type', $header);
print $title;
print $content;
CRM_Utils_System::civiExit();
}
else {
return $content;
}
}
}