本文整理汇总了PHP中CRM_Contact_Form_Search::isSearchContext方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_Form_Search::isSearchContext方法的具体用法?PHP CRM_Contact_Form_Search::isSearchContext怎么用?PHP CRM_Contact_Form_Search::isSearchContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_Form_Search
的用法示例。
在下文中一共展示了CRM_Contact_Form_Search::isSearchContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$session = CRM_Core_Session::singleton();
//this is done to unset searchRows variable assign during AddToHousehold and AddToOrganization
$this->set('searchRows', '');
$context = $this->get('context');
if (in_array($context, array('smog', 'amtg'))) {
$urlParams = 'reset=1&force=1&context=smog&gid=';
$urlParams .= $context == 'smog' ? $this->get('gid') : $this->get('amtgID');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/group/search', $urlParams));
return;
}
$ssID = $this->get('ssID');
if ($this->_action == CRM_Core_Action::BASIC) {
$fragment = 'search';
} else {
if ($this->_action == CRM_Core_Action::PROFILE) {
$fragment = 'search/builder';
} else {
if ($this->_action == CRM_Core_Action::ADVANCED) {
$fragment = 'search/advanced';
} else {
$fragment = 'search/custom';
}
}
}
$path = 'force=1';
if (isset($ssID)) {
$path .= "&reset=1&ssID={$ssID}";
}
if (!CRM_Contact_Form_Search::isSearchContext($context)) {
$context = 'search';
}
$path .= "&context={$context}";
//set the user context for redirection of task actions
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
require_once 'CRM/Utils/Rule.php';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$path .= "&qfKey={$qfKey}";
}
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $path);
$session->replaceUserContext($url);
return;
}
示例2: postProcess
//.........这里部分代码省略.........
}
}
if (is_array($outGroups)) {
foreach ($outGroups as $key => $id) {
if ($id) {
$groups['exclude'][] = $id;
}
}
}
$mailings = array();
if (is_array($inMailings)) {
foreach ($inMailings as $key => $id) {
if ($id) {
$mailings['include'][] = $id;
}
}
}
if (is_array($outMailings)) {
foreach ($outMailings as $key => $id) {
if ($id) {
$mailings['exclude'][] = $id;
}
}
}
$session = CRM_Core_Session::singleton();
$params['groups'] = $groups;
$params['mailings'] = $mailings;
if ($this->get('mailing_id')) {
$ids = array();
// don't create a new mailing if already exists
$ids['mailing_id'] = $this->get('mailing_id');
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
// delete previous includes/excludes, if mailing already existed
require_once 'CRM/Contact/DAO/Group.php';
foreach (array('groups', 'mailings') as $entity) {
$mg = new CRM_Mailing_DAO_Group();
$mg->mailing_id = $ids['mailing_id'];
$mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
$mg->find();
while ($mg->fetch()) {
$mg->delete();
}
}
} else {
// new mailing, so lets set the created_id
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = CRM_Mailing_BAO_Mailing::create($params, $ids);
$this->set('mailing_id', $mailing->id);
$count = CRM_Mailing_BAO_Mailing::getRecipientsCount(true, false, $mailing->id);
$this->set('count', $count);
$this->assign('count', $count);
$this->set('groups', $groups);
$this->set('mailings', $mailings);
if ($qf_Group_submit) {
//when user perform mailing from search context
//redirect it to search result CRM-3711.
$ssID = $this->get('ssID');
$context = $this->get('context');
if ($ssID && $this->_searchBasedMailing) {
if ($this->_action == CRM_Core_Action::BASIC) {
$fragment = 'search';
} else {
if ($this->_action == CRM_Core_Action::PROFILE) {
$fragment = 'search/builder';
} else {
if ($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}";
}
$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.
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $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);
}
}
}
示例3: postProcess
//.........这里部分代码省略.........
}
}
if (is_array($outGroups)) {
foreach ($outGroups as $key => $id) {
if ($id) {
$groups['exclude'][] = $id;
}
}
}
$mailings = array();
if (is_array($inMailings)) {
foreach ($inMailings as $key => $id) {
if ($id) {
$mailings['include'][] = $id;
}
}
}
if (is_array($outMailings)) {
foreach ($outMailings as $key => $id) {
if ($id) {
$mailings['exclude'][] = $id;
}
}
}
$session = CRM_Core_Session::singleton();
$params['groups'] = $groups;
$params['mailings'] = $mailings;
if ($this->get('mailing_id')) {
$ids = array();
// don't create a new mailing if already exists
$ids['mailing_id'] = $this->get('mailing_id');
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
// delete previous includes/excludes, if mailing already existed
foreach (array('groups', 'mailings') as $entity) {
$mg = new CRM_Mailing_DAO_Group();
$mg->mailing_id = $ids['mailing_id'];
$mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
$mg->find();
while ($mg->fetch()) {
$mg->delete();
}
}
} else {
// new mailing, so lets set the created_id
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
$mailing = CRM_Mailing_BAO_Mailing::create($params, $ids);
$this->set('mailing_id', $mailing->id);
$dedupeEmail = FALSE;
if (isset($params['dedupe_email'])) {
$dedupeEmail = $params['dedupe_email'];
}
// also compute the recipients and store them in the mailing recipients table
CRM_Mailing_BAO_Mailing::getRecipients($mailing->id, $mailing->id, NULL, NULL, TRUE, $dedupeEmail);
$count = CRM_Mailing_BAO_Recipients::mailingSize($mailing->id);
$this->set('count', $count);
$this->assign('count', $count);
$this->set('groups', $groups);
$this->set('mailings', $mailings);
if ($qf_Group_submit) {
//when user perform mailing from search context
//redirect it to search result CRM-3711.
$ssID = $this->get('ssID');
$context = $this->get('context');
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}";
}
$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.
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
return $this->controller->setDestination($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');
return $this->controller->setDestination($url);
}
}
}
示例4: preProcess
/**
* Build the form object.
*/
public function preProcess()
{
CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
$this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
$this->assign('atypefile', FALSE);
if ($this->_atypefile) {
$this->assign('atypefile', TRUE);
}
$session = CRM_Core_Session::singleton();
$this->_currentUserId = $session->get('userID');
$this->_currentlyViewedContactId = $this->get('contactId');
if (!$this->_currentlyViewedContactId) {
$this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
}
$this->assign('contactId', $this->_currentlyViewedContactId);
// Give the context.
if (!isset($this->_context)) {
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
$this->_context = 'search';
} elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) {
$this->_context = 'activity';
}
$this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
}
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & CRM_Core_Action::DELETE) {
if (!CRM_Core_Permission::check('delete activities')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
// CRM-6957
// When we come from contact search, activity id never comes.
// So don't try to get from object, it might gives you wrong one.
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
$this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
$this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
$this->assign('atype', $this->_activityTypeId);
$this->assign('activityId', $this->_activityId);
// Check for required permissions, CRM-6264.
if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) {
$this->assign('permission', 'edit');
}
if (!$this->_activityTypeId && $this->_activityId) {
$this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
}
// Assigning Activity type name.
if ($this->_activityTypeId) {
$activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
if ($activityTName[$this->_activityTypeId]) {
$this->_activityTypeName = $activityTName[$this->_activityTypeId];
$this->assign('activityTName', $activityTName[$this->_activityTypeId]);
}
}
// Set title.
if (isset($activityTName)) {
$activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
$this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
if ($this->_currentlyViewedContactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
// Check if this is default domain contact CRM-10482.
if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
$displayName .= ' (' . ts('default organization') . ')';
}
CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
} else {
CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
}
}
// Check the mode when this form is called either single or as
// search task action.
if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
$this->_single = TRUE;
$this->assign('urlPath', 'civicrm/activity');
} else {
// Set the appropriate action.
$url = CRM_Utils_System::currentPath();
$urlArray = explode('/', $url);
$searchPath = array_pop($urlArray);
$searchType = 'basic';
$this->_action = CRM_Core_Action::BASIC;
switch ($searchPath) {
case 'basic':
$searchType = $searchPath;
$this->_action = CRM_Core_Action::BASIC;
break;
case 'advanced':
$searchType = $searchPath;
$this->_action = CRM_Core_Action::ADVANCED;
break;
//.........这里部分代码省略.........
示例5: testMail
/**
* Form rule to send out a test mailing.
*
* @param aray $testParams
* @param array $files
* Any files posted to the form.
* @param array $self
* An current this object.
*
* @return bool
* true on successful SMTP handoff
*/
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 (!empty($testParams['sendtest'])) {
if (!($testParams['test_group'] || $testParams['test_email'])) {
CRM_Core_Session::setStatus(ts('You did not provide an email address or select a group.'), ts('Test not sent.'), 'error');
$error = TRUE;
}
if ($testParams['test_email']) {
$emailAdd = explode(',', $testParams['test_email']);
foreach ($emailAdd as $key => $value) {
$email = trim($value);
$testParams['emails'][] = $email;
$emails .= ($emails ? ',' : '') . "'" . CRM_Core_DAO::escapeString($email) . "'";
if (!CRM_Utils_Rule::email($email)) {
CRM_Core_Session::setStatus(ts('Please enter a valid email address.'), ts('Test not sent.'), 'error');
$error = TRUE;
}
}
}
if ($error) {
$url = CRM_Utils_System::url($urlString, $urlParams);
CRM_Utils_System::redirect($url);
return $error;
}
}
if (!empty($testParams['_qf_Test_submit'])) {
//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("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));
//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);
} else {
$status = ts("Click the 'Continue' action to resume working on it.");
$url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
}
CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
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 (!empty($testParams['_qf_Test_next']) && $self->get('count') <= 0) {
return array('_qf_default' => ts("You can not schedule or send this mailing because there are currently no recipients selected. Click 'Previous' to return to the Select Recipients step, OR click 'Save & Continue Later'."));
}
if (!empty($_POST['_qf_Import_refresh']) || !empty($testParams['_qf_Test_next']) || empty($testParams['sendtest'])) {
$error = TRUE;
return $error;
}
$job = new CRM_Mailing_BAO_MailingJob();
$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 = "\nSELECT e.id, e.contact_id, e.email\nFROM civicrm_email e\nINNER JOIN civicrm_contact c ON e.contact_id = c.id\nWHERE e.email IN ({$emails})\nAND e.on_hold = 0\nAND c.is_opt_out = 0\nAND c.do_not_email = 0\nAND c.is_deleted = 0\nAND c.is_deceased = 0\nGROUP BY e.id\nORDER BY e.is_bulkmail DESC, e.is_primary DESC\n";
$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);
//.........这里部分代码省略.........
示例6: postProcess
//.........这里部分代码省略.........
}
}
} else {
$text_message = $formValues['text_message'];
$params['body_text'] = $text_message;
$this->set('textFile', $params['body_text']);
$this->set('text_message', $params['body_text']);
$html_message = $formValues['html_message'];
// dojo editor does some html conversion when tokens are
// inserted as links. Hence token replacement fails.
// this is hack to revert html conversion for { to %7B and
// } to %7D by dojo editor
$html_message = str_replace('%7B', '{', str_replace('%7D', '}', $html_message));
$params['body_html'] = $html_message;
$this->set('htmlFile', $params['body_html']);
$this->set('html_message', $params['body_html']);
}
$params['name'] = $this->get('name');
$session = CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
$msgTemplate = NULL;
//mail template is composed
if ($formValues['upload_type']) {
$composeParams = array();
foreach ($composeFields as $key) {
if (!empty($formValues[$key])) {
$composeParams[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
if (!empty($composeParams['updateTemplate'])) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['id'] = $formValues['template'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (!empty($composeParams['saveTemplate'])) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['msg_title'] = $composeParams['saveTemplateName'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (isset($msgTemplate->id)) {
$params['msg_template_id'] = $msgTemplate->id;
} else {
$params['msg_template_id'] = CRM_Utils_Array::value('template', $formValues);
}
$this->set('template', $params['msg_template_id']);
}
CRM_Core_BAO_File::formatAttachment($formValues, $params, 'civicrm_mailing', $this->_mailingID);
$ids['mailing_id'] = $this->_mailingID;
//handle mailing from name & address.
$fromEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'], CRM_Core_OptionGroup::values('from_email_address'));
//get the from email address
$params['from_email'] = CRM_Utils_Mail::pluckEmailFromHeader($fromEmailAddress);
//get the from Name
$params['from_name'] = CRM_Utils_Array::value(1, explode('"', $fromEmailAddress));
//Add Reply-To to headers
if (!empty($formValues['reply_to_address'])) {
$replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
$params['replyto_email'] = CRM_Utils_Array::value($formValues['reply_to_address'], $replyToEmail);
}
/* Build the mailing object */
CRM_Mailing_BAO_Mailing::create($params, $ids);
if (isset($this->_submitValues['_qf_Upload_upload_save']) && $this->_submitValues['_qf_Upload_upload_save'] == 'Save & Continue Later') {
//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}";
}
$session = CRM_Core_Session::singleton();
$draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
$status = ts("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, ts('Mailing Saved'), 'success');
// Redirect user to search.
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
} else {
$status = ts("Click the 'Continue' action to resume working on it.");
$url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
}
CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
return $this->controller->setDestination($url);
}
}
示例7: postProcess
/**
* 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'));
}
示例8: postProcess
/**
* Process the posted form values. Approve /reject a mailing.
*/
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_MailingJob();
$job->mailing_id = $ids['mailing_id'];
$job->delete();
} else {
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $ids['mailing_id'];
$mailing->find(TRUE);
$params['scheduled_date'] = CRM_Utils_Date::processDate($mailing->scheduled_date);
}
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'));
}
示例9: postProcess
/**
* 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);
}
// Previously, we checked if $mailing->is_template, and did *not*
// schedule if it was set. Discussed with Lobo, removed that check
// as it appeared to prevent mails being scheduled if they were
// saved as a template, and this wasn't the documented behaviour.
// $saveTemplate = $this->controller->exportValue('saveTemplate');
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');
// 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;
} else {
// reset them in case this mailing was rejected
$params['approver_id'] = 'null';
$params['approval_date'] = 'null';
$params['approval_status_id'] = 'null';
}
/* Build the mailing object */
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 && !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'));
}
示例10: postProcess
public function postProcess()
{
$params = $ids = array();
$session = CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
$uploadParams = array('reply_id', 'unsubscribe_id', 'optout_id', 'resubscribe_id');
$uploadParamsBoolean = array('override_verp', 'forward_replies', 'url_tracking', 'open_tracking', 'auto_responder');
$qf_Settings_submit = $this->controller->exportValue($this->_name, '_qf_Settings_submit');
foreach ($uploadParams as $key) {
$params[$key] = $this->controller->exportvalue($this->_name, $key);
$this->set($key, $this->controller->exportvalue($this->_name, $key));
}
foreach ($uploadParamsBoolean as $key) {
if ($this->controller->exportvalue($this->_name, $key)) {
$params[$key] = TRUE;
} else {
$params[$key] = FALSE;
}
$this->set($key, $this->controller->exportvalue($this->_name, $key));
}
$params['visibility'] = $this->controller->exportvalue($this->_name, 'visibility');
// override_verp must be flipped, as in 3.2 we reverted
// its meaning to ‘should CiviMail manage replies?’ – i.e.,
// ‘should it *not* override Reply-To: with VERP-ed address?’
$params['override_verp'] = !$params['override_verp'];
$ids['mailing_id'] = $this->get('mailing_id');
// update mailing
CRM_Mailing_BAO_Mailing::create($params, $ids);
if ($qf_Settings_submit) {
//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}";
}
$draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
$status = ts("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));
// Redirect user to search.
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
} else {
$status = ts("Click the 'Continue' action to resume working on it.");
$url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
}
CRM_Core_Session::setStatus($status, ts('Mailing Saved'), 'success');
CRM_Utils_System::redirect($url);
}
}
示例11: preProcess
/**
* Function to build the form
*
* @return None
* @access public
*/
function preProcess()
{
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', false);
if ($this->_cdType) {
$this->assign('cdType', true);
return CRM_Custom_Form_CustomData::preProcess($this);
}
$this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
$this->assign('atypefile', false);
if ($this->_atypefile) {
$this->assign('atypefile', true);
}
$this->_addAssigneeContact = CRM_Utils_Array::value('assignee_contact', $_GET);
$this->assign('addAssigneeContact', false);
if ($this->_addAssigneeContact) {
$this->assign('addAssigneeContact', true);
}
$this->_addTargetContact = CRM_Utils_Array::value('target_contact', $_GET);
$this->assign('addTargetContact', false);
if ($this->_addTargetContact) {
$this->assign('addTargetContact', true);
}
$session = CRM_Core_Session::singleton();
$this->_currentUserId = $session->get('userID');
//give the context.
if (!$this->_context) {
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
require_once 'CRM/Contact/Form/Search.php';
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
$this->_context = 'search';
}
$this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
}
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & CRM_Core_Action::DELETE) {
if (!CRM_Core_Permission::check('delete activities')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
}
//CRM-6957
//when we come from contact search, activity id never comes.
//so don't try to get from object, it might gives you wrong one.
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
$this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
$this->_currentlyViewedContactId = $this->get('contactId');
if (!$this->_currentlyViewedContactId) {
$this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
}
$this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
$this->assign('atype', $this->_activityTypeId);
//check for required permissions, CRM-6264
require_once 'CRM/Case/BAO/Case.php';
if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
if (!$this->_activityTypeId && $this->_activityId) {
$this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
}
//Assigning Activity type name
if ($this->_activityTypeId) {
require_once 'CRM/Core/OptionGroup.php';
$activityTName = CRM_Core_OptionGroup::values('activity_type', false, false, false, 'AND v.value = ' . $this->_activityTypeId, 'name');
if ($activityTName[$this->_activityTypeId]) {
$this->assign('activityTName', $activityTName[$this->_activityTypeId]);
}
}
// Assign pageTitle to be "Activity - "+ activity name
$pageTitle = 'Activity - ' . CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
$this->assign('pageTitle', $pageTitle);
//check the mode when this form is called either single or as
//search task action
if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
$this->_single = true;
$this->assign('urlPath', 'civicrm/activity');
} else {
//set the appropriate action
$url = CRM_Utils_System::currentPath();
$seachPath = array_pop(explode('/', $url));
$searchType = 'basic';
$this->_action = CRM_Core_Action::BASIC;
switch ($seachPath) {
case 'basic':
$searchType = $seachPath;
$this->_action = CRM_Core_Action::BASIC;
break;
case 'advanced':
$searchType = $seachPath;
$this->_action = CRM_Core_Action::ADVANCED;
break;
//.........这里部分代码省略.........
示例12: elseif
/**
* 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) {
//.........这里部分代码省略.........