Most of the noise is in the shared pre-process code so my focus is on paring that down
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_activity';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'activity_id';
+ }
+
}
return TRUE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_contact';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'contact_id';
+ }
+
}
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_contribution';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'contribution_id';
+ }
+
}
}
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, $form->getQueryMode());
- $query->_distinctComponentClause = " ( " . $form::$tableName . ".id )";
- $query->_groupByComponentClause = " GROUP BY " . $form::$tableName . ".id ";
+ $query->_distinctComponentClause = $form->getDistinctComponentClause();
+ $query->_groupByComponentClause = $form->getGroupByComponentClause();
$result = $query->searchQuery(0, 0, $sortOrder);
- $selector = $form::$entityShortname . '_id';
+ $selector = $form->getEntityAliasField();
while ($result->fetch()) {
$entityIds[] = $result->$selector;
}
}
if (!empty($entityIds)) {
- $form->_componentClause = ' ' . $form::$tableName . '.id IN ( ' . implode(',', $entityIds) . ' ) ';
+ $form->_componentClause = ' ' . $form->getTableName() . '.id IN ( ' . implode(',', $entityIds) . ' ) ';
$form->assign('totalSelected' . ucfirst($form::$entityShortname) . 's', count($entityIds));
}
*/
public function setContactIDs() {
$this->_contactIds = CRM_Core_DAO::getContactIDsFromComponent($this->_entityIds,
- $this::$tableName
+ $this->getTableName()
);
}
return $this->controller->exportValues('Basic');
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ CRM_Core_Error::deprecatedFunctionWarning('function should be overridden');
+ return $this::$tableName;
+ }
+
+ /**
+ * Get the clause for grouping by the component.
+ *
+ * @return string
+ */
+ public function getDistinctComponentClause() {
+ return " ( " . $this->getTableName() . ".id )";
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getGroupByComponentClause() {
+ return " GROUP BY " . $this->getTableName() . ".id ";
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ CRM_Core_Error::deprecatedFunctionWarning('function should be overridden');
+ return $this::$entityShortname . '_id';
+ }
+
}
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_participant';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'participant_id';
+ }
+
}
throw new CRM_Core_Exception('Unreachable code');
}
$this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($entityShortname) . '_EXPORT');
- $formTaskClassName = "CRM_{$entityShortname}_Form_Task";
-
- if (isset($formTaskClassName::$entityShortname)) {
- $this::$entityShortname = $formTaskClassName::$entityShortname;
- if (isset($formTaskClassName::$tableName)) {
- $this::$tableName = $formTaskClassName::$tableName;
- }
- }
- else {
- $this::$entityShortname = $entityShortname;
- $this::$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDAOName()));
- }
+ $this::$entityShortname = strtolower($entityShortname);
$values = $this->getSearchFormValues();
$count = 0;
$this->set('selectAll', $this->_selectAll);
$this->set('exportMode', $this->_exportMode);
$this->set('componentClause', $this->_componentClause);
- $this->set('componentTable', $this->_componentTable);
+ $this->set('componentTable', $this->getTableName());
+ }
+
+ /**
+ * Get the name of the table for the relevant entity.
+ */
+ public function getTableName() {
+ throw new CRM_Core_Exception('should be over-riden');
}
/**
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_case';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'case_id';
+ }
+
}
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_grant';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'grant_id';
+ }
+
}
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_membership';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'membership_id';
+ }
+
}
return FALSE;
}
+ /**
+ * Get the name of the table for the relevant entity.
+ *
+ * @return string
+ */
+ public function getTableName() {
+ return 'civicrm_pledge';
+ }
+
+ /**
+ * Get the group by clause for the component.
+ *
+ * @return string
+ */
+ public function getEntityAliasField() {
+ return 'pledge_id';
+ }
+
}