示例#1
0
文件: V1.php 项目: nlegoff/Phraseanet
 /**
  * Retrieve information about one basket
  *
  * @param  Basket $basket
  *
  * @return array
  */
 private function list_basket(Application $app, Basket $basket)
 {
     $ret = ['basket_id' => $basket->getId(), 'owner' => $this->list_user($basket->getUser()), 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), 'name' => $basket->getName(), 'pusher_usr_id' => $basket->getPusher() ? $basket->getPusher()->getId() : null, 'pusher' => $basket->getPusher() ? $this->list_user($basket->getPusher()) : null, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation()];
     if ($basket->getValidation()) {
         $users = array_map(function ($participant) use($app) {
             $user = $participant->getUser();
             return ['usr_id' => $user->getId(), 'usr_name' => $user->getDisplayName(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->getId() != $app['authentication']->getUser()->getId(), 'user' => $this->list_user($user)];
         }, iterator_to_array($basket->getValidation()->getParticipants()));
         $expires_on_atom = $basket->getValidation()->getExpires();
         if ($expires_on_atom instanceof \DateTime) {
             $expires_on_atom = $expires_on_atom->format(DATE_ATOM);
         }
         $ret = array_merge(['validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($app, $app['authentication']->getUser()), 'validation_confirmed' => $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($app['authentication']->getUser()), 'validation_initiator_user' => $this->list_user($basket->getValidation()->getInitiator())], $ret);
     }
     return $ret;
 }
示例#2
0
 public function isOwner(Basket $basket, User $user)
 {
     return $basket->getUser()->getId() === $user->getId();
 }
 /**
  * {@inheritDoc}
  */
 public function getUser()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
     return parent::getUser();
 }