protected function loadObjects() { parent::loadObjects(); if (($this->isPost() || $this->hasData()) && ($searchObj = $this->getPrimary()) instanceof CSD_Search && I2CE_FormStorage::getStorageMechanism($searchObj->getName()) instanceof I2CE_FormStorage_CSDSearch) { //this will populate "result" field $searchObj->setID("1"); //so it will populate if (($maxField = $searchObj->getField('max')) instanceof I2CE_FormField_INT) { if ($maxField->getValue() > 200) { $maxField->setValue(200); } } if (($entityIDField = $searchObj->getField('entityID')) instanceof I2CE_FormField_STRING_LINE) { list($form, $id) = array_pad(explode('|', $entityIDField->getValue(), 2), 2, ''); if ($id) { $entityIDField->setValue($id); } } $searchObj->populate(true); if (($matches = $searchObj->getField('matches')) instanceof I2CE_FormField_ASSOC_MAP_RESULTS && count($matches->getValue()) > 200) { $this->userMessage("To Many Results To Display. Please refine your search"); I2CE::raiseError("Too many results"); $this->bad_result = true; $matches->setValue(array()); if (($resultField = $searchObj->getField('result')) instanceof I2CE_FormField) { $resultField->setValue(''); } } } return true; }
/** * Checks to see if there are any permissions in the page's args for the given action. * If so, it evaluates them. If not returns true. * @returns boolean */ protected function checkActionPermission($action) { if (!($primaryFormName = $this->getPrimaryFormName())) { return false; //weirdness. should just stop whatever is happening } if (!parent::checkActionPermission($action)) { return false; } $listConfig = $this->getListConfig(); if (array_key_exists('edit_task', $listConfig) && $listConfig['edit_task']) { return $this->hasPermission("task(" . $listConfig['edit_task'] . ")"); } else { return true; } }
protected function _display($supress_output = false) { if ($this->getAction() != 'remap') { return parent::_display($supress_output); } $this->template->addHeaderLink('mootools-core.js'); $this->template->addHeaderLink('mootools-more.js'); parent::_display($supress_output); if ($errors = I2CE_Dumper::cleanlyEndOutputBuffers()) { I2CE::raiseError("Errors:\n" . $errors); } $this->ff = I2CE_FormFactory::instance(); if (!$this->request_exists('id') || !($formid = $this->request('id'))) { $this->pushError("Bad list id {$id}"); //needs to be localized return false; } $success = true; list($form, $id) = array_pad(explode("|", $formid, 2), 2, ''); if ($id == '*') { $where = array('operator' => 'FIELD_LIMIT', 'field' => 'remap', 'style' => 'not_null', 'data' => array()); $ids = I2CE_FormStorage::search($form, false, $where); I2CE::raiseError("Form {$form} has remapping data for " . implode(" ", $ids)); if (count($ids) > 0) { foreach (I2CE_List::getFieldsMappingToList($form) as $rform => $fields) { foreach ($fields as $fieldObj) { $field = $fieldObj->getName(); foreach ($ids as $id) { I2CE::raiseError("Checking for remaps on {$rform}+{$field}"); $success &= $this->doRemap($rform, $field, $form . '|' . $id); } } } } $url = "index.php/auto_list?form_name=" . $form; } else { $form = ''; if (!$this->request_exists('form_name') || !($form = $this->request('form_name')) || !in_array($form, $this->ff->getForms())) { $this->pushError("Form {$form} not found"); return false; } $field = ''; if (!$this->request_exists('field') || !($field = $this->request('field'))) { $this->pushError("Bad Field {$field}"); return false; } $success = $this->doRemap($form, $field, $formid); $url = "index.php/auto_list?id={$formid}&form_name=" . $form; } if ($success) { $this->pushContent("Data was succesully remapped. Continue on to database lists <a href='{$url}'>site</a>?"); } else { $this->pushContent("Data was <b>not</b> succesully remapped. Continue on to database lists <a href='{$url}'>site</a>?"); } return true; }