public function afterDelete($record) { $this->getDi()->resourceAccessTable->clearAccess(amstrtoint($record->name), Am_CustomField::ACCESS_TYPE); foreach ($this->getDi()->savedFormTable->findBy() as $savedForm) { if ($row = $savedForm->findBrickById('field-' . $record->name)) { $savedForm->removeBrickConfig($row['class'], $row['id']); $savedForm->update(); } } }
function setupDefaultProtcetionForCustomFields() { if (version_compare($this->db_version, '4.2.20') < 0) { echo "Setup default protection for custom fields..."; foreach ($this->getDi()->userTable->customFields()->getAll() as $field) { if (isset($field->from_config) && $field->from_config) { $this->getDi()->resourceAccessTable->setAccess(amstrtoint($field->name), Am_CustomField::ACCESS_TYPE, array(ResourceAccess::FN_FREE_WITHOUT_LOGIN => array(json_encode(array('start' => null, 'stop' => null, 'text' => ___('Free Access without log-in')))))); } } echo "Done<br>\n"; } }
function insertBrick(HTML_QuickForm2_Container $form) { if (!$this->getConfig('skip_access_check') && isset($this->field->from_config) && $this->field->from_config) { $hasAccess = Am_Di::getInstance()->auth->getUserId() ? Am_Di::getInstance()->resourceAccessTable->userHasAccess(Am_Di::getInstance()->auth->getUser(), amstrtoint($this->field->name), Am_CustomField::ACCESS_TYPE) : Am_Di::getInstance()->resourceAccessTable->guestHasAccess(amstrtoint($this->field->name), Am_CustomField::ACCESS_TYPE); if (!$hasAccess) { return; } } switch ($this->getConfig('display_type', self::TYPE_NORMAL)) { case self::TYPE_HIDDEN: $form->addHidden($this->field->getName())->setValue($this->getConfig('value')); break; case self::TYPE_READONLY: $el = $this->field->addToQF2($form); $el->toggleFrozen(true); break; case self::TYPE_NORMAL: $this->field->addToQF2($form); break; default: throw new Am_Exception_InternalError(sprintf('Unknown display type [%s] in %s::%s', $this->getConfig('display_type', self::TYPE_NORMAL), __CLASS__, __METHOD__)); } }
function importAddFieldDefs() { $member_fields = $this->db3->selectCell("SELECT blob_value FROM ?_config WHERE name=?", 'member_fields'); $def3 = array(); if ($member_fields) { $_def3 = unserialize($member_fields); $def3 = array(); foreach ($_def3 as $v) { $def3[$v['name']] = $v; } $_def4 = $this->getDi()->userTable->customFields()->getAll(); $def4 = array(); foreach ($_def4 as $v) { $def4[$v->getName()] = $v; } foreach ($def3 as $name => $def) { if (!isset($def4[$name])) { $cf = $this->getCfDataSource(); $def = array_merge($def, (array) $def['additional_fields']); $def['values'] = array('default' => (array) @$def['default'], 'options' => @$def['options']); $def['validate_func'] = array_filter(array($this->translateValidateFunc($def['validate_func']))); if ($def['sql']) { //try to check existing columns in ?_user try { $this->getDi()->db->select("SELECT ?# from ?_user LIMIT 1", $def['name']); } catch (Am_Exception_Db $e) { $cf->insertRecord(null, $def); } continue; } $cf->insertRecord(null, $def); } } $this->getDi()->userTable->addFieldsFromSavedConfig(); foreach ($this->getDi()->userTable->customFields()->getAll() as $field) { if (isset($field->from_config) && $field->from_config) { $this->getDi()->resourceAccessTable->setAccess(amstrtoint($field->name), Am_CustomField::ACCESS_TYPE, array(ResourceAccess::FN_FREE_WITHOUT_LOGIN => array(json_encode(array('start' => null, 'stop' => null, 'text' => ___('Free Access without log-in')))))); } } } return $def3; }