Beispiel #1
0
 /**
  * Sets user group for the user.
  *
  * @param kyUserGroup $user_group User group.
  * @return kyUser
  */
 public function setUserGroup(kyUserGroup $user_group)
 {
     $this->user_group = ky_assure_object($user_group, 'kyUserGroup');
     $this->user_group_id = $this->user_group !== null ? $this->user_group->getId() : null;
     return $this;
 }
 /**
  * Add user group to the list of groups that can be assigned to this department.
  * Automatically sets custom user visibility flag to True.
  *
  * @param kyUserGroup $user_group User group that can be assigned to this department.
  * @param bool $clear Clear the list before adding.
  * @return kyDepartment
  */
 public function addUserGroup(kyUserGroup $user_group, $clear = false)
 {
     if ($clear) {
         $this->user_groups = array();
         $this->user_group_ids = array();
     }
     //do nothing if it's already present
     if (in_array($user_group->getId(), $this->user_group_ids)) {
         return $this;
     }
     $this->user_group_ids[] = $user_group->getId();
     $this->user_visibility_custom = true;
     return $this;
 }
 /**
  * Add user group to the list of groups that this news item will be visible to.
  * Automatically sets custom user visibility flag to True.
  *
  * @param kyUserGroup $user_group User group that this news item will be visible to.
  * @param bool $clear Clear the list before adding.
  * @return kyNewsItem
  */
 public function addUserGroup(kyUserGroup $user_group, $clear = false)
 {
     if ($clear) {
         $this->user_groups = array();
         $this->user_group_ids = array();
     }
     if (!in_array($user_group->getId(), $this->user_group_ids)) {
         $this->user_group_ids[] = $user_group->getId();
         $this->user_visibility_custom = true;
     }
     return $this;
 }
 /**
  * Returns whether this ticket type is visible to specified user group.
  *
  * @param kyUserGroup|int $user_group User group or its identifier.
  * @return bool
  * @filterBy
  */
 public function isVisibleToUserGroup($user_group)
 {
     if ($this->type !== self::TYPE_PUBLIC) {
         return false;
     }
     if ($this->user_visibility_custom === false) {
         return true;
     }
     if ($user_group instanceof kyUserGroup) {
         $user_group_id = $user_group->getId();
     } else {
         $user_group_id = intval($user_group);
     }
     return in_array($user_group_id, $this->user_group_ids);
 }