/** * Function to set variables up before form is built * * @return void */ function preProcess(&$form) { $form->_addBlockName = CRM_Utils_Request::retrieve('block', 'String', CRM_Core_DAO::$_nullObject); $additionalblockCount = CRM_Utils_Request::retrieve('count', 'Positive', CRM_Core_DAO::$_nullObject); $form->assign("addBlock", false); if ($form->_addBlockName && $additionalblockCount) { $form->assign("addBlock", true); $form->assign("blockName", $form->_addBlockName); $form->assign("blockId", $additionalblockCount); $form->set($form->_addBlockName . "_Block_Count", $additionalblockCount); } $className = CRM_Utils_System::getClassName($form); if (in_array($className, array('CRM_Event_Form_ManageEvent_Location', 'CRM_Contact_Form_Domain'))) { $form->_blocks = array('Address' => ts('Address'), 'Email' => ts('Email'), 'Phone' => ts('Phone')); } $form->assign('blocks', $form->_blocks); $form->assign('className', $className); // get address sequence. if (!($addressSequence = $form->get('addressSequence'))) { require_once 'CRM/Core/BAO/Address.php'; $addressSequence = CRM_Core_BAO_Address::addressSequence(); $form->set('addressSequence', $addressSequence); } $form->assign('addressSequence', $addressSequence); }
/** * build all the data structures needed to build the form * * @param * @return void * @access public */ function preProcess() { //special case for custom search, directly give option to download csv file $customSearchID = $this->get('customSearchID'); if ($customSearchID) { require_once 'CRM/Export/BAO/Export.php'; CRM_Export_BAO_Export::exportCustom($this->get('customSearchClass'), $this->get('formValues'), $this->get(CRM_Utils_Sort::SORT_ORDER)); } $this->_selectAll = false; $this->_exportMode = self::CONTACT_EXPORT; // get the submitted values based on search if ($this->_action == CRM_Core_Action::ADVANCED) { $values = $this->controller->exportValues('Advanced'); } else { if ($this->_action == CRM_Core_Action::PROFILE) { $values = $this->controller->exportValues('Builder'); } else { if ($this->_action == CRM_Core_Action::COPY) { $values = $this->controller->exportValues('Custom'); } else { // we need to determine component export $stateMachine =& $this->controller->getStateMachine(); $formName = CRM_Utils_System::getClassName($stateMachine); $componentName = explode('_', $formName); $components = array('Contribute', 'Member', 'Event', 'Pledge', 'Case'); if (in_array($componentName[1], $components)) { eval('$this->_exportMode = self::' . strtoupper($componentName[1]) . '_EXPORT;'); require_once "CRM/{$componentName[1]}/Form/Task.php"; eval('CRM_' . $componentName[1] . '_Form_Task::preprocess();'); $values = $this->controller->exportValues('Search'); } else { $values = $this->controller->exportValues('Basic'); } } } } require_once 'CRM/Contact/Task.php'; $this->_task = $values['task']; if ($this->_exportMode == self::CONTACT_EXPORT) { $contactTasks = CRM_Contact_Task::taskTitles(); $taskName = $contactTasks[$this->_task]; require_once "CRM/Contact/Form/Task.php"; CRM_Contact_Form_Task::preprocess(); } else { $this->assign('taskName', "Export {$componentName['1']}"); eval('$componentTasks = CRM_' . $componentName[1] . '_Task::tasks();'); $taskName = $componentTasks[$this->_task]; } $this->assign('totalSelectedRecords', count($this->_componentIds)); $this->assign('taskName', $taskName); // all records actions = save a search if ($values['radio_ts'] == 'ts_all' || $this->_task == CRM_Contact_Task::SAVE_SEARCH) { $this->_selectAll = true; $this->assign('totalSelectedRecords', $this->get('rowCount')); } $this->set('componentIds', $this->_componentIds); $this->set('selectAll', $this->_selectAll); $this->set('exportMode', $this->_exportMode); $this->set('componentClause', $this->_componentClause); }
/** * build the form elements for an email object * * @param CRM_Core_Form $form reference to the form object * @param array $location the location object to store all the form elements in * @param int $locationId the locationId we are dealing with * @param int $count the number of blocks to create * * @return void * @access public * @static */ static function buildQuickForm(&$form, $addressBlockCount = null) { // passing this via the session is AWFUL. we need to fix this if (!$addressBlockCount) { $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1; } else { $blockId = $addressBlockCount; } $form->applyFilter('__ALL__', 'trim'); //Email box $form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType)) { //Block type $form->addElement('select', "email[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType()); //On-hold checkbox $form->addElement('advcheckbox', "email[{$blockId}][on_hold]", null); //Bulkmail checkbox $js = array('id' => "Email_" . $blockId . "_IsBulkmail", 'onClick' => 'singleSelect( this.id );'); $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", null, '', $js); //is_Primary radio $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40)); $form->addWysiwyg("email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40)); } } }
/** * Build all the data structures needed to build the form. * * @param * * @return void */ public function preProcess() { $this->_selectAll = FALSE; $this->_exportMode = self::RELATIONSHIP_EXPORT; $this->_componentIds = array(); $this->_componentClause = NULL; // we need to determine component export $stateMachine = $this->controller->getStateMachine(); $formName = CRM_Utils_System::getClassName($stateMachine); $componentName = explode('_', $formName); $className = "CRM_Relationship_Form_Task"; $className::preProcessCommon($this, TRUE); $values = $this->controller->exportValues('Search'); $count = 0; $this->_matchingContacts = FALSE; if (CRM_Utils_Array::value('radio_ts', $values) == 'ts_sel') { foreach ($values as $key => $value) { if (strstr($key, 'mark_x')) { $count++; } if ($count > 2) { $this->_matchingContacts = TRUE; break; } } } $this->_task = $values['task']; $this->assign('taskName', "Export {$componentName['1']}"); $className = "CRM_{$componentName[1]}_Task"; $componentTasks = $className::tasks(); $taskName = $componentTasks[$this->_task]; $component = TRUE; if ($this->_componentTable) { $query = "SELECT count(*) FROM {$this->_componentTable}"; $totalSelectedRecords = CRM_Core_DAO::singleValueQuery($query); } else { $totalSelectedRecords = count($this->_componentIds); } $this->assign('totalSelectedRecords', $totalSelectedRecords); $this->assign('taskName', $taskName); $this->assign('component', $component); // all records actions = save a search if ($values['radio_ts'] == 'ts_all') { $this->_selectAll = TRUE; $rowCount = $this->get('rowCount'); if ($rowCount > 2) { $this->_matchingContacts = TRUE; } $this->assign('totalSelectedRecords', $rowCount); } $this->assign('matchingContacts', $this->_matchingContacts); $this->set('componentIds', $this->_componentIds); $this->set('selectAll', $this->_selectAll); $this->set('exportMode', $this->_exportMode); $this->set('componentClause', $this->_componentClause); $this->set('componentTable', $this->_componentTable); }
function getTemplateFileName() { $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionClass(CRM_Utils_System::getClassName($this->_customClass))) { $fileName = $ext->getTemplatePath(CRM_Utils_System::getClassName($this->_customClass)) . '/' . $ext->getTemplateName(CRM_Utils_System::getClassName($this->_customClass)); } else { $fileName = $this->_customClass->templateFile(); } return $fileName ? $fileName : parent::getTemplateFileName(); }
function getTemplateFileName() { $ext = new CRM_Core_Extensions(); if ($ext->isExtensionClass(CRM_Utils_System::getClassName($this->_customClass))) { $fileName = $ext->getTemplatePath(CRM_Utils_System::getClassName($this->_customClass)) . '/' . $ext->getTemplateName(CRM_Utils_System::getClassName($this->_customClass)); } else { $fileName = $this->_customClass->templateFile(); } return $fileName ? $fileName : parent::getTemplateFileName(); }
function getTemplateFileName() { require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); if ($ext->isExtensionClass(CRM_Utils_System::getClassName($this->_customClass))) { $filename = $ext->getTemplatePath(CRM_Utils_System::getClassName($this->_customClass)); } else { $fileName = $this->_customClass->templateFile(); } return $fileName ? $fileName : parent::getTemplateFileName(); }
/** * @param $form */ static function preProcessFromAddress(&$form) { $form->_single = FALSE; $className = CRM_Utils_System::getClassName($form); if (property_exists($form, '_context') && $form->_context != 'search' && $className == 'CRM_Contact_Form_Task_Email') { $form->_single = TRUE; } $form->_emails = $emails = array(); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); $form->_contactIds = array($contactID); $contactEmails = CRM_Core_BAO_Email::allEmails($contactID); $form->_onHold = array(); $fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name'); foreach ($contactEmails as $emailId => $item) { $email = $item['email']; if (!$email && count($emails) < 1) { // set it if no emails are present at all $form->_noEmails = TRUE; } else { if ($email) { if (in_array($email, $emails)) { // CRM-3624 continue; } $emails[$emailId] = '"' . $fromDisplayName . '" <' . $email . '> '; $form->_onHold[$emailId] = $item['on_hold']; $form->_noEmails = FALSE; } } $form->_emails[$emailId] = $emails[$emailId]; $emails[$emailId] .= $item['locationType']; if ($item['is_primary']) { $emails[$emailId] .= ' ' . ts('(preferred)'); } $emails[$emailId] = htmlspecialchars($emails[$emailId]); } $form->assign('noEmails', $form->_noEmails); if ($form->_noEmails) { CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address')); } // now add domain from addresses $domainEmails = array(); $domainFrom = CRM_Core_OptionGroup::values('from_email_address'); foreach (array_keys($domainFrom) as $k) { $domainEmail = $domainFrom[$k]; $domainEmails[$domainEmail] = htmlspecialchars($domainEmail); $form->_emails[$domainEmail] = $domainEmail; } $form->_fromEmails = CRM_Utils_Array::crmArrayMerge($emails, $domainEmails); }
/** * This function is to build the date-format form * * @param Object $form the form object that we are operating on * * @static * @access public */ static function buildAllowedDateFormats(&$form) { $dateOptions = array(); if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Import_Form_DataSource') { $dateText = ts('yyyy-mm-dd OR yyyy-mm-dd HH:mm OR yyyymmdd OR yyyymmdd HH:mm (1998-12-25 OR 1998-12-25 15:33 OR 19981225 OR 19981225 10:30 OR ( 2008-9-1 OR 2008-9-1 15:33 OR 20080901 15:33)'); } else { $dateText = ts('yyyy-mm-dd OR yyyymmdd (1998-12-25 OR 19981225) OR (2008-9-1 OR 20080901)'); } $dateOptions[] = $form->createElement('radio', NULL, NULL, $dateText, self::DATE_yyyy_mm_dd); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('mm/dd/yy OR mm-dd-yy (12/25/98 OR 12-25-98) OR (9/1/08 OR 9-1-08)'), self::DATE_mm_dd_yy); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('mm/dd/yyyy OR mm-dd-yyyy (12/25/1998 OR 12-25-1998) OR (9/1/2008 OR 9-1-2008)'), self::DATE_mm_dd_yyyy); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('Month dd, yyyy (December 12, 1998)'), self::DATE_Month_dd_yyyy); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd-mon-yy OR dd/mm/yy (25-Dec-98 OR 25/12/98)'), self::DATE_dd_mon_yy); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd/mm/yyyy (25/12/1998) OR (1/9/2008)'), self::DATE_dd_mm_yyyy); $form->addGroup($dateOptions, 'dateFormats', ts('Date Format'), '<br/>'); $form->setDefaults(array('dateFormats' => self::DATE_yyyy_mm_dd)); }
/** * This function is to build the date-format form * * @param Object $form the form object that we are operating on * * @static * @access public */ static function buildAllowedDateFormats(&$form) { $dateOptions = array(); require_once "CRM/Utils/System.php"; if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Import_Form_UploadFile') { $dateText = ts('yyyy-mm-dd OR yyyymmdd OR yyyymmdd hh:mm (1998-12-25 OR 19981225 OR 19981225 10:30) OR (2008-9-1 OR 20080901 10:30)'); } else { $dateText = ts('yyyy-mm-dd OR yyyymmdd (1998-12-25 OR 19981225) OR (2008-9-1 OR 20080901)'); } $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, $dateText, self::DATE_yyyy_mm_dd); $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('mm/dd/yy OR mm-dd-yy (12/25/98 OR 12-25-98) OR (9/1/08 OR 9-1-08)'), self::DATE_mm_dd_yy); $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('mm/dd/yyyy OR mm-dd-yyyy (12/25/1998 OR 12-25-1998) OR (9/1/2008 OR 9-1-2008)'), self::DATE_mm_dd_yyyy); $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('Month dd, yyyy (December 12, 1998)'), self::DATE_Month_dd_yyyy); $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('dd-mon-yy OR dd/mm/yy (25-Dec-98 OR 25/12/98)'), self::DATE_dd_mon_yy); $dateOptions[] = HTML_QuickForm::createElement('radio', null, null, ts('dd/mm/yyyy (25/12/1998) OR (1/9/2008)'), self::DATE_dd_mm_yyyy); $form->addGroup($dateOptions, 'dateFormats', ts('Date Format'), '<br/>'); $form->setDefaults(array('dateFormats' => self::DATE_yyyy_mm_dd)); }
/** * Set variables up before form is built. * * @param CRM_Core_Form $form * * @return void */ public static function preProcess(&$form) { $form->_addBlockName = CRM_Utils_Request::retrieve('block', 'String', CRM_Core_DAO::$_nullObject); $additionalblockCount = CRM_Utils_Request::retrieve('count', 'Positive', CRM_Core_DAO::$_nullObject); $form->assign('addBlock', FALSE); if ($form->_addBlockName && $additionalblockCount) { $form->assign('addBlock', TRUE); $form->assign('blockName', $form->_addBlockName); $form->assign('blockId', $additionalblockCount); $form->set($form->_addBlockName . '_Block_Count', $additionalblockCount); } if (is_a($form, 'CRM_Event_Form_ManageEvent_Location') || is_a($form, 'CRM_Contact_Form_Domain')) { $form->_blocks = array('Address' => ts('Address'), 'Email' => ts('Email'), 'Phone' => ts('Phone')); } $form->assign('blocks', $form->_blocks); $form->assign('className', CRM_Utils_System::getClassName($form)); // get address sequence. if (!($addressSequence = $form->get('addressSequence'))) { $addressSequence = CRM_Core_BAO_Address::addressSequence(); $form->set('addressSequence', $addressSequence); } $form->assign('addressSequence', $addressSequence); }
/** * All CRM single or multi page pages should inherit from this class. * * @param string title descriptive title of the controller * @param boolean whether controller is modal * @param string scope name of session if we want unique scope, used only by Controller_Simple * @param boolean addSequence should we add a unique sequence number to the end of the key * @param boolean ignoreKey should we not set a qfKey for this controller (for standalone forms) * * @access public * * @return void * */ function __construct($title = null, $modal = true, $mode = null, $scope = null, $addSequence = false, $ignoreKey = false) { // add a unique validable key to the name $name = CRM_Utils_System::getClassName($this); $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey); $this->HTML_QuickForm_Controller($name, $modal); $this->_title = $title; if ($scope) { $this->_scope = $scope; } else { $this->_scope = CRM_Utils_System::getClassName($this); } $this->_scope = $this->_scope . '_' . $this->_key; // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template =& CRM_Core_Smarty::singleton(); self::$_session =& CRM_Core_Session::singleton(); } $snippet = CRM_Utils_Array::value('snippet', $_REQUEST); //$snippet = CRM_Utils_Request::retrieve( 'snippet', 'Integer', $this, false, null, $_REQUEST ); if ($snippet) { if ($snippet == 3) { $this->_print = CRM_Core_Smarty::PRINT_PDF; } else { if ($snippet == 4) { $this->_print = CRM_Core_Smarty::PRINT_NOFORM; self::$_template->assign('suppressForm', true); } else { if ($snippet == 5) { $this->_print = CRM_Core_Smarty::PRINT_NOFORM; } else { $this->_print = CRM_Core_Smarty::PRINT_SNIPPET; } } } } // if the request has a reset value, initialize the controller session if (CRM_Utils_Array::value('reset', $_GET)) { $this->reset(); } // set the key in the session // do this at the end so we have initialized the object // and created the scope etc $this->set('qfKey', $this->_key); require_once 'CRM/Utils/Request.php'; // also retrieve and store destination in session $this->_destination = CRM_Utils_Request::retrieve('destination', 'String', $this, false, null, $_REQUEST); }
/** * Build the compose mail form. * * @param CRM_Core_Form $form * * @return void */ public static function commonCompose(&$form) { //get the tokens. $tokens = array(); if (method_exists($form, 'listTokens')) { $tokens = array_merge($form->listTokens(), $tokens); } //sorted in ascending order tokens by ignoring word case $form->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens)); $templates = array(); $textFields = array('text_message' => ts('HTML Format'), 'sms_text_message' => ts('SMS Message')); $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS'); $className = CRM_Utils_System::getClassName($form); if ($className != 'CRM_SMS_Form_Upload' && $className != 'CRM_Contact_Form_Task_SMS' && $className != 'CRM_Contact_Form_Task_SMS') { $form->add('wysiwyg', 'html_message', ts('HTML Format'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); if ($className != 'CRM_Admin_Form_ScheduleReminders') { unset($modePrefixes['SMS']); } } else { unset($textFields['text_message']); unset($modePrefixes['Mail']); } //insert message Text by selecting "Select Template option" foreach ($textFields as $id => $label) { $prefix = NULL; if ($id == 'sms_text_message') { $prefix = "SMS"; $form->assign('max_sms_length', CRM_SMS_Provider::MAX_SMS_CHAR); } $form->add('textarea', $id, $label, array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this, '{$prefix}')")); } foreach ($modePrefixes as $prefix) { if ($prefix == 'SMS') { $templates[$prefix] = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE, TRUE); } else { $templates[$prefix] = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE); } if (!empty($templates[$prefix])) { $form->assign('templates', TRUE); $form->add('select', "{$prefix}template", ts('Use Template'), array('' => ts('- select -')) + $templates[$prefix], FALSE, array('onChange' => "selectValue( this.value, '{$prefix}');")); } $form->add('checkbox', "{$prefix}updateTemplate", ts('Update Template'), NULL); $form->add('checkbox', "{$prefix}saveTemplate", ts('Save As New Template'), NULL, FALSE, array('onclick' => "showSaveDetails(this, '{$prefix}');")); $form->add('text', "{$prefix}saveTemplateName", ts('Template Title')); } // I'm not sure this is ever called. $action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF' && $action == CRM_Core_Action::VIEW) { $form->freeze('html_message'); } }
/** * Use the form name to create the tpl file name. * * @return string */ public function getTemplateFileName() { return strtr(CRM_Utils_System::getClassName($this), array('_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR)) . '.tpl'; }
/** * Check whether a method is present ( & supported ) by the payment processor object. * * @param string $method * Method to check for. * * @return bool */ public function isSupported($method = 'cancelSubscription') { return method_exists(CRM_Utils_System::getClassName($this), $method); }
/** * Build the price set form. * * @param CRM_Core_Form $form * * @return void */ public static function buildPriceSet(&$form) { $priceSetId = $form->get('priceSetId'); $userid = $form->getVar('_userID'); if (!$priceSetId) { return; } $validFieldsOnly = TRUE; $className = CRM_Utils_System::getClassName($form); if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) { $validFieldsOnly = FALSE; } $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly); $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); $form->_quickConfig = $quickConfig = 0; if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) { $quickConfig = 1; } $form->assign('quickConfig', $quickConfig); if ($className == "CRM_Contribute_Form_Contribution_Main") { $form->_quickConfig = $quickConfig; } $form->assign('priceSet', $form->_priceSet); $component = 'contribution'; if ($className == 'CRM_Member_Form_Membership') { $component = 'membership'; } if ($className == 'CRM_Contribute_Form_Contribution_Main') { $feeBlock =& $form->_values['fee']; if (!empty($form->_useForMember)) { $component = 'membership'; } } else { $feeBlock =& $form->_priceSet['fields']; } // call the hook. CRM_Utils_Hook::buildAmount($component, $form, $feeBlock); foreach ($feeBlock as $field) { if (CRM_Utils_Array::value('visibility', $field) == 'public' || !$validFieldsOnly) { $options = CRM_Utils_Array::value('options', $field); if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) { $checklifetime = self::checkCurrentMembership($options, $userid); if ($checklifetime) { $form->assign('ispricelifetime', TRUE); } } if (!is_array($options)) { continue; } CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options); } } }
public static function formatFieldsForOptionFull(&$form) { $priceSet = $form->get('priceSet'); $priceSetId = $form->get('priceSetId'); if (!$priceSetId || !is_array($priceSet) || empty($priceSet) || !CRM_Utils_Array::value('optionsMaxValueTotal', $priceSet)) { return; } $skipParticipants = $formattedPriceSetDefaults = array(); if ($form->_allowConfirmation && (isset($form->_pId) || isset($form->_additionalParticipantId))) { $participantId = isset($form->_pId) ? $form->_pId : $form->_additionalParticipantId; $pricesetDefaults = CRM_Event_Form_EventFees::setDefaultPriceSet($participantId, $form->_eventId); // modify options full to respect the selected fields // options on confirmation. $formattedPriceSetDefaults = self::formatPriceSetParams($form, $pricesetDefaultOptions); // to skip current registered participants fields option count on confirmation. $skipParticipants[] = $form->_participantId; if (!empty($form->_additionalParticipantIds)) { $skipParticipants = array_merge($skipParticipants, $form->_additionalParticipantIds); } } $className = CRM_Utils_System::getClassName($form); //get the current price event price set options count. $currentOptionsCount = self::getPriceSetOptionCount($form); $recordedOptionsCount = CRM_Event_BAO_Participant::priceSetOptionsCount($form->_eventId, $skipParticipants); foreach ($form->_feeBlock as &$field) { $optionFullIds = array(); $fieldId = $field['id']; if (!is_array($field['options'])) { continue; } foreach ($field['options'] as &$option) { $optId = $option['id']; $count = CRM_Utils_Array::value('count', $option, 0); $maxValue = CRM_Utils_Array::value('max_value', $option, 0); $dbTotalCount = CRM_Utils_Array::value($optId, $recordedOptionsCount, 0); $currentTotalCount = CRM_Utils_Array::value($optId, $currentOptionsCount, 0); // Do not consider current count for select field, // since we are not going to freeze the options. if ($field['html_type'] == 'Select') { $totalCount = $dbTotalCount; } else { $totalCount = $currentTotalCount + $dbTotalCount; } $isFull = FALSE; if ($maxValue && ($totalCount >= $maxValue || $totalCount + $count > $maxValue)) { $isFull = TRUE; $optionFullIds[$optId] = $optId; } //here option is not full, //but we don't want to allow participant to increase //seats at the time of re-walking registration. if ($count && $form->_allowConfirmation && !empty($formattedPriceSetDefaults)) { if (!CRM_Utils_Array::value("price_{$field}", $formattedPriceSetDefaults) || !CRM_Utils_Array::value($opId, $formattedPriceSetDefaults["price_{$fieldId}"])) { $optionFullIds[$optId] = $optId; $isFull = TRUE; } } $option['is_full'] = $isFull; $option['db_total_count'] = $dbTotalCount; $option['total_option_count'] = $dbTotalCount + $currentTotalCount; } //ignore option full for offline registration. if ($className == 'CRM_Event_Form_Participant') { $optionFullIds = array(); } //finally get option ids in. $field['option_full_ids'] = $optionFullIds; } }
/** * Function to build the compose PDF letter form * * @param $form * * @return None * @access public */ public static function commonLetterCompose(&$form) { //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); if (CRM_Utils_System::getClassName($form) == 'CRM_Mailing_Form_Upload') { $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens); } //@todo move this fn onto the form if (CRM_Utils_System::getClassName($form) == 'CRM_Contribute_Form_Task_PDFLetter') { $tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens); } if (method_exists($form, 'listTokens')) { $tokens = array_merge($form->listTokens(), $tokens); } //sorted in ascending order tokens by ignoring word case natcasesort($tokens); $form->assign('tokens', json_encode($tokens)); $form->add('select', 'token1', ts('Insert Tokens'), $tokens, FALSE, array('size' => "5", 'multiple' => TRUE, 'onchange' => "return tokenReplHtml(this);")); $form->_templates = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE); if (!empty($form->_templates)) { $form->assign('templates', TRUE); $form->add('select', 'template', ts('Select Template'), array('' => ts('- select -')) + $form->_templates, FALSE, array('onChange' => "selectValue( this.value );")); $form->add('checkbox', 'updateTemplate', ts('Update Template'), NULL); } $form->add('checkbox', 'saveTemplate', ts('Save As New Template'), NULL, FALSE, array('onclick' => "showSaveDetails(this);")); $form->add('text', 'saveTemplateName', ts('Template Title')); $form->addWysiwyg('html_message', ts('Your Letter'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); $action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF' && $action == CRM_Core_Action::VIEW) { $form->freeze('html_message'); } }
/** * Process the form after the input has been submitted and validated. * * * @param CRM_Core_Form $form * * @return void */ public static function postProcess(&$form) { // check and ensure that $thisValues = $form->controller->exportValues($form->getName()); $fromSmsProviderId = $thisValues['sms_provider_id']; // process message template if (!empty($thisValues['saveTemplate']) || !empty($thisValues['updateTemplate'])) { $messageTemplate = array('msg_text' => $thisValues['sms_text_message'], 'is_active' => TRUE); if (!empty($thisValues['saveTemplate'])) { $messageTemplate['msg_title'] = $thisValues['saveTemplateName']; CRM_Core_BAO_MessageTemplate::add($messageTemplate); } if (!empty($thisValues['template']) && !empty($thisValues['updateTemplate'])) { $messageTemplate['id'] = $thisValues['template']; unset($messageTemplate['msg_title']); CRM_Core_BAO_MessageTemplate::add($messageTemplate); } } // format contact details array to handle multiple sms from same contact $formattedContactDetails = array(); $tempPhones = array(); foreach ($form->_contactIds as $key => $contactId) { $phone = $form->_toContactPhone[$key]; if ($phone) { $phoneKey = "{$contactId}::{$phone}"; if (!in_array($phoneKey, $tempPhones)) { $tempPhones[] = $phoneKey; if (!empty($form->_contactDetails[$contactId])) { $formattedContactDetails[] = $form->_contactDetails[$contactId]; } } } } // $smsParams carries all the arguments provided on form (or via hooks), to the provider->send() method // this gives flexibity to the users / implementors to add their own args via hooks specific to their sms providers $smsParams = $thisValues; unset($smsParams['sms_text_message']); $smsParams['provider_id'] = $fromSmsProviderId; $contactIds = array_keys($form->_contactDetails); $allContactIds = array_keys($form->_allContactDetails); list($sent, $activityId, $countSuccess) = CRM_Activity_BAO_Activity::sendSMS($formattedContactDetails, $thisValues, $smsParams, $contactIds); if ($countSuccess > 0) { CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $countSuccess)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $countSuccess)), 'success'); } if (is_array($sent)) { // At least one PEAR_Error object was generated. // Display the error messages to the user. $status = '<ul>'; foreach ($sent as $errMsg) { $status .= '<li>' . $errMsg . '</li>'; } $status .= '</ul>'; CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($sent), 'plural' => '%count Messages Not Sent')), 'info'); } else { //Display the name and number of contacts for those sms is not sent. $smsNotSent = array_diff_assoc($allContactIds, $contactIds); if (!empty($smsNotSent)) { $not_sent = array(); foreach ($smsNotSent as $index => $contactId) { $displayName = $form->_allContactDetails[$contactId]['display_name']; $phone = $form->_allContactDetails[$contactId]['phone']; $contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactId}"); $not_sent[] = "<a href='{$contactViewUrl}' title='{$phone}'>{$displayName}</a>"; } $status = '(' . ts('because no phone number on file or communication preferences specify DO NOT SMS or Contact is deceased'); if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') { $status .= ' ' . ts("or the contact is not part of the activity '%1'", array(1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT)); } $status .= ')<ul><li>' . implode('</li><li>', $not_sent) . '</li></ul>'; CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($smsNotSent), 'plural' => '%count Messages Not Sent')), 'info'); } } }
/** * class constructor * * @param string $title title of the page * @param int $mode mode of the page * * @return CRM_Core_Page */ function CRM_Core_Page($title = null, $mode = null) { $this->_name = CRM_Utils_System::getClassName($this); $this->_title = $title; $this->_mode = $mode; // let the constructor initialize this, should happen only once if (!isset($GLOBALS['_CRM_CORE_PAGE']['_template'])) { $GLOBALS['_CRM_CORE_PAGE']['_template'] =& CRM_Core_Smarty::singleton(); $GLOBALS['_CRM_CORE_PAGE']['_session'] =& CRM_Core_Session::singleton(); } // if the request has a reset value, initialize the controller session if (CRM_Utils_Array::value('reset', $_GET)) { $this->reset(); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $className = CRM_Utils_System::getClassName($this); $session =& CRM_Core_Session::singleton(); $buttons = array(); if ($this->_single) { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $uploadNames = $this->get( 'uploadNames' ); $buttons = array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and Done'), 'spacing' => ' ', 'subName' => 'done'), array('type' => 'cancel', 'name' => ts('Cancel'))); $this->addButtons($buttons); } else { $buttons = array(); if (!$this->_first) { $buttons[] = array('type' => 'back', 'name' => ts('<< Previous'), 'spacing' => ' '); } $buttons[] = array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => ' ', 'isDefault' => true); $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); $this->addButtons($buttons); } $this->add('hidden', 'is_template', $this->_isTemplate); }
/** * Build the price set form. * * @param CRM_Core_Form $form * * @return void */ public static function buildPriceSet(&$form) { $priceSetId = $form->get('priceSetId'); if (!$priceSetId) { return; } $validFieldsOnly = TRUE; $className = CRM_Utils_System::getClassName($form); if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) { $validFieldsOnly = FALSE; } $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly); $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); $validPriceFieldIds = array_keys($form->_priceSet['fields']); $form->_quickConfig = $quickConfig = 0; if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) { $quickConfig = 1; } $form->assign('quickConfig', $quickConfig); if ($className == 'CRM_Contribute_Form_Contribution_Main') { $form->_quickConfig = $quickConfig; } $form->assign('priceSet', $form->_priceSet); $component = 'contribution'; if ($className == 'CRM_Member_Form_Membership') { $component = 'membership'; } if ($className == 'CRM_Contribute_Form_Contribution_Main') { $feeBlock =& $form->_values['fee']; if (!empty($form->_useForMember)) { $component = 'membership'; } } else { $feeBlock =& $form->_priceSet['fields']; } // call the hook. CRM_Utils_Hook::buildAmount($component, $form, $feeBlock); // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions $adminFieldVisible = FALSE; if (CRM_Core_Permission::check('administer CiviCRM')) { $adminFieldVisible = TRUE; } foreach ($feeBlock as $id => $field) { if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE || !$validFieldsOnly) { $options = CRM_Utils_Array::value('options', $field); if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) { $userid = $form->getVar('_membershipContactID'); $checklifetime = self::checkCurrentMembership($options, $userid); if ($checklifetime) { $form->assign('ispricelifetime', TRUE); } } if (!is_array($options) || !in_array($id, $validPriceFieldIds)) { continue; } CRM_Price_BAO_PriceField::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options); } } }
/** * Add all the elements shared between, * normal voter search and voter listing (GOTV form) * * @param CRM_Core_Form $form */ public static function buildSearchForm(&$form) { $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address'); $className = CRM_Utils_System::getClassName($form); $form->add('text', 'sort_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $form->add('text', 'street_name', ts('Street Name'), $attributes['street_name']); $form->add('text', 'street_number', ts('Street Number'), $attributes['street_number']); $form->add('text', 'street_unit', ts('Street Unit'), $attributes['street_unit']); $form->add('text', 'street_address', ts('Street Address'), $attributes['street_address']); $form->add('text', 'city', ts('City'), $attributes['city']); $form->add('text', 'postal_code', ts('Postal Code'), $attributes['postal_code']); //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator); $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2')); $groups = CRM_Core_PseudoConstant::nestedGroup(); $form->add('select', 'group', ts('Groups'), $groups, FALSE, array('multiple' => 'multiple', 'class' => 'crm-select2')); $showInterviewer = FALSE; if (CRM_Core_Permission::check('administer CiviCampaign')) { $showInterviewer = TRUE; } $form->assign('showInterviewer', $showInterviewer); if ($showInterviewer || $className == 'CRM_Campaign_Form_Gotv') { $form->addEntityRef('survey_interviewer_id', ts('Interviewer'), array('class' => 'big')); $userId = NULL; if (isset($form->_interviewerId) && $form->_interviewerId) { $userId = $form->_interviewerId; } if (!$userId) { $session = CRM_Core_Session::singleton(); $userId = $session->get('userID'); } if ($userId) { $defaults = array(); $defaults['survey_interviewer_id'] = $userId; $form->setDefaults($defaults); } } //build ward and precinct custom fields. $query = ' SELECT fld.id, fld.label FROM civicrm_custom_field fld INNER JOIN civicrm_custom_group grp on fld.custom_group_id = grp.id WHERE grp.name = %1'; $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('Voter_Info', 'String'))); $customSearchFields = array(); while ($dao->fetch()) { foreach (array('ward', 'precinct') as $name) { if (stripos($name, $dao->label) !== FALSE) { $fieldId = $dao->id; $fieldName = 'custom_' . $dao->id; $customSearchFields[$name] = $fieldName; CRM_Core_BAO_CustomField::addQuickFormElement($form, $fieldName, $fieldId, FALSE); break; } } } $form->assign('customSearchFields', $customSearchFields); $surveys = CRM_Campaign_BAO_Survey::getSurveys(); if (empty($surveys) && $className == 'CRM_Campaign_Form_Search') { CRM_Core_Error::statusBounce(ts('Could not find survey for %1 respondents.', array(1 => $form->get('op'))), CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')); } //CRM-7406 -- //If survey had associated campaign and //campaign has some contact groups, don't //allow to search the contacts those are not //in given campaign groups ( ie not in constituents ) $props = array('class' => 'crm-select2'); if ($form->get('searchVoterFor') == 'reserve') { $props['onChange'] = "buildCampaignGroups( );return false;"; } $form->add('select', 'campaign_survey_id', ts('Survey'), $surveys, TRUE, $props); }
/** * All CRM single or multi page pages should inherit from this class. * * @param string title descriptive title of the controller * @param boolean whether controller is modal * @param string scope name of session if we want unique scope, used only by Controller_Simple * @param boolean addSequence should we add a unique sequence number to the end of the key * @param boolean ignoreKey should we not set a qfKey for this controller (for standalone forms) * * @access public * * @return void * */ function __construct($title = NULL, $modal = TRUE, $mode = NULL, $scope = NULL, $addSequence = FALSE, $ignoreKey = FALSE) { // this has to true for multiple tab session fix $addSequence = TRUE; // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); self::$_session = CRM_Core_Session::singleton(); } // lets try to get it from the session and/or the request vars // we do this early on in case there is a fatal error in retrieving the // key and/or session $this->_entryURL = CRM_Utils_Request::retrieve('entryURL', 'String', $this); // add a unique validable key to the name $name = CRM_Utils_System::getClassName($this); if ($name == 'CRM_Core_Controller_Simple' && !empty($scope)) { // use form name if we have, since its a lot better and // definitely different for different forms $name = $scope; } $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey); $this->_title = $title; if ($scope) { $this->_scope = $scope; } else { $this->_scope = CRM_Utils_System::getClassName($this); } $this->_scope = $this->_scope . '_' . $this->_key; // only use the civicrm cache if we have a valid key // else we clash with other users CRM-7059 if (!empty($this->_key)) { CRM_Core_Session::registerAndRetrieveSessionObjects(array("_{$name}_container", array('CiviCRM', $this->_scope))); } $this->HTML_QuickForm_Controller($name, $modal); $snippet = CRM_Utils_Array::value('snippet', $_REQUEST); if ($snippet) { if ($snippet == 3) { $this->_print = CRM_Core_Smarty::PRINT_PDF; } elseif ($snippet == 4) { // this is used to embed fragments of a form $this->_print = CRM_Core_Smarty::PRINT_NOFORM; self::$_template->assign('suppressForm', TRUE); $this->_generateQFKey = FALSE; } elseif ($snippet == 5) { // this is used for popups and inlined ajax forms // also used for the various tabs via TabHeader $this->_print = CRM_Core_Smarty::PRINT_NOFORM; } elseif ($snippet == 6) { $this->_print = CRM_Core_Smarty::PRINT_NOFORM; $this->_QFResponseType = 'json'; } else { $this->_print = CRM_Core_Smarty::PRINT_SNIPPET; } } // if the request has a reset value, initialize the controller session if (CRM_Utils_Array::value('reset', $_GET)) { $this->reset(); // in this case we'll also cache the url as a hidden form variable, this allows us to // redirect in case the session has disappeared on us $this->_entryURL = CRM_Utils_System::makeURL(NULL, TRUE, FALSE, NULL, TRUE); $this->set('entryURL', $this->_entryURL); } // set the key in the session // do this at the end so we have initialized the object // and created the scope etc $this->set('qfKey', $this->_key); // also retrieve and store destination in session $this->_destination = CRM_Utils_Request::retrieve('civicrmDestination', 'String', $this, FALSE, NULL, $_REQUEST); }
/** * Use the form name to create the tpl file name. * * @return string */ public function getTemplateFileName() { $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionClass(CRM_Utils_System::getClassName($this))) { $filename = $ext->getTemplateName(CRM_Utils_System::getClassName($this)); $tplname = $ext->getTemplatePath(CRM_Utils_System::getClassName($this)) . DIRECTORY_SEPARATOR . $filename; } else { $tplname = strtr(CRM_Utils_System::getClassName($this), array('_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR)) . '.tpl'; } return $tplname; }
/** * Use the form name to create the tpl file name * * @return string * @access public */ function getTemplateFileName() { return str_replace('_', DIRECTORY_SEPARATOR, CRM_Utils_System::getClassName($this)) . '.tpl'; }
/** * Store required custom data info. * * @param CRM_Core_Form $form * @param array $groupTree */ public static function storeRequiredCustomDataInfo(&$form, $groupTree) { if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $requireOmission = NULL; foreach ($groupTree as $csId => $csVal) { // only process Address entity fields if ($csVal['extends'] != 'Address') { continue; } foreach ($csVal['fields'] as $cdId => $cdVal) { if ($cdVal['is_required']) { $elementName = $cdVal['element_name']; if (in_array($elementName, $form->_required)) { // store the omitted rule for a element, to be used later on $requireOmission .= $cdVal['element_custom_name'] . ','; } } } } $form->_addressRequireOmission = rtrim($requireOmission, ','); } }
/** * Set default values for the form. Note that in edit/view mode * the default values are retrieved from the database * * * @param CRM_Core_Form $form * @param $defaults * * @return void */ public static function setDefaultValues(&$form, &$defaults) { $contactEditOptions = $form->get('contactEditOptions'); if ($form->_action & CRM_Core_Action::ADD) { if (array_key_exists('TagsAndGroups', $contactEditOptions)) { // set group and tag defaults if any if ($form->_gid) { $defaults['group'][$form->_gid] = 1; } if ($form->_tid) { $defaults['tag'][$form->_tid] = 1; } } } else { if (array_key_exists('TagsAndGroups', $contactEditOptions)) { // set the group and tag ids $groupElementType = 'checkbox'; if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $groupElementType = 'select'; } self::setDefaults($form->_contactId, $defaults, self::ALL, NULL, $groupElementType); } } }
/** * Initiate event fee. * * @param CRM_Core_Form $form * @param int $eventID * * @throws Exception */ public static function initEventFee(&$form, $eventID) { // get price info // retrive all active price set fields. $discountId = CRM_Core_BAO_Discount::findSet($eventID, 'civicrm_event'); if (property_exists($form, '_discountId') && $form->_discountId) { $discountId = $form->_discountId; } //CRM-16456 get all price field including expired one. $getAllPriceField = TRUE; $className = CRM_Utils_System::getClassName($form); if ($className == 'CRM_Event_Form_ParticipantFeeSelection' && $form->_action == CRM_Core_Action::UPDATE) { $getAllPriceField = FALSE; } if ($discountId) { $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id'); $price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', $getAllPriceField, $priceSetId); } else { $price = CRM_Price_BAO_PriceSet::initSet($form, $eventID, 'civicrm_event', $getAllPriceField); } if (property_exists($form, '_context') && ($form->_context == 'standalone' || $form->_context == 'participant')) { $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($eventID, 'civicrm_event'); if (is_array($discountedEvent)) { foreach ($discountedEvent as $key => $priceSetId) { $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId); $priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); $form->_values['discount'][$key] = CRM_Utils_Array::value('fields', $priceSet); $fieldID = key($form->_values['discount'][$key]); $form->_values['discount'][$key][$fieldID]['name'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'title'); } } } $eventFee = CRM_Utils_Array::value('fee', $form->_values); if (!is_array($eventFee) || empty($eventFee)) { $form->_values['fee'] = array(); } //fix for non-upgraded price sets.CRM-4256. if (isset($form->_isPaidEvent)) { $isPaidEvent = $form->_isPaidEvent; } else { $isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']); } if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !empty($form->_values['fee'])) { foreach ($form->_values['fee'] as $k => $fees) { foreach ($fees['options'] as $options) { if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) { unset($form->_values['fee'][$k]); } } } } if ($isPaidEvent && empty($form->_values['fee'])) { if (CRM_Utils_System::getClassName($form) != 'CRM_Event_Form_Participant') { CRM_Core_Error::fatal(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)))); } } }
/** * Build the form object elements for an email object. * * @param CRM_Core_Form $form * Reference to the form object. * @param int $blockCount * Block number to build. * @param bool $blockEdit * Is it block edit. */ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) { // passing this via the session is AWFUL. we need to fix this if (!$blockCount) { $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1; } else { $blockId = $blockCount; } $form->applyFilter('__ALL__', 'trim'); //Email box $form->addField("email[{$blockId}][email]", array('entity' => 'email')); $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType) || $blockEdit) { //Block type $form->addField("email[{$blockId}][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight')); //TODO: Refactor on_hold field to select. $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail(); //On-hold select if ($multipleBulk) { $holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out')); $form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions); } else { $form->addField("email[{$blockId}][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox')); } //Bulkmail checkbox $form->assign('multipleBulk', $multipleBulk); if ($multipleBulk) { $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js); } else { $js = array('id' => "Email_" . $blockId . "_IsBulkmail"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js); } //is_Primary radio $js = array('id' => "Email_" . $blockId . "_IsPrimary"); if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40)); $form->add('wysiwyg', "email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40)); } } }