コード例 #1
0
ファイル: systemtagmanager.php プロジェクト: kenwi/core
 /**
  * {@inheritdoc}
  */
 public function getTag($tagName, $userVisible, $userAssignable)
 {
     $userVisible = (int) $userVisible;
     $userAssignable = (int) $userAssignable;
     $result = $this->selectTagQuery->setParameter('name', $tagName)->setParameter('visibility', $userVisible)->setParameter('editable', $userAssignable)->execute();
     $row = $result->fetch();
     $result->closeCursor();
     if (!$row) {
         throw new TagNotFoundException('Tag ("' . $tagName . '", ' . $userVisible . ', ' . $userAssignable . ') does not exist');
     }
     return $this->createSystemTagFromRow($row);
 }
コード例 #2
0
ファイル: testcase.php プロジェクト: farukuzun/core-1
 /**
  * Remove all entries from the filecache table
  *
  * @param IQueryBuilder $queryBuilder
  */
 protected static function tearDownAfterClassCleanFileCache(IQueryBuilder $queryBuilder)
 {
     $queryBuilder->delete('filecache')->execute();
 }
コード例 #3
0
ファイル: dbconfigservice.php プロジェクト: fabricecetic/core
 private function getMountsFromQuery(IQueryBuilder $query)
 {
     $result = $query->execute();
     $mounts = $result->fetchAll();
     $mountIds = array_map(function ($mount) {
         return $mount['mount_id'];
     }, $mounts);
     $applicable = $this->getApplicableForMounts($mountIds);
     $config = $this->getConfigForMounts($mountIds);
     $options = $this->getOptionsForMounts($mountIds);
     return array_map(function ($mount, $applicable, $config, $options) {
         $mount['type'] = (int) $mount['type'];
         $mount['priority'] = (int) $mount['priority'];
         $mount['applicable'] = $applicable;
         $mount['config'] = $config;
         $mount['options'] = $options;
         return $mount;
     }, $mounts, $applicable, $config, $options);
 }
コード例 #4
0
 private function getMountsFromQuery(IQueryBuilder $query)
 {
     $result = $query->execute();
     $mounts = $result->fetchAll();
     $uniqueMounts = [];
     foreach ($mounts as $mount) {
         $id = $mount['mount_id'];
         if (!isset($uniqueMounts[$id])) {
             $uniqueMounts[$id] = $mount;
         }
     }
     $uniqueMounts = array_values($uniqueMounts);
     $mountIds = array_map(function ($mount) {
         return $mount['mount_id'];
     }, $uniqueMounts);
     $mountIds = array_values(array_unique($mountIds));
     $applicable = $this->getApplicableForMounts($mountIds);
     $config = $this->getConfigForMounts($mountIds);
     $options = $this->getOptionsForMounts($mountIds);
     return array_map(function ($mount, $applicable, $config, $options) {
         $mount['type'] = (int) $mount['type'];
         $mount['priority'] = (int) $mount['priority'];
         $mount['applicable'] = $applicable;
         $mount['config'] = $config;
         $mount['options'] = $options;
         return $mount;
     }, $uniqueMounts, $applicable, $config, $options);
 }
コード例 #5
0
ファイル: Data.php プロジェクト: drognisep/Portfolio-Site
 /**
  * @param IQueryBuilder $query
  * @param string $user
  * @param int $since
  * @param string $sort
  *
  * @return array Headers that should be set on the response
  *
  * @throws \OutOfBoundsException If $since is not owned by $user
  */
 protected function setOffsetFromSince(IQueryBuilder $query, $user, $since, $sort)
 {
     if ($since) {
         $queryBuilder = $this->connection->getQueryBuilder();
         $queryBuilder->select('*')->from('activity')->where($queryBuilder->expr()->eq('activity_id', $queryBuilder->createNamedParameter((int) $since)));
         $result = $queryBuilder->execute();
         $activity = $result->fetch();
         $result->closeCursor();
         if ($activity) {
             if ($activity['affecteduser'] !== $user) {
                 throw new \OutOfBoundsException('Invalid since', 2);
             }
             $timestamp = (int) $activity['timestamp'];
             if ($sort === 'DESC') {
                 $query->andWhere($query->expr()->lte('timestamp', $query->createNamedParameter($timestamp)));
                 $query->andWhere($query->expr()->lt('activity_id', $query->createNamedParameter($since)));
             } else {
                 $query->andWhere($query->expr()->gte('timestamp', $query->createNamedParameter($timestamp)));
                 $query->andWhere($query->expr()->gt('activity_id', $query->createNamedParameter($since)));
             }
             return [];
         }
     }
     /**
      * Couldn't find the since, so find the oldest one and set the header
      */
     $fetchQuery = $this->connection->getQueryBuilder();
     $fetchQuery->select('activity_id')->from('activity')->where($fetchQuery->expr()->eq('affecteduser', $fetchQuery->createNamedParameter($user)))->orderBy('timestamp', $sort)->setMaxResults(1);
     $result = $fetchQuery->execute();
     $activity = $result->fetch();
     $result->closeCursor();
     if ($activity !== false) {
         return ['X-Activity-First-Known' => (int) $activity['activity_id']];
     }
     return [];
 }
コード例 #6
0
ファイル: Handler.php プロジェクト: drognisep/Portfolio-Site
 /**
  * Turn a notification into an input statement
  *
  * @param IQueryBuilder $sql
  * @param INotification $notification
  */
 protected function sqlInsert(IQueryBuilder $sql, INotification $notification)
 {
     $sql->setValue('app', $sql->createParameter('app'))->setParameter('app', $notification->getApp());
     $sql->setValue('user', $sql->createParameter('user'))->setParameter('user', $notification->getUser());
     $sql->setValue('timestamp', $sql->createParameter('timestamp'))->setParameter('timestamp', $notification->getDateTime()->getTimestamp());
     $sql->setValue('object_type', $sql->createParameter('objectType'))->setParameter('objectType', $notification->getObjectType());
     $sql->setValue('object_id', $sql->createParameter('objectId'))->setParameter('objectId', $notification->getObjectId());
     $sql->setValue('subject', $sql->createParameter('subject'))->setParameter('subject', $notification->getSubject());
     $sql->setValue('subject_parameters', $sql->createParameter('subject_parameters'))->setParameter('subject_parameters', json_encode($notification->getSubjectParameters()));
     $sql->setValue('message', $sql->createParameter('message'))->setParameter('message', $notification->getMessage());
     $sql->setValue('message_parameters', $sql->createParameter('message_parameters'))->setParameter('message_parameters', json_encode($notification->getMessageParameters()));
     $sql->setValue('link', $sql->createParameter('link'))->setParameter('link', $notification->getLink());
     $actions = [];
     foreach ($notification->getActions() as $action) {
         /** @var IAction $action */
         $actions[] = ['label' => $action->getLabel(), 'link' => $action->getLink(), 'type' => $action->getRequestType(), 'primary' => $action->isPrimary()];
     }
     $sql->setValue('actions', $sql->createParameter('actions'))->setParameter('actions', json_encode($actions));
 }