/**
  * Remove all limitations for a policy
  *
  * @param mixed $policyId
  *
  * @return void
  */
 public function removePolicyLimitations($policyId)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation'), $this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation_value'))->from($this->handler->quoteTable('ezpolicy'))->leftJoin($this->handler->quoteTable('ezpolicy_limitation'), $query->expr->eq($this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), $this->handler->quoteColumn('id', 'ezpolicy')))->leftJoin($this->handler->quoteTable('ezpolicy_limitation_value'), $query->expr->eq($this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), $this->handler->quoteColumn('id', 'ezpolicy_limitation')))->where($query->expr->eq($this->handler->quoteColumn('id', 'ezpolicy'), $query->bindValue($policyId, null, \PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $limitationIdsSet = array();
     $limitationValuesSet = array();
     while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
         if ($row['ezpolicy_limitation_id'] !== null) {
             $limitationIdsSet[$row['ezpolicy_limitation_id']] = true;
         }
         if ($row['ezpolicy_limitation_value_id'] !== null) {
             $limitationValuesSet[$row['ezpolicy_limitation_value_id']] = true;
         }
     }
     if (!empty($limitationIdsSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationIdsSet)));
         $query->prepare()->execute();
     }
     if (!empty($limitationValuesSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation_value'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationValuesSet)));
         $query->prepare()->execute();
     }
 }
 /**
  * Loads user with user ID.
  *
  * @param string $login
  * @param string|null $email
  *
  * @return array
  */
 public function loadByLoginOrMail($login, $email = null)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($this->handler->quoteColumn('contentobject_id', 'ezuser'), $this->handler->quoteColumn('login', 'ezuser'), $this->handler->quoteColumn('email', 'ezuser'), $this->handler->quoteColumn('password_hash', 'ezuser'), $this->handler->quoteColumn('password_hash_type', 'ezuser'), $this->handler->quoteColumn('is_enabled', 'ezuser_setting'), $this->handler->quoteColumn('max_login', 'ezuser_setting'))->from($this->handler->quoteTable('ezuser'))->leftJoin($this->handler->quoteTable('ezuser_setting'), $query->expr->eq($this->handler->quoteColumn('user_id', 'ezuser_setting'), $this->handler->quoteColumn('contentobject_id', 'ezuser')))->where(empty($email) ? $query->expr->eq($this->handler->quoteColumn('login', 'ezuser'), $query->bindValue($login)) : $query->expr->lOr($query->expr->eq($this->handler->quoteColumn('login', 'ezuser'), $query->bindValue($login)), $query->expr->eq($this->handler->quoteColumn('email', 'ezuser'), $query->bindValue($email))));
     $statement = $query->prepare();
     $statement->execute();
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }
 /**
  * Loads an array with data about UrlWildcards (paged)
  *
  * @param mixed $offset
  * @param mixed $limit
  *
  * @return array
  */
 public function loadUrlWildcardsData($offset = 0, $limit = -1)
 {
     $limit = $limit === -1 ? self::MAX_LIMIT : $limit;
     /** @var $query \ezcQuerySelect */
     $query = $this->dbHandler->createSelectQuery();
     $query->select("*")->from($this->dbHandler->quoteTable("ezurlwildcard"))->limit($limit > 0 ? $limit : self::MAX_LIMIT, $offset);
     $stmt = $query->prepare();
     $stmt->execute();
     return $stmt->fetchAll(\PDO::FETCH_ASSOC);
 }
