示例#1
0
 /**
  * Return an array of all IXP names where the array key is the IXP id.
  *
  * NOTE: Super user can see all IXPs and customer user can see only those which
  *         is assigned to the users customer.
  *
  * @param  \Entities\User $user User to limit IXP names
  * @return array An array of all IXP names with the IXP id as the key.
  */
 public function getNames($user)
 {
     $dql = "SELECT i.id AS id, i.name AS name FROM Entities\\IXP i";
     if ($user->getPrivs() != \Entities\User::AUTH_SUPERUSER) {
         $dql .= " WHERE ?1 MEMBER OF i.Customers";
     }
     $dql .= " ORDER BY name ASC";
     $query = $this->getEntityManager()->createQuery($dql);
     if ($user->getPrivs() != \Entities\User::AUTH_SUPERUSER) {
         $query->setParameter(1, $user->getCustomer()->getId());
     }
     $aixps = $query->getResult();
     $ixps = [];
     foreach ($aixps as $i) {
         $ixps[$i['id']] = $i['name'];
     }
     return $ixps;
 }
 public function getPrivs()
 {
     $this->__load();
     return parent::getPrivs();
 }