'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ("url" => "course_list.php", "name" => get_lang('CourseList')); // Get all course categories $table_user = Database :: get_main_table(TABLE_MAIN_USER); //Get the course infos $course = api_get_course_info($course_code); if (empty($course)) { header('Location: course_list.php'); exit; } // Get course teachers $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; $sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.c_id ='".$course['real_id']."'". $order_clause; $res = Database::query($sql); $course_teachers = array(); while ($obj = Database::fetch_object($res)) { $course_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } // Get all possible teachers without the course teachers /*$sql = "SELECT u.user_id,lastname,firstname FROM $table_user as u INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status = 1 or status = 2 ".$order_clause;*/ /** @var Doctrine\ORM\EntityManager $em */ /*$em = $this->getDoctrine()->getManager(); $userManager = $em->getRepository('ChamiloUserBundle:User'); var_dump($userManager->getTeachers());*/ //$userManager->get $teachersInPlatform = CourseManager::get_teacher_list_from_course_code($course['real_id']); $teachers = array(); $platform_teachers[0] = '-- '.get_lang('NoManager').' --'; foreach ($teachersInPlatform as $teacher) { $teacherId = $teacher['user_id']; if (!array_key_exists($teacherId, $course_teachers)) { $teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']); } if (isset($course['tutor_name']) && isset($course_teachers[$teacherId]) && $course['tutor_name'] == $course_teachers[$teacherId]) { $course['tutor_name'] = $teacherId; } //We add in the array platform teachers $platform_teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']); } //Case where there is no teacher in the course if (count($course_teachers) ==0 ) { $sql='SELECT tutor_name FROM '.$course_table.' WHERE code="'.$course_code.'"'; $res = Database::query($sql); $tutor_name=Database::result($res,0,0); $course['tutor_name']=array_search($tutor_name,$platform_teachers); } // Build the form $form = new FormValidator('update_course'); $form->addElement('hidden','code',$course_code); //title $form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6')); $form->applyFilter('title','html_filter'); $form->applyFilter('title','trim'); // Code $element = $form->addElement('text', 'real_code', array(get_lang('CourseCode'), get_lang('ThisValueCantBeChanged'))); $element->freeze(); // Id $element = $form->addElement('text', 'real_id', 'id'); $element->freeze(); // visual code $form->add_textfield('visual_code', array(get_lang('VisualCode'), get_lang('OnlyLettersAndNumbers'), get_lang('ThisValueIsUsedInTheCourseURL')), true, array('class' => 'span4')); $form->applyFilter('visual_code','strtoupper'); $form->applyFilter('visual_code','html_filter'); //$form->addElement('text', tutor_name', get_lang('CourseTitular')); //$form->addElement('select', 'tutor_name', get_lang('CourseTitular'), $platform_teachers, array('style'=>'width:350px','id'=>'tutor_name_id', 'class'=>'chzn-select')); //$form->applyFilter('tutor_name','html_filter'); //$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, 'multiple=multiple size="4" style="width: 150px;"'); $group = array( $form->createElement('select', 'platform_teachers', '', $teachers, ' id="platform_teachers" multiple=multiple size="4" style="width:300px;"'), $form->createElement('select', 'course_teachers', '', $course_teachers, ' id="course_teachers" multiple=multiple size="4" style="width:300px;"') ); $multiSelectTemplate = $form->getDoubleMultipleSelectTemplate(); $renderer = $form->defaultRenderer(); $renderer->setElementTemplate($multiSelectTemplate, 'group'); $form->addGroup( $group, 'group', get_lang('CourseTeachers'), '