<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent {
/**
- * what blocks should we show and hide.
+ * What blocks should we show and hide.
*
* @var CRM_Core_ShowHideBlocks
*/
protected $_profilePostMultipleAdd = array();
/**
- * Function to set variables up before form is built
+ * Set variables up before form is built
*
* @return void
- * @access public
*/
- function preProcess() {
+ public function preProcess() {
$this->_addProfileBottom = CRM_Utils_Array::value('addProfileBottom', $_GET, FALSE);
$this->_profileBottomNum = CRM_Utils_Array::value('addProfileNum', $_GET, 0);
$this->_addProfileBottomAdd = CRM_Utils_Array::value('addProfileBottomAdd', $_GET, FALSE);
}
/**
- * This function sets the default values for the form.
+ * Set default values for the form.
* the default values are retrieved from the database
*
- * @access public
*
* @return void
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
if ($this->_addProfileBottom || $this->_addProfileBottomAdd) {
return;
}
list($defaults['custom_pre_id'],
$defaults['custom_post']
- ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+ ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
// Get the id for the event registration profile
$eventRegistrationIdParams = $eventRegistrationIdDefaults = array(
list($defaults['additional_custom_pre_id'],
$defaults['additional_custom_post']
- ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinAddParams);
+ ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinAddParams);
if (isset($defaults['additional_custom_post']) && is_numeric($defaults['additional_custom_post'])) {
$defaults['additional_custom_post_id'] = $defaults['additional_custom_post'];
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
if (!empty($defaults['registration_start_date'])) {
- list($defaults['registration_start_date'],
- $defaults['registration_start_date_time']
- ) = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'],
- 'activityDateTime'
- );
+ list($defaults['registration_start_date'], $defaults['registration_start_date_time'])
+ = CRM_Utils_Date::setDateDefaults($defaults['registration_start_date'], 'activityDateTime');
}
if (!empty($defaults['registration_end_date'])) {
- list($defaults['registration_end_date'],
- $defaults['registration_end_date_time']
- ) = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'],
- 'activityDateTime'
- );
+ list($defaults['registration_end_date'], $defaults['registration_end_date_time'])
+ = CRM_Utils_Date::setDateDefaults($defaults['registration_end_date'], 'activityDateTime');
}
return $defaults;
/**
* Fix what blocks to show/hide based on the default values set
*
- * @param array $defaults the array of default values
- *
- * @internal param bool $force should we set show hide based on input defaults
+ * @param array $defaults
+ * The array of default values.
*
* @return void
*/
- function setShowHide($defaults) {
+ public function setShowHide($defaults) {
$this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1),
''
);
}
/**
- * Function to build the form
+ * Build the form object
*
* @return void
- * @access public
*/
public function buildQuickForm() {
if ($this->_addProfileBottom) {
$this->addElement('checkbox',
'is_online_registration',
- ts('Allow Online Registration?'),
+ ts('Allow Online Registration'),
NULL,
array(
- 'onclick' => "return showHideByValue('is_online_registration',
- '',
- 'registration_blocks',
- 'block',
- 'radio',
- false );",
+ 'onclick' => "return showHideByValue('is_online_registration'," .
+ "''," .
+ "'registration_blocks'," .
+ "'block'," .
+ "'radio'," .
+ "false );",
)
);
}
$params = array(
- 'used' => 'Supervised',
+ 'used' => 'Supervised',
'contact_type' => 'Individual',
);
$dedupeRuleFields = CRM_Dedupe_BAO_Rule::dedupeRuleFields($params);
}
/**
- * Function to build Registration Block
+ * Build Registration Block
*
- * @param $form
+ * @param CRM_Core_Form $form
*
- * @internal param int $pageId
- * @static
*/
- function buildRegistrationBlock(&$form) {
+ public function buildRegistrationBlock(&$form) {
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
- $attributes['intro_text']['click_wysiwyg'] = true;
+ $attributes['intro_text']['click_wysiwyg'] = TRUE;
$form->addWysiwyg('intro_text', ts('Introductory Text'), $attributes['intro_text']);
// FIXME: This hack forces height of editor to 175px. Need to modify QF classes for editors to allow passing
// explicit height and width.
$footerAttribs = array(
'rows' => 2,
'cols' => 40,
- 'click_wysiwyg' => true,
+ 'click_wysiwyg' => TRUE,
);
$form->addWysiwyg('footer_text', ts('Footer Text'), $footerAttribs);
- extract( self::getProfileSelectorTypes() );
+ extract(self::getProfileSelectorTypes());
//CRM-15427
- $form->addProfileSelector( 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
- $form->addProfileSelector( 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
- $form->addProfileSelector( 'additional_custom_pre_id', ts('Profile for Additional Participants') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
- $form->addProfileSelector( 'additional_custom_post_id', ts('Profile for Additional Participants') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('additional_custom_pre_id', ts('Profile for Additional Participants') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('additional_custom_post_id', ts('Profile for Additional Participants') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
}
/**
* depends on getProfileSelectorTypes
*
* @param array &$form
- * @param int $count unique index
- * @param string $prefix dom element ID prefix
- * @param string $label Label
- * @param array $configs Optional, for addProfileSelector(), defaults to using getProfileSelectorTypes()
- **/
- function buildMultipleProfileBottom(&$form, $count, $prefix = '', $label = 'Include Profile', $configs = null) {
- extract( ( is_null($configs) ) ? self::getProfileSelectorTypes() : $configs );
+ * @param int $count
+ * Unique index.
+ * @param string $prefix
+ * Dom element ID prefix.
+ * @param string $label
+ * Label.
+ * @param array $configs
+ * Optional, for addProfileSelector(), defaults to using getProfileSelectorTypes().
+ */
+ public function buildMultipleProfileBottom(&$form, $count, $prefix = '', $label = 'Include Profile', $configs = NULL) {
+ extract((is_null($configs)) ? self::getProfileSelectorTypes() : $configs);
$element = $prefix . "custom_post_id_multiple[$count]";
- $label .= '<br />'.ts('(bottom of page)');
- $form->addProfileSelector( $element, $label, $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $label .= '<br />' . ts('(bottom of page)');
+ $form->addProfileSelector($element, $label, $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
}
/**
* Create initializers for addprofileSelector
*
- * @return array( 'allowCoreTypes' => array(), 'allowSubTypes' => array(), 'profileEntities' => array() )
- **/
- static function getProfileSelectorTypes() {
+ * @return array
+ * ['allowCoreTypes' => array, 'allowSubTypes' => array, 'profileEntities' => array]
+ */
+ public static function getProfileSelectorTypes() {
$configs = array(
'allowCoreTypes' => array(),
'allowSubTypes' => array(),
'profileEntities' => array(),
);
- $configs['allowCoreTypes'] = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
+ $configs['allowCoreTypes'] = array_merge(array(
+ 'Contact',
+ 'Individual',
+ ), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$configs['allowCoreTypes'][] = 'Participant';
//CRM-15427
- $id = CRM_Utils_Request::retrieve( 'id' , 'Integer' );
+ $id = CRM_Utils_Request::retrieve('id', 'Integer');
if ($id) {
$participantEventType = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $id, 'event_type_id', 'id');
- $participantRole = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'default_role_id');
+ $participantRole = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'default_role_id');
$configs['allowSubTypes']['ParticipantEventName'] = array($id);
$configs['allowSubTypes']['ParticipantEventType'] = array($participantEventType);
$configs['allowSubTypes']['ParticipantRole'] = array($participantRole);
}
$configs['profileEntities'][] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
- $configs['profileEntities'][] = array('entity_name' => 'participant_1', 'entity_type' => 'ParticipantModel', 'entity_sub_type' => '*');
+ $configs['profileEntities'][] = array(
+ 'entity_name' => 'participant_1',
+ 'entity_type' => 'ParticipantModel',
+ 'entity_sub_type' => '*',
+ );
- return $configs;
+ return $configs;
}
/**
- * Function to build Confirmation Block
+ * Build Confirmation Block
*
- * @param $form
+ * @param CRM_Core_Form $form
*
- * @internal param int $pageId
- * @static
*/
- function buildConfirmationBlock(&$form) {
+ public function buildConfirmationBlock(&$form) {
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
- $attributes['confirm_text']['click_wysiwyg'] = true;
+ $attributes['confirm_text']['click_wysiwyg'] = TRUE;
// CRM-11182 - Optional confirmation page for free events
$is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_id, 'is_monetary');
$form->assign('is_monetary', $is_monetary);
$footerAttribs = array(
'rows' => 2,
'cols' => 40,
- 'click_wysiwyg' => true,
+ 'click_wysiwyg' => TRUE,
);
$form->addWysiwyg('confirm_footer_text', ts('Footer Text'), $footerAttribs);
}
/**
- * Function to build Email Block
+ * Build Email Block
*
- * @param $form
+ * @param CRM_Core_Form $form
*
- * @internal param int $pageId
- * @static
*/
- function buildMailBlock(&$form) {
+ public function buildMailBlock(&$form) {
$form->registerRule('emailList', 'callback', 'emailList', 'CRM_Utils_Rule');
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
$form->addYesNo('is_email_confirm', ts('Send Confirmation Email?'), NULL, NULL, array('onclick' => "return showHideByValue('is_email_confirm','','confirmEmail','block','radio',false);"));
}
/**
- * @param $form
+ * @param CRM_Core_Form $form
*/
- function buildThankYouBlock(&$form) {
+ public function buildThankYouBlock(&$form) {
$attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event');
- $attributes['thankyou_text']['click_wysiwyg'] = true;
+ $attributes['thankyou_text']['click_wysiwyg'] = TRUE;
$form->add('text', 'thankyou_title', ts('Title'), $attributes['thankyou_title']);
$form->addWysiwyg('thankyou_text', ts('Introductory Text'), $attributes['thankyou_text']);
// FIXME: This hack forces height of editor to 175px. Need to modify QF classes for editors to allow passing
$footerAttribs = array(
'rows' => 2,
'cols' => 40,
- 'click_wysiwyg' => true,
+ 'click_wysiwyg' => TRUE,
);
$form->addWysiwyg('thankyou_footer_text', ts('Footer Text'), $footerAttribs);
}
/**
* Add local and global form rules
*
- * @access protected
*
* @return void
*/
- function addRules() {
+ public function addRules() {
if ($this->_addProfileBottom || $this->_addProfileBottomAdd) {
return;
}
}
/**
- * global validation rules for the form
+ * Global validation rules for the form
*
- * @param $values
+ * @param array $values
* @param $files
- * @param $form
- *
- * @internal param array $fields posted values of the form
+ * @param CRM_Core_Form $form
*
- * @return array list of errors to be posted back to the form
- * @static
- * @access public
+ * @return array
+ * list of errors to be posted back to the form
*/
- static function formRule($values, $files, $form) {
+ public static function formRule($values, $files, $form) {
if (!empty($values['is_online_registration'])) {
if (!$values['confirm_title']) {
isset($values['registration_end_date'])
) {
$start = CRM_Utils_Date::processDate($values['registration_start_date']);
- $end = CRM_Utils_Date::processDate($values['registration_end_date']);
+ $end = CRM_Utils_Date::processDate($values['registration_end_date']);
if ($end < $start) {
$errorMsg['registration_end_date'] = ts('Registration end date should be after Registration start date');
}
* Collect all email fields for an array of profile ids
*
* @param $profileIds
- * @return boolean
+ * @return bool
*/
- static function getEmailFields($profileIds) {
+ public static function getEmailFields($profileIds) {
$emailFields = array();
foreach ($profileIds as $profileId) {
if ($profileId && is_numeric($profileId)) {
* Check if a profile contains required fields
*
* @param $profileIds
- * @return boolean
+ * @return bool
*/
- static function isProfileComplete($profileIds) {
+ public static function isProfileComplete($profileIds) {
$profileReqFields = array();
foreach ($profileIds as $profileId) {
if ($profileId && is_numeric($profileId)) {
*
* @param $profileIds
* @param int $rgId
- * @return boolean
+ * @return bool
*/
-
public static function canProfilesDedupe($profileIds, $rgId = 0) {
-
// find the unsupervised rule
-
$rgParams = array(
'used' => 'Unsupervised',
'contact_type' => 'Individual',
$index = array();
foreach ($combos as $comboid => $combo) {
foreach ($combo as $cfield) {
- $index[$cfield][$comboid] = true;
+ $index[$cfield][$comboid] = TRUE;
}
$combos[$comboid] = array_fill_keys($combo, 0);
$okCombos[$comboid] = array_fill_keys($combo, 2);
// check each of the fields in the index against the profile field
foreach ($index as $ifield => $icombos) {
- if(strpos($field['name'], $ifield) !== false) {
+ if (strpos($field['name'], $ifield) !== FALSE) {
// we found the field in the profile, now record it in the index
foreach ($icombos as $icombo => $dontcare) {
// check the combos to see if everything is > 0
foreach ($combos as $comboid => $combo) {
- $complete = false;
+ $complete = FALSE;
foreach ($combo as $cfield) {
if ($cfield > 0) {
- $complete = true;
+ $complete = TRUE;
}
else {
// this combo isn't complete--skip to the next combo
continue 2;
}
}
- if ($complete) { return 1; }
+ if ($complete) {
+ return 1;
+ }
}
// no combo succeeded
/**
* Add additional profiles from the form to an array of profile ids.
- *
*/
- static function addMultipleProfiles(&$profileIds, $values, $field) {
+ public static function addMultipleProfiles(&$profileIds, $values, $field) {
if ($multipleProfiles = CRM_Utils_Array::value($field, $values)) {
foreach ($multipleProfiles as $profileId) {
$profileIds[] = $profileId;
}
/**
- * Function to process the form
+ * Process the form submission
*
- * @access public
*
* @return void
*/
'entity_id' => $this->_id,
);
-
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$ufAdd[1] = $params['custom_pre_id'];
$wtAdd = 1;
}
- elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {}
+ elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
+ }
else {
$ufAdd[1] = $params['additional_custom_pre_id'];
$wtAdd = 1;
if (empty($params['additional_custom_post_id'])) {
$ufAdd[2] = $params['custom_post_id'];
}
- elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {}
+ elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
+ }
else {
$ufAdd[2] = $params['additional_custom_post_id'];
}
self::addMultipleProfiles($profileIds, $params, 'custom_post_id_multiple');
self::addMultipleProfiles($additionalProfileIds, $params, 'additional_custom_post_id_multiple');
- $cantDedupe = false;
+ $cantDedupe = FALSE;
$rgId = CRM_Utils_Array::value('dedupe_rule_group_id', $params, 0);
switch (self::canProfilesDedupe($profileIds, $rgId)) {
$dedupeTitle = 'Duplicate Matching Impossible';
$cantDedupe = ts("The selected profiles do not contain the fields necessary to match registrations with existing contacts. This means all anonymous registrations will result in a new contact.");
break;
+
case 1:
$dedupeTitle = 'Duplicate Contacts Possible';
$cantDedupe = ts("The selected profiles can collect enough information to match registrations with existing contacts, but not all of the relevant fields are required. Anonymous registrations may result in duplicate contacts.");
}
if (!empty($params['is_multiple_registrations'])) {
- switch(self::canProfilesDedupe($additionalProfileIds, $rgId)) {
+ switch (self::canProfilesDedupe($additionalProfileIds, $rgId)) {
case 0:
$dedupeTitle = 'Duplicate Matching Impossible';
if ($cantDedupe) {
$cantDedupe = ts("The selected profiles do not contain the fields necessary to match additional participants with existing contacts. This means all additional participants will result in a new contact.");
}
break;
+
case 1:
if (!$cantDedupe) {
$dedupeTitle = 'Duplicate Contacts Possible';
parent::endPostProcess();
}
- //end of function
/**
* Return a descriptive name for the page, used in wizard header
*
* @return string
- * @access public
*/
public function getTitle() {
return ts('Online Registration');
}
-}
+}