本文整理汇总了PHP中CRM_PCP_BAO_PCP::getPcpEntityTable方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_PCP_BAO_PCP::getPcpEntityTable方法的具体用法?PHP CRM_PCP_BAO_PCP::getPcpEntityTable怎么用?PHP CRM_PCP_BAO_PCP::getPcpEntityTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_PCP_BAO_PCP
的用法示例。
在下文中一共展示了CRM_PCP_BAO_PCP::getPcpEntityTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_pcpteams_create
/**
* File for the CiviCRM APIv3 group functions
*
* @package CiviCRM_APIv3
* @subpackage API_pcpteams
* @copyright CiviCRM LLC (c) 2004-2014
*/
function civicrm_api3_pcpteams_create($params)
{
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
// $params['pcp_title'] = $pcp['title'];
// $params['pcp_contact_id'] = $pcp['contact_id'];
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
// 1 -> waiting review
// 2 -> active / approved (default for now)
$params['status_id'] = CRM_Utils_Array::value('status_id', $params, 2);
// active by default for now
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 1);
$pcp = CRM_Pcpteams_BAO_PCP::create($params, FALSE);
//Custom Set
$customFields = CRM_Core_BAO_CustomField::getFields('PCP', FALSE, FALSE, NULL, NULL, TRUE);
$isCustomValueSet = FALSE;
foreach ($customFields as $fieldID => $fieldValue) {
list($tableName, $columnName, $cgId) = CRM_Core_BAO_CustomField::getTableColumnGroup($fieldID);
if (!empty($params[$columnName]) || !empty($params["custom_{$fieldID}"])) {
$isCustomValueSet = TRUE;
//FIXME: to find out the custom value exists, set -1 as default now
$params["custom_{$fieldID}_-1"] = !empty($params[$columnName]) ? $params[$columnName] : $params["custom_{$fieldID}"];
}
}
if ($isCustomValueSet) {
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $pcp->id, 'PCP');
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pcp', $pcp->id);
}
//end custom set
$values = array();
@_civicrm_api3_object_to_array_unique_fields($pcp, $values[$pcp->id]);
return civicrm_api3_create_success($values, $params, 'Pcpteams', 'create');
}
示例2: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
*/
public function run()
{
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
$permissionCheck = FALSE;
$statusMessage = '';
if ($config->userFramework != 'Joomla') {
$permissionCheck = CRM_Core_Permission::check('administer CiviCRM');
}
//get the pcp id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$prms = array('id' => $this->_id);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
$this->_component = $pcpInfo['page_type'];
if (empty($pcpInfo)) {
$statusMessage = ts('The personal campaign page you requested is currently unavailable.');
CRM_Core_Error::statusBounce($statusMessage, $config->userFrameworkBaseURL);
}
CRM_Utils_System::setTitle($pcpInfo['title']);
$this->assign('pcp', $pcpInfo);
$pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
// check if PCP is created by anonymous user
$anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);
if ($anonymousPCP) {
$loginURL = $config->userSystem->getLoginURL();
$anonMessage = ts('Once you\'ve received your new account welcome email, you can <a href=%1>click here</a> to login and promote your campaign page.', array(1 => $loginURL));
CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success');
} else {
$statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.');
}
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($pcpInfo['page_type']);
$pcpBlock->entity_id = $pcpInfo['page_id'];
$pcpBlock->find(TRUE);
// Redirect back to source page in case of error.
if ($pcpInfo['page_type'] == 'contribute') {
$urlBase = 'civicrm/contribute/transact';
} elseif ($pcpInfo['page_type'] == 'event') {
$urlBase = 'civicrm/event/register';
}
if ($pcpInfo['status_id'] != $approvedId || !$pcpInfo['is_active']) {
if ($pcpInfo['contact_id'] != $session->get('userID') && !$permissionCheck) {
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
}
} else {
$getStatus = CRM_PCP_BAO_PCP::getStatus($this->_id, $this->_component);
if (!$getStatus) {
// PCP not enabled for this contribution page. Forward everyone to source page
CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
}
}
$default = array();
if ($pcpBlock->target_entity_type == 'contribute') {
$urlBase = 'civicrm/contribute/transact';
} elseif ($pcpBlock->target_entity_type == 'event') {
$urlBase = 'civicrm/event/register';
}
if ($pcpBlock->entity_table == 'civicrm_event') {
$page_class = 'CRM_Event_DAO_Event';
$this->assign('pageName', CRM_Event_PseudoConstant::event($pcpInfo['page_id']));
CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date', 'registration_start_date', 'registration_end_date'));
} elseif ($pcpBlock->entity_table == 'civicrm_contribution_page') {
$page_class = 'CRM_Contribute_DAO_ContributionPage';
$this->assign('pageName', CRM_Contribute_PseudoConstant::contributionPage($pcpInfo['page_id'], TRUE));
CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date'));
}
$pageInfo = $default[$pcpInfo['page_id']];
if ($pcpInfo['contact_id'] == $session->get('userID')) {
$owner = $pageInfo;
$owner['status'] = CRM_Utils_Array::value($pcpInfo['status_id'], $pcpStatus);
$this->assign('owner', $owner);
$link = CRM_PCP_BAO_PCP::pcpLinks();
$hints = array(CRM_Core_Action::UPDATE => ts('Change the content and appearance of your page'), CRM_Core_Action::DETACH => ts('Send emails inviting your friends to support your campaign!'), CRM_Core_Action::VIEW => ts('Copy this link to share directly with your network!'), CRM_Core_Action::BROWSE => ts('Update your personal contact information'), CRM_Core_Action::DISABLE => ts('De-activate the page (you can re-activate it later)'), CRM_Core_Action::ENABLE => ts('Activate the page (you can de-activate it later)'), CRM_Core_Action::DELETE => ts('Remove the page (this cannot be undone!)'));
$replace = array('id' => $this->_id, 'block' => $pcpBlock->id, 'pageComponent' => $this->_component);
if (!$pcpBlock->is_tellfriend_enabled || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) {
unset($link['all'][CRM_Core_Action::DETACH]);
}
switch ($pcpInfo['is_active']) {
case 1:
unset($link['all'][CRM_Core_Action::ENABLE]);
break;
case 0:
unset($link['all'][CRM_Core_Action::DISABLE]);
break;
}
$this->assign('links', $link['all']);
$this->assign('hints', $hints);
$this->assign('replace', $replace);
}
//.........这里部分代码省略.........
示例3: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active', 'is_notify');
foreach ($checkBoxes as $key) {
if (!isset($params[$key])) {
$params[$key] = 0;
}
}
$session = CRM_Core_Session::singleton();
$contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
if (!$contactID) {
$contactID = $this->get('contactID');
}
$params['title'] = $params['pcp_title'];
$params['intro_text'] = $params['pcp_intro_text'];
$params['contact_id'] = $contactID;
$params['page_id'] = $this->get('component_page_id') ? $this->get('component_page_id') : $this->_contriPageId;
$params['page_type'] = $this->_component;
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
$approval_needed = $pcpBlock->is_approval_needed;
$approvalMessage = NULL;
if ($this->get('action') & CRM_Core_Action::ADD) {
$params['status_id'] = $approval_needed ? 1 : 2;
$approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
}
$params['id'] = $this->_pageId;
$pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
//create page in wordpress
create_wp_campaign($pcp->title, $pcp->contact_id, $pcp->id);
CRM_Core_Error::debug_log_message("Calling create_wp_campaign.... Params title: {$pcp->title}, contact_id: {$pcp->contact_id}, pcp_id: {$pcp->id} ");
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
$pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
$statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
//send notification of PCP create/update.
$pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
$notifyParams = array();
$notifyStatus = "";
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
if ($emails = $pcpBlock->notify_email) {
$this->assign('pcpTitle', $pcp->title);
if ($this->_pageId) {
$this->assign('mode', 'Update');
} else {
$this->assign('mode', 'Add');
}
$pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
$this->assign('pcpStatus', $pcpStatus);
$this->assign('pcpId', $pcp->id);
$supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
$this->assign('supporterUrl', $supporterUrl);
$supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
$this->assign('supporterName', $supporterName);
if ($this->_component == 'contribute') {
$pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
} elseif ($this->_component == 'event') {
$pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
}
$this->assign('contribPageUrl', $pageUrl);
$this->assign('contribPageTitle', $contribPageTitle);
$managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
$this->assign('managePCPUrl', $managePCPUrl);
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
//if more than one email present for PCP notification ,
//first email take it as To and other as CC and First email
//address should be sent in users email receipt for
//support purpose.
$emailArray = explode(',', $emails);
$to = $emailArray[0];
unset($emailArray[0]);
$cc = implode(',', $emailArray);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
//.........这里部分代码省略.........
示例4: getPcpBlockId
static function getPcpBlockId($eventId, $component = 'event')
{
if (empty($eventId)) {
return null;
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($component);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $eventId;
$pcpBlock->find(TRUE);
return $pcpBlock->id;
}