本文整理汇总了PHP中CRM_PCP_BAO_PCP类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_PCP_BAO_PCP类的具体用法?PHP CRM_PCP_BAO_PCP怎么用?PHP CRM_PCP_BAO_PCP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_PCP_BAO_PCP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allForContact
public static function allForContact($contactId)
{
$statusNames = CRM_Core_OptionGroup::values("pcp_status", FALSE, FALSE, FALSE, NULL, 'name');
$query = "SELECT\r\n pcp.id,\r\n pcp.title,\r\n pcp.status_id,\r\n pcp.page_id,\r\n count(cc.total_amount) as contribution_count,\r\n sum(cc.total_amount) as amount_raised,\r\n pcp.goal_amount,\r\n pcp.currency\r\n FROM civicrm_pcp pcp\r\n LEFT JOIN civicrm_contribution_soft cs ON ( pcp.id = cs.pcp_id )\r\n LEFT JOIN civicrm_contribution cc ON ( cs.contribution_id = cc.id)\r\n WHERE pcp.contact_id = %1\r\n GROUP BY pcp.id";
$cpages = CRM_Core_DAO::executeQuery($query, array(1 => array($contactId, 'Integer')));
$pages = array();
while ($cpages->fetch()) {
$pages[] = array('id' => $cpages->id, 'title' => $cpages->title, 'status' => $statusNames[$cpages->status_id], 'page' => CRM_PCP_BAO_PCP::getPcpPageTitle($cpages->page_id, 'contribute'), 'contribution_count' => $cpages->contribution_count, 'amount_raised' => $cpages->amount_raised, 'goal_amount' => $cpages->goal_amount, 'currency' => $cpages->currency);
}
return $pages;
}
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$id = CRM_PCP_BAO_PCP::getSupporterProfileId($this->_pageId, $this->_component);
if (CRM_PCP_BAO_PCP::checkEmailProfile($id)) {
$this->assign('profileDisplay', TRUE);
}
$fields = NULL;
if ($this->_contactID) {
if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
} else {
CRM_Core_BAO_CMSUser::buildForm($this, $id, TRUE);
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
}
if ($fields) {
$this->assign('fields', $fields);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if (isset($field['data_type']) && $field['data_type'] == 'File') {
// ignore file upload fields
continue;
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
$this->_fields[$key] = $field;
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_contactID) {
$addCaptcha = TRUE;
}
}
if ($addCaptcha) {
$captcha =& CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
if ($this->_component == 'contribute') {
$this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
} elseif ($this->_component == 'event') {
$this->assign('campaignName', CRM_Event_PseudoConstant::event($this->_pageId));
}
if ($this->_single) {
$button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
} else {
$button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => TRUE);
}
$this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
$this->addButtons($button);
}
示例3: setDefaultValues
/**
* Function used to set defaults for soft credit block.
*
* @param $defaults
* @param $form
*/
public static function setDefaultValues(&$defaults, &$form)
{
//Used to hide/unhide PCP and/or Soft-credit Panes
$noPCP = $noSoftCredit = TRUE;
if (!empty($form->_softCreditInfo['soft_credit'])) {
$noSoftCredit = FALSE;
foreach ($form->_softCreditInfo['soft_credit'] as $key => $value) {
$defaults["soft_credit_amount[{$key}]"] = CRM_Utils_Money::format($value['amount'], NULL, '%a');
$defaults["soft_credit_contact_id[{$key}]"] = $value['contact_id'];
$defaults["soft_credit_type[{$key}]"] = $value['soft_credit_type'];
}
}
if (!empty($form->_softCreditInfo['pcp_id'])) {
$noPCP = FALSE;
$pcpInfo = $form->_softCreditInfo;
$pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
$contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
$defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
$defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
$defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
$defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
$defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
}
$form->assign('noSoftCredit', $noSoftCredit);
$form->assign('noPCP', $noPCP);
}
示例4: preProcess
//.........这里部分代码省略.........
} else {
$paymentsDue = $payments;
}
}
}
if ($multipleDue) {
// Show link to pledge tab since more than one pledge has a payment due
$pledgeTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge");
CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. <a href="%1">Click here to view their Pledges tab</a> and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)));
} elseif ($paymentsDue) {
// Show user link to oldest Pending or Overdue pledge payment
$ppAmountDue = CRM_Utils_Money::format($payments['amount'], $payments['currency']);
$ppSchedDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $payments['id'], 'scheduled_date'));
if ($this->_mode) {
$ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge&mode=live");
} else {
$ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge");
}
CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. <a href="%1">Click here to enter a pledge payment</a>.', array(1 => $ppUrl, 2 => $ppAmountDue, 3 => $ppSchedDate)));
}
}
}
}
}
$this->_values = array();
// current contribution id
if ($this->_id) {
//to get Premium id
$sql = "\nSELECT *\nFROM civicrm_contribution_product\nWHERE contribution_id = {$this->_id}\n";
$dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
if ($dao->fetch()) {
$this->_premiumID = $dao->id;
$this->_productDAO = $dao;
}
$dao->free();
$ids = array();
$params = array('id' => $this->_id);
CRM_Contribute_BAO_Contribution::getValues($params, $this->_values, $ids);
//do check for online / recurring contributions
$fids = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnIds($this->_id, 'civicrm_contribution');
$this->_online = CRM_Utils_Array::value('entityFinancialTrxnId', $fids);
//don't allow to update all fields for recuring contribution.
if (!$this->_online) {
$this->_online = CRM_Utils_Array::value('contribution_recur_id', $this->_values);
}
$this->assign('isOnline', $this->_online ? TRUE : FALSE);
//unset the honor type id:when delete the honor_contact_id
//and edit the contribution, honoree infomation pane open
//since honor_type_id is present
if (!CRM_Utils_Array::value('honor_contact_id', $this->_values)) {
unset($this->_values['honor_type_id']);
}
//to get note id
$daoNote = new CRM_Core_BAO_Note();
$daoNote->entity_table = 'civicrm_contribution';
$daoNote->entity_id = $this->_id;
if ($daoNote->find(TRUE)) {
$this->_noteID = $daoNote->id;
$this->_values['note'] = $daoNote->note;
}
$this->_contributionType = $this->_values['contribution_type_id'];
$csParams = array('contribution_id' => $this->_id);
$softCredit = CRM_Contribute_BAO_Contribution::getSoftContribution($csParams, TRUE);
if (CRM_Utils_Array::value('soft_credit_to', $softCredit)) {
$softCredit['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softCredit['soft_credit_to'], 'sort_name');
}
$this->_values['soft_credit_to'] = CRM_Utils_Array::value('sort_name', $softCredit);
$this->_values['softID'] = CRM_Utils_Array::value('soft_credit_id', $softCredit);
$this->_values['soft_contact_id'] = CRM_Utils_Array::value('soft_credit_to', $softCredit);
if (CRM_Utils_Array::value('pcp_id', $softCredit)) {
$pcpId = CRM_Utils_Array::value('pcp_id', $softCredit);
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
$contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
$this->_values['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $softCredit) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
$this->_values['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $softCredit);
$this->_values['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $softCredit);
$this->_values['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $softCredit);
$this->_values['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $softCredit);
}
//display check number field only if its having value or its offline mode.
if (CRM_Utils_Array::value('payment_instrument_id', $this->_values) == CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name') || CRM_Utils_Array::value('check_number', $this->_values)) {
$this->assign('showCheckNumber', TRUE);
}
}
// when custom data is included in this page
if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
$this->set('type', 'Contribution');
$this->set('subType', CRM_Utils_Array::value('contribution_type_id', $_POST));
$this->set('entityId', $this->_id);
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$this->_lineItems = array();
if ($this->_id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1);
empty($lineItem) ? null : ($this->_lineItems[] = $lineItem);
}
$this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
}
示例5: civicrm_api3_pcpteams_delete
function civicrm_api3_pcpteams_delete($params)
{
//check permission to delete
$permParams = array('pcp_id' => $params['id']);
if (!_civicrm_pcpteams_permission_check($permParams, CRM_Core_Permission::EDIT)) {
return civicrm_api3_create_error('insufficient permission to delete this record');
}
$result = array();
CRM_PCP_BAO_PCP::deleteById($params['id']);
return civicrm_api3_create_success($result, $params);
}
示例6: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
// get the submitted form values.
$formValues = $this->controller->exportValues($this->_name);
$formValues['entity_id'] = $this->_entityId;
$formValues['entity_table'] = $this->_entityTable;
$formValues['source_contact_id'] = $this->_contactID;
$formValues['is_test'] = $this->_action ? 1 : 0;
$formValues['title'] = $this->_title;
$formValues['campaign_id'] = $this->_campaignId;
CRM_Friend_BAO_Friend::create($formValues);
$this->assign('status', 'thankyou');
$defaults = array();
$defaults['entity_id'] = $this->_entityId;
$defaults['entity_table'] = $this->_entityTable;
CRM_Friend_BAO_Friend::getValues($defaults);
if ($this->_entityTable == 'civicrm_pcp') {
$defaults['thankyou_text'] = $defaults['thankyou_title'] = ts('Thank you for your support');
$defaults['thankyou_text'] = ts('Thanks for supporting this campaign by spreading the word to your friends.');
} elseif ($this->_entityTable == 'civicrm_contribution_page') {
// If this is tell a friend after contributing, give donor link to create their own fundraising page
if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {
$linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=contribute", FALSE, NULL, TRUE, TRUE);
$this->assign('linkTextUrl', $linkTextUrl);
$this->assign('linkText', $linkText);
}
} elseif ($this->_entityTable == 'civicrm_event') {
// If this is tell a friend after registering for an event, give donor link to create their own fundraising page
require_once 'CRM/PCP/BAO/PCP.php';
if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {
$linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=event", FALSE, NULL, TRUE, TRUE);
$this->assign('linkTextUrl', $linkTextUrl);
$this->assign('linkText', $linkText);
}
}
CRM_Utils_System::setTitle($defaults['thankyou_title']);
$this->assign('thankYouText', $defaults['thankyou_text']);
}
示例7: buildQuickForm
//.........这里部分代码省略.........
if ($this->_priceSetId && empty($this->_ccid)) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
//we allow premium for pledge during pledge creation only.
if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
//don't build pledge block when mid is passed
if (!$this->_mid && empty($this->_ccid)) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
//to create an cms user
if (!$this->_contactID && empty($this->_ccid)) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
if (!is_array($this->_values['custom_post_id'])) {
$profileIDs = array($this->_values['custom_post_id']);
} else {
$profileIDs = $this->_values['custom_post_id'];
}
foreach ($profileIDs as $pid) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
$profileID = $pid;
$createCMSUser = TRUE;
break;
}
}
}
if ($createCMSUser) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
if ($this->_pcpId && empty($this->_ccid)) {
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
$pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
// Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
if (!empty($text)) {
$pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
}
$this->assign('pcpSupporterText', $pcp_supporter_text);
}
$prms = array('id' => $this->_pcpId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
if ($pcpInfo['is_honor_roll']) {
$this->assign('isHonor', TRUE);
$this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
$extraOption = array('onclick' => "return pcpAnonymous( );");
$elements = array();
$elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
$elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
$this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
$this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
}
if (empty($this->_values['fee']) && empty($this->_ccid)) {
CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
}
//we have to load confirm contribution button in template
//when multiple payment processor as the user
//can toggle with payment processor selection
$billingModePaymentProcessors = 0;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $values) {
if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
$billingModePaymentProcessors++;
}
}
}
if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
$allAreBillingModeProcessors = TRUE;
} else {
$allAreBillingModeProcessors = FALSE;
}
if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
$submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => ' ', 'isDefault' => TRUE);
// Add submit-once behavior when confirm page disabled
if (empty($this->_values['is_confirm_enabled'])) {
$submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
}
//change button name for updating contribution
if (!empty($this->_ccid)) {
$submitButton['name'] = ts('Confirm Payment');
}
$this->addButtons(array($submitButton));
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}
示例8: browse
/**
* Browse all custom data groups.
*
*
* @param null $action
*
* @return void
* @access public
* @static
*/
function browse($action = NULL)
{
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
if ($this->_sortByCharacter == 1 || !empty($_POST)) {
$this->_sortByCharacter = '';
}
$status = CRM_PCP_BAO_PCP::buildOptions('status_id', 'create');
$pcpSummary = $params = array();
$whereClause = NULL;
if (!empty($_POST) || !empty($_GET['page_type'])) {
if (!empty($_POST['status_id'])) {
$whereClause = ' AND cp.status_id = %1';
$params['1'] = array($_POST['status_id'], 'Integer');
}
if (!empty($_POST['page_type'])) {
$whereClause .= ' AND cp.page_type = %2';
$params['2'] = array($_POST['page_type'], 'String');
} elseif (!empty($_GET['page_type'])) {
$whereClause .= ' AND cp.page_type = %2';
$params['2'] = array($_GET['page_type'], 'String');
}
if (!empty($_POST['page_id'])) {
$whereClause .= ' AND cp.page_id = %4 AND cp.page_type = "contribute"';
$params['4'] = array($_POST['page_id'], 'Integer');
}
if (!empty($_POST['event_id'])) {
$whereClause .= ' AND cp.page_id = %5 AND cp.page_type = "event"';
$params['5'] = array($_POST['event_id'], 'Integer');
}
if ($whereClause) {
$this->set('whereClause', $whereClause);
$this->set('params', $params);
} else {
$this->set('whereClause', NULL);
$this->set('params', NULL);
}
}
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
//check for delete CRM-4418
$allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
// get all contribution pages
$query = "SELECT id, title, start_date, end_date FROM civicrm_contribution_page WHERE (1)";
$cpages = CRM_Core_DAO::executeQuery($query);
while ($cpages->fetch()) {
$pages['contribute'][$cpages->id]['id'] = $cpages->id;
$pages['contribute'][$cpages->id]['title'] = $cpages->title;
$pages['contribute'][$cpages->id]['start_date'] = $cpages->start_date;
$pages['contribute'][$cpages->id]['end_date'] = $cpages->end_date;
}
// get all event pages. pcp campaign start and end dates for event related pcp's use the online registration start and end dates,
// altho if target is contribution page this might not be correct. fixme? dgg
$query = "SELECT id, title, start_date, end_date, registration_start_date, registration_end_date\n FROM civicrm_event\n WHERE is_template IS NULL OR is_template != 1";
$epages = CRM_Core_DAO::executeQuery($query);
while ($epages->fetch()) {
$pages['event'][$epages->id]['id'] = $epages->id;
$pages['event'][$epages->id]['title'] = $epages->title;
$pages['event'][$epages->id]['start_date'] = $epages->registration_start_date;
$pages['event'][$epages->id]['end_date'] = $epages->registration_end_date;
}
$params = $this->get('params') ? $this->get('params') : array();
$title = '1';
if ($this->_sortByCharacter !== NULL) {
$clauses[] = "cp.title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
}
$query = "\n SELECT cp.id, cp.contact_id , cp.status_id, cp.title, cp.is_active, cp.page_type, cp.page_id\n FROM civicrm_pcp cp\n WHERE {$title}" . $this->get('whereClause') . " ORDER BY cp.status_id";
$pcp = CRM_Core_DAO::executeQuery($query, $params);
while ($pcp->fetch()) {
$action = array_sum(array_keys($this->links()));
$contact = CRM_Contact_BAO_Contact::getDisplayAndImage($pcp->contact_id);
$class = '';
if ($pcp->status_id != $approvedId || $pcp->is_active != 1) {
$class = 'disabled';
}
switch ($pcp->status_id) {
case 2:
$action -= CRM_Core_Action::RENEW;
break;
case 3:
$action -= CRM_Core_Action::REVERT;
break;
}
switch ($pcp->is_active) {
case 1:
$action -= CRM_Core_Action::ENABLE;
break;
case 0:
$action -= CRM_Core_Action::DISABLE;
break;
}
if (!$allowToDelete) {
//.........这里部分代码省略.........
示例9: 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.
*
* @param
*
* @return void
* @access public
*/
function run()
{
// get the requested action
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
if ($action & CRM_Core_Action::REVERT) {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
CRM_PCP_BAO_PCP::setIsActive($id, 0);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
} elseif ($action & CRM_Core_Action::RENEW) {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
CRM_PCP_BAO_PCP::setIsActive($id, 1);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
} elseif ($action & CRM_Core_Action::DELETE) {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
$controller = new CRM_Core_Controller_Simple('CRM_PCP_Form_PCP', 'Personal Campaign Page', CRM_Core_Action::DELETE);
//$this->setContext( $id, $action );
$controller->set('id', $id);
$controller->process();
return $controller->run();
}
// finally browse
$this->browse();
// parent run
parent::run();
}
示例10: formRule
/**
* Validation.
*
* @param array $params
* (ref.) an assoc array of name/value pairs.
*
* @param $files
* @param $self
*
* @return bool|array
* mixed true or array of errors
*/
public static function formRule($params, $files, $self)
{
$errors = array();
if (!empty($params['is_active'])) {
if (!empty($params['is_tellfriend_enabled']) && CRM_Utils_Array::value('tellfriend_limit', $params) <= 0) {
$errors['tellfriend_limit'] = ts('if Tell Friend is enabled, Maximum recipients limit should be greater than zero.');
}
if (empty($params['supporter_profile_id'])) {
$errors['supporter_profile_id'] = ts('Supporter profile is a required field.');
} else {
if (CRM_PCP_BAO_PCP::checkEmailProfile($params['supporter_profile_id'])) {
$errors['supporter_profile_id'] = ts('Profile is not configured with Email address.');
}
}
if ($emails = CRM_Utils_Array::value('notify_email', $params)) {
$emailArray = explode(',', $emails);
foreach ($emailArray as $email) {
if ($email && !CRM_Utils_Rule::email(trim($email))) {
$errors['notify_email'] = ts('A valid Notify Email address must be specified');
}
}
}
}
return empty($errors) ? TRUE : $errors;
}
示例11: postProcess
/**
* Process the form
*
* @param null
*
* @return void
* @access public
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_PCP_BAO_PCP::deleteById($this->_id);
CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title)), ts('Page Deleted'), 'success');
} else {
$params = $this->controller->exportValues($this->_name);
$parent = $this->controller->getParent();
if (!empty($params)) {
$fields = array('status_id', 'page_id');
foreach ($fields as $field) {
if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field])) {
$parent->set($field, $params[$field]);
} else {
$parent->set($field, NULL);
}
}
}
}
}
示例12: buildQuickForm
//.........这里部分代码省略.........
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
self::buildRecur($this);
}
} elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
}
if ($this->_priceSetId) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
if (!empty($this->_fields)) {
$profileAddressFields = array();
foreach ($this->_fields as $key => $value) {
CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
}
$this->set('profileAddressFields', $profileAddressFields);
}
//to create an cms user
if (!$this->_userID) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
if (!is_array($this->_values['custom_post_id'])) {
$profileIDs = array($this->_values['custom_post_id']);
} else {
$profileIDs = $this->_values['custom_post_id'];
}
foreach ($profileIDs as $pid) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
$profileID = $pid;
$createCMSUser = TRUE;
break;
}
}
}
if ($createCMSUser) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
if ($this->_pcpId) {
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
$this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
}
$this->assign('pcp', TRUE);
$this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
$extraOption = array('onclick' => "return pcpAnonymous( );");
$elements = array();
$elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
$elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
$this->addGroup($elements, 'pcp_is_anonymous', NULL, ' ');
$this->_defaults['pcp_is_anonymous'] = 0;
$this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
//we have to load confirm contribution button in template
//when multiple payment processor as the user
//can toggle with payment processor selection
$billingModePaymentProcessors = 0;
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $key => $values) {
if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
$billingModePaymentProcessors++;
}
}
}
if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
$allAreBillingModeProcessors = TRUE;
} else {
$allAreBillingModeProcessors = FALSE;
}
if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => ' ', 'isDefault' => TRUE)));
}
$this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
}
示例13: setDefaultValues
/**
* Function used to set defaults for soft credit block
*/
static function setDefaultValues(&$defaults, &$form)
{
if (!empty($form->_softCreditInfo['soft_credit'])) {
foreach ($form->_softCreditInfo['soft_credit'] as $key => $value) {
$defaults["soft_credit_amount[{$key}]"] = CRM_Utils_Money::format($value['amount'], NULL, '%a');
$defaults["soft_credit_contact_select_id[{$key}]"] = $value['contact_id'];
$defaults["soft_credit_type[{$key}]"] = $value['soft_credit_type'];
}
} elseif (!empty($form->_softCreditInfo['pcp_id'])) {
$pcpInfo = $form->_softCreditInfo;
$pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
$contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
$defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
$defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
$defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
$defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
$defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
}
}
示例14: buildUserDashBoard
/**
* Function to build user dashboard
*
* @return void
* @access public
*/
function buildUserDashBoard()
{
//build component selectors
$dashboardElements = array();
$config = CRM_Core_Config::singleton();
$this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'user_dashboard_options');
$components = CRM_Core_Component::getEnabledComponents();
$this->assign('contactId', $this->_contactId);
foreach ($components as $name => $component) {
$elem = $component->getUserDashboardElement();
if (!$elem) {
continue;
}
if (!empty($this->_userOptions[$name]) && (CRM_Core_Permission::access($component->name) || CRM_Core_Permission::check($elem['perm'][0]))) {
$userDashboard = $component->getUserDashboardObject();
$dashboardElements[] = array('class' => 'crm-dashboard-' . strtolower($component->name), 'sectionTitle' => $elem['title'], 'templatePath' => $userDashboard->getTemplateFileName(), 'weight' => $elem['weight']);
$userDashboard->run();
}
}
if (!empty($this->_userOptions['Permissioned Orgs'])) {
$dashboardElements[] = array('class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl', 'sectionTitle' => ts('Your Contacts / Organizations'), 'weight' => 40);
}
if (!empty($this->_userOptions['PCP'])) {
$dashboardElements[] = array('class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl', 'sectionTitle' => ts('Personal Campaign Pages'), 'weight' => 40);
list($pcpBlock, $pcpInfo) = CRM_PCP_BAO_PCP::getPcpDashboardInfo($this->_contactId);
$this->assign('pcpBlock', $pcpBlock);
$this->assign('pcpInfo', $pcpInfo);
}
if (!empty($this->_userOptions['Assigned Activities'])) {
// Assigned Activities section
$dashboardElements[] = array('class' => 'crm-dashboard-assignedActivities', 'templatePath' => 'CRM/Activity/Page/UserDashboard.tpl', 'sectionTitle' => ts('Your Assigned Activities'), 'weight' => 5);
$userDashboard = new CRM_Activity_Page_UserDashboard();
$userDashboard->run();
}
usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
$this->assign('dashboardElements', $dashboardElements);
if (!empty($this->_userOptions['Groups'])) {
$this->assign('showGroup', TRUE);
//build group selector
$gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
$gContact->run();
} else {
$this->assign('showGroup', FALSE);
}
}
示例15: preProcess
//.........这里部分代码省略.........
foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
// check selected payment processor is active
if (!$eachPaymentProcessor) {
CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
}
// ensure that processor has a valid config
$payment = CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
$error = $payment->checkConfig();
if (!empty($error)) {
CRM_Core_Error::fatal($error);
}
}
}
}
}
//init event fee.
self::initEventFee($this, $this->_eventId);
// get the profile ids
$ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// set profiles for additional participants
if ($this->_values['event']['is_multiple_registrations']) {
// CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
// set same profile for additional contacts.
if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
$this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
}
if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
$this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
}
// now check for no profile condition, in that case is_active = 0
if (isset($preActive) && !$preActive) {
unset($this->_values['additional_custom_pre_id']);
}
if (isset($postActive) && !$postActive) {
unset($this->_values['additional_custom_post_id']);
}
}
// get the billing location type
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
// CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
//$this->_bltID = array_search( ts('Billing'), $locationTypes );
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
CRM_Core_Payment_Form::setCreditCardFields($this);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$this->set('values', $this->_values);
$this->set('fields', $this->_fields);
$this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
$this->set('availableRegistrations', $this->_availableRegistrations);
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
// check if this is a paypal auto return and redirect accordingly
if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
$url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
CRM_Utils_System::redirect($url);
}
$this->_contributeMode = $this->get('contributeMode');
$this->assign('contributeMode', $this->_contributeMode);
// setting CMS page title
CRM_Utils_System::setTitle($this->_values['event']['title']);
$this->assign('title', $this->_values['event']['title']);
$this->assign('paidEvent', $this->_values['event']['is_monetary']);
// we do not want to display recently viewed items on Registration pages
$this->assign('displayRecent', FALSE);
// Registration page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', TRUE);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
// Handle PCP
$pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
if ($pcpId) {
$pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
$this->_pcpId = $pcp['pcpId'];
$this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
}
// assign all event properties so wizard templates can display event info.
$this->assign('event', $this->_values['event']);
$this->assign('location', $this->_values['location']);
$this->assign('bltID', $this->_bltID);
$isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
$this->assign('isShowLocation', $isShowLocation);
//CRM-6907
$config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
//lets allow user to override campaign.
$campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
$this->_values['event']['campaign_id'] = $campID;
}
}