/** * Notin constructor. * * @param string $field Field. * @param string $value Value. * * @throws InvalidArgumentException If $field is not 'category'. */ public function __construct($field, $value) { parent::__construct($field, $value); if ($field != 'category') { throw new InvalidArgumentException('The in operator "notin" supports only "category" as field.'); } self::$filter = null; }
/** * In constructor. * * @param string $objectType Object type. * @param string $field Field. * @param string $value Value. * * @throws InvalidArgumentException If $field is not 'category'. */ public function __construct($objectType, $field, $value) { // cast all numbers in the list to integers because of security if ($field == 'id') { $ids = explode(',', $value); $newValue = array(); foreach ($ids as $id) { $newValue[] = (int) $id; } $value = $newValue; } parent::__construct($objectType, $field, $value); if ($field != 'category' && $field != 'id') { throw new InvalidArgumentException('The in operator "in" supports only "category" and "id" as field.'); } self::$filter = null; }
/** * Add an expression this the current open group. * * @param string $string A expression in the format field:oper:value . * * @return TimeIt_Filter_Container $this * @throws LogicException If there's no open group. */ public function addExp($string) { if (count($this->groups) === 0) { throw new LogicException('No groups found!'); } $op = TimeIt_Filter_OperatorIf::operatorFromExp($this->objectType, $string); if ($op) { $this->groups[count($this->groups) - 1][] = $op; $this->prepared = false; if ($this->objectType == 'event') { // security: add cr_uid expression if there is a share filter for private events. if ($op->getField() == 'sharing' && ($op instanceof TimeIt_Filter_OP_le || $op instanceof TimeIt_Filter_OP_lt || (int) $op->getValue() <= 2 && ($op instanceof TimeIt_Filter_OP_eq || TimeIt_Filter_OP_ne) || $op instanceof TimeIt_Filter_OP_like && ($op->getValue() == '%2%' || $op->getValue() == '2%' || $op->getValue() == '2' || $op->getValue() == '%1%' || $op->getValue() == '1%' || $op->getValue() == '1'))) { $op2 = TimeIt_Filter_OP_Interface::operatorFromExp($this->objectType, 'cr_uid:eq:-1'); if ($op2 != null) { $this->groups[count($this->groups) - 1][] = $op2; } } } } return $this; }