/** * Assign a branch to this lesson * * This function is used to correlate a branch to the lesson * All users of the branch should be assigned to this lesson * * <br/>Example: * <code> * $lesson -> assignBranch(2); // The lesson will be assigned to branch with id 2 * </code> * * @param $branch_ID the id of the branch to be assigned * @return boolean true/false * @since 3.6.0 * @access public */ public function assignBranch($branch_ID) { $this->getBranches(); // Check if the branch is not assigned as offered by this lesson if ($this->branches[$branch_ID]['lessons_ID'] == "") { if ($ok = eF_insertTableData("module_hcd_lesson_to_branch", array("branches_ID" => $branch_ID, "lessons_ID" => $this->lesson['id']))) { $this->branches[$branch_ID]['lessons_ID'] = $this->lesson['id']; $newBranch = new EfrontBranch($branch_ID); $employees = $newBranch->getEmployees(false, true); //get data flat $this->addUsers($employees['login'], $employees['user_type']); } else { throw new EfrontLessonException(_EMPLOYEESRECORDCOULDNOTBEUPDATED, EfrontLessonException::DATABASE_ERROR); } } return true; }
/** * Assign a branch to this course * * This function is used to correlate a branch to the course * All users of the branch should be assigned to this course * * <br/>Example: * <code> * $course -> assignBranch(2); // The course will be assigned to branch with id 2 * </code> * * @param $branch_ID the id of the branch to be assigned * @return boolean true/false * @since 3.6.0 * @access public */ public function assignBranch($branch_ID) { $this->getBranches(); // Check if the branch is not assigned as offered by this course if ($this->branches[$branch_ID]['courses_ID'] == "") { eF_insertTableData("module_hcd_course_to_branch", array("branches_ID" => $branch_ID, "courses_ID" => $this->course['id'])); $this->branches[$branch_ID]['courses_ID'] = $this->course['id']; $newBranch = new EfrontBranch($branch_ID); $employees = $newBranch->getEmployees(false, true); //get data flat $this->addUsers($employees['login'], $employees['user_type']); } return true; }
private function doUnenrollUsers() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); if ($_GET['type'] == 'job') { foreach (EfrontJob::getAllJobs() as $key => $value) { $entities[$value['job_description_ID']] = $value['description']; } if ($_GET['entry']) { $entity = new EfrontJob($_GET['entry']); $courses = $entity->getJobCourses(array('archive' => false)); $users = $entity->getEmployees(); } } elseif ($_GET['type'] == 'branch') { foreach (EfrontBranch::getAllBranches() as $key => $value) { $entities[$value['branch_ID']] = $value['name']; } if ($_GET['entry']) { $entity = new EfrontBranch($_GET['entry']); $courses = $entity->getBranchCourses(array('archive' => false)); $users = $entity->getEmployees(); } } elseif ($_GET['type'] == 'group') { foreach (EfrontGroup::getGroups() as $key => $value) { $entities[$value['id']] = $value['name']; } if ($_GET['entry']) { $entity = new EfrontGroup($_GET['entry']); $courses = $entity->getGroupCourses(array('archive' => false)); $users = $entity->getGroupUsers(); } } if ($_GET['ajax'] && $_GET['remove_users_from_courses']) { try { foreach ($courses as $course) { $course->removeUsers($users); } exit; } catch (Exception $e) { handleAjaxExceptions($e); } } $smarty->assign("T_ENTITIES_LIST", $entities); }