当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Array::crmIsEmptyArray方法代码示例

本文整理汇总了PHP中CRM_Utils_Array::crmIsEmptyArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::crmIsEmptyArray方法的具体用法?PHP CRM_Utils_Array::crmIsEmptyArray怎么用?PHP CRM_Utils_Array::crmIsEmptyArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Array的用法示例。


在下文中一共展示了CRM_Utils_Array::crmIsEmptyArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     $formparams = $this->exportValues();
     $caseId = $formparams['unclosed_case_id'];
     $filedActivities = 0;
     foreach ($this->_activityHolderIds as $key => $id) {
         $targetContactValues = $defaults = array();
         $params = array('id' => $id);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
             if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
                 $targetContactValues = array_combine(array_unique($defaults['target_contact']), explode(';', trim($defaults['target_contact_value'])));
                 $targetContactValues = implode(',', array_keys($targetContactValues));
             }
             $params = array('caseID' => $caseId, 'activityID' => $id, 'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'], 'targetContactIds' => $targetContactValues, 'mode' => 'file');
             $error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params);
             if (empty($error_msg['error_msg'])) {
                 $filedActivities++;
             } else {
                 CRM_Core_Session::setStatus($error_msg['error_msg'], ts("Error"), "error");
             }
         } else {
             CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array(1 => empty($defaults['subject']) ? '' : $defaults['subject'], 2 => $defaults['activity_date_time'])), ts("Error"), "error");
         }
     }
     CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success");
     CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:FileOnCase.php

示例2: _toRearrangeTokenArray

 static function _toRearrangeTokenArray($tokens)
 {
     $tokenArray = array();
     if (CRM_Utils_Array::crmIsEmptyArray($tokens)) {
         return $tokenArray;
     }
     foreach ($tokens as $key => $value) {
         $explodedValues = explode('_', $value);
         $tokenArray[$explodedValues[0]][$explodedValues[2]] = $value;
     }
     return $tokenArray;
 }
开发者ID:veda-consulting,项目名称:uk.co.vedaconsulting.module.civirelationshiptokens,代码行数:12,代码来源:Utils.php

示例3: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $targetContactValues = $defaults = array();
     $params = array('id' => $this->_activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $defaults['case_activity_subject'] = $defaults['subject'];
     if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
         $targetContactValues = array_combine(array_unique($defaults['target_contact']), explode(';', trim($defaults['target_contact_value'])));
     }
     $this->assign('targetContactValues', empty($targetContactValues) ? FALSE : $targetContactValues);
     return $defaults;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:20,代码来源:ActivityToCase.php

示例4: run

 function run()
 {
     $qrToken = QRCODE_SETTING_DB_COLUMN_QRCODE_TOKEN;
     $qrTarget = QRCODE_SETTING_DB_COLUMN_QRCODE_TARGET;
     $argExt = QRCODE_SETTING_DB_COLUMN_QRCODE_ARG_EXT;
     $argCs = QRCODE_SETTING_DB_COLUMN_QRCODE_ARG_CS;
     $QrCodeDAO = CRM_Civiqrcode_Form_QRCodeSettings::getQrDetails();
     $existingQrcodeTokens = array();
     while ($QrCodeDAO->fetch()) {
         $url = CRM_Utils_System::url('civicrm/admin/form/qrcodesetting', 'reset=1&action=update&id=' . $QrCodeDAO->id, TRUE);
         $existingQrcodeTokens[$QrCodeDAO->id] = array('qr_token_name' => $QrCodeDAO->{$qrToken}, 'qr_target_url' => $QrCodeDAO->{$qrTarget}, 'arg_externalid' => $QrCodeDAO->{$argExt}, 'arg_checksum' => $QrCodeDAO->{$argCs}, 'token_replace' => "[CiviCRM.civiqrcode.{$QrCodeDAO->{$qrToken}};block=w:image;ope=changepic]", 'action' => sprintf("<span><a href='%s'>Edit</a></span>&nbsp;\n                                        <span><a href='javascript:void(0)' onclick='delQrCode(%d);'>Delete</a></span>", $url, $QrCodeDAO->id));
     }
     if (!CRM_Utils_Array::crmIsEmptyArray($existingQrcodeTokens)) {
         $this->assign('existingQrcodeTokens', $existingQrcodeTokens);
     }
     $this->assign('addone', CRM_Utils_System::url('civicrm/admin/form/qrcodesetting', 'reset=1'));
     parent::run();
 }
