set('entity', $entity); $id = explode(',', CRM_Utils_Request::retrieve('id', 'CommaSeparatedIntegers', $this, TRUE)); // Check permissions $perm = civicrm_api3($entity, 'get', [ 'return' => 'id', 'options' => ['limit' => 0], 'check_permissions' => 1, 'id' => ['IN' => $id], ]); $this->set('id', implode(',', array_keys($perm['values']))); if ($entity == 'Contact') { $this->set('cids', implode(',', array_keys($perm['values']))); } $this->_stateMachine = new CRM_Export_StateMachine_Standalone($this, $action); // create and instantiate the pages $this->addPages($this->_stateMachine, $action); // add all the actions $this->addActions(); } /** * Export forms are historically tightly coupled to search forms,so this simulates * the output of a search form, with an array of checkboxes for each selected entity. * * @param string $pageName * @return array */ public function exportValues($pageName = NULL) { $values = parent::exportValues(); $values['radio_ts'] = 'ts_sel'; foreach (explode(',', $this->get('id')) as $id) { if ($id) { $values[CRM_Core_Form::CB_PREFIX . $id] = 1; } } // Set the "task" selector value to Export $className = 'CRM_' . $this->get('entity') . '_Task'; foreach ($className::tasks() as $taskId => $task) { $taskForm = (array) $task['class']; if ($taskForm[0] == 'CRM_Export_Form_Select') { $values['task'] = $taskId; } } return $values; } }