Skip to content

Commit

Permalink
Non functional changes towards shared functions in Core_Form_Task
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jun 21, 2018
1 parent 09e6644 commit 67cd5d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CRM/Contact/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function preProcess() {
* Common pre-processing function.
*
* @param CRM_Core_Form $form
*
* @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
$form->_contactIds = array();
Expand Down
31 changes: 16 additions & 15 deletions CRM/Export/Form/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,16 @@ public function preProcess() {
$this->_componentIds = array();
$this->_componentClause = NULL;

$stateMachine = $this->controller->getStateMachine();
$formName = CRM_Utils_System::getClassName($stateMachine);
$isStandalone = $formName == 'CRM_Export_StateMachine_Standalone';
$this::$queryMode = $this->controller->get('component_mode');

// we need to determine component export
$componentName = explode('_', $formName);
$components = array('Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity');

if ($isStandalone) {
$componentName = array('CRM', $this->controller->get('entity'));
}

$componentMode = $this->controller->get('component_mode');
// FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts
switch ($componentMode) {
switch ($this::$queryMode) {
case CRM_Contact_BAO_Query::MODE_CONTRIBUTE:
$entityShortname = 'Contribute';
$entityDAOName = $entityShortname;
break;

case CRM_Contact_BAO_Query::MODE_MEMBER:
Expand All @@ -120,33 +113,41 @@ public function preProcess() {

case CRM_Contact_BAO_Query::MODE_EVENT:
$entityShortname = 'Event';
$entityDAOName = $entityShortname;
break;

case CRM_Contact_BAO_Query::MODE_PLEDGE:
$entityShortname = 'Pledge';
$entityDAOName = $entityShortname;
break;

case CRM_Contact_BAO_Query::MODE_CASE:
$entityShortname = 'Case';
$entityDAOName = $entityShortname;
break;

case CRM_Contact_BAO_Query::MODE_GRANT:
$entityShortname = 'Grant';
$entityDAOName = $entityShortname;
break;

case CRM_Contact_BAO_Query::MODE_ACTIVITY:
$entityShortname = 'Activity';
$entityDAOName = $entityShortname;
break;

default:
// FIXME: Code cleanup, we may not need to do this $componentName code here.
$formName = CRM_Utils_System::getClassName($this->controller->getStateMachine());
$componentName = explode('_', $formName);
if ($formName == 'CRM_Export_StateMachine_Standalone') {
$componentName = array('CRM', $this->controller->get('entity'));
}
$entityShortname = $componentName[1]; // Contact
$entityDAOName = $entityShortname;
break;
}

if (empty($entityDAOName)) {
$entityDAOName = $entityShortname;
}

if (in_array($entityShortname, $components)) {
$this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($entityShortname) . '_EXPORT');
$formTaskClassName = "CRM_{$entityShortname}_Form_Task";
Expand Down Expand Up @@ -196,7 +197,7 @@ public function preProcess() {
}
}

$formTaskClassName::preProcessCommon($this, !$isStandalone);
$formTaskClassName::preProcessCommon($this);

// $component is used on CRM/Export/Form/Select.tpl to display extra information for contact export
($this->_exportMode == self::CONTACT_EXPORT) ? $component = FALSE : $component = TRUE;
Expand Down

0 comments on commit 67cd5d2

Please sign in to comment.