开发者ID:veda-consulting,项目名称:uk.co.vedaconsulting.module.civiqrcode,代码行数:18,代码来源:QRCodeSettings.php

示例5: buildQuickForm

 /**
  * Function used to build form element for soft credit block
  *
  * @param object   $form form object
  * @access public
  *
  * @return void
  */
 static function buildQuickForm(&$form)
 {
     $prefix = 'soft_credit_';
     // by default generate 5 blocks
     $item_count = 6;
     $showSoftCreditRow = 2;
     $showCreateNew = TRUE;
     if ($form->_action & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
             $showCreateNew = FALSE;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, $prefix);
         $form->addMoney("{$prefix}amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "{$prefix}id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $form->assign('siteHasPCPs', 1);
         $pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1', FALSE, NULL, FALSE);
         $form->assign('pcpDataUrl', $pcpDataUrl);
         $form->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
         $form->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
         $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
         $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
         $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
     }
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->assign('showCreateNew', $showCreateNew);
     // Tell tpl to hide soft credit field if contribution is linked directly to a PCP Page
     if (CRM_Utils_Array::value('pcp_made_through_id', $form->_values)) {
         $form->assign('pcpLinked', 1);
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:50,代码来源:SoftCredit.php

示例6: addPCPFields

 /**
  * Add PCP fields for the new contribution form and others.
  *
  * @param CRM_Core_Form &$form
  *   The form being built.
  * @param string $suffix
  *   A suffix to add to field names.
  */
 public static function addPCPFields(&$form, $suffix = '')
 {
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $form->assign('siteHasPCPs', 1);
         // Fixme: Not a true entityRef field. Relies on PCP.js.tpl
         $form->add('text', "pcp_made_through_id{$suffix}", ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
         // stores the label
         $form->add('hidden', "pcp_made_through{$suffix}");
         $form->addElement('checkbox', "pcp_display_in_roll{$suffix}", ts('Display in Honor Roll?'), NULL);
         $form->addElement('text', "pcp_roll_nickname{$suffix}", ts('Name (for Honor Roll)'));
         $form->addElement('textarea', "pcp_personal_note{$suffix}", ts('Personal Note (for Honor Roll)'));
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:23,代码来源:SoftCredit.php

示例7: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $values
  *   Posted values of the form.
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($values, $files, $self)
 {
     // If $values['_qf_Participant_next'] is Delete or
     // $values['event_id'] is empty, then return
     // instead of proceeding further.
     if (CRM_Utils_Array::value('_qf_Participant_next', $values) == 'Delete' || !$values['event_id']) {
         return TRUE;
     }
     $errorMsg = array();
     if (!empty($values['payment_processor_id'])) {
         // make sure that payment instrument values (e.g. credit card number and cvv) are valid
         CRM_Core_Payment_Form::validatePaymentInstrument($values['payment_processor_id'], $values, $errorMsg, NULL);
     }
     if (!empty($values['record_contribution'])) {
         if (empty($values['financial_type_id'])) {
             $errorMsg['financial_type_id'] = ts('Please enter the associated Financial Type');
         }
         if (empty($values['payment_instrument_id'])) {
             $errorMsg['payment_instrument_id'] = ts('Payment Method is a required field.');
         }
     }
     // validate contribution status for 'Failed'.
     if ($self->_onlinePendingContributionId && !empty($values['record_contribution']) && CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Failed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
         $errorMsg['contribution_status_id'] = ts('Please select a valid payment status before updating.');
     }
     // do the amount validations.
     //skip for update mode since amount is freeze, CRM-6052
     if (!$self->_id && empty($values['total_amount']) && empty($self->_values['line_items']) || $self->_id && !$self->_paymentId && isset($self->_values['line_items']) && is_array($self->_values['line_items'])) {
         if ($priceSetId = CRM_Utils_Array::value('priceSetId', $values)) {
             CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $values, $errorMsg, TRUE);
         }
     }
     // For single additions - show validation error if the contact has already been registered
     // for this event with the same role.
     if ($self->_single && $self->_action & CRM_Core_Action::ADD) {
         $contactId = $self->_contactId;
         $eventId = CRM_Utils_Array::value('event_id', $values);
         if (!empty($contactId) && !empty($eventId)) {
             $dupeCheck = new CRM_Event_BAO_Participant();
             $dupeCheck->contact_id = $contactId;
             $dupeCheck->event_id = $eventId;
             $dupeCheck->find(TRUE);
             if (!empty($dupeCheck->id)) {
                 $errorMsg['event_id'] = ts("This contact has already been assigned to this event.");
             }
         }
     }
     return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:60,代码来源:Participant.php

示例8: processActivity

 /**
  * Process activity creation.
  *
  * @param array $params
  *   Associated array of submitted values.
  *
  * @return self|null|object
  */
 protected function processActivity(&$params)
 {
     $activityAssigned = array();
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     // format assignee params
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         if ($this->_activityId) {
             $assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
             $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         }
     }
     // call begin post process. Idea is to let injecting file do
     // any processing before the activity is added/updated.
     $this->beginPostProcess($params);
     $activity = CRM_Activity_BAO_Activity::create($params);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     // Save static tags.
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
     // Save free tags.
     if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
     }
     // call end post process. Idea is to let injecting file do any
     // processing needed, after the activity has been added/updated.
     $this->endPostProcess($params, $activity);
     // CRM-9590
     if (!empty($params['is_multi_activity'])) {
         $this->_activityIds[] = $activity->id;
     } else {
         $this->_activityId = $activity->id;
     }
     // create follow up activity if needed
     $followupStatus = '';
     $followupActivity = NULL;
     if (!empty($params['followup_activity_type_id'])) {
         $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         $followupStatus = ts('A followup activity has been scheduled.');
     }
     // send copy to assignee contacts.CRM-4509
     $mailStatus = '';
     if (Civi::settings()->get('activity_assignee_notification')) {
         $activityIDs = array($activity->id);
         if ($followupActivity) {
             $activityIDs = array_merge($activityIDs, array($followupActivity->id));
         }
         $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityIDs, TRUE, FALSE);
         if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
             $mailToContacts = array();
             // Build an associative array with unique email addresses.
             foreach ($activityAssigned as $id => $dnc) {
                 if (isset($id) && array_key_exists($id, $assigneeContacts)) {
                     $mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
                 }
             }
             $sent = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts);
             if ($sent) {
                 $mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
             }
         }
         // Also send email to follow-up activity assignees if set
         if ($followupActivity) {
             $mailToFollowupContacts = array();
             foreach ($assigneeContacts as $values) {
                 if ($values['activity_id'] == $followupActivity->id) {
                     $mailToFollowupContacts[$values['email']] = $values;
                 }
             }
             $sentFollowup = CRM_Activity_BAO_Activity::sendToAssignee($followupActivity, $mailToFollowupContacts);
             if ($sentFollowup) {
                 $mailStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
             }
         }
     }
     // set status message
     $subject = '';
     if (!empty($params['subject'])) {
         $subject = "'" . $params['subject'] . "'";
     }
     CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
     return $activity;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:99,代码来源:Activity.php

