function _init_fields() { if (!empty($this->_fields)) { return $this->_fields; } $modin = $this->getModin(); if (!$modin) { return false; } $sourceDef = get_class($this) . $modin; //check registry for field defs $reg =& AMP_Registry::instance(); $definedSources =& $reg->getEntry(AMP_REGISTRY_SYSTEM_DATASOURCE_DEFS); if (!$definedSources) { $definedSources = AMP_cache_get(AMP_REGISTRY_SYSTEM_DATASOURCE_DEFS); } if ($definedSources && isset($definedSources[$sourceDef])) { return $definedSources[$sourceDef]; } require_once 'AMP/System/UserData.php'; $moduleSource = new AMPSystem_UserData($this->dbcon, $modin); if (!$moduleSource->hasData()) { return false; } $md = $moduleSource->getData(); $fields = $this->_allowed_keys; $keys = array('label', 'public', 'type', 'required', 'values', 'lookup', 'size', 'enabled'); foreach ($fields as $fname) { if (!$fname) { continue; } if (!(isset($md['enabled_' . $fname]) && $md['enabled_' . $fname])) { continue; } $field = array(); foreach ($keys as $key) { $field[$key] = $md[$key . "_" . $fname]; } $field = $this->_register_lookups($field); $this->_fields[$fname] = $field; } //Publish Field Hack if ($md['publish']) { $publish_field = array('type' => 'checkbox', 'label' => '<span class=publish_label>PUBLISH</span>', 'required' => false, 'public' => false, 'values' => 0, 'size' => null, 'enabled' => true); $this->_fields['publish'] = $publish_field; } //cache field defs to registry $definedSources[$sourceDef] = $this->_fields; $reg->setEntry(AMP_REGISTRY_SYSTEM_DATASOURCE_DEFS, $definedSources); AMP_cache_set(AMP_REGISTRY_SYSTEM_DATASOURCE_DEFS, $definedSources); return $this->_fields; }
function AMPSystemLookup_FormFields($form_id) { if (!$form_id) { return false; } require_once 'AMP/System/UserData.php'; $form_def = new AMPSystem_UserData(AMP_Registry::getDbcon(), $form_id); $data = $form_def->getData(); foreach ($data as $key => $value) { if (substr($key, 0, 8) == 'enabled_' && $value) { $short_key = substr($key, 8); $this->dataset[$short_key] = $data['label_' . $short_key]; } } }
function _register_base() { /* $dbcon = &$this->dbcon; // Fetch database definition of module. $sql = "SELECT * FROM userdata_fields WHERE id=" . $dbcon->qstr( $this->instance ); $rs = $dbcon->CacheExecute( $sql ) or trigger_error( "Error retreiving module information from database: " . $dbcon->ErrorMsg() ); $md = $this->_module_def = $rs->FetchRow(); */ $moduleSource = new AMPSystem_UserData($this->dbcon, $this->instance); if (!$moduleSource->hasData()) { return false; } $md = $this->_module_def = $moduleSource->getData(); // Define module class $this->class = isset($md['class']) ? $md['class'] : 1; $this->modTemplateID = $md['modidinput'] or 10; // Define module variables. $this->name = $md['name']; // Define redirect config. Legacy, will be replaced by redirect plugin. $this->redirect = $md['redirect']; // Define email config. fixme, will be replaced by email plugins. if ($md['useemail'] == 1) { $this->mailto = $md['mailto']; $this->subject = $md['subject']; } }