Whether the user ID condition is met
@param array $condition
@return boolean
356929
public function id(array $condition)
    {
        $user_id = $this->user->getId();
        return $this->compare($user_id, $condition['value'], $condition['operator']);
    }
1012471
public function fetch($condition = array())
    {
        $query = self::getInstance($this, $condition);

        return $this->getRepository()->fetch($query);
    }
1305647
public function where( $condition ) {
		if ( ! $condition instanceof ConditionInterface ) {
			$condition = func_get_args();
		}

		$condition = $this->router->mergeConditionAttribute(
			$this->getAttribute( 'condition' ),
			$condition
		);

		return $this->attribute( 'condition', $condition );
	}
924198
public function product(array $condition, array $data)
    {
        $is_product = (int) isset($data['product_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_product, $value, $condition['operator']);
    }
545871
public function hasAccess(array $url, array $user): bool
    {
        $result = parent::hasAccess($url, $user);

        if (!$result) {
            return $result;
        }

        if (!empty($user['is_supervisor']) && $user['is_supervisor']) {
            $users = Utils::getReportToUsers($user['id']);

            foreach ($users as $userRecord) {
                $result = (new AccessFactory())->hasAccess($url, $userRecord->toArray());

                if ($result) {
                    return $result;
                }
            }
        }

        return false;
    }
1154734
public function categoryId(array $condition, array $data)
    {
        if (empty($data['product_id']) || empty($data['category_id'])) {
            return false;
        }

        return $this->compare($data['category_id'], $condition['value'], $condition['operator']);
    }
42210
private static function filterCondition($condition)
    {
        foreach($condition as $k => $v) {
            if (is_array($v)) {
                $condition[$k] = array_values($v);
                foreach($v as $vv) {
                    if (is_array($vv)) {
                        throw new InvalidArgumentException('Nested arrays are not allowed in condition for findAll() and findOne().');
                    }
                }
            }
        }
        return $condition;
    }
431975
public function filterHashCondition(array $data, $condition)
    {
        foreach ($condition as $column => $value) {
            if (is_array($value)) {
                // IN condition
                $data = $this->filterInCondition($data, 'IN', [$column, $value]);
            } else {
                $data = array_filter($data, function ($row) use ($column, $value) {
                    if ($value instanceof \Closure) {
                        return call_user_func($value, $row[$column]);
                    }

                    return $row[$column] == $value;
                });
            }
        }

        return $data;
    }
902486
public function filterOne(array $condition)
	{
		$p = $this->getPlaceholder();

		foreach ($condition as $column => $value) {
			$c = $this->checkAliases($column);

			$this->data_source->andWhere("$c = :$p")
				->setParameter($p, $value);
		}

		return $this;
	}
747332
protected function validateCondition($condition)
    {
        $condition = trim(strtolower($condition));

        if ('and' !== $condition && 'or' !== $condition) {
            throw new \Exception("Condition can only be one of: 'and', 'or'.");
        }

        return $condition;
    }
596952
public function brandCategoryId(array $condition, array $data)
    {
        if (empty(empty($data['product_id']) || $data['brand_category_id'])) {
            return false;
        }

        return $this->compare($data['brand_category_id'], $condition['value'], $condition['operator']);
    }
5359
public function getBy(array $condition) : User
    {
        if (!$user = User::find()->andWhere($condition)->limit(1)->one()) {
            throw new NotFoundException($this->i18n->t('setrun/user', 'User not found'));
        }
        return $user;
    }
356662
public function addConditions(array $conditions = array())
    {
        foreach ($conditions as $key => $condition) {
            if (is_array($condition)) {
                call_user_func_array(array($this, 'addCondition'), $condition);
            } elseif (!$this->getBuilder()->getHelper()->isNumber($key)) {
                call_user_func_array(array($this, 'addCondition'), array($key, $condition));
            } else {
                $this->addCondition($condition);
            }
        }

        return $this;
    }
603072
public function equals(\Skeleton\Pager\Sql\Condition $condition) {
		if ($this->get_local_field() != $condition->get_local_field()) {
			return false;
		}

		if ($this->get_comparison() == '=' AND $condition->get_comparison() == 'IN') {
			foreach ($condition->get_value() as $value) {
				if (in_array($value, $this->get_value())) {
					return true;
				}
			}
		}

		if ($condition->get_comparison() == '=' AND $this->get_comparison() == 'IN') {
			foreach ($this->get_value() as $value) {
				if (in_array($value, $condition->get_value())) {
					return true;
				}
			}
		}

		if ($this->get_comparison() != $condition->get_comparison()) {
			return false;
		}

		if (!is_array($this->get_value()) and !is_array($condition->get_value())) {
			if ($this->get_value() != $condition->get_value()) {
				return false;
			}
		} elseif (is_array($this->get_value()) and is_array($condition->get_value())) {
			$diff = array_diff($this->get_value(), $condition->get_value());
			if (count($diff) > 0) {
				return false;
			}
		} else {
			return false;
		}

		return true;
	}
30545
public function sku(array $condition, array $data)
    {
        if (empty($data['cart']['items']) || !in_array($condition['operator'], array('=', '!='))) {
            return false;
        }

        return $this->compare(array_keys($data['cart']['items']), $condition['value'], $condition['operator']);
    }
278802
public function has_access($condition, Array $entity)
	{
		// get the group driver instance
		$group_driver = \Auth::group($entity[0]);

		// parse the requested permissions so we can check them
		$condition = static::_parse_conditions($condition);

		// if we couldn't parse the conditions, don't have a driver, or the driver doesn't export roles, bail out
		if ( ! is_array($condition) || empty($group_driver) || ! is_callable(array($group_driver, 'get_roles')))
		{
			return false;
		}

		// get the permission area and the permission rights to be checked
		$area    = $condition[0];

		// any actions defined?
		if ( ! is_array($condition[1]) and preg_match('#(.*)?\[(.*)?\]#', $condition[1], $matches))
		{
			$rights = (array) $matches[1];
			$actions = explode(',', $matches[2]);
		}
		else
		{
			$rights  = (array) $condition[1];
			$actions = array();
		}

		// fetch the current user object
		$user = Auth::get_user();

		// some storage to collect the current rights and revoked rights, and the global flag
		$current_rights = array();
		$revoked_rights = array();
		$global_access = null;

		// assemble the current users effective rights
		$cache_key = \Config::get('ormauth.cache_prefix', 'auth').'.permissions.user_'.($user ? $user->id : 0);
		try
		{
			list($current_rights, $revoked_rights, $global_access) = \Cache::get($cache_key);
		}
		catch (\CacheNotFoundException $e)
		{
			// get the role objects assigned to this group
			$current_roles  = $entity[1]->roles;

			// if we have a user, add the roles directly assigned to the user
			if ($user)
			{
				$current_roles = \Arr::merge($current_roles, Auth::get_user()->roles);
			}

			foreach ($current_roles as $role)
			{
				// role grants all access
				if ($role->filter == 'A')
				{
					$global_access = true;
				}

				// role denies all access
				elseif ($role->filter == 'D')
				{
					$global_access = false;
				}

				// role defines a permission revocation
				elseif ($role->filter == 'R')
				{
					// fetch the permissions of this role
					foreach ($role->permissions as $permission)
					{
						isset($revoked_rights[$permission->area][$permission->permission]) or $revoked_rights[$permission->area][$permission->permission] = array();
						foreach ($role->rolepermission as $rolepermission)
						{
							if ($rolepermission->role_id == $role->id and $rolepermission->perms_id == $permission->id)
							{
								$revoked_rights[$permission->area][$permission->permission] = array_merge(
									$revoked_rights[$permission->area][$permission->permission],
									array_intersect_key(
										$permission->actions ?: array(),
										array_flip($rolepermission->actions ?: array())
									)
								);
								break;
							}
						}
					}
				}

				// standard role, add it to the current rights set
				else
				{
					// fetch the permissions of this role
					foreach ($role->permissions as $permission)
					{
						isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array();
						foreach ($role->rolepermission as $rolepermission)
						{
							if ($rolepermission->role_id == $role->id and $rolepermission->perms_id == $permission->id)
							{
								$current_rights[$permission->area][$permission->permission] = array_merge(
									$current_rights[$permission->area][$permission->permission],
									array_intersect_key(
										$permission->actions ?: array(),
										array_flip($rolepermission->actions ?: array())
									)
								);
								break;
							}
						}
					}
				}
			}

			// if this user doesn't have a global filter applied...
			if (is_array($current_rights))
			{
				if ($user)
				{
					// add the users group rights
					foreach ($user->group->permissions as $permission)
					{
						isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array();
						foreach ($user->group->grouppermission as $grouppermission)
						{
							if ($grouppermission->group_id == $user->group_id and $grouppermission->perms_id == $permission->id)
							{
								$current_rights[$permission->area][$permission->permission] = array_merge(
									$current_rights[$permission->area][$permission->permission],
									array_intersect_key(
										$permission->actions ?: array(),
										array_flip($grouppermission->actions ?: array())
									)
								);
								break;
							}
						}
					}

					// add the users personal rights
					foreach ($user->permissions as $permission)
					{
						isset($current_rights[$permission->area][$permission->permission]) or $current_rights[$permission->area][$permission->permission] = array();
						foreach ($user->userpermission as $userpermission)
						{
							if ($userpermission->user_id == $user->id and $userpermission->perms_id == $permission->id)
							{
								$current_rights[$permission->area][$permission->permission] = array_merge(
									$current_rights[$permission->area][$permission->permission],
									array_intersect_key(
										$permission->actions ?: array(),
										array_flip($userpermission->actions ?: array())
									)
								);
								break;
							}
						}
					}
				}
			}

			// save the rights in the cache
			\Cache::set($cache_key, array($current_rights, $revoked_rights, $global_access));
		}

		// check for a revocation first
		foreach ($rights as $right)
		{
			// check revocation permissions
			if ( isset($revoked_rights[$area]) and array_key_exists($right, $revoked_rights[$area]))
			{
				$revoked = true;

				// need to check any actions?
				foreach ($actions as $action)
				{
					if ( ! in_array($action, $revoked_rights[$area][$right]))
					{
						$revoked = false;
						break;
					}
				}

				// right revoked?
				if ($revoked)
				{
					return false;
				}
			}
		}

		// was a global filter applied?
		if (is_bool($global_access))
		{
			// we're done here
			return $global_access;
		}

		// start checking rights, terminate false when right not found
		foreach ($rights as $right)
		{
			// check basic permissions
			if ( ! isset($current_rights[$area]) or ! array_key_exists($right, $current_rights[$area]))
			{
				return false;
			}

			// need to check any actions?
			foreach ($actions as $action)
			{
				if ( ! in_array($action, $current_rights[$area][$right]))
				{
					return false;
				}
			}
		}

		// all necessary rights were found, return true
		return true;
	}
1222579
public function filter( $condition ) {
		$elements = array();

		foreach ( $this->elements as $element ) {
			if ( call_user_func( $condition, $element ) ) {
				$elements[] = $element;
			}
		}

		return $this->new_from_trusted( $elements );
	}