示例9: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($values, $files, $self)
 {
     $errorMsg = array();
     if (!empty($values['tax_rate'])) {
         if ($values['tax_rate'] <= 0 || $values['tax_rate'] > 100) {
             $errorMsg['tax_rate'] = ts('Tax Rate Should be between 0 - 100');
         }
     }
     return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? true : $errorMsg;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:19,代码来源:FinancialAccount.php

示例10: setDefaultValues

 /**
  * Set default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $this->_defaults = parent::setDefaultValues();
     $targetContactValues = array();
     foreach ($this->_caseId as $key => $val) {
         //get all clients.
         $clients = CRM_Case_BAO_Case::getContactNames($val);
         if (isset($this->_activityId) && empty($_POST)) {
             if (!CRM_Utils_Array::crmIsEmptyArray($this->_defaults['target_contact'])) {
                 $targetContactValues = array_combine(array_unique($this->_defaults['target_contact']), explode(';', trim($this->_defaults['target_contact_value'])));
                 //exclude all clients.
                 foreach ($clients as $clientId => $vals) {
                     if (array_key_exists($clientId, $targetContactValues)) {
                         unset($targetContactValues[$clientId]);
                     }
                 }
             }
         }
         $this->assign('targetContactValues', empty($targetContactValues) ? FALSE : $targetContactValues);
         if (isset($this->_encounterMedium)) {
             $this->_defaults['medium_id'] = $this->_encounterMedium;
         } elseif (empty($this->_defaults['medium_id'])) {
             // set default encounter medium CRM-4816
             $medium = CRM_Core_OptionGroup::values('encounter_medium', FALSE, FALSE, FALSE, 'AND is_default = 1');
             if (count($medium) == 1) {
                 $this->_defaults['medium_id'] = key($medium);
             }
         }
         return $this->_defaults;
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:38,代码来源:Activity.php

示例11: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($values, $files, $self)
 {
     // If $values['_qf_Participant_next'] is Delete or
     // $values['event_id'] is empty, then return
     // instead of proceeding further.
     if (CRM_Utils_Array::value('_qf_Participant_next', $values) == 'Delete' || !$values['event_id']) {
         return TRUE;
     }
     $errorMsg = array();
     //check if contact is selected in standalone mode
     if (isset($values['contact_select_id'][1]) && !$values['contact_select_id'][1]) {
         $errorMsg['contact[1]'] = ts('Please select a contact or create new contact');
     }
     if (CRM_Utils_Array::value('payment_processor_id', $values)) {
         // make sure that credit card number and cvv are valid
         CRM_Core_Payment_Form::validateCreditCard($values, $errorMsg);
     }
     if (CRM_Utils_Array::value('record_contribution', $values)) {
         if (!CRM_Utils_Array::value('financial_type_id', $values)) {
             $errorMsg['financial_type_id'] = ts('Please enter the associated Financial Type');
         }
         if (!CRM_Utils_Array::value('payment_instrument_id', $values)) {
             $errorMsg['payment_instrument_id'] = ts('Paid By is a required field.');
         }
     }
     // validate contribution status for 'Failed'.
     if ($self->_onlinePendingContributionId && CRM_Utils_Array::value('record_contribution', $values) && CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Failed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'))) {
         $errorMsg['contribution_status_id'] = ts('Please select a valid payment status before updating.');
     }
     // do the amount validations.
     //skip for update mode since amount is freeze, CRM-6052
     if (!$self->_id && !CRM_Utils_Array::value('total_amount', $values) && empty($self->_values['line_items']) || $self->_id && !$self->_paymentId && isset($self->_values['line_items']) && is_array($self->_values['line_items'])) {
         if ($priceSetId = CRM_Utils_Array::value('priceSetId', $values)) {
             CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $values, $errorMsg, TRUE);
         }
     }
     return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:47,代码来源:Participant.php

示例12: buildQuickForm

 /**
  * Function used to build form element for soft credit block.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildQuickForm(&$form)
 {
     if (!empty($form->_honor_block_is_active)) {
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = 'soft_credit';
         $ufJoinDAO->entity_id = $form->_id;
         if ($ufJoinDAO->find(TRUE)) {
             $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
             if ($jsonData) {
                 foreach (array('honor_block_title', 'honor_block_text') as $name) {
                     $form->assign($name, $jsonData[$name]);
                 }
                 $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
                 // radio button for Honor Type
                 foreach ($jsonData['soft_credit_types'] as $value) {
                     $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
                 }
                 $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
             }
         }
         return $form;
     }
     // by default generate 10 blocks
     $item_count = 11;
     $showSoftCreditRow = 2;
     if ($form->getAction() & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
     } elseif (!empty($form->_pledgeID)) {
         //Check and select most recent completed contrubtion and use it to retrieve
         //soft-credit information to use as default for current pledge payment, CRM-13981
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
         foreach ($pledgePayments as $id => $record) {
             if ($record['contribution_id']) {
                 $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
                 if ($record['status'] == 'Completed' && count($softCredits) > 0) {
                     $form->_softCreditInfo = $softCredits;
                 }
             }
         }
     }
     if (property_exists($form, "_softCreditInfo")) {
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
         $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         $form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $form->assign('siteHasPCPs', 1);
         // Fixme: Not a true entityRef field. Relies on PCP.js.tpl
         $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
         // stores the label
         $form->add('hidden', 'pcp_made_through');
         $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
         $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
         $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
     }
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:77,代码来源:SoftCredit.php

示例13: processActivity

 /**
  * Process activity creation
  *
  * @param array $params associated array of submitted values
  * @access protected
  */
 protected function processActivity(&$params)
 {
     $activityAssigned = array();
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     // format assignee params
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         if ($this->_activityId) {
             $assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
             $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         }
     }
     // call begin post process. Idea is to let injecting file do
     // any processing before the activity is added/updated.
     $this->beginPostProcess($params);
     $activity = CRM_Activity_BAO_Activity::create($params);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     //save static tags
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
     //save free tags
     if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
     }
     // call end post process. Idea is to let injecting file do any
     // processing needed, after the activity has been added/updated.
     $this->endPostProcess($params, $activity);
     // CRM-9590
     if (CRM_Utils_Array::value('is_multi_activity', $params)) {
         $this->_activityIds[] = $activity->id;
     } else {
         $this->_activityId = $activity->id;
     }
     // create follow up activity if needed
     $followupStatus = '';
     if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
         CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         $followupStatus = ts('A followup activity has been scheduled.');
     }
     // send copy to assignee contacts.CRM-4509
     $mailStatus = '';
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
         $mailToContacts = array();
         $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, TRUE, FALSE);
         //build an associative array with unique email addresses.
         foreach ($activityAssigned as $id => $dnc) {
             if (isset($id) && array_key_exists($id, $assigneeContacts)) {
                 $mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
             }
         }
         if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
             //include attachments while sending a copy of activity.
             $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
             $ics = new CRM_Activity_BAO_ICalendar($activity);
             $ics->addAttachment($attachments, $mailToContacts);
             // CRM-8400 add param with _currentlyViewedContactId for URL link in mail
             CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
             $ics->cleanup();
             $mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
         }
     }
     // set status message
     $subject = '';
     if (CRM_Utils_Array::value('subject', $params)) {
         $subject = "'" . $params['subject'] . "'";
     }
     CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
     return $activity;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:83,代码来源:Activity.php

