/**
* This includes the submitted values of the search form
+ * @var array
*/
static protected $_searchFormValues;
* @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
- $form->_contactIds = array();
- $form->_contactTypes = array();
+ $form->_contactIds = [];
+ $form->_contactTypes = [];
$useTable = (CRM_Utils_System::getClassName($form->controller->getStateMachine()) == 'CRM_Export_StateMachine_Standalone');
$form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks));
if ($useTable) {
- $form->_componentTable = CRM_Utils_SQL_TempTable::build()->setCategory('tskact')->setDurable()->setId($qfKey)->getName();
- $sql = " DROP TABLE IF EXISTS {$form->_componentTable}";
- CRM_Core_DAO::executeQuery($sql);
-
- $sql = "CREATE TABLE {$form->_componentTable} ( contact_id int primary key) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
- CRM_Core_DAO::executeQuery($sql);
+ $tempTable = CRM_Utils_SQL_TempTable::build()->setCategory('tskact')->setDurable()->setId($qfKey)->setUtf8();
+ $form->_componentTable = $tempTable->getName();
+ $tempTable->drop();
+ $tempTable->createWithColumns('contact_id int primary key');
}
// all contacts or action = save a search
$allCids[$cacheKey] = self::getContactIds($form);
}
- $form->_contactIds = array();
+ $form->_contactIds = [];
if ($useTable) {
$count = 0;
- $insertString = array();
+ $insertString = [];
foreach ($allCids[$cacheKey] as $cid => $ignore) {
$count++;
$insertString[] = " ( {$cid} ) ";
$string = implode(',', $insertString);
$sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES $string";
CRM_Core_DAO::executeQuery($sql);
- $insertString = array();
+ $insertString = [];
}
}
if (!empty($insertString)) {
elseif (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel') {
// selected contacts only
// need to perform action on only selected contacts
- $insertString = array();
+ $insertString = [];
// refire sql in case of custom search
if ($form->_action == CRM_Core_Action::COPY) {
// fix for CRM-5165
$sortByCharacter = $form->get('sortByCharacter');
if ($sortByCharacter && $sortByCharacter != 1) {
- $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0);
+ $params[] = ['sortByCharacter', '=', $sortByCharacter, 0, 0];
}
$queryOperator = $form->get('queryOperator');
if (!$queryOperator) {
$queryOperator
);
- $contactIds = array();
+ $contactIds = [];
while ($dao->fetch()) {
$contactIds[$dao->contact_id] = $dao->contact_id;
}
return $contactIds;
}
-
/**
* Set default values for the form. Relationship that in edit/view action.
*
* @return array
*/
public function setDefaultValues() {
- $defaults = array();
+ $defaults = [];
return $defaults;
}
* @param bool $submitOnce
*/
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
- $this->addButtons(array(
- array(
- 'type' => $nextType,
- 'name' => $title,
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => $backType,
- 'name' => ts('Cancel'),
- 'icon' => 'fa-times',
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => $nextType,
+ 'name' => $title,
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => $backType,
+ 'name' => ts('Cancel'),
+ 'icon' => 'fa-times',
+ ],
+ ]);
}
/**
// Get Head of Household & Household Member relationships
$relationKeyMOH = CRM_Utils_Array::key('Household Member of', $contactRelationshipTypes);
$relationKeyHOH = CRM_Utils_Array::key('Head of Household for', $contactRelationshipTypes);
- $householdRelationshipTypes = array(
+ $householdRelationshipTypes = [
$relationKeyMOH => $contactRelationshipTypes[$relationKeyMOH],
$relationKeyHOH => $contactRelationshipTypes[$relationKeyHOH],
- );
+ ];
$relID = implode(',', $this->_contactIds);
$this->_contactIds[] = $householdsDAO->household_id;
}
}
- $householdsDAO->free();
}
// If contact list has changed, households will probably be at the end of
// the list. Sort it again by sort_name.
if (implode(',', $this->_contactIds) != $relID) {
- $result = civicrm_api3('Contact', 'get', array(
- 'return' => array('id'),
- 'id' => array('IN' => $this->_contactIds),
- 'options' => array(
+ $result = civicrm_api3('Contact', 'get', [
+ 'return' => ['id'],
+ 'id' => ['IN' => $this->_contactIds],
+ 'options' => [
'limit' => 0,
'sort' => "sort_name",
- ),
- ));
+ ],
+ ]);
$this->_contactIds = array_keys($result['values']);
}
}
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String');
$cacheKey = "civicrm search {$qfKey}";
- $cids = array();
+ $cids = [];
// Gymanstic time!
foreach (Civi::service('prevnext')->getSelection($cacheKey) as $cacheKey => $values) {
$cids = array_unique(array_merge($cids, array_keys($values)));
$searchParams = $this->controller->exportValues();
if ($searchParams['radio_ts'] == 'ts_sel') {
// Create a static group.
- $randID = md5(time() . rand(1, 1000)); // groups require a unique name
+ // groups require a unique name
+ $randID = md5(time() . rand(1, 1000));
$grpTitle = "Hidden Group {$randID}";
$grpID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $grpTitle, 'id', 'title');
if (!$grpID) {
- $groupParams = array(
+ $groupParams = [
'title' => $grpTitle,
'is_active' => 1,
'is_hidden' => 1,
- 'group_type' => array('2' => 1),
- );
+ 'group_type' => ['2' => 1],
+ ];
$group = CRM_Contact_BAO_Group::create($groupParams);
$grpID = $group->id;
CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $group->id);
$newGroupTitle = "Hidden Group {$grpID}";
- $groupParams = array(
+ $groupParams = [
'id' => $grpID,
'name' => CRM_Utils_String::titleToVar($newGroupTitle),
'title' => $newGroupTitle,
- 'group_type' => array('2' => 1),
- );
+ 'group_type' => ['2' => 1],
+ ];
CRM_Contact_BAO_Group::create($groupParams);
}
// note at this point its a static group
- return array($grpID, NULL);
+ return [$grpID, NULL];
}
else {
// Create a smart group.
$ssId = $this->get('ssID');
- $hiddenSmartParams = array(
- 'group_type' => array('2' => 1),
+ $hiddenSmartParams = [
+ 'group_type' => ['2' => 1],
// queryParams have been preprocessed esp WRT any entity reference fields - see +
// https://github.com/civicrm/civicrm-core/pull/13250
'form_values' => $this->get('queryParams'),
'saved_search_id' => $ssId,
'search_custom_id' => $this->get('customSearchID'),
'search_context' => $this->get('context'),
- );
+ ];
list($smartGroupId, $savedSearchId) = CRM_Contact_BAO_Group::createHiddenSmartGroup($hiddenSmartParams);
- return array($smartGroupId, $savedSearchId);
+ return [$smartGroupId, $savedSearchId];
}
}