Наследование: use trait erLhcoreClassDBTrait
 public function afterRemove()
 {
     $db = ezcDbInstance::get();
     $stmt = $db->prepare('DELETE FROM lh_userdep WHERE dep_group_id = :dep_group_id AND user_id = :user_id');
     $stmt->bindValue(':dep_group_id', $this->dep_group_id);
     $stmt->bindValue(':user_id', $this->user_id);
     $stmt->execute();
     erLhcoreClassModelDepartamentGroupMember::updateUserDepartmentsIds($this->user_id);
 }
 public function afterRemove()
 {
     foreach (erLhcoreClassModelDepartamentGroupUser::getList(array('limit' => false, 'filter' => array('dep_group_id' => $this->id))) as $groupUser) {
         $groupUser->removeThis();
     }
     foreach (erLhcoreClassModelDepartamentGroupMember::getList(array('limit' => false, 'filter' => array('dep_group_id' => $this->id))) as $groupMember) {
         $groupMember->removeThis();
     }
 }
Пример #3
0
 public static function assignDepartmentsToGroup(erLhcoreClassModelDepartamentGroup $departamentGroup, $ids)
 {
     $members = erLhcoreClassModelDepartamentGroupMember::getList(array('limit' => false, 'filter' => array('dep_group_id' => $departamentGroup->id)));
     $newMembers = array();
     $removeMembers = array();
     $oldMembers = array();
     // Remove old members
     foreach ($members as $member) {
         if (!in_array($member->dep_id, $ids)) {
             $member->removeThis();
         } else {
             $oldMembers[] = $member->dep_id;
         }
     }
     // Store new members
     foreach ($ids as $id) {
         if (!in_array($id, $oldMembers)) {
             $member = new erLhcoreClassModelDepartamentGroupMember();
             $member->dep_id = $id;
             $member->dep_group_id = $departamentGroup->id;
             $member->saveThis();
         }
     }
 }