/** * @ApiDoc( * section="Bundle Editor", * description="Saves the php class definition into a php class" * ) * * Target path is specified in $general['file']. * * @Rest\QueryParam(name="class", requirements=".*", strict=true, description="The PHP class name") * @Rest\RequestParam(name="list", strict=false, description="The `list` value array") * @Rest\RequestParam(name="add", strict=false, description="The `add` value array") * @Rest\RequestParam(name="general", strict=false, description="The `general` value array") * @Rest\RequestParam(name="methods", strict=false, description="The `methods` value array") * @Rest\RequestParam(name="fields", strict=false, description="The `fields` value array") * * @Rest\Post("/admin/system/bundle/editor/window") * * @param ParamFetcher $paramFetcher * * @return bool */ public function setWindowDefinitionAction(ParamFetcher $paramFetcher) { $class = $paramFetcher->get('class'); $list = $paramFetcher->get('list') ?: null; $add = $paramFetcher->get('add') ?: null; $general = $paramFetcher->get('general') ?: null; $methods = $paramFetcher->get('methods') ?: null; $fields = $paramFetcher->get('fields') ?: null; if (substr($class, 0, 1) != '\\') { $class = '\\' . $class; } $path = $general['file']; $sourcecode = "<?php\n\n"; $lSlash = strrpos($class, '\\'); $class2Name = $lSlash !== -1 ? substr($class, $lSlash + 1) : $class; $parentClass = '\\Jarves\\Controller\\ObjectCrudController'; $objectDefinition = $this->objects->getDefinition($general['object']); if ($objectDefinition->isNested()) { $parentClass = '\\Jarves\\Controller\\NestedObjectCrudController'; } $namespace = substr(substr($class, 1), 0, $lSlash); if (substr($namespace, -1) == '\\') { $namespace = substr($namespace, 0, -1); } $sourcecode .= "namespace {$namespace};\n \n"; $sourcecode .= 'class ' . $class2Name . ' extends ' . $parentClass . " {\n\n"; if (count($fields) > 0) { $this->addVar($sourcecode, 'fields', $fields); } if (is_array($list)) { foreach ($list as $listVarName => $listVar) { $this->addVar($sourcecode, $listVarName, $listVar); } } if (is_array($add)) { foreach ($add as $varName => $var) { $this->addVar($sourcecode, $varName, $var); } } $blacklist = array('class', 'file'); if (is_array($general)) { foreach ($general as $varName => $var) { if (array_search($varName, $blacklist) !== false) { continue; } $this->addVar($sourcecode, $varName, $var); } } if (is_array($methods)) { foreach ($methods as $name => $source) { $this->addMethod($sourcecode, $source); } } $sourcecode .= "\n}\n"; $sourcecode = str_replace("\r", '', $sourcecode); $fs = $this->localFilesystem; $result = $fs->write($path, $sourcecode); $this->reconfigureJarves(); return $result; }
/** * Important call directly after the creation of this class. * * @param string $objectKey * @param Object $definition */ public function configure($objectKey, $definition) { $this->objectKey = \Jarves\Objects::normalizeObjectKey($objectKey); $this->definition = $definition; foreach ($this->definition->getFields() as $field) { if ($field->isPrimaryKey()) { $this->primaryKeys[] = $field->getId(); } } }
public function getColumns() { if (AbstractStorage::MANY_TO_ONE == $this->getFieldDefinition()->getObjectRelation() || AbstractStorage::ONE_TO_ONE == $this->getFieldDefinition()->getObjectRelation()) { $foreignObjectDefinition = $this->objects->getDefinition($this->getFieldDefinition()->getObject()); if (!$foreignObjectDefinition) { throw new ObjectNotFoundException(sprintf('ObjectKey `%s` not found in field `%s` of object `%s`', $this->getFieldDefinition()->getObject(), $this->getFieldDefinition()->getId(), $this->getFieldDefinition()->getObjectDefinition()->getId())); } /** @var $columns ColumnDefinition[] */ $columns = []; foreach ($foreignObjectDefinition->getPrimaryKeys() as $pk) { $fieldColumns = $pk->getFieldType()->getColumns(); $columns = array_merge($columns, $fieldColumns); } //rename columns to fieldId+column.id foreach ($columns as &$column) { $column = clone $column; $column->setName($this->getFieldDefinition()->getId() . ucfirst($column->getName())); } return $columns; } return []; }
/** * @ApiDoc( * section="ACL Management", * description="Search user and group" * ) * * @Rest\QueryParam(name="q", requirements=".*", description="Search query") * * @Rest\Get("/user/acl/search") * * @param string $q * * @return array array('users' => array, 'groups' => array()) */ public function getSearch($q) { $q = str_replace("*", "%", $q); $userFilter = array(); $groupFilter = array(); if ($q) { $userFilter = array(array('username', 'like', "{$q}%"), 'OR', array('first_name', 'like', "{$q}%"), 'OR', array('last_name', 'like', "{$q}%"), 'OR', array('email', 'like', "{$q}%")); $groupFilter = array(array('name', 'like', "{$q}%")); } $users = $this->objects->getList('jarves/user', $userFilter, array('limit' => 10, 'fields' => 'id,username,email,groups.name,firstName,lastName')); $this->setAclCount($users, 0); $groups = $this->objects->getList('jarves/group', $groupFilter, array('fields' => 'name', 'limit' => 10)); $this->setAclCount($groups, 1); return array('users' => $users, 'groups' => $groups); }
/** * {@inheritdoc} */ public function getParents($pk, $options = null) { $query = $this->getQueryClass(); $item = $query->findPK($this->getPropelPk($pk)); if (!$item) { throw new \Exception('Can not found entry. ' . var_export($pk, true)); } if (!$item->getRgt()) { throw new \Exception('Entry it not in a tree. ' . var_export($pk, true)); } list($fields, $relations, $relationFields) = $this->getFields(@$options['fields']); $selects = array_keys($fields); $selects[] = 'Lft'; $selects[] = 'Rgt'; // $selects[] = 'Title'; $query->select($selects); $this->mapOptions($query, $options); $this->mapToOneRelationFields($query, $relations, $relationFields); $query->ancestorsOf($item); $query->orderByLevel(); $stmt = $this->getStm($query); $clazz = $this->getPhpName(); $result = array(); if ($this->definition['nestedRootAsObject']) { //fetch root object entry $scopeField = 'get' . ucfirst($this->definition['nestedRootObjectField']); $scopeId = $item->{$scopeField}(); $root = $this->objects->get($this->definition['nestedRootObject'], $scopeId); $root['_object'] = $this->definition['nestedRootObject']; $result[] = $root; } $item = false; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { //propels nested set requires a own root item, we do not return this if (false === $item) { $item = true; continue; } $item = $this->populateRow($clazz, $row, $selects, $relations, $relationFields, $options['permissionCheck']); $result[] = $item; } return $result; }
protected function addForeignKey(Object $object, RelationDefinitionInterface $relation, &$xmlTable) { $relationName = $relation->getName(); $foreignObject = $this->objects->getDefinition($relation->getForeignObjectKey()); if (!$foreignObject) { throw new ModelBuildException(sprintf('Foreign object `%s` does not exist in relation `%s`', $relation->getForeignObjectKey(), $relation->getName())); } if ($object->getStorageService() !== $foreignObject->getStorageService()) { throw new ModelBuildException(sprintf('Can not create a relation between two different dataModels. Got `%s` but `%s` is needed.', $foreignObject->getStorageService(), $object->getStorageService())); } $pluralizer = new StandardEnglishPluralizer(); $foreignPhpName = ucfirst($pluralizer->getSingularForm(lcfirst($relationName))); $foreigns = $xmlTable->xpath('foreign-key[@phpName=\'' . $foreignPhpName . '\']'); if ($foreigns) { $foreignKey = current($foreigns); } else { $foreignKey = $xmlTable->addChild('foreign-key'); } $foreignKey['phpName'] = $foreignPhpName; $foreignKey['foreignTable'] = $foreignObject->getTable(); if ($refName = $relation->getRefName()) { $foreignKey['refPhpName'] = ucfirst($pluralizer->getSingularForm(lcfirst($refName))); } $foreignKey['onDelete'] = $relation->getOnDelete(); $foreignKey['onUpdate'] = $relation->getOnUpdate(); if (!$relation->getWithConstraint()) { $foreignKey['skipSql'] = 'true'; } $references = $foreignKey->xpath("reference[not(@custom='true')]"); foreach ($references as $i => $ref) { unset($references[$i][0]); } foreach ($relation->getReferences() as $reference) { $localName = Tools::camelcase2Underscore($reference->getLocalColumn()->getName()); $references = $foreignKey->xpath('reference[@local=\'' . $localName . '\']'); if ($references) { $xmlReference = current($references); } else { $xmlReference = $foreignKey->addChild('reference'); } $xmlReference['local'] = $localName; $xmlReference['foreign'] = Tools::camelcase2Underscore($reference->getForeignColumn()->getName()); } if ($foreignObject->getWorkspace()) { if (!$object->getWorkspace()) { $columns = $xmlTable->xpath('column[@name=\'workspace_id\']'); if (!$columns) { $newCol = $xmlTable->addChild('column'); $newCol['name'] = 'workspace_id'; $newCol['type'] = 'INTEGER'; $newCol['defaultValue'] = '1'; } } $localName = 'workspace_id'; $references = $foreignKey->xpath('reference[@local=\'' . $localName . '\']'); if ($references) { $xmlReference = current($references); } else { $xmlReference = $foreignKey->addChild('reference'); } $xmlReference['local'] = $localName; $xmlReference['foreign'] = 'workspace_id'; } }
/** * @param ACLRequest $aclRequest * * @return bool */ public function check(ACLRequest $aclRequest) { $objectKey = Objects::normalizeObjectKey($aclRequest->getObjectKey()); $targetType = $aclRequest->getTargetType(); $targetId = $aclRequest->getTargetId(); $pk = $aclRequest->getPrimaryKey(); $field = $aclRequest->getField(); $pk = $this->objects->normalizePkString($objectKey, $pk); if (ACL::TARGET_TYPE_USER === $targetType && null === $targetId) { //0 means guest $targetId = $this->pageStack->getUser() ? $this->pageStack->getUser()->getId() : 0; } $user = $this->pageStack->getUser(); if ($user) { $groupIds = $user->getGroupIds(); if (false !== strpos(',' . $groupIds . ',', ',1,')) { //user is in the admin group, so he has always access. return true; } } if (ACL::TARGET_TYPE_USER === $targetType && 1 === $targetId) { //user admin has always access return true; } if (ACL::TARGET_TYPE_GROUP === $targetType && 1 === $targetId) { //group admin has always access return true; } if (0 === $targetId) { //guests do always have no access return false; } if (ACL::TARGET_TYPE_GROUP === $targetType && !$targetId) { throw new \InvalidArgumentException('For type TARGET_TYPE_GROUP a targetId is required.'); } $cacheKey = null; if ($pk && $this->getCaching()) { $pkString = $this->objects->getObjectUrlId($objectKey, $pk); $cacheKey = md5($targetType . '.' . $targetId . '.' . $objectKey . '/' . $pkString . '/' . json_encode($field)); $cached = $this->cacher->getDistributedCache('core/acl/' . $cacheKey); if (null !== $cached) { return $cached; } } $rules = self::getRules($objectKey, $aclRequest->getMode(), $targetType, $targetId); if (count($rules) === 0) { //no rules found, so we have no access return false; } $access = null; $currentObjectPk = $pk; $definition = $this->objects->getDefinition($objectKey); $not_found = true; //starts directly as if we were in the parent checking. $parent_acl = $aclRequest->isAsParent(); $fCount = null; $fKey = null; $fValue = null; $fIsArray = is_array($field); if ($fIsArray) { $fCount = count($field); $fKey = key($field); $fValue = current($field); if (is_int($fKey)) { $fKey = $fValue; $fValue = null; } } $depth = 0; $match = false; $originObjectItemPk = $currentObjectPk; while ($not_found) { $currentObjectPkString = null; if ($currentObjectPk) { $currentObjectPkString = $this->objects->getObjectUrlId($objectKey, $currentObjectPk); } $depth++; if ($depth > 50) { $not_found = false; break; } foreach ($rules as $aclRule) { if ($parent_acl && !$aclRule['sub']) { //as soon we enter the parent_acl mode we only take acl rules into consideration //that are also valid for children (sub=true) continue; } $match = false; /* * CUSTOM CONSTRAINT */ if ($aclRule['constraint_type'] === ACL::CONSTRAINT_CONDITION) { $objectItem = null; if ($originObjectItemPk === $currentObjectPk && null !== $aclRequest->getPrimaryObjectItem()) { $objectItem = $aclRequest->getPrimaryObjectItem(); } else { if ($originObjectItemPk) { $objectItem = $this->objects->get($objectKey, $currentObjectPk); } } if ($objectItem && $this->conditionOperator->satisfy($aclRule['constraint_code'], $objectItem, $objectKey)) { $match = true; } /* * EXACT */ } else { if ($aclRule['constraint_type'] === ACL::CONSTRAINT_EXACT) { if ($currentObjectPk && $aclRule['constraint_code'] === $currentObjectPkString) { $match = true; } /** * ALL */ } else { $match = true; } } if (!$match && $aclRule['sub'] && $currentObjectPk) { // we need to check if a parent matches this $acl as we have sub=true $parentItem = $this->objects->normalizePkString($objectKey, $currentObjectPk); $parentCondition = Condition::create($aclRule['constraint_code']); $parentOptions['fields'] = $this->conditionOperator->extractFields($parentCondition); while ($parentItem = $this->objects->getParent($objectKey, $this->objects->getObjectPk($objectKey, $parentItem), $parentOptions)) { if ($aclRule['constraint_type'] === ACL::CONSTRAINT_CONDITION && $this->conditionOperator->satisfy($parentCondition, $parentItem)) { $match = true; break; } else { if ($aclRule['constraint_type'] === ACL::CONSTRAINT_EXACT && $aclRule['constraint_code'] === $this->objects->getObjectUrlId($objectKey, $parentItem)) { $match = true; break; } } } } if ($match) { //match, check all $field $field2Key = $field; if ($field) { if ($fIsArray && $fCount === 1) { if (is_string($fKey) && is_array($aclRule['fields'][$fKey])) { //this field has limits if (($field2Acl = $aclRule['fields'][$fKey]) !== null) { if (is_array($field2Acl[0])) { //complex field rule, $field2Acl = ([{access: no, condition: [['id', '>', 2], ..]}, {}, ..]) foreach ($field2Acl as $fRule) { $satisfy = false; if (($f = $definition->getField($fKey)) && $f->getType() === 'object') { $uri = $f->getObject() . '/' . $fValue; $uriObject = $this->objects->getFromUrl($uri); $satisfy = $this->conditionOperator->satisfy($fRule['condition'], $uriObject); } else { if (null !== $fValue) { $satisfy = $this->conditionOperator->satisfy($fRule['condition'], $field); } } if ($satisfy) { return $fRule['access'] === 1 ? true : false; } } //if no field rules fits, we consider the whole rule if ($aclRule['access'] !== 2) { return $aclRule['access'] === 1 ? true : false; } } else { //simple field rule $field2Acl = ({"value1": yes, "value2": no} if ($field2Acl[$fKey] !== null) { return $field2Acl[$fKey] === 1 ? true : false; } else { //current($field) is not exactly defined in $field2Acl, so we set $access to $acl['access'] // //if access = 2 then wo do not know it, cause 2 means 'inherited', so maybe //a other rule has more detailed rule if ($aclRule['access'] !== 2) { $access = $aclRule['access'] === 1 ? true : false; break; } } } } } else { //this field has only true or false $field2Key = $fKey; } } if (!is_array($field2Key)) { if ($aclRule['fields'] && ($field2Acl = $aclRule['fields'][$field2Key]) !== null && !is_array($aclRule['fields'][$field2Key])) { $access = $field2Acl === 1 ? true : false; break; } else { //$field is not exactly defined, so we set $access to $acl['access'] //and maybe a rule with the same code has the field defined // if access = 2 then this rule is only for exactly define fields if ($aclRule['access'] !== 2) { $access = $aclRule['access'] === 1 ? true : false; break; } } } } else { $access = $aclRule['access'] === 1 ? true : false; break; } } } //foreach if (null === $access && $definition->isNested() && $pk) { //$access has not defined yet (no rule matched yet). Check if nested and $pk is given //load its root and check again if (null === ($currentObjectPk = $this->objects->getParentPk($objectKey, $currentObjectPk))) { $access = $aclRequest->isRootHasAccess() ? true : $access; break; } $parent_acl = true; } else { break; } } $access = (bool) $access; if ($pk && $this->getCaching()) { $this->cacher->setDistributedCache('core/acl/' . $cacheKey, $access); } return $access; }
/** * @param string $objectKey * @return Object * * @throws BundleNotFoundException */ public function getObject($objectKey) { $objectKey = Objects::normalizeObjectKey($objectKey); if (false === strpos($objectKey, '/')) { return null; } list($bundleName, $objectName) = explode('/', $objectKey); if ('bundle' !== substr($bundleName, -6)) { $bundleName .= 'bundle'; } if (!($config = $this->getConfig($bundleName))) { throw new BundleNotFoundException(sprintf('Bundle `%s` not found. [%s]', $bundleName, $objectKey)); } return $config->getObject($objectName); }
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method) { if (!($objectName = $route->getDefault('_jarves_object')) || !($object = $this->objects->getDefinition($objectName))) { return; } if ($entryPointPath = $route->getDefault('_jarves_entry_point')) { $adminUtils = new \Jarves\Admin\Utils($this->jarves); $entryPoint = $adminUtils->getEntryPoint($entryPointPath); $annotation->setSection(sprintf('%s %s %s', $entryPoint->isFrameworkWindow() ? 'Framework Window: ' : '', $entryPoint->getBundle() ? ($entryPoint->getBundle()->getLabel() ?: $entryPoint->getBundle()->getBundleName()) . ', ' : 'No Bundle, ', $entryPoint->getLabel() ?: $entryPoint->getPath())); } else { $objectKey = $route->getDefault('_jarves_object_section') ?: $route->getDefault('_jarves_object'); $objectSection = $this->objects->getDefinition($objectKey); $annotation->setSection(sprintf('Object %s', $objectKey)); } $filters = $annotation->getFilters(); if (@$filters['fields']) { $fields = []; foreach ($object->getFields() as $field) { if ('object' === $field->getId()) { $foreignObject = $this->objects->getDefinition($field->getObject()); foreach ($foreignObject->getFields() as $fField) { $filters[] = $field->getId() . '.' . $fField->getId(); } } else { $fields[] = $field->getId(); } } $annotation->addFilter('fields', ['requirement' => '.*', 'description' => "Comma separated list of fields. Possible fields to select: \n" . implode(', ', $fields)]); } $annotation->setDescription(str_replace('%object%', $object->getBundle()->getBundleName() . ':' . lcfirst($object->getId()), $annotation->getDescription())); $isRelationRoute = $route->getDefault('_jarves_object_relation'); $requirePk = $route->getDefault('_jarves_object_requirePk'); $method = explode(':', $route->getDefault('_controller'))[1]; // maybe in version 1.1 // if ($isRelationRoute) { // $objectKey = $route->getDefault('_jarves_object_section') ? : $route->getDefault('_jarves_object'); // $objectParent = $this->jarves->getObjects()->getDefinition($objectKey); // // foreach ($objectParent->getFields() as $field) { // if ($field->isPrimaryKey()) { // $annotation->addRequirement( // $field->getId(), // [ // 'requirement' => $field->getRequiredRegex(), // 'dataType' => $field->getPhpDataType(), // 'description' => '(' . $objectParent->getId() . ') ' . $field->getDescription() // ] // ); // } // } // } if ($requirePk) { foreach ($object->getFields() as $field) { if (!$field->hasFieldType()) { continue; } if ($field->isPrimaryKey()) { $annotation->addRequirement(($isRelationRoute ? lcfirst($object->getId()) . '_' : '') . $field->getId(), ['requirement' => $field->getRequiredRegex(), 'dataType' => $field->getPhpDataType(), 'description' => $isRelationRoute ? '(' . $object->getId() . ') ' : '']); } } } //add all fields to some actions if (in_array($method, ['addItemAction', 'patchItemAction', 'updateItemAction'])) { foreach ($object->getFields() as $field) { if (!$field->hasFieldType()) { continue; } if ($field->isRequired() && !$field->getDefault()) { $annotation->addRequirement($field->getId(), array('requirement' => $field->getRequiredRegex(), 'dataType' => $field->getPhpDataType(), 'description' => ($isRelationRoute ? '(' . $object->getId() . ') ' : '') . $field->getLabel())); } else { $annotation->addParameter($field->getId(), array('format' => $field->getRequiredRegex(), 'dataType' => $field->getPhpDataType(), 'default' => $field->getDefault(), 'description' => $field->getLabel() . ($field->isAutoIncrement() ? ' (autoIncremented)' : ''), 'readonly' => false, 'required' => false)); } } } }
/** * Adds a item. * * @param string $objectKey * @param array $values * @param mixed $targetPk Full PK as array or as primary key string (url). * @param string $position If nested set. `first` (child), `last` (last child), `prev` (sibling), `next` (sibling) * @param bool $targetObjectKey If this object key differs from $objectKey then we'll use $pk as `scope`. Also * it is then only possible to have position `first` and `last`. * @param array $options * * @return mixed * * @throws \Jarves\Exceptions\InvalidArgumentException */ public function add($objectKey, $values, $targetPk = null, $position = 'first', $targetObjectKey = null, array $options = array()) { $targetPk = $this->normalizePk($objectKey, $targetPk); $objectKey = Objects::normalizeObjectKey($objectKey); if ($targetObjectKey) { $targetObjectKey = Objects::normalizeObjectKey($targetObjectKey); } $repository = $this->getRepository($objectKey, $options); return $repository->add($values, $targetPk, $position, $targetObjectKey); }
/** * @return string */ public function getObject() { return Objects::normalizeObjectKey($this->object); }
/** * When ObjectCrudController is without custom sub class used, then we need to get the object information * from the route, defined in Jarves\Router\RestApiLoader * * @return string */ protected function detectObjectKeyFromRoute() { $request = $this->requestStack->getCurrentRequest(); return $request ? Objects::normalizeObjectKey($request->attributes->get('_jarves_object')) : ''; }
/** * Adds a new news-feed entry. If not message (means null) is passed we generate a diff. * * @param Objects $repo * @param string $objectKey * @param array $item * @param string $verb * @param string|null $message * @throws \Propel\Runtime\Exception\PropelException */ public function newNewsFeed(Objects $repo, $objectKey, $item, $verb, $message = null) { $definition = $repo->getDefinition($objectKey); $itemLabel = ''; if ($labelField = $definition->getLabelField()) { $itemLabel = $item[$labelField]; } if (!$itemLabel) { $pks = $definition->getPrimaryKeys(); $itemLabel = '#' . $item[$pks[0]->getId()]; } $username = '******'; $userId = 0; if ($user = $this->pageStack->getUser()) { $userId = $user->getId(); if ($user->getFirstName() || $user->getLastName()) { $username = $user->getFirstName(); if ($username) { $username .= ' '; } $username .= $user->getLastName(); } else { $username = $user->getUsername(); } } $newsFeed = new \Jarves\Model\NewsFeed(); $newsFeed->setUsername($username); $newsFeed->setUserId($userId); $newsFeed->setVerb($verb); $newsFeed->setTargetObject($objectKey); $newsFeed->setTargetPk($repo->getObjectUrlId($objectKey, $item)); $newsFeed->setTargetLabel($itemLabel); $newsFeed->setCreated(time()); $newsFeed->setMessage(null === $message ? $this->generateDiff($repo, $objectKey, $item) : $message); $newsFeed->save(); }
/** * @param array $objectItem * @param array $conditionRule * @param string $objectKey * * @return bool */ public function checkRule($objectItem, $conditionRule, $objectKey = null) { $field = $conditionRule[0]; $operator = $conditionRule[1]; $value = $conditionRule[2]; if (is_numeric($field)) { $ovalue = $field; } else { $ovalue = @$objectItem[$field]; if (null === $ovalue && $objectKey && ($definition = $this->objects->getDefinition($objectKey))) { $tableName = substr($field, 0, strpos($field, '.')); $fieldName = substr($field, strpos($field, '.') + 1); if ($tableName === $definition->getTable()) { $ovalue = $objectItem[$fieldName]; } } } if ($value instanceof ConditionSubSelect) { $value = $value->getValue($objectKey); } //'<', '>', '<=', '>=', '=', 'LIKE', 'IN', 'REGEXP' switch (strtoupper($operator)) { case '!=': case 'NOT EQUAL': return $ovalue != $value; case 'LIKE': $value = preg_quote($value, '/'); $value = str_replace('%', '.*', $value); $value = str_replace('_', '.', $value); return !!preg_match('/^' . $value . '$/', $ovalue); case 'REGEXP': return !!preg_match('/' . preg_quote($value, '/') . '/', $ovalue); case 'NOT IN': return strpos(',' . $value . ',', ',' . $ovalue . ',') === false; case 'IN': return strpos(',' . $value . ',', ',' . $ovalue . ',') !== false; case '<': case 'LESS': return $ovalue < $value; case '>': case 'GREATER': return $ovalue > $value; case '<=': case '=<': case 'LESSEQUAL': return $ovalue <= $value; case '>=': case '=>': case 'GREATEREQUAL': return $ovalue >= $value; case '= CURRENT_USER': case 'EQUAL CURRENT_USER': return $this->pageStack->isLoggedIn() && $ovalue == $this->pageStack->getUser()->getId(); case '!= CURRENT_USER': case 'NOT EQUAL CURRENT_USER': return $this->pageStack->isLoggedIn() && $ovalue != $this->pageStack->getUser()->getId(); case '=': case 'EQUAL': default: return $ovalue == $value; } }