本文整理汇总了PHP中CRM_Campaign_BAO_Survey::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Survey::retrieve方法的具体用法?PHP CRM_Campaign_BAO_Survey::retrieve怎么用?PHP CRM_Campaign_BAO_Survey::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
parent::preProcess();
require_once 'CRM/Utils/Rule.php';
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= '&qfKey=' . $qfKey;
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/search/custom', $urlParams);
$session->replaceUserContext($url);
//get the survey id from user submitted values.
$this->_surveyId = CRM_Utils_Array::value('survey_id', $this->get('formValues'));
$isHeld = CRM_Utils_Array::value('status_id', $this->get('formValues'));
if (!$this->_surveyId || !$isHeld) {
CRM_Core_Error::statusBounce(ts("Please search with 'Is Held' and 'Survey Id' filters to apply this action."));
}
$session = CRM_Core_Session::singleton();
if (empty($this->_contactIds) || !$session->get('userID')) {
CRM_Core_Error::statusBounce(ts("Could not find contacts for release voters resevation Or Missing Interviewer contact."));
}
$this->_interviewerId = $session->get('userID');
$surveyDetails = array();
$params = array('id' => $this->_surveyId);
$this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
$numVoters = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM " . self::ACTIVITY_SURVEY_DETAIL_TABLE . " WHERE status_id = 'H' AND survey_id = %1 AND interviewer_id = %2", array(1 => array($this->_surveyId, 'Integer'), 2 => array($this->_interviewerId, 'Integer')));
if (!isset($numVoters) || $numVoters < 1) {
CRM_Core_Error::statusBounce(ts("All voters held by you are already released for this survey."));
}
$this->assign('surveyTitle', $surveyDetails['title']);
}
示例2: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if ($this->_surveyId) {
$this->_single = TRUE;
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
$this->set('entityId', $this->_surveyId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
CRM_Campaign_Form_Survey_TabHeader::build($this);
}
示例3: preProcess
public function preProcess()
{
parent::preProcess();
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Configure Survey') . ' - ' . $this->_surveyTitle);
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
}
if ($this->_name != 'Petition') {
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url)));
}
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
}
$this->set('values', $this->_values);
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// for custom data
$this->assign('entityID', $this->_surveyId);
}
示例4: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Survey'));
} else {
CRM_Utils_System::setTitle(ts('Delete Survey'));
}
}
$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);
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
$session->pushUserContext($url);
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
}
$this->set('values', $this->_values);
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// for custom data
$this->assign('entityID', $this->_surveyId);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Petition'));
} else {
CRM_Utils_System::setTitle(ts('Delete Petition'));
}
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
$session->pushUserContext($url);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
}
示例5: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Delete Survey') . ' - ' . $this->_surveyTitle);
}
示例6: preProcess
public function preProcess()
{
parent::preProcess();
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
}
$this->set('values', $this->_values);
}
$query = "SELECT MAX(id) as id, title FROM civicrm_report_instance WHERE name = %1";
$params = array(1 => array("survey_{$this->_surveyId}", 'String'));
$result = CRM_Core_DAO::executeQuery($query, $params);
if ($result->fetch()) {
$this->_reportId = $result->id;
$this->_reportTitle = $result->title;
}
}
示例7: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
parent::preProcess();
//get the survey id from user submitted values.
$this->_surveyId = $this->get('surveyId');
$this->_interviewerId = $this->get('interviewerId');
if (!$this->_surveyId) {
CRM_Core_Error::statusBounce(ts("Could not find Survey Id."));
}
if (!$this->_interviewerId) {
CRM_Core_Error::statusBounce(ts("Missing Interviewer contact."));
}
if (!is_array($this->_contactIds) || empty($this->_contactIds)) {
CRM_Core_Error::statusBounce(ts("Could not find contacts for reservation."));
}
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
//get the survey activities.
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = array();
foreach (array('Scheduled') as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
}
// these are the activities count that are linked to the current
// interviewer and current survey and not the list of ALL survey activities
$this->_numVoters = CRM_Campaign_BAO_Survey::getSurveyActivities($this->_surveyId, $this->_interviewerId, $statusIds, NULL, TRUE);
//validate the selected survey.
$this->validateSurvey();
$this->assign('surveyTitle', $this->_surveyDetails['title']);
$this->assign('activityType', $this->_surveyDetails['activity_type_id']);
$this->assign('surveyId', $this->_surveyId);
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
}
//set the title.
CRM_Utils_System::setTitle(ts('Reserve Respondents'));
}
示例8: run
/**
* @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', CRM_Core_DAO::$_nullObject);
$subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject);
$hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject);
$activity_id = CRM_Utils_Request::retrieve('a', 'String', CRM_Core_DAO::$_nullObject);
$petition_id = CRM_Utils_Request::retrieve('pid', 'String', CRM_Core_DAO::$_nullObject);
if (!$petition_id) {
$petition_id = CRM_Utils_Request::retrieve('p', 'String', CRM_Core_DAO::$_nullObject);
}
if (!$contact_id || !$subscribe_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
$result = $this->confirm($contact_id, $subscribe_id, $hash, $activity_id, $petition_id);
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);
$this->assign('petition_id', $petition_id);
$this->assign('survey_id', $petition_id);
$pparams['id'] = $petition_id;
$this->petition = array();
CRM_Campaign_BAO_Survey::retrieve($pparams, $this->petition);
$this->assign('is_share', CRM_Utils_Array::value('is_share', $this->petition));
$this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition));
$this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->petition));
CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->petition));
// send thank you email
$params['contactId'] = $contact_id;
$params['email-Primary'] = $email;
$params['sid'] = $petition_id;
$params['activityId'] = $activity_id;
CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK);
return parent::run();
}
示例9: run
function run()
{
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$petition_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this);
$params['id'] = $petition_id;
$this->petition = array();
CRM_Campaign_BAO_Survey::retrieve($params, $this->petition);
$this->assign('petitionTitle', $this->petition['title']);
$this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition));
$this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->petition));
$this->assign('survey_id', $petition_id);
$this->assign('status_id', $id);
CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->petition));
// send thank you or email verification emails
/*
* sendEmailMode
* 1 = connected user via login/pwd - thank you
* or dedupe contact matched who doesn't have a tag CIVICRM_TAG_UNCONFIRMED - thank you
* login using fb connect - thank you + click to add msg to fb wall
* 2 = send a confirmation request email
*/
return parent::run();
}
示例10: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if ($this->_surveyId) {
$this->_single = TRUE;
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
CRM_Campaign_Form_Survey_TabHeader::build($this);
}
示例11: postProcess
/**
* Form submission of petition signature
*
* @access public
* @return None
*/
public function postProcess()
{
if (defined('CIVICRM_TAG_UNCONFIRMED')) {
// Check if contact 'email confirmed' tag exists, else create one
// This should be in the petition module initialise code to create a default tag for this
require_once 'api/v2/Tag.php';
$tag_params['name'] = CIVICRM_TAG_UNCONFIRMED;
$tag = civicrm_tag_get($tag_params);
if ($tag['is_error'] == 1) {
//create tag
$tag_params['description'] = CIVICRM_TAG_UNCONFIRMED;
$tag_params['is_reserved'] = 1;
$tag_params['used_for'] = 'civicrm_contact';
$tag = civicrm_tag_create($tag_params);
$this->_tagId = $tag['tag_id'];
} else {
$this->_tagId = $tag['id'];
}
}
// export the field values to be used for saving the profile form
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
// format params
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
if ($this->_action & CRM_Core_Action::ADD) {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
if (isset($this->_surveyId)) {
$params['sid'] = $this->_surveyId;
}
if (isset($this->_contactId)) {
$params['contactId'] = $this->_contactId;
}
// if logged in user, skip dedupe
if ($this->_loggedIn) {
$ids[0] = $this->_contactId;
} else {
// dupeCheck - check if contact record already exists
// code modified from api/v2/Contact.php-function civicrm_contact_check_params()
require_once 'CRM/Dedupe/Finder.php';
$params['contact_type'] = $this->_ctype;
//TODO - current dedupe finds soft deleted contacts - adding param is_deleted not working
//$params['is_deleted'] = 0; // ignore soft deleted contacts
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, $params['contact_type']);
$dedupeParams['check_permission'] = '';
//dupesByParams($params, $ctype, $level = 'Strict', $except = array())
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type']);
}
switch (count($ids)) {
case 0:
//no matching contacts - create a new contact
require_once 'CRM/Campaign/BAO/Survey.php';
$petition_params['id'] = $this->_surveyId;
$petition = array();
CRM_Campaign_BAO_Survey::retrieve($petition_params, $petition);
// Add a source for this new contact
$params['source'] = ts('Petition Signature') . ' ' . $this->petition['title'];
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
break;
case 1:
$this->_contactId = $ids[0];
// check if user has already signed this petition - redirects to Thank You if true
$this->redirectIfSigned($params);
// dedupe matched single contact, check for 'unconfirmed' tag
if (defined('CIVICRM_TAG_UNCONFIRMED')) {
require_once 'CRM/Core/DAO/EntityTag.php';
$tag =& new CRM_Core_DAO_EntityTag();
$tag->entity_id = $this->_contactId;
$tag->tag_id = $this->_tagId;
if (!$tag->find()) {
// send thank you email directly, the user is known and validated
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
} else {
// send email verification email
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
}
}
break;
default:
// more than 1 matching contact
// for time being, take the first matching contact (not sure that's the best strategy, but better than creating another duplicate)
$this->_contactId = $ids[0];
// check if user has already signed this petition - redirects to Thank You if true
$this->redirectIfSigned($params);
if (defined('CIVICRM_TAG_UNCONFIRMED')) {
require_once 'CRM/Core/DAO/EntityTag.php';
//.........这里部分代码省略.........
示例12: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
$this->_votingTab = $this->get('votingTab');
$this->_reserveToInterview = $this->get('reserveToInterview');
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
$this->{"_{$fld}"} = $this->get($fld);
}
//get the target voter ids.
if ($this->_votingTab) {
$this->getVoterIds();
}
} else {
parent::preProcess();
//get the survey id from user submitted values.
$this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
$this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
}
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
}
$orderClause = FALSE;
$buttonName = $this->controller->getButtonName();
if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
$orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
} elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
$orderByParams = array(1 => array('column' => 'civicrm_address.street_name', 'order' => 'ASC'), 2 => array('column' => 'civicrm_address.street_number%2', 'order' => 'ASC'), 3 => array('column' => 'civicrm_address.street_number', 'order' => 'ASC'), 4 => array('column' => 'contact_a.sort_name', 'order' => 'ASC'));
}
$orderBy = array();
if (!empty($orderByParams)) {
foreach ($orderByParams as $key => $val) {
if (!empty($val['column'])) {
$orderBy[] = "{$val['column']} {$val['order']}";
}
}
if (!empty($orderBy)) {
$orderClause = "ORDER BY " . implode(', ', $orderBy);
}
}
$this->_contactIds = array_unique($this->_contactIds);
if (!empty($this->_contactIds) && $orderClause) {
$clause = 'contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
$sql = "\nSELECT contact_a.id\nFROM civicrm_contact contact_a\nLEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id\nWHERE {$clause}\n{$orderClause}";
$this->_contactIds = array();
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$this->_contactIds[] = $dao->id;
}
}
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$returnProperties['contact_sub_type'] = TRUE;
//validate all voters for required activity.
//get the survey activities for given voters.
$this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$scheduledStatusId = array_search('Scheduled', $activityStatus);
$activityIds = array();
foreach ($this->_contactIds as $key => $voterId) {
$actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
$statusId = CRM_Utils_Array::value('status_id', $actVals);
$activityId = CRM_Utils_Array::value('activity_id', $actVals);
if ($activityId && $statusId && $scheduledStatusId == $statusId) {
$activityIds["activity_id_{$voterId}"] = $activityId;
} else {
unset($this->_contactIds[$key]);
}
}
//retrieve the contact details.
$voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
$this->_allowAjaxReleaseButton = FALSE;
if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
$this->_allowAjaxReleaseButton = TRUE;
}
//validate voter ids across profile.
$this->filterVoterIds();
$this->assign('votingTab', $this->_votingTab);
$this->assign('componentIds', $this->_contactIds);
$this->assign('componentIdsJson', json_encode($this->_contactIds));
$this->assign('voterDetails', $voterDetails);
$this->assign('readOnlyFields', $readOnlyFields);
$this->assign('interviewerId', $this->_interviewerId);
$this->assign('surveyActivityIds', json_encode($activityIds));
$this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
//get the survey values.
$this->_surveyValues = $this->get('surveyValues');
if (!is_array($this->_surveyValues)) {
$this->_surveyValues = array();
if ($this->_surveyId) {
$surveyParams = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
}
$this->set('surveyValues', $this->_surveyValues);
//.........这里部分代码省略.........
示例13: sendEmail
/**
* takes an associative array and sends a thank you or email verification email
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @param $sendEmailMode
*
* @throws Exception
* @return void
@access public
* @static
*/
public static function sendEmail($params, $sendEmailMode)
{
/* sendEmailMode
* CRM_Campaign_Form_Petition_Signature::EMAIL_THANK
* connected user via login/pwd - thank you
* or dedupe contact matched who doesn't have a tag CIVICRM_TAG_UNCONFIRMED - thank you
* or login using fb connect - thank you + click to add msg to fb wall
*
* CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM
* send a confirmation request email
*/
// check if the group defined by CIVICRM_PETITION_CONTACTS exists, else create it
$petitionGroupName = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'petition_contacts', NULL, 'Petition Contacts');
$dao = new CRM_Contact_DAO_Group();
$dao->title = $petitionGroupName;
if (!$dao->find(TRUE)) {
$dao->is_active = 1;
$dao->visibility = 'User and User Admin Only';
$dao->save();
}
$group_id = $dao->id;
// get petition info
$petitionParams['id'] = $params['sid'];
$petitionInfo = array();
CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
if (empty($petitionInfo)) {
CRM_Core_Error::fatal('Petition doesn\'t exist.');
}
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$toName = CRM_Contact_BAO_Contact::displayName($params['contactId']);
$replyTo = "do-not-reply@{$emailDomain}";
// set additional general message template params (custom tokens to use in email msg templates)
// tokens then available in msg template as {$petition.title}, etc
$petitionTokens['title'] = $petitionInfo['title'];
$petitionTokens['petitionId'] = $params['sid'];
$tplParams['petition'] = $petitionTokens;
switch ($sendEmailMode) {
case CRM_Campaign_Form_Petition_Signature::EMAIL_THANK:
// add this contact to the CIVICRM_PETITION_CONTACTS group
// Cannot pass parameter 1 by reference
$p = array($params['contactId']);
CRM_Contact_BAO_GroupContact::addContactsToGroup($p, $group_id, 'API');
if ($params['email-Primary']) {
CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_petition', 'valueName' => 'petition_sign', 'contactId' => $params['contactId'], 'tplParams' => $tplParams, 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'toName' => $toName, 'toEmail' => $params['email-Primary'], 'replyTo' => $replyTo, 'petitionId' => $params['sid'], 'petitionTitle' => $petitionInfo['title']));
}
break;
case CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM:
// create mailing event subscription record for this contact
// this will allow using a hash key to confirm email address by sending a url link
$se = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $params['email-Primary'], $params['contactId'], 'profile');
// require_once 'CRM/Core/BAO/Domain.php';
// $domain = CRM_Core_BAO_Domain::getDomain();
$config = CRM_Core_Config::singleton();
$localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
$replyTo = implode($config->verpSeparator, array($localpart . 'c', $se->contact_id, $se->id, $se->hash)) . "@{$emailDomain}";
$confirmUrl = CRM_Utils_System::url('civicrm/petition/confirm', "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&p={$params['sid']}", TRUE);
$confirmUrlPlainText = CRM_Utils_System::url('civicrm/petition/confirm', "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&p={$params['sid']}", TRUE, NULL, FALSE);
// set email specific message template params and assign to tplParams
$petitionTokens['confirmUrl'] = $confirmUrl;
$petitionTokens['confirmUrlPlainText'] = $confirmUrlPlainText;
$tplParams['petition'] = $petitionTokens;
if ($params['email-Primary']) {
CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_petition', 'valueName' => 'petition_confirmation_needed', 'contactId' => $params['contactId'], 'tplParams' => $tplParams, 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'toName' => $toName, 'toEmail' => $params['email-Primary'], 'replyTo' => $replyTo, 'petitionId' => $params['sid'], 'petitionTitle' => $petitionInfo['title'], 'confirmUrl' => $confirmUrl));
}
break;
}
}
示例14: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
$this->_interviewToRelease = $this->get('interviewToRelease');
if ($this->_interviewToRelease) {
//user came from interview form.
foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
$this->{"_{$fld}"} = $this->get($fld);
}
if (!empty($this->_contactIds)) {
$this->assign('totalSelectedContacts', count($this->_contactIds));
}
} else {
parent::preProcess();
//get the survey id from user submitted values.
$this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
$this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
}
if (!$this->_surveyId) {
CRM_Core_Error::statusBounce(ts("Please search with 'Survey', to apply this action."));
}
if (!$this->_interviewerId) {
CRM_Core_Error::statusBounce(ts('Missing Interviewer contact.'));
}
if (!is_array($this->_contactIds) || empty($this->_contactIds)) {
CRM_Core_Error::statusBounce(ts('Could not find respondents to release.'));
}
$surveyDetails = array();
$params = array('id' => $this->_surveyId);
$this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = array();
foreach (array('Scheduled') as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
}
//fetch the target survey activities.
$this->_surveyActivities = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId, $statusIds);
if (count($this->_surveyActivities) < 1) {
CRM_Core_Error::statusBounce(ts('We could not found respondent for this survey to release.'));
}
$this->assign('surveyTitle', $surveyDetails['title']);
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
}
//set the title.
CRM_Utils_System::setTitle(ts('Release Respondents'));
}
示例15: postProcess
/**
* Form submission of petition signature.
*/
public function postProcess()
{
$tag_name = Civi::settings()->get('tag_unconfirmed');
if ($tag_name) {
// Check if contact 'email confirmed' tag exists, else create one
// This should be in the petition module initialise code to create a default tag for this
$tag_params['name'] = $tag_name;
$tag_params['version'] = 3;
$tag = civicrm_api('tag', 'get', $tag_params);
if ($tag['count'] == 0) {
//create tag
$tag_params['description'] = $tag_name;
$tag_params['is_reserved'] = 1;
$tag_params['used_for'] = 'civicrm_contact';
$tag = civicrm_api('tag', 'create', $tag_params);
}
$this->_tagId = $tag['id'];
}
// export the field values to be used for saving the profile form
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
// format params
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
if ($this->_action & CRM_Core_Action::ADD) {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
if (isset($this->_surveyId)) {
$params['sid'] = $this->_surveyId;
}
if (isset($this->_contactId)) {
$params['contactId'] = $this->_contactId;
}
// if logged in user, skip dedupe
if ($this->_loggedIn) {
$ids[0] = $this->_contactId;
} else {
// dupeCheck - check if contact record already exists
// code modified from api/v2/Contact.php-function civicrm_contact_check_params()
$params['contact_type'] = $this->_ctype;
//TODO - current dedupe finds soft deleted contacts - adding param is_deleted not working
// ignore soft deleted contacts
//$params['is_deleted'] = 0;
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, $params['contact_type']);
$dedupeParams['check_permission'] = '';
//dupesByParams($params, $ctype, $level = 'Unsupervised', $except = array())
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type']);
}
$petition_params['id'] = $this->_surveyId;
$petition = array();
CRM_Campaign_BAO_Survey::retrieve($petition_params, $petition);
switch (count($ids)) {
case 0:
//no matching contacts - create a new contact
// Add a source for this new contact
$params['source'] = ts('Petition Signature') . ' ' . $this->petition['title'];
if ($this->petition['bypass_confirm']) {
// send thank you email directly, bypassing confirmation
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
} else {
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
}
break;
case 1:
$this->_contactId = $params['contactId'] = $ids[0];
// check if user has already signed this petition - redirects to Thank You if true
$this->redirectIfSigned($params);
if ($this->petition['bypass_confirm']) {
// send thank you email directly, bypassing confirmation
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
break;
}
// dedupe matched single contact, check for 'unconfirmed' tag
if ($tag_name) {
$tag = new CRM_Core_DAO_EntityTag();
$tag->entity_id = $this->_contactId;
$tag->tag_id = $this->_tagId;
if (!$tag->find()) {
// send thank you email directly, the user is known and validated
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
} else {
// send email verification email
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
}
}
break;
//.........这里部分代码省略.........