当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getAuthenticatedUser方法代码示例

本文整理汇总了PHP中Alchemy\Phrasea\Application::getAuthenticatedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getAuthenticatedUser方法的具体用法?PHP Application::getAuthenticatedUser怎么用?PHP Application::getAuthenticatedUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alchemy\Phrasea\Application的用法示例。


在下文中一共展示了Application::getAuthenticatedUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUnvalidated

 private static function getUnvalidated(Application $app, $home = false)
 {
     $terms = [];
     foreach ($app->getDataboxes() as $databox) {
         try {
             $cgus = $databox->get_cgus();
             if (!isset($cgus[$app['locale']])) {
                 throw new Exception('No CGus for this locale');
             }
             $name = $databox->get_label($app['locale']);
             $update = $cgus[$app['locale']]['updated_on'];
             $value = $cgus[$app['locale']]['value'];
             $userValidation = true;
             if (!$home) {
                 if (!$app->getAclForUser($app->getAuthenticatedUser())->has_access_to_sbas($databox->get_sbas_id())) {
                     continue;
                 }
                 $userValidation = $app['settings']->getUserSetting($app->getAuthenticatedUser(), 'terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== '';
             }
             if ($userValidation) {
                 $terms[$name] = ['sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update];
             }
         } catch (\Exception $e) {
         }
     }
     return $terms;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:27,代码来源:cgu.php

示例2: getUserSetting

 public function getUserSetting($setting, $default = null)
 {
     if (false === $this->app->getAuthenticatedUser() instanceof User) {
         return $default;
     }
     return $this->app['settings']->getUserSetting($this->app->getAuthenticatedUser(), $setting, $default);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:PhraseanetExtension.php

示例3: getSearchStatus

 public static function getSearchStatus(Application $app)
 {
     $structures = $stats = [];
     foreach ($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas() as $databox) {
         $see_all = false;
         foreach ($databox->get_collections() as $collection) {
             if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($collection->get_base_id(), 'chgstatus')) {
                 $see_all = true;
                 break;
             }
         }
         $status = $databox->getStatusStructure()->toArray();
         if (!$see_all) {
             $status = array_filter($status, function ($statusbit) {
                 return (bool) $statusbit['searchable'];
             });
         }
         ksort($status);
         $structures[$databox->get_sbas_id()] = array('name' => $databox->get_label($app['locale']), 'status' => $status);
     }
     ksort($structures);
     return $structures;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:23,代码来源:status.php

示例4: get_notifications

 public function get_notifications()
 {
     $unread = 0;
     $sql = 'SELECT count(id) as total, sum(unread) as unread
         FROM notifications WHERE usr_id = :usr_id';
     $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute([':usr_id' => $this->app->getAuthenticatedUser()->getId()]);
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if ($row) {
         $unread = $row['unread'];
     }
     if ($unread < 3) {
         $sql = 'SELECT * FROM notifications
           WHERE usr_id = :usr_id ORDER BY created_on DESC LIMIT 0,4';
     } else {
         $sql = 'SELECT * FROM notifications
           WHERE usr_id = :usr_id AND unread="1" ORDER BY created_on DESC';
     }
     $ret = [];
     $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute([':usr_id' => $this->app->getAuthenticatedUser()->getId()]);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rs as $row) {
         $type = 'eventsmanager_' . $row['type'];
         if (!isset($this->pool_classes[$type])) {
             continue;
         }
         $data = @json_decode($row['datas'], true);
         if (json_last_error() !== JSON_ERROR_NONE) {
             continue;
         }
         $datas = $this->pool_classes[$type]->datas($data, $row['unread']);
         if (!isset($this->pool_classes[$type]) || count($datas) === 0) {
             $sql = 'DELETE FROM notifications WHERE id = :id';
             $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
             $stmt->execute([':id' => $row['id']]);
             $stmt->closeCursor();
             continue;
         }
         $ret[] = array_merge($datas, ['created_on' => $this->app['date-formatter']->getPrettyString(new DateTime($row['created_on'])), 'icon' => $this->pool_classes[$type]->icon_url(), 'id' => $row['id'], 'unread' => $row['unread']]);
     }
     return $ret;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:45,代码来源:broker.php

示例5: get_grouping_parents

 /**
  * @return set_selection
  */
 public function get_grouping_parents()
 {
     $sql = 'SELECT r.record_id
         FROM regroup g
           INNER JOIN (record r
             INNER JOIN collusr c
               ON site = :site
                 AND usr_id = :usr_id
                 AND c.coll_id = r.coll_id
                 AND ((status ^ mask_xor) & mask_and)=0
                 AND r.parent_record_id = 1
           )
           ON (g.rid_parent = r.record_id)
         WHERE rid_child = :record_id';
     $stmt = $this->get_databox()->get_connection()->prepare($sql);
     $stmt->execute([':site' => $this->app['conf']->get(['main', 'key']), ':usr_id' => $this->app->getAuthenticatedUser()->getId(), ':record_id' => $this->get_record_id()]);
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $set = new set_selection($this->app);
     foreach ($rs as $row) {
         $set->add_element(new record_adapter($this->app, $this->get_sbas_id(), $row['record_id']));
     }
     return $set;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:27,代码来源:adapter.php

示例6: fromRequest

 /**
  * Create a new RecordRequest from current request
  *
  * @param  Application    $app
  * @param  Request        $request
  * @param  boolean        $flattenStories
  * @param  array          $rightsColl
  * @param  array          $rightsDatabox
  * @return RecordsRequest|\record_adapter[]
  */
 public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = [], array $rightsDatabox = [])
 {
     $elements = $received = [];
     $basket = null;
     if ($request->get('ssel')) {
         $basket = $app['converter.basket']->convert($request->get('ssel'));
         $app['acl.basket']->hasAccess($basket, $app->getAuthenticatedUser());
         foreach ($basket->getElements() as $basket_element) {
             $received[$basket_element->getRecord($app)->get_serialize_key()] = $basket_element->getRecord($app);
         }
     } elseif ($request->get('story')) {
         $repository = $app['repo.story-wz'];
         $storyWZ = $repository->findByUserAndId($app, $app->getAuthenticatedUser(), $request->get('story'));
         $received[$storyWZ->getRecord($app)->get_serialize_key()] = $storyWZ->getRecord($app);
     } else {
         foreach (explode(";", $request->get('lst')) as $bas_rec) {
             $basrec = explode('_', $bas_rec);
             if (count($basrec) != 2) {
                 continue;
             }
             try {
                 $record = new \record_adapter($app, (int) $basrec[0], (int) $basrec[1]);
                 $received[$record->get_serialize_key()] = $record;
                 unset($record);
             } catch (NotFoundHttpException $e) {
                 continue;
             }
         }
     }
     $elements = $received;
     $to_remove = [];
     foreach ($elements as $id => $record) {
         if (!$app->getAclForUser($app->getAuthenticatedUser())->has_access_to_record($record)) {
             $to_remove[] = $id;
             continue;
         }
         foreach ($rightsColl as $right) {
             if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($record->get_base_id(), $right)) {
                 $to_remove[] = $id;
                 continue;
             }
         }
         foreach ($rightsDatabox as $right) {
             if (!$app->getAclForUser($app->getAuthenticatedUser())->has_right_on_sbas($record->get_sbas_id(), $right)) {
                 $to_remove[] = $id;
                 continue;
             }
         }
     }
     foreach ($to_remove as $id) {
         unset($elements[$id]);
     }
     return new static($elements, new ArrayCollection($received), $basket, $flattenStories);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:64,代码来源:RecordsRequest.php

示例7: updateClientInfos

 public static function updateClientInfos(Application $app, $appId)
 {
     if (!$app->getAuthenticator()->isAuthenticated()) {
         return;
     }
     $session = $app['repo.sessions']->find($app['session']->get('session_id'));
     if (!$session) {
         throw new SessionNotFound('No session found');
     }
     if (!$session->hasModuleId($appId)) {
         $module = new SessionModule();
         $module->setModuleId($appId);
         $module->setSession($session);
         $session->addModule($module);
         $app['orm.em']->persist($module);
         $app['orm.em']->persist($session);
         $app['orm.em']->flush();
     }
     $appName = ['1' => 'Prod', '2' => 'Client', '3' => 'Admin', '4' => 'Report', '5' => 'Thesaurus', '6' => 'Compare', '7' => 'Validate', '8' => 'Upload', '9' => 'API'];
     if (isset($appName[$appId])) {
         $sbas_ids = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_sbas());
         foreach ($sbas_ids as $sbas_id) {
             try {
                 $logger = $app['phraseanet.logger']($app->findDataboxById($sbas_id));
                 $databox = $app->findDataboxById($sbas_id);
                 $connbas = $databox->get_connection();
                 $sql = 'SELECT appli FROM log WHERE id = :log_id';
                 $stmt = $connbas->prepare($sql);
                 $stmt->execute([':log_id' => $logger->get_id()]);
                 $row3 = $stmt->fetch(PDO::FETCH_ASSOC);
                 $stmt->closeCursor();
                 if (!$row3) {
                     throw new Exception('no log');
                 }
                 $applis = unserialize($row3['appli']);
                 if (!in_array($appId, $applis)) {
                     $applis[] = $appId;
                 }
                 $sql = 'UPDATE log SET appli = :applis WHERE id = :log_id';
                 $params = [':applis' => serialize($applis), ':log_id' => $logger->get_id()];
                 $stmt = $connbas->prepare($sql);
                 $stmt->execute($params);
                 $stmt->closeCursor();
             } catch (\Exception $e) {
             }
         }
     }
     return;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:Logger.php

示例8: __construct

 /**
  * Constructor
  *
  * @param Application $app
  * @param string      $d1      the minimal date of the report
  * @param string      $d2      the maximal date of the report
  * @param integer     $sbas_id the id of the base where we want to connect
  * @param string      $collist
  */
 public function __construct(Application $app, $d1, $d2, $sbas_id, $collist)
 {
     $this->app = $app;
     $this->dmin = $d1;
     $this->dmax = $d2;
     $this->sbas_id = $sbas_id;
     $this->list_coll_id = $collist;
     $this->user_id = $this->app->getAuthenticatedUser()->getId();
     $this->periode = sprintf('%s - %s ', $this->app['date-formatter']->getPrettyString(new \DateTime($d1)), $this->app['date-formatter']->getPrettyString(new \DateTime($d2)));
     $this->dbname = phrasea::sbas_labels($sbas_id, $app);
     $this->cor = $this->setCor();
     $this->jour = $this->setDay();
     $this->month = $this->setMonth();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:23,代码来源:report.php

示例9: __construct

 /**
  *
  * @param  Application $app
  * @param  string      $lst
  * @param  integer     $sstid
  * @param  integer     $storyWZid
  * @return set_export
  */
 public function __construct(Application $app, $lst, $sstid, $storyWZid = null)
 {
     $this->app = $app;
     $download_list = [];
     $remain_hd = [];
     if ($storyWZid) {
         $repository = $app['repo.story-wz'];
         $storyWZ = $repository->findByUserAndId($this->app, $app->getAuthenticatedUser(), $storyWZid);
         $lst = $storyWZ->getRecord($this->app)->get_serialize_key();
     }
     if ($sstid != "") {
         $repository = $app['repo.baskets'];
         /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
         $Basket = $repository->findUserBasket($sstid, $app->getAuthenticatedUser(), false);
         $this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
         foreach ($Basket->getElements() as $basket_element) {
             $base_id = $basket_element->getRecord($this->app)->get_base_id();
             $record_id = $basket_element->getRecord($this->app)->get_record_id();
             if (!isset($remain_hd[$base_id])) {
                 if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
                     $remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
                 } else {
                     $remain_hd[$base_id] = false;
                 }
             }
             $current_element = $download_list[] = new record_exportElement($app, $basket_element->getRecord($this->app)->get_sbas_id(), $record_id, $Basket->getName(), $remain_hd[$base_id]);
             $remain_hd[$base_id] = $current_element->get_remain_hd();
         }
     } else {
         $this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);
         $tmp_lst = explode(';', $lst);
         $n = 1;
         foreach ($tmp_lst as $basrec) {
             $basrec = explode('_', $basrec);
             if (count($basrec) != 2) {
                 continue;
             }
             try {
                 $record = new record_adapter($this->app, $basrec[0], $basrec[1]);
             } catch (\Exception_Record_AdapterNotFound $e) {
                 continue;
             }
             if ($record->isStory()) {
                 foreach ($record->get_children() as $child_basrec) {
                     $base_id = $child_basrec->get_base_id();
                     $record_id = $child_basrec->get_record_id();
                     if (!isset($remain_hd[$base_id])) {
                         if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
                             $remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
                         } else {
                             $remain_hd[$base_id] = false;
                         }
                     }
                     $current_element = $download_list[] = new record_exportElement($app, $child_basrec->get_sbas_id(), $record_id, $record->get_title(null, null, true) . '_' . $n, $remain_hd[$base_id]);
                     $remain_hd[$base_id] = $current_element->get_remain_hd();
                 }
             } else {
                 $base_id = $record->get_base_id();
                 $record_id = $record->get_record_id();
                 if (!isset($remain_hd[$base_id])) {
                     if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
                         $remain_hd[$base_id] = $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id);
                     } else {
                         $remain_hd[$base_id] = false;
                     }
                 }
                 $current_element = $download_list[$basrec[0] . '_' . $basrec[1]] = new record_exportElement($app, $record->get_sbas_id(), $record_id, '', $remain_hd[$base_id]);
                 $remain_hd[$base_id] = $current_element->get_remain_hd();
             }
             $n++;
         }
     }
     $this->elements = $download_list;
     $display_download = [];
     $display_orderable = [];
     $this->total_download = 0;
     $this->total_order = 0;
     $this->total_ftp = 0;
     $this->businessFieldsAccess = false;
     foreach ($this->elements as $download_element) {
         if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
             $this->businessFieldsAccess = true;
         }
         foreach ($download_element->get_downloadable() as $name => $properties) {
             if (!isset($display_download[$name])) {
                 $display_download[$name] = ['size' => 0, 'total' => 0, 'available' => 0, 'refused' => []];
             }
             $display_download[$name]['total']++;
             if ($properties !== false) {
                 $display_download[$name]['available']++;
                 $display_download[$name]['label'] = $properties['label'];
                 $display_download[$name]['class'] = $properties['class'];
//.........这里部分代码省略.........
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:export.php

示例10: __construct

 public function __construct(Application $app, $env, $pos, $contId, SearchEngineInterface $search_engine = null, $query = '', SearchEngineOptions $options = null)
 {
     $number = null;
     $this->env = $env;
     $this->app = $app;
     $this->pos = $pos;
     $this->searchEngine = $search_engine;
     $this->query = $query;
     $this->options = $options;
     switch ($env) {
         case "RESULT":
             if (null === $search_engine) {
                 throw new \LogicException('Search Engine should be provided');
             }
             $results = $search_engine->query($query, (int) $pos, 1, $options);
             if ($results->getResults()->isEmpty()) {
                 throw new Exception('Record introuvable');
             }
             foreach ($results->getResults() as $record) {
                 $number = $pos;
                 $this->original_item = $record;
                 $sbas_id = $record->getDataboxId();
                 $record_id = $record->getRecordId();
                 break;
             }
             break;
         case "REG":
             $contId = explode('_', $contId);
             $sbas_id = $contId[0];
             $record_id = $contId[1];
             $this->container = new record_adapter($app, $sbas_id, $record_id);
             $this->original_item = $this->container;
             if ($pos == 0) {
                 $number = 0;
             } else {
                 $children = $this->container->get_children();
                 foreach ($children as $child) {
                     $sbas_id = $child->get_sbas_id();
                     $this->original_item = $child;
                     $record_id = $child->get_record_id();
                     if ($child->getNumber() == $pos) {
                         break;
                     }
                 }
                 $number = $pos;
                 $this->total = $children->get_count();
             }
             break;
         case "BASK":
             $Basket = $app['converter.basket']->convert($contId);
             $app['acl.basket']->hasAccess($Basket, $app->getAuthenticatedUser());
             /* @var $Basket Basket */
             $this->container = $Basket;
             $this->total = $Basket->getElements()->count();
             $i = 0;
             $first = true;
             foreach ($Basket->getElements() as $element) {
                 /* @var $element BasketElement */
                 $i++;
                 if ($first) {
                     $this->original_item = $element;
                     $sbas_id = $element->getRecord($this->app)->get_sbas_id();
                     $record_id = $element->getRecord($this->app)->get_record_id();
                     $this->name = $Basket->getName();
                     $number = $element->getOrd();
                 }
                 $first = false;
                 if ($element->getOrd() == $pos) {
                     $this->original_item = $element;
                     $sbas_id = $element->getRecord($this->app)->get_sbas_id();
                     $record_id = $element->getRecord($this->app)->get_record_id();
                     $this->name = $Basket->getName();
                     $number = $element->getOrd();
                 }
             }
             break;
         case "FEED":
             $entry = $app['repo.feed-entries']->find($contId);
             $this->container = $entry;
             $this->total = count($entry->getItems());
             $i = 0;
             $first = true;
             foreach ($entry->getItems() as $element) {
                 $i++;
                 if ($first) {
                     $sbas_id = $element->getRecord($this->app)->get_sbas_id();
                     $record_id = $element->getRecord($this->app)->get_record_id();
                     $this->name = $entry->getTitle();
                     $this->original_item = $element;
                     $number = $element->getOrd();
                 }
                 $first = false;
                 if ($element->getOrd() == $pos) {
                     $sbas_id = $element->getRecord($this->app)->get_sbas_id();
                     $record_id = $element->getRecord($this->app)->get_record_id();
                     $this->name = $entry->getTitle();
                     $this->original_item = $element;
                     $number = $element->getOrd();
                 }
             }
//.........这里部分代码省略.........
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:preview.php

示例11: addItem

 protected function addItem(Application $app, \DOMDocument $document, \DOMNode $node, FeedEntry $entry)
 {
     $item = $this->addTag($document, $node, 'item');
     $feed = $entry->getFeed();
     if ($feed->isPublic()) {
         $link = $app['feed.link-generator-collection']->generatePublic($feed, FeedLinkGenerator::FORMAT_RSS);
     } else {
         $link = $app['feed.link-generator-collection']->generate($feed, $app->getAuthenticatedUser(), FeedLinkGenerator::FORMAT_RSS);
     }
     $this->addTag($document, $item, 'title', $entry->getTitle());
     $this->addTag($document, $item, 'description', $entry->getSubtitle());
     $author = sprintf('%s (%s)', $entry->getAuthorEmail(), $entry->getAuthorName());
     $created_on = $entry->getCreatedOn()->format(DATE_RFC2822);
     $this->addTag($document, $item, 'author', $author);
     $this->addTag($document, $item, 'pubDate', $created_on);
     $this->addTag($document, $item, 'guid', $link->getURI());
     $this->addTag($document, $item, 'link', $link->getURI());
     /**
      *  Missing :
      *
      *  category  Includes the item in one or more categories. More.
      *  comments  URL of a page for comments relating to the item. More.
      *  enclosure  Describes a media object that is attached to the item. More.
      *  source    The RSS channel that the item came from. More.
      *
      */
     foreach ($entry->getItems() as $content) {
         $this->addContent($app, $document, $item, $content);
     }
     return $item;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:31,代码来源:RssFormatter.php


注:本文中的Alchemy\Phrasea\Application::getAuthenticatedUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。