/** * add new member to course * * @param Courses_Model_Course $course * @param Tinebase_Model_FullUser $user * @return Tinebase_Model_FullUser * * @todo use importMembers() here to avoid duplication */ public function createNewMember(Courses_Model_Course $course, Tinebase_Model_FullUser $user) { $this->checkRight(Courses_Acl_Rights::ADD_NEW_USER); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating new member for ' . $course->name); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($course->toArray(), TRUE)); } $password = $user->applyOptionsAndGeneratePassword($this->_getNewUserConfig($course)); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($user->toArray(), TRUE)); } $newMember = $this->_userController->create($user, $password, $password); // add to default group and manage access group for user $this->_groupController->addGroupMember(Tinebase_Group::getInstance()->getDefaultGroup()->getId(), $newMember->getId()); $this->_manageAccessGroups(array($newMember->getId()), $course); $this->_addToStudentGroup(array($newMember->getId())); return $newMember; }