示例14: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess($params = NULL)
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $deleteParams = array('id' => $this->_activityId);
         $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
         CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
         // delete tags for the entity
         $tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
         CRM_Core_BAO_EntityTag::del($tagParams);
         CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."));
         return;
     }
     // store the submitted values in an array
     if (!$params) {
         $params = $this->controller->exportValues($this->_name);
     }
     //set activity type id
     if (!CRM_Utils_Array::value('activity_type_id', $params)) {
         $params['activity_type_id'] = $this->_activityTypeId;
     }
     if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
     }
     // store the date with proper format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     // assigning formated value to related variable
     if (CRM_Utils_Array::value('target_contact_id', $params)) {
         $params['target_contact_id'] = explode(',', $params['target_contact_id']);
     } else {
         $params['target_contact_id'] = array();
     }
     if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
         $params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
     } else {
         $params['assignee_contact_id'] = array();
     }
     // get ids for associated contacts
     if (!$params['source_contact_id']) {
         $params['source_contact_id'] = $this->_currentUserId;
     } else {
         $params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
     }
     if (isset($this->_activityId)) {
         $params['id'] = $this->_activityId;
     }
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
     // format target params
     if (!$this->_single) {
         $params['target_contact_id'] = $this->_contactIds;
     }
     $activityAssigned = array();
     // format assignee params
     if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
         //skip those assignee contacts which are already assigned
         //while sending a copy.CRM-4509.
         $activityAssigned = array_flip($params['assignee_contact_id']);
         if ($this->_activityId) {
             $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
             $activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
         }
     }
     // call begin post process. Idea is to let injecting file do
     // any processing before the activity is added/updated.
     $this->beginPostProcess($params);
     $activity = CRM_Activity_BAO_Activity::create($params);
     // add tags if exists
     $tagParams = array();
     if (!empty($params['tag'])) {
         foreach ($params['tag'] as $tag) {
             $tagParams[$tag] = 1;
         }
     }
     //save static tags
     CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
     //save free tags
     if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
         CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
     }
     // call end post process. Idea is to let injecting file do any
     // processing needed, after the activity has been added/updated.
     $this->endPostProcess($params, $activity);
     // CRM-9590
     $this->_activityId = $activity->id;
     // create follow up activity if needed
     $followupStatus = '';
     if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
         $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
         $followupStatus = ts('A followup activity has been scheduled.');
     }
     // send copy to assignee contacts.CRM-4509
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Activity.php

