本文整理汇总了PHP中CustomField::getRights方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::getRights方法的具体用法?PHP CustomField::getRights怎么用?PHP CustomField::getRights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomField
的用法示例。
在下文中一共展示了CustomField::getRights方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$isSent = Request::get(1, VAR_URI) == 'send';
$this->breadcrumb->add('Hinzufügen');
$this->header();
$_positions = $this->getPositions();
$positions = Core::constructObjectArray($_positions);
$_fieldTypes = $this->getFieldTypes();
$fieldTypes = Core::constructObjectArray($_fieldTypes);
$data = array('name' => '', 'description' => '', 'internal' => '', 'priority' => 0, 'position' => reset($_positions), 'type' => reset($_fieldTypes), 'read' => array(), 'write' => array());
foreach (CustomField::getRights() as $right) {
foreach (array('read', 'write') as $type) {
$data[$type][$right] = 1;
}
}
$error = array();
if ($isSent) {
// Base options for every field
$options = array_merge($this->getValidator(), array('internal' => array(Validator::OPTIONAL => true, Validator::MULTIPLE => array(array(Validator::MESSAGE => 'Der interne Name enthält Zeichen die nicht erlaubt sind. Erlaubt sind: a-z, 0-9, _, -', Validator::REGEXP => Validator::RE_URI, Validator::OPTIONAL => true), array(Validator::MESSAGE => 'Der interne Name darf maximal 32 Zeichen lang sein.', Validator::MAX_LENGTH => 32), array(Validator::MESSAGE => 'Der interne Name existiert bereits für eine anderes Feld der Tabelle.', Validator::CLOSURE => function ($internal) use(&$_positions) {
if (!empty($internal)) {
$db = Database::getObject();
$db->query("SELECT id FROM <p>fields WHERE internal = <internal> AND position IN(<_positions:string[]>)", compact("internal", "_positions"));
return $db->numRows() == 0;
}
return true;
// If nothing is specified we will generate a valid name
}))), 'position' => array(Validator::MESSAGE => 'Der Anzeigeort ist ungültig.', Validator::LIST_CS => $_positions), 'type' => array(Validator::MESSAGE => 'Der Feldtyp ist ungültig.', Validator::LIST_CS => $_fieldTypes)));
// get additional options for the specified field
$type = Request::get('type');
if (isset($fieldTypes[$type])) {
$options = array_merge($options, $fieldTypes[$type]->getValidationParams(true));
}
extract(Validator::checkRequest($options));
if (count($error) == 0) {
$field = $fieldTypes[$data['type']];
$this->injectDataToField($field, $data);
if ($field->create()) {
CmsPage::ok("Das Feld wurde erfolgreich angelegt.");
} else {
$error[] = 'Das Feld konnt leider nicht angelegt werden.';
}
}
if (count($error) > 0) {
CmsPage::error($error);
}
}
if (!$isSent || count($error) > 0) {
$tpl = Response::getObject()->appendTemplate("/Cms/admin/fields_add");
$tpl->assign('positions', $positions, false);
$tpl->assign('types', $fieldTypes, false);
$tpl->assign('data', $data, false);
$tpl->assign('baseUri', $this->getBaseURI());
$tpl->output();
}
$this->footer();
}
示例2: ensurePermissionsValid
public static function ensurePermissionsValid($permissions)
{
$data = array();
foreach (CustomField::getRights() as $right) {
foreach (array('read', 'write') as $type) {
if (empty($permissions[$type][$right])) {
$data[$type][$right] = 0;
} else {
$data[$type][$right] = 1;
}
}
}
return $data;
}