Esempio n. 4
0
 /**
  * Returns relevant field information for the specified field
  *
  * The returned information is returned as an array of the attribute
  * identifier and the sort column, which should be used.
  *
  * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given $fieldIdentifier.
  *
  * @caching
  * @param string $fieldIdentifier
  *
  * @return array
  */
 protected function getFieldsInformation($fieldIdentifier)
 {
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->quoteColumn('id', 'ezcontentclass_attribute'), $this->dbHandler->quoteColumn('data_type_string', 'ezcontentclass_attribute'))->from($this->dbHandler->quoteTable('ezcontentclass_attribute'))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('identifier', 'ezcontentclass_attribute'), $query->bindValue($fieldIdentifier)), $query->expr->eq($this->dbHandler->quoteColumn('is_searchable', 'ezcontentclass_attribute'), $query->bindValue(1, null, \PDO::PARAM_INT))));
     $statement = $query->prepare();
     $statement->execute();
     if (!($rows = $statement->fetchAll(\PDO::FETCH_ASSOC))) {
         throw new InvalidArgumentException("\$criterion->target", "No searchable fields found for the given criterion target '{$fieldIdentifier}'.");
     }
     $fieldMapArray = array();
     foreach ($rows as $row) {
         if (!isset($fieldMapArray[$row['data_type_string']])) {
             $converter = $this->fieldConverterRegistry->getConverter($row['data_type_string']);
             if (!$converter instanceof Converter) {
                 throw new RuntimeException("getConverter({$row['data_type_string']}) did not return a converter, got: " . gettype($converter));
             }
             $fieldMapArray[$row['data_type_string']] = array('ids' => array(), 'column' => $converter->getIndexColumn());
         }
         $fieldMapArray[$row['data_type_string']]['ids'][] = $row['id'];
     }
     return $fieldMapArray;
 }
 /**
  * Get sorted arrays of content IDs, which should be returned
  *
  * @param Criterion $criterion
  * @param array $sort
  * @param mixed $offset
  * @param mixed $limit
  * @param mixed $translations
  *
  * @return int[]
  */
 protected function getContentIds(Criterion $criterion, $sort, $offset, $limit, $translations)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($this->handler->quoteColumn('id', 'ezcontentobject'));
     if ($sort !== null) {
         $this->sortClauseConverter->applySelect($query, $sort);
     }
     $query->from($this->handler->quoteTable('ezcontentobject'));
     $query->innerJoin('ezcontentobject_version', 'ezcontentobject.id', 'ezcontentobject_version.contentobject_id');
     if ($sort !== null) {
         $this->sortClauseConverter->applyJoin($query, $sort);
     }
     $query->where($this->getQueryCondition($criterion, $query, $translations));
     if ($sort !== null) {
         $this->sortClauseConverter->applyOrderBy($query, $sort);
     }
     $query->limit($limit, $offset);
     $statement = $query->prepare();
     $statement->execute();
     return $statement->fetchAll(\PDO::FETCH_COLUMN);
 }
 /**
  * Get ezcontent_language Id
  * @param \eZ\Publish\Core\Persistence\Legacy\EzcDbHandler $connection
  * @param $languageCode
  * @return int
  */
 protected function getLanguageId($connection, $languageCode)
 {
     /** @var \ezcQuerySelect $selectQuery */
     $selectQuery = $connection->createSelectQuery();
     $selectQuery->select($connection->quoteColumn('id'))->from($connection->quoteTable('ezcontent_language'))->where($selectQuery->expr->eq($connection->quoteColumn('locale'), $selectQuery->bindValue($languageCode, null, \PDO::PARAM_STR)));
     $statement = $selectQuery->prepare();
     $statement->execute();
     $row = $statement->fetch();
     if (isset($row['id'])) {
         return $row['id'];
     }
     return 0;
 }
 /**
  * Creates a generalized query for fetching object state group(s)
  *
  * @return \ezcQuerySelect
  */
 protected function createObjectStateGroupFindQuery()
 {
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->aliasedColumn($query, 'default_language_id', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'id', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'identifier', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'language_mask', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'description', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'language_id', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'real_language_id', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'name', 'ezcobj_state_group_language'))->from($this->dbHandler->quoteTable('ezcobj_state_group'))->innerJoin($this->dbHandler->quoteTable('ezcobj_state_group_language'), $query->expr->eq($this->dbHandler->quoteColumn('id', 'ezcobj_state_group'), $this->dbHandler->quoteColumn('contentobject_state_group_id', 'ezcobj_state_group_language')));
     return $query;
 }