示例15: buildQuickForm


//.........这里部分代码省略.........
         $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         foreach (array('Cancelled', 'Failed', 'In Progress') as $supress) {
             unset($status[CRM_Utils_Array::key($supress, $statusName)]);
         }
     }
     $this->add('select', 'contribution_status_id', ts('Contribution Status'), $status, FALSE, array('onClick' => "if (this.value != 3) {  status();} else return false", 'onChange' => "return showHideByValue('contribution_status_id','3','cancelInfo','table-row','select',false);"));
     // add various dates
     $this->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
     if ($this->_online) {
         $this->assign('hideCalender', TRUE);
     }
     $element = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
     if ($this->_online) {
         $element->freeze();
     }
     $this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
     $this->addDateTime('cancel_date', ts('Cancelled Date'), FALSE, array('formatType' => 'activityDateTime'));
     $this->add('textarea', 'cancel_reason', ts('Cancellation Reason'), $attributes['cancel_reason']);
     $recurJs = NULL;
     if ($buildRecurBlock) {
         $recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
     }
     $element = $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL, $recurJs);
     if ($this->_online) {
         $element->freeze();
     }
     if (empty($this->_lineItems)) {
         $buildPriceSet = FALSE;
         $priceSets = CRM_Price_BAO_Set::getAssoc(FALSE, 'CiviContribute');
         if (!empty($priceSets) && !$this->_ppID) {
             $buildPriceSet = TRUE;
         }
         // don't allow price set for contribution if it is related to participant, or if it is a pledge payment
         // and if we already have line items for that participant. CRM-5095
         if ($buildPriceSet && $this->_id) {
             $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
             $pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'id', 'contribution_id');
             if ($pledgePaymentId) {
                 $buildPriceSet = FALSE;
             }
             if ($participantID = CRM_Utils_Array::value('participant', $componentDetails)) {
                 $participantLI = CRM_Price_BAO_LineItem::getLineItems($participantID);
                 if (!CRM_Utils_System::isNull($participantLI)) {
                     $buildPriceSet = FALSE;
                 }
             }
         }
         $hasPriceSets = FALSE;
         if ($buildPriceSet) {
             $hasPriceSets = TRUE;
             $element = $this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );"));
             if ($this->_online) {
                 $element->freeze();
             }
         }
         $this->assign('hasPriceSets', $hasPriceSets);
         $currencyFreeze = FALSE;
         if ($this->_online || $this->_ppID) {
             $attributes['total_amount'] = array_merge($attributes['total_amount'], array('READONLY' => TRUE, 'style' => "background-color:#EBECE4"));
             $optionTypes = array('1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?'));
             $element = $this->addRadio('option_type', NULL, $optionTypes, array(), '<br/>');
             $currencyFreeze = TRUE;
         }
         $element = $this->addMoney('total_amount', ts('Total Amount'), $hasPriceSets ? FALSE : TRUE, $attributes['total_amount'], TRUE, 'currency', NULL, $currencyFreeze);
     }
     $element = $this->add('text', 'source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     //CRM-7362 --add campaigns.
     CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $this->assign('siteHasPCPs', 1);
         $pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', "className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1", FALSE, NULL, FALSE);
         $this->assign('pcpDataUrl', $pcpDataUrl);
         $this->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
         $this->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
         $this->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
         $this->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
         $this->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
     }
     $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&reset=1&context=softcredit&id={$this->_id}", FALSE, NULL, FALSE);
     $this->assign('dataUrl', $dataUrl);
     $this->addElement('text', 'soft_credit_to', ts('Soft Credit To'));
     // Tell tpl to hide Soft Credit field if contribution is linked directly to a PCP Page
     if (CRM_Utils_Array::value('pcp_made_through_id', $this->_values)) {
         $this->assign('pcpLinked', 1);
     }
     $this->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id'));
     $js = NULL;
     if (!$this->_mode) {
         $js = array('onclick' => "return verify( );");
     }
     $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
     $this->assign('outBound_option', $mailingInfo['outBound_option']);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Contribution.php


注:本文中的CRM_Utils_Array::crmIsEmptyArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。