/** * Method addSystem_user_group * Add a System_user_group to the System_user * @param $object Instance of System_group */ public function addSystemUserGroup(SystemGroup $systemusergroup) { $object = new SystemUserGroup(); $object->system_group_id = $systemusergroup->id; $object->system_user_id = $this->id; $object->store(); }
/** * Store the object and its aggregates */ public function store() { // store the object itself parent::store(); // delete the related System_userSystem_user_group objects $criteria = new TCriteria(); $criteria->add(new TFilter('system_user_id', '=', $this->id)); $repository = new TRepository('SystemUserGroup'); $repository->delete($criteria); // store the related System_userSystem_user_group objects if ($this->system_user_groups) { foreach ($this->system_user_groups as $system_user_group) { $system_user_system_user_group = new SystemUserGroup(); $system_user_system_user_group->system_group_id = $system_user_group->id; $system_user_system_user_group->system_user_id = $this->id; $system_user_system_user_group->store(); } } // delete the related System_userSystem_user_program objects $criteria = new TCriteria(); $criteria->add(new TFilter('system_user_id', '=', $this->id)); $repository = new TRepository('SystemUserProgram'); $repository->delete($criteria); // store the related System_userSystem_user_program objects if ($this->system_user_programs) { foreach ($this->system_user_programs as $system_user_program) { $system_user_system_user_program = new SystemUserProgram(); $system_user_system_user_program->system_program_id = $system_user_program->id; $system_user_system_user_program->system_user_id = $this->id; $system_user_system_user_program->store(); } } }