コード例 #1
0
 protected function build_user_info_form()
 {
     if (api_is_western_name_order()) {
         $this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
         $this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
     } else {
         $this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
         $this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
     }
     $this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
     $this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
     $this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
     $this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
     $this->addButtonSave(get_lang('Back'), 'submit');
 }
コード例 #2
0
 /**
  * Get all users that are registered in the course. No matter the status
  *
  * @param Course $course
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getSubscribedUsers(Course $course)
 {
     // Course builder
     $queryBuilder = $this->createQueryBuilder('c');
     // Selecting user info.
     $queryBuilder->select('DISTINCT user');
     // Selecting courses for users.
     $queryBuilder->innerJoin('c.users', 'subscriptions');
     $queryBuilder->innerJoin('ChamiloUserBundle:User', 'user', Join::WITH, 'subscriptions.user = user.id');
     if (api_is_western_name_order()) {
         $queryBuilder->add('orderBy', 'user.firstname ASC');
     } else {
         $queryBuilder->add('orderBy', 'user.lastname ASC');
     }
     $wherePart = $queryBuilder->expr()->andx();
     // Get only users subscribed to this course
     $wherePart->add($queryBuilder->expr()->eq('c.id', $course->getId()));
     // $wherePart->add($queryBuilder->expr()->eq('c.status', $status));
     $queryBuilder->where($wherePart);
     //var_dump($queryBuilder->getQuery()->getSQL());
     //$q = $queryBuilder->getQuery();
     //return $q->execute();
     return $queryBuilder;
 }
コード例 #3
0
 /**
  * Get actual array data
  * @return array 2-dimensional array - each array contains the elements:
  * 0: user id
  * 1: user lastname
  * 2: user firstname
  * 3+: evaluation/link scores
  */
 public function get_data($users_sorting = 0, $users_start = 0, $users_count = null, $items_start = 0, $items_count = null, $ignore_score_color = false, $show_all = false)
 {
     // do some checks on users/items counts, redefine if invalid values
     if (!isset($users_count)) {
         $users_count = count($this->users) - $users_start;
     }
     if ($users_count < 0) {
         $users_count = 0;
     }
     if (!isset($items_count)) {
         $items_count = count($this->evals) + count($this->links) - $items_start;
     }
     if ($items_count < 0) {
         $items_count = 0;
     }
     // copy users to a new array that we will sort
     // TODO - needed ?
     $userTable = array();
     foreach ($this->users as $user) {
         $userTable[] = $user;
     }
     // sort users array
     if ($users_sorting & self::FVDG_SORT_LASTNAME) {
         usort($userTable, array('FlatViewDataGenerator', 'sort_by_last_name'));
     } elseif ($users_sorting & self::FVDG_SORT_FIRSTNAME) {
         usort($userTable, array('FlatViewDataGenerator', 'sort_by_first_name'));
     }
     if ($users_sorting & self::FVDG_SORT_DESC) {
         $userTable = array_reverse($userTable);
     }
     // select the requested users
     $selected_users = array_slice($userTable, $users_start, $users_count);
     // generate actual data array
     $scoredisplay = ScoreDisplay::instance();
     $data = array();
     $displaytype = SCORE_DIV;
     if ($ignore_score_color) {
         $displaytype |= SCORE_IGNORE_SPLIT;
     }
     //@todo move these in a function
     $sum_categories_weight_array = array();
     $mainCategoryId = null;
     $mainCourseCategory = $this->getMainCourseCategory();
     if (!empty($mainCourseCategory)) {
         $mainCategoryId = $mainCourseCategory->get_id();
     }
     if (isset($this->category) && !empty($this->category)) {
         $categories = Category::load(null, null, null, $this->category->get_id());
         if (!empty($categories)) {
             foreach ($categories as $category) {
                 $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
             }
         } else {
             $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();
         }
     }
     $parent_id = $this->category->get_parent_id();
     if ($parent_id == 0 or $this->params['only_subcat'] == $this->category->get_id()) {
         $main_weight = $this->category->get_weight();
         $grade_model_id = $this->category->get_grade_model_id();
     } else {
         $main_cat = Category::load($parent_id, null, null);
         $main_weight = $main_cat[0]->get_weight();
         $grade_model_id = $main_cat[0]->get_grade_model_id();
     }
     $use_grade_model = true;
     if (empty($grade_model_id) || $grade_model_id == -1) {
         $use_grade_model = false;
     }
     $export_to_pdf = false;
     if (isset($this->params['export_pdf']) && $this->params['export_pdf']) {
         $export_to_pdf = true;
     }
     foreach ($selected_users as $user) {
         $row = array();
         if ($export_to_pdf) {
             $row['user_id'] = $user_id = $user[0];
             //user id
         } else {
             $row[] = $user_id = $user[0];
             //user id
         }
         if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
             if ($export_to_pdf) {
                 $row['official_code'] = $user[4];
                 //official code
             } else {
                 $row[] = $user[4];
                 //official code
             }
         }
         if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) {
             if ($export_to_pdf) {
                 $row['name'] = api_get_person_name($user[3], $user[2]);
                 //last name
             } else {
                 $row[] = api_get_person_name($user[3], $user[2]);
                 //last name
             }
         } else {
             if ($export_to_pdf) {
                 if (api_is_western_name_order()) {
                     $row['firstname'] = $user[3];
                     $row['lastname'] = $user[2];
                 } else {
                     $row['lastname'] = $user[2];
                     $row['firstname'] = $user[3];
                 }
             } else {
                 if (api_is_western_name_order()) {
                     $row[] = $user[3];
                     //first name
                     $row[] = $user[2];
                     //last name
                 } else {
                     $row[] = $user[2];
                     //last name
                     $row[] = $user[3];
                     //first name
                 }
             }
         }
         $item_value = 0;
         $item_value_total = 0;
         $item_total = 0;
         $convert_using_the_global_weight = true;
         $course_code = api_get_course_id();
         $session_id = api_get_session_id();
         $allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id');
         $evaluationsAdded = array();
         if ($parent_id == 0 && !empty($allcat)) {
             foreach ($allcat as $sub_cat) {
                 $score = $sub_cat->calc_score($user_id);
                 $real_score = $score;
                 $divide = $score[1] == 0 ? 1 : $score[1];
                 $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
                 $item_value = $score[0] / $divide * $main_weight;
                 //Fixing total when using one or multiple gradebooks
                 $percentage = $sub_cat->get_weight() / $sub_cat_percentage * $sub_cat_percentage / $this->category->get_weight();
                 $item_value = $percentage * $item_value;
                 $item_total += $sub_cat->get_weight();
                 /*
                                     if ($convert_using_the_global_weight) {                                             
                                         $score[0] = $score[0]/$main_weight*$sub_cat->get_weight();                        
                                         $score[1] = $main_weight ;
                                     }                    
                 */
                 if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
                     //if (true) {
                     $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
                     $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
                     $temp_score = Display::tip($real_score, $temp_score);
                 } else {
                     $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
                     $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
                     $temp_score = Display::tip($temp_score, $real_score);
                 }
                 if (!isset($this->params['only_total_category']) || isset($this->params['only_total_category']) && $this->params['only_total_category'] == false) {
                     if (!$show_all) {
                         $row[] = $temp_score . ' ';
                     } else {
                         $row[] = $temp_score;
                     }
                 }
                 $item_value_total += $item_value;
             }
             if ($convert_using_the_global_weight) {
                 //$item_total = $main_weight;
             }
         } else {
             $result = $this->parseEvaluations($user_id, $sum_categories_weight_array, $items_count, $items_start, $show_all, $row);
             $item_total += $result['item_total'];
             $item_value_total += $result['item_value_total'];
             $evaluationsAdded = $result['evaluations_added'];
             $item_total = $main_weight;
         }
         // All evaluations
         $result = $this->parseEvaluations($user_id, $sum_categories_weight_array, $items_count, $items_start, $show_all, $row, $mainCategoryId, $evaluationsAdded);
         $item_total += $result['item_total'];
         $item_value_total += $result['item_value_total'];
         $total_score = array($item_value_total, $item_total);
         if (!$show_all) {
             if ($export_to_pdf) {
                 $row['total'] = $scoredisplay->display_score($total_score);
             } else {
                 $row[] = $scoredisplay->display_score($total_score);
             }
         } else {
             if ($export_to_pdf) {
                 $row['total'] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS);
             } else {
                 $row[] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS);
             }
         }
         unset($score);
         $data[] = $row;
     }
     return $data;
 }
コード例 #4
0
     SocialManager::send_invitation_friend_user($_REQUEST['user_id'], $subject, $invitationContent);
     break;
 case 'find_users':
     if (api_is_anonymous()) {
         echo '';
         break;
     }
     $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
     $tbl_my_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_my_user_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_access_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $search = Database::escape_string($_REQUEST['q']);
     $access_url_id = api_get_multiple_access_url() == 'true' ? api_get_current_access_url_id() : 1;
     $user_id = api_get_user_id();
     $is_western_name_order = api_is_western_name_order();
     $likeCondition = " AND (firstname LIKE '%{$search}%' OR lastname LIKE '%{$search}%' OR email LIKE '%{$search}%') ";
     if (api_get_setting('social.allow_social_tool') == 'true' && api_get_setting('message.allow_message_tool') == 'true') {
         // All users
         if (api_get_setting('message.allow_send_message_to_all_platform_users') == 'true' || api_is_platform_admin()) {
             if ($access_url_id != 0) {
                 $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n                            FROM {$tbl_user} u LEFT JOIN {$tbl_access_url_rel_user} r ON u.user_id = r.user_id\n                            WHERE\n                                u.status <> 6  AND\n                                u.user_id <> {$user_id} AND\n                                r.access_url_id = {$access_url_id}\n                                {$likeCondition} ";
             } else {
                 $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n                            FROM {$tbl_user} u\n                            WHERE\n                                u.status <> 6  AND\n                                u.user_id <> {$user_id}\n                                {$likeCondition} ";
             }
         } else {
             //only my contacts
             if ($access_url_id != 0) {
                 $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n                            FROM {$tbl_access_url_rel_user} r, {$tbl_my_user_friend} uf\n                            INNER JOIN {$tbl_my_user} AS u\n                            ON uf.friend_user_id = u.user_id\n                            WHERE\n                                u.status <> 6 AND\n                                relation_type NOT IN(" . USER_RELATION_TYPE_DELETED . ", " . USER_RELATION_TYPE_RRHH . ") AND\n                                uf.user_id = {$user_id} AND\n                                friend_user_id <> {$user_id} AND\n                                u.user_id = r.user_id AND\n                                r.access_url_id = {$access_url_id}\n                                {$likeCondition}";
             } else {
                 $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n                            FROM {$tbl_my_user_friend} uf\n                            INNER JOIN {$tbl_my_user} AS u\n                            ON uf.friend_user_id = u.user_id\n         \t                WHERE\n                                u.status <> 6 AND\n                                relation_type NOT IN(" . USER_RELATION_TYPE_DELETED . ", " . USER_RELATION_TYPE_RRHH . ") AND\n                                uf.user_id = {$user_id} AND\n                                friend_user_id <> {$user_id}\n                                {$likeCondition}";
コード例 #5
0
ファイル: authldap.php プロジェクト: marcyves/cool
/**
 * Get the users to display on the current page.
 * @see SortableTable#get_table_data($from)
 * @author	Mustapha Alouani
 */
function ldap_get_user_data($from, $number_of_items, $column, $direction)
{
    $users = array();
    $is_western_name_order = api_is_western_name_order();
    if (isset($_GET['submit'])) {
        $info = ldap_get_users();
        if ($info['count'] > 0) {
            for ($key = 0; $key < $info["count"]; $key++) {
                $user = array();
                // Get uid from dn
                //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in
                //the corresponding index of the array
                //$dn_array=ldap_explode_dn($info[$key]["dn"],1);
                //$user[] = $dn_array[0]; // uid is first key
                //$user[] = $dn_array[0]; // uid is first key
                $user[] = $info[$key]['uid'][0];
                $user[] = $info[$key]['uid'][0];
                if ($is_western_name_order) {
                    $user[] = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8');
                    $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
                } else {
                    $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
                    $user[] = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8');
                }
                $user[] = $info[$key]['mail'][0];
                $outab[] = $info[$key]['eduPersonPrimaryAffiliation'][0];
                // Ici "student"
                $users[] = $user;
            }
        } else {
            Display::display_error_message(get_lang('NoUser'));
        }
    }
    return $users;
}
コード例 #6
0
                $val = api_substr($field_value[0], 8, api_strlen($field_value[0]));
                $list[$val] = 1;
            }
        }
    }

    // We use the same form as in auth/profile.php
    $form = new FormValidator(
        'profile',
        'post',
        api_get_self()."?".str_replace('&show_form=1', '&show_form=1', $_SERVER['QUERY_STRING']),
        null,
        array('style' => 'width: 75%; float: '.($text_dir == 'rtl' ? 'right;' : 'left;'))
    );

    if (api_is_western_name_order()) {
        if ($list['firstname'] == 1) {
            //FIRST NAME
            $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
            if (api_get_setting('profile', 'name') !== 'true') {
                $form->freeze(array('firstname'));
            }
            $form->applyFilter(array('firstname'), 'stripslashes');
            $form->applyFilter(array('firstname'), 'trim');
            $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
        }
        if ($list['lastname'] == 1) {
            //    LAST NAME
            $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
            if (api_get_setting('profile', 'name') !== 'true') {
                $form->freeze(array('lastname'));
コード例 #7
0
 /**
  * Get data for users list in sortable with pagination
  * @param $from
  * @param $number_of_items
  * @param $column
  * @param $direction
  * @param $includeInvitedUsers boolean Whether include the invited users
  * @return array
  */
 public static function get_user_data($from, $number_of_items, $column, $direction, $includeInvitedUsers = false)
 {
     global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
     $course_code = Database::escape_string($course_code);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $access_url_id = api_get_current_access_url_id();
     // get all users data from a course for sortable with limit
     if (is_array($user_ids)) {
         $user_ids = array_map('intval', $user_ids);
         $condition_user = "******" . implode(',', $user_ids) . ") ";
     } else {
         $user_ids = intval($user_ids);
         $condition_user = "******";
     }
     if (!empty($_GET['user_keyword'])) {
         $keyword = trim(Database::escape_string($_GET['user_keyword']));
         $condition_user .= " AND (\n                user.firstname LIKE '%" . $keyword . "%' OR\n                user.lastname LIKE '%" . $keyword . "%'  OR\n                user.username LIKE '%" . $keyword . "%'  OR\n                user.email LIKE '%" . $keyword . "%'\n             ) ";
     }
     $url_table = null;
     $url_condition = null;
     if (api_is_multiple_url_enabled()) {
         $url_table = ", " . $tbl_url_rel_user . "as url_users";
         $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='{$access_url_id}'";
     }
     $invitedUsersCondition = '';
     if (!$includeInvitedUsers) {
         $invitedUsersCondition = " AND user.status != " . INVITEE;
     }
     $sql = "SELECT  user.user_id as user_id,\n                    user.official_code  as col0,\n                    user.lastname       as col1,\n                    user.firstname      as col2,\n                    user.username       as col3\n                FROM {$tbl_user} as user {$url_table}\n    \t        {$condition_user} {$url_condition} {$invitedUsersCondition}";
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     $column = intval($column);
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $sql .= " ORDER BY col{$column} {$direction} ";
     $sql .= " LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $users = array();
     $course_info = api_get_course_info($course_code);
     $total_surveys = 0;
     $total_exercises = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 3);
     if (empty($session_id)) {
         $survey_user_list = array();
         $survey_list = SurveyManager::get_surveys($course_code, $session_id);
         $total_surveys = count($survey_list);
         if (!empty($survey_list)) {
             foreach ($survey_list as $survey) {
                 $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']);
                 foreach ($user_list as $user_id) {
                     isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : ($survey_user_list[$user_id] = 1);
                 }
             }
         }
     }
     while ($user = Database::fetch_array($res, 'ASSOC')) {
         $courseInfo = api_get_course_info($course_code);
         $courseId = $courseInfo['real_id'];
         $user['official_code'] = $user['col0'];
         $user['lastname'] = $user['col1'];
         $user['firstname'] = $user['col2'];
         $user['username'] = $user['col3'];
         $user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $session_id));
         $avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id);
         $avg_student_progress = Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $session_id);
         if (empty($avg_student_progress)) {
             $avg_student_progress = 0;
         }
         $user['average_progress'] = $avg_student_progress . '%';
         $total_user_exercise = Tracking::get_exercise_student_progress($total_exercises, $user['user_id'], $courseId, $session_id);
         $user['exercise_progress'] = $total_user_exercise;
         $total_user_exercise = Tracking::get_exercise_student_average_best_attempt($total_exercises, $user['user_id'], $courseId, $session_id);
         $user['exercise_average_best_attempt'] = $total_user_exercise;
         if (is_numeric($avg_student_score)) {
             $user['student_score'] = $avg_student_score . '%';
         } else {
             $user['student_score'] = $avg_student_score;
         }
         $user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id);
         $user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
         $user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id);
         $user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseInfo, $session_id);
         // we need to display an additional profile field
         $user['additional'] = '';
         if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
             if (isset($additional_user_profile_info[$user['user_id']]) && is_array($additional_user_profile_info[$user['user_id']])) {
                 $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
             }
         }
         if (empty($session_id)) {
             $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) . ' / ' . $total_surveys;
         }
         $user['link'] = '<center><a href="../mySpace/myStudents.php?student=' . $user['user_id'] . '&details=true&course=' . $course_code . '&origin=tracking_course&id_session=' . $session_id . '"><img src="' . api_get_path(WEB_IMG_PATH) . 'icons/22/2rightarrow.png" border="0" /></a></center>';
         // store columns in array $users
         $is_western_name_order = api_is_western_name_order();
         $user_row = array();
         $user_row[] = $user['official_code'];
         //0
         if ($is_western_name_order) {
             $user_row[] = $user['firstname'];
             $user_row[] = $user['lastname'];
         } else {
             $user_row[] = $user['lastname'];
             $user_row[] = $user['firstname'];
         }
         $user_row[] = $user['username'];
         $user_row[] = $user['time'];
         $user_row[] = $user['average_progress'];
         $user_row[] = $user['exercise_progress'];
         $user_row[] = $user['exercise_average_best_attempt'];
         $user_row[] = $user['student_score'];
         $user_row[] = $user['count_assignments'];
         $user_row[] = $user['count_messages'];
         if (empty($session_id)) {
             $user_row[] = $user['survey'];
         }
         $user_row[] = $user['first_connection'];
         $user_row[] = $user['last_connection'];
         if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
             $user_row[] = $user['additional'];
         }
         $user_row[] = $user['link'];
         $users[] = $user_row;
         if ($export_csv) {
             if (empty($session_id)) {
                 $user_row = array_map('strip_tags', $user_row);
                 unset($user_row[14]);
                 unset($user_row[15]);
             } else {
                 $user_row = array_map('strip_tags', $user_row);
                 unset($user_row[13]);
                 unset($user_row[14]);
             }
             $csv_content[] = $user_row;
         }
     }
     return $users;
 }
コード例 #8
0
 /**
  * Get users inside a course session
  */
 static function get_users_in_course_session($courseId, $id_session, $sort, $direction, $from = null, $limit = null)
 {
     $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
     $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $courseId = Database::escape_string($courseId);
     $id_session = Database::escape_string($id_session);
     $from = intval($from);
     $limit = intval($limit);
     $is_western_name_order = api_is_western_name_order();
     //Select the number of users
     $sql = " SELECT DISTINCT u.user_id," . ($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname') . ", u.username, scru.id_user as is_subscribed\n                 FROM {$tbl_session_rel_user} sru INNER JOIN {$tbl_user} u ON (u.user_id=sru.id_user)\n                      LEFT JOIN {$tbl_session_rel_course_rel_user} scru ON (u.user_id = scru.id_user AND scru.c_id = '" . $courseId . "' )\n                 WHERE  sru.id_session = '{$id_session}' AND\n                        sru.moved_to = 0 AND sru.moved_status <> " . SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION . " AND\n                        sru.relation_type<>" . SESSION_RELATION_TYPE_RRHH;
     $sql .= " ORDER BY {$sort} {$direction} ";
     if (!empty($from) && !empty($limit)) {
         $sql .= " LIMIT {$from}, {$limit}";
     }
     $result = Database::query($sql);
     if (Database::num_rows($result)) {
         return Database::store_result($result);
     }
     return false;
 }
コード例 #9
0
ファイル: rsys.php プロジェクト: ilosada/chamilo-lms-icpna
 function get_table_waiting_users($from, $per_page, $column, $direction)
 {
     $from = intval($from);
     $per_page = intval($per_page);
     $column = intval($column);
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     /*$sql = "SELECT dummy AS col0, ".(api_is_western_name_order() ? "CONCAT(u.firstname,' ',u.lastname)" : "CONCAT(u.lastname,' ',u.firstname)")." AS col1, s.user_id AS col2, accepted AS col3
     								 	FROM ".Rsys :: getTable('subscription')." s
     								 	INNER JOIN ".Database :: get_main_table(TABLE_MAIN_USER)." u ON s.user_id = u.user_id ";
     		if (!empty ($_GET['rid'])) {
     			$sql .= " WHERE s.reservation_id = '".$_GET['rid']."'";
     		}
     		$sql .= " ORDER BY col".$column." ".$direction." LIMIT ".$from.",".$per_page;*/
     $sql = "SELECT dummy AS col0, " . (api_is_western_name_order() ? "CONCAT(u.firstname,' ',u.lastname)" : "CONCAT(u.lastname,' ',u.firstname)") . " AS col1, s.user_id AS col2, accepted AS col3, r.start_at, r.end_at, s.start_at, s.end_at\n\t\t\tFROM " . Rsys::getTable('subscription') . " s," . Database::get_main_table(TABLE_MAIN_USER) . " u," . Database::get_main_table(TABLE_MAIN_RESERVATION_RESERVATION) . " r\n\t\t\twhere u.user_id = s.user_id\n\t\t\tand s.reservation_id = r.id";
     if (!empty($_GET['rid'])) {
         $sql .= " and r.id = '" . Database::escape_string($_GET['rid']) . "'";
     }
     $sql .= " ORDER BY col" . $column . " " . $direction . " LIMIT " . $from . "," . $per_page;
     $result = Database::query($sql);
     while ($array = Database::fetch_array($result, 'NUM')) {
         $arr[] = $array;
     }
     $count = 0;
     $x = count($arr);
     while ($count < $x) {
         $sql = "SELECT name\n\t\t\t\t\tFROM " . Database::get_main_table(TABLE_MAIN_CLASS) . " cl\n\t\t\t\t\tINNER JOIN " . Database::get_main_table(TABLE_MAIN_CLASS_USER) . " cu ON cu.class_id = cl.id\n\t\t\t\t\tWHERE cu.user_id=" . $arr[$count][2] . " LIMIT 1";
         $result = Database::query($sql);
         while ($array = Database::fetch_array($result, 'NUM')) {
             $arr2[] = $array;
         }
         $arr[$count][2] = $arr2[0][0];
         $count++;
     }
     $count = -1;
     if (is_array($arr)) {
         foreach ($arr as $lijn) {
             $count++;
             $controle = false;
             $tabel[$count][0] = $lijn[0];
             $tabel[$count][1] = $lijn[1];
             if ($lijn[3] == 0) {
                 $tabel[$count][5] = '<img src="../img/wrong.gif" onclick="document.location.href=\'m_reservation.php?action=accept&rid=' . $_GET['rid'] . '&amp;dummy=' . $lijn[0] . '&switch=edit&set=1\'" />';
             } else {
                 $tabel[$count][5] = '<img src="../img/right.gif" onclick="document.location.href=\'m_reservation.php?action=accept&rid=' . $_GET['rid'] . '&amp;dummy=' . $lijn[0] . '&switch=edit&set=0\'" />';
             }
             $tabel[$count][2] = $lijn[2];
             if ($lijn[6] == '0000-00-00 00:00:00' && $lijn[7] == '0000-00-00 00:00:00') {
                 $tabel[$count][3] = $lijn[4];
                 $tabel[$count][4] = $lijn[5];
             } else {
                 $tabel[$count][3] = $lijn[6];
                 $tabel[$count][4] = $lijn[7];
             }
             $tabel[$count][6] = '<img src="../img/wrong.gif" onclick="document.location.href=\'m_reservation.php?action=accept&rid=' . $_GET['rid'] . '&amp;dummy=' . $lijn[0] . '&switch=delete\'" />';
         }
     }
     return $tabel;
 }
コード例 #10
0
/**
 * Get the users to display on the current page.
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    global $_configuration;
    $url_access_id = api_get_current_access_url_id();
    $course_code = api_get_course_id();
    $courseId = api_get_course_int_id();
    $session_id = api_get_session_id();
    // Database table definitions
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
    $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
    $table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
    $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
    // adding teachers
    $is_western_name_order = api_is_western_name_order();
    if (api_get_setting('show_email_addresses') == 'true') {
        $select_fields = "u.user_id              AS col0,\n                u.official_code        AS col1,\n                " . ($is_western_name_order ? "u.firstname         AS col2,\n                u.lastname             AS col3," : "u.lastname          AS col2,\n                u.firstname            AS col3,") . "\n                u.email \t           AS col4,\n                u.active               AS col5,\n                u.user_id              AS col6";
    } else {
        $select_fields = "u.user_id              AS col0,\n                u.official_code        AS col1,\n                " . ($is_western_name_order ? "u.firstname         AS col2,\n                u.lastname             AS col3," : "u.lastname          AS col2,\n                u.firstname            AS col3,") . "\n                u.active               AS col4,\n                u.user_id              AS col5";
    }
    if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'teacher') {
        // adding a teacher through a session
        if (!empty($session_id)) {
            $sql = "SELECT {$select_fields}\n\t\t\t\t\tFROM {$user_table} u\n\t\t\t\t\tLEFT JOIN {$tbl_session_rel_course_user} cu on u.user_id = cu.id_user AND cu.c_id ='" . $courseId . "' AND id_session ='" . $session_id . "'\n                    INNER JOIN  {$tbl_url_rel_user} as url_rel_user ON (url_rel_user.user_id = u.user_id) ";
            // applying the filter of the additional user profile fields
            if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value']) and api_get_setting('ProfilingFilterAddingUsers') == 'true') {
                $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                $sql .= "\n\t\t\t\t\tLEFT JOIN {$table_user_field_values} field_values\n\t\t\t\t\t\tON field_values.user_id = u.user_id\n\t\t\t\t\tWHERE cu.id_user IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL)\n\t\t\t\t\t\tAND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n\t\t\t\t\t\tAND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "'";
            } else {
                $sql .= "WHERE cu.id_user IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
            }
            $sql .= " AND access_url_id= {$url_access_id}";
        } else {
            // adding a teacher NOT through a session
            $sql = "SELECT {$select_fields}\n                    FROM {$user_table} u\n                    LEFT JOIN {$course_user_table} cu on u.user_id = cu.user_id and cu.c_id = '" . $courseId . "'";
            // applying the filter of the additional user profile fields
            if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value']) and api_get_setting('ProfilingFilterAddingUsers') == 'true') {
                $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                $sql .= "\n\t\t\t\t\t\tLEFT JOIN {$table_user_field_values} field_values\n\t\t\t\t\t\t\tON field_values.user_id = u.user_id\n\t\t\t\t\t\tWHERE cu.user_id IS NULL AND u.status<>" . DRH . "\n\t\t\t\t\t\t\tAND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n\t\t\t\t\t\t\tAND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "'";
            } else {
                $sql .= "WHERE cu.user_id IS NULL AND u.status<>" . DRH . " ";
            }
            // adding a teacher NOT trough a session on a portal with multiple URLs
            if ($_configuration['multiple_access_urls']) {
                if ($url_access_id != -1) {
                    $sql = "SELECT {$select_fields}\n\t\t\t\t\t\tFROM {$user_table} u\n\t\t\t\t\t\tLEFT JOIN {$course_user_table} cu on u.user_id = cu.user_id and cu.c_id ='" . $courseId . "'\n\t\t\t\t\t\tINNER JOIN  {$tbl_url_rel_user} as url_rel_user ON (url_rel_user.user_id = u.user_id) ";
                    // applying the filter of the additional user profile fields
                    if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value']) and api_get_setting('ProfilingFilterAddingUsers') == 'true') {
                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                        $sql .= "\n\t\t\t\t\t\t\tLEFT JOIN {$table_user_field_values} field_values\n\t\t\t\t\t\t\t\tON field_values.user_id = u.user_id\n\t\t\t\t\t\t\tWHERE cu.user_id IS NULL AND u.status<>" . DRH . "\n\t\t\t\t\t\t\t\tAND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n\t\t\t\t\t\t\t\tAND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "'";
                    } else {
                        $sql .= "WHERE cu.user_id IS NULL AND u.status<>" . DRH . " AND access_url_id= {$url_access_id} ";
                    }
                }
            }
        }
    } else {
        // adding a student
        if (!empty($session_id)) {
            $sql = "SELECT {$select_fields}\n                    FROM {$user_table} u\n                    LEFT JOIN {$tbl_session_rel_course_user} cu ON u.user_id = cu.id_user AND cu.c_id ='" . $courseId . "' AND id_session ='" . $session_id . "' ";
            if (api_is_multiple_url_enabled()) {
                $sql .= " INNER JOIN  {$tbl_url_rel_user} as url_rel_user ON (url_rel_user.user_id = u.user_id) ";
            }
            // applying the filter of the additional user profile fields
            if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value'])) {
                $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                $sql .= "\n                    LEFT JOIN {$table_user_field_values} field_values\n                        ON field_values.user_id = u.user_id\n                    WHERE cu.id_user IS NULL AND u.status<>" . DRH . " AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL)\n                        AND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n                        AND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "'";
            } else {
                $sql .= "WHERE cu.id_user IS NULL AND u.status<>" . DRH . " AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
            }
            if (api_is_multiple_url_enabled()) {
                $sql .= "AND access_url_id = {$url_access_id}";
            }
        } else {
            $sql = "SELECT {$select_fields}\n                    FROM {$user_table} u\n                    LEFT JOIN {$course_user_table} cu on u.user_id = cu.user_id and cu.c_id ='" . $courseId . "'";
            // applying the filter of the additional user profile fields
            if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value'])) {
                $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                $sql .= "\n\t\t\t\t\tLEFT JOIN {$table_user_field_values} field_values\n\t\t\t\t\t\tON field_values.user_id = u.user_id\n\t\t\t\t\tWHERE cu.user_id IS NULL AND u.status<>" . DRH . "\n\t\t\t\t\t\tAND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n\t\t\t\t\t\tAND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "'";
            } else {
                $sql .= "WHERE cu.user_id IS NULL AND u.status<>" . DRH . " ";
            }
            //showing only the courses of the current Chamilo access_url_id
            if (api_is_multiple_url_enabled()) {
                if ($url_access_id != -1) {
                    $sql = "SELECT {$select_fields}\n\t\t\t\t\t\tFROM {$user_table} u\n\t\t\t\t\t\tLEFT JOIN {$course_user_table} cu on u.user_id = cu.user_id and cu.c_id ='" . $courseId . "'\n\t\t\t\t\t\tINNER JOIN  {$tbl_url_rel_user} as url_rel_user\n\t\t\t\t\t\tON (url_rel_user.user_id = u.user_id) ";
                    // applying the filter of the additional user profile fields
                    if (isset($_GET['subscribe_user_filter_value']) and !empty($_GET['subscribe_user_filter_value']) and api_get_setting('ProfilingFilterAddingUsers') == 'true') {
                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
                        $sql .= "\n\t\t\t\t\t\t\tLEFT JOIN {$table_user_field_values} field_values\n\t\t\t\t\t\t\t\tON field_values.user_id = u.user_id\n\t\t\t\t\t\t\tWHERE cu.user_id IS NULL AND u.status<>" . DRH . "\n\t\t\t\t\t\t\t\tAND field_values.field_id = '" . Database::escape_string($field_identification[0]) . "'\n\t\t\t\t\t\t\t\tAND field_values.field_value = '" . Database::escape_string($field_identification[1]) . "' AND access_url_id= {$url_access_id}  ";
                    } else {
                        $sql .= "WHERE  cu.user_id IS NULL AND u.status<>" . DRH . " AND access_url_id= {$url_access_id} ";
                    }
                }
            }
        }
    }
    // adding additional WHERE statements to the SQL for the search functionality
    if (isset($_REQUEST['keyword'])) {
        $keyword = Database::escape_string(trim($_REQUEST['keyword']));
        $sql .= " AND (firstname LIKE '%" . $keyword . "%' OR lastname LIKE '%" . $keyword . "%'   OR email LIKE '%" . $keyword . "%'  OR username LIKE '%" . $keyword . "%'  OR official_code LIKE '%" . $keyword . "%')";
        if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
            // we also want to search for users who have something in their profile fields that matches the keyword
            $additional_users = search_additional_profile_fields($keyword);
        }
        // getting all the users of the course (to make sure that we do not display users that are already in the course)
        if (!empty($session_id)) {
            $a_course_users = CourseManager::get_user_list_from_course_code($course_code, $session_id);
        } else {
            $a_course_users = CourseManager::get_user_list_from_course_code($course_code, 0);
        }
        foreach ($a_course_users as $user_id => $course_user) {
            $users_of_course[] = $course_user['user_id'];
        }
    }
    $sql .= " AND u.status != " . ANONYMOUS . " ";
    // Sorting and pagination (used by the sortable table)
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql);
    $users = array();
    while ($user = Database::fetch_row($res)) {
        $users[] = $user;
        $_SESSION['session_user_id'][] = $user[0];
        if ($is_western_name_order) {
            $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]);
        } else {
            $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]);
        }
    }
    // adding additional users based on the search on the additional profile fields
    if (isset($_REQUEST['keyword'])) {
        if (isset($additional_users) && is_array($additional_users)) {
            foreach ($additional_users as $additional_user_key => $additional_user_value) {
                if (!in_array($additional_user_key, $_SESSION['session_user_id']) and !in_array($additional_user_key, $users_of_course)) {
                    $users[] = array($additional_user_value['col0'], $additional_user_value['col1'], $additional_user_value['col2'] . '*', $additional_user_value['col3'] . '*', $additional_user_value['col4'], $additional_user_value['col5'], $additional_user_value['col6']);
                }
            }
        }
    }
    return $users;
}
コード例 #11
0
ファイル: coaches.php プロジェクト: KRCM13/chamilo-lms
			            </td>
                    </tr>';
        } else {
            echo '<tr class="' . $css_class . '">
			        <td>' . $lastname . '</td><td>' . $firstname . '</td>
			        <td>' . $s_connection_time . '</td>
			        <td>
			            <a href="course.php?type=coach&user_id=' . $id_coach . '">
			            <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a></td>
                    <td>
                        <a href="student.php?type=coach&user_id=' . $id_coach . '">
                        <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>
                    </td>
                    </tr>';
        }
        if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
            $data[$id_coach]["firstname"] = $firstname;
            $data[$id_coach]["lastname"] = $lastname;
        } else {
            $data[$id_coach]["lastname"] = $lastname;
            $data[$id_coach]["firstname"] = $firstname;
        }
        $data[$id_coach]["connection_time"] = $s_connection_time;
    }
} else {
    // No results
    echo '<tr><td colspan="5">' . get_lang("NoResult") . '</td></tr>';
}
echo '</table>';
if (isset($_POST['export'])) {
    export_csv($header, $data, 'coaches.csv');
コード例 #12
0
 /**
  * @param array $form
  * @param $to_already_selected
  */
 public static function show_to_form($form, $to_already_selected)
 {
     $order = 'lastname';
     if (api_is_western_name_order()) {
         $order = 'firstname';
     }
     $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
     $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
     self::construct_not_selected_select_form_validator($form, $group_list, $user_list, $to_already_selected);
 }
コード例 #13
0
ファイル: user_list.php プロジェクト: KRCM13/chamilo-lms
/**
*	Make sure this function is protected because it does NOT check password!
*
*	This function defines globals.
*   @param  int     $userId
 *
*   @return bool    False on failure, redirection on success
*	@author Evie Embrechts
*   @author Yannick Warnier <*****@*****.**>
*/
function loginUser($userId)
{
    $userId = intval($userId);
    $userInfo = api_get_user_info($userId);
    // Check if the user is allowed to 'login_as'
    $canLoginAs = api_can_login_as($userId);
    if (!$canLoginAs || empty($userInfo)) {
        return false;
    }
    $firstname = $userInfo['firstname'];
    $lastname = $userInfo['lastname'];
    if (api_is_western_name_order()) {
        $message = sprintf(get_lang('AttemptingToLoginAs'), $firstname, $lastname, $userId);
    } else {
        $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
    }
    if ($userId) {
        // Logout the current user
        LoginDelete(api_get_user_id());
        Session::erase('_user');
        Session::erase('is_platformAdmin');
        Session::erase('is_allowedCreateCourse');
        Session::erase('_uid');
        // Cleaning session variables
        $_user['firstName'] = $userInfo['firstname'];
        $_user['lastName'] = $userInfo['lastname'];
        $_user['mail'] = $userInfo['email'];
        //$_user['lastLogin'] = $user_data['login_date'];
        $_user['official_code'] = $userInfo['official_code'];
        $_user['picture_uri'] = $userInfo['picture_uri'];
        $_user['user_id'] = $userId;
        $_user['id'] = $userId;
        $_user['status'] = $userInfo['status'];
        // Filling session variables with new data
        Session::write('_uid', $userId);
        Session::write('_user', $userInfo);
        Session::write('is_platformAdmin', (bool) UserManager::is_admin($userId));
        Session::write('is_allowedCreateCourse', (bool) ($userInfo['status'] == 1));
        // will be useful later to know if the user is actually an admin or not (example reporting)
        Session::write('login_as', true);
        $target_url = api_get_path(WEB_PATH) . "user_portal.php";
        $message .= '<br />' . sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="' . $target_url . '">' . $target_url . '</a>');
        Display::display_header(get_lang('UserList'));
        Display::display_normal_message($message, false);
        Display::display_footer();
        exit;
    }
}
コード例 #14
0
ファイル: course.lib.php プロジェクト: feroli1000/chamilo-lms
 /**
  * Send an email to tutor after the auth-suscription of a student in your course
  * @author Carlos Vargas <*****@*****.**>, Dokeos Latino
  * @param  int $user_id the id of the user
  * @param  string $course_code the course code
  * @param  bool $send_to_tutor_also
  * @return string we return the message that is displayed when the action is successful
  */
 public static function email_to_tutor($user_id, $courseId, $send_to_tutor_also = false)
 {
     if ($user_id != strval(intval($user_id))) {
         return false;
     }
     $courseId = intval($courseId);
     $information = api_get_course_info_by_id($courseId);
     $course_code = $information['code'];
     $student = api_get_user_info($user_id);
     $name_course = $information['title'];
     $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " WHERE c_id ='" . $courseId . "'";
     // TODO: Ivan: This is a mistake, please, have a look at it. Intention here is diffcult to be guessed.
     //if ($send_to_tutor_also = true)
     // Proposed change:
     if ($send_to_tutor_also) {
         $sql .= " AND is_tutor=1";
     } else {
         $sql .= " AND status=1";
     }
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         $tutor = api_get_user_info($row['user_id']);
         $emailto = $tutor['email'];
         $emailsubject = get_lang('NewUserInTheCourse') . ': ' . $name_course;
         $emailbody = get_lang('Dear') . ': ' . api_get_person_name($tutor['firstname'], $tutor['lastname']) . "\n";
         $emailbody .= get_lang('MessageNewUserInTheCourse') . ': ' . $name_course . "\n";
         $emailbody .= get_lang('UserName') . ': ' . $student['username'] . "\n";
         if (api_is_western_name_order()) {
             $emailbody .= get_lang('FirstName') . ': ' . $student['firstname'] . "\n";
             $emailbody .= get_lang('LastName') . ': ' . $student['lastname'] . "\n";
         } else {
             $emailbody .= get_lang('LastName') . ': ' . $student['lastname'] . "\n";
             $emailbody .= get_lang('FirstName') . ': ' . $student['firstname'] . "\n";
         }
         $emailbody .= get_lang('Email') . ': <a href="mailto:' . $student['email'] . '">' . $student['email'] . "</a>\n\n";
         $recipient_name = api_get_person_name($tutor['firstname'], $tutor['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
         $sender_name = api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
         $email_admin = api_get_setting('admin.administrator_email');
         $additionalParameters = array('smsType' => SmsPlugin::NEW_USER_SUBSCRIBED_COURSE, 'userId' => $tutor['user_id'], 'userUsername' => $student['username'], 'courseCode' => $course_code);
         api_mail_html($recipient_name, $emailto, $emailsubject, $emailbody, $sender_name, $email_admin, null, null, null, $additionalParameters);
     }
 }
コード例 #15
0
 /**
  * Exports the complete report as an XLS file
  * @return	boolean		False on error
  */
 public function exportCompleteReportXLS($document_path = '', $user_id = null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null)
 {
     global $charset;
     $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
     $filename = 'exercise_results_' . date('YmdGis') . '.xls';
     if (!empty($user_id)) {
         $filename = 'exercise_results_user_' . $user_id . '_' . date('YmdGis') . '.xls';
     }
     $workbook = new Spreadsheet_Excel_Writer();
     $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
     $workbook->setVersion(8);
     // BIFF8
     $workbook->send($filename);
     $worksheet =& $workbook->addWorksheet('Report ' . date('YmdGis'));
     $worksheet->setInputEncoding(api_get_system_encoding());
     $line = 0;
     $column = 0;
     //skip the first column (row titles)
     // check if exists column 'user'
     $with_column_user = false;
     foreach ($this->results as $result) {
         if (!empty($result['last_name']) && !empty($result['first_name'])) {
             $with_column_user = true;
             break;
         }
     }
     if ($with_column_user) {
         $worksheet->write($line, $column, get_lang('Email'));
         $column++;
         if (api_is_western_name_order()) {
             $worksheet->write($line, $column, get_lang('FirstName'));
             $column++;
             $worksheet->write($line, $column, get_lang('LastName'));
             $column++;
         } else {
             $worksheet->write($line, $column, get_lang('LastName'));
             $column++;
             $worksheet->write($line, $column, get_lang('FirstName'));
             $column++;
         }
     }
     if ($export_user_fields) {
         //show user fields section with a big th colspan that spans over all fields
         $extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
         //show the fields names for user fields
         foreach ($extra_user_fields as $field) {
             $worksheet->write($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
             $column++;
         }
     }
     $worksheet->write($line, $column, get_lang('Title'));
     $column++;
     $worksheet->write($line, $column, get_lang('StartDate'));
     $column++;
     $worksheet->write($line, $column, get_lang('EndDate'));
     $column++;
     $worksheet->write($line, $column, get_lang('Duration') . ' (' . get_lang('MinMinutes') . ')');
     $column++;
     $worksheet->write($line, $column, get_lang('Score'));
     $column++;
     $worksheet->write($line, $column, get_lang('Total'));
     $column++;
     $worksheet->write($line, $column, get_lang('Status'));
     $line++;
     foreach ($this->results as $row) {
         $column = 0;
         if ($with_column_user) {
             $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
             $column++;
             if (api_is_western_name_order()) {
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
                 $column++;
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
                 $column++;
             } else {
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
                 $column++;
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
                 $column++;
             }
         }
         if ($export_user_fields) {
             //show user fields data, if any, for this user
             $user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
             foreach ($user_fields_values as $value) {
                 $worksheet->write($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
                 $column++;
             }
         }
         $worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
         $column++;
         $worksheet->write($line, $column, $row['start_date']);
         $column++;
         $worksheet->write($line, $column, $row['end_date']);
         $column++;
         $worksheet->write($line, $column, $row['duration']);
         $column++;
         $worksheet->write($line, $column, $row['result']);
         $column++;
         $worksheet->write($line, $column, $row['max']);
         $column++;
         $worksheet->write($line, $column, $row['status']);
         $line++;
     }
     $workbook->close();
     return true;
 }
コード例 #16
0
ファイル: student.php プロジェクト: KRCM13/chamilo-lms
function get_users($from, $limit, $column, $direction)
{
    $active = isset($_GET['active']) ? $_GET['active'] : 1;
    $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
    $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
    $lastConnectionDate = null;
    if (!empty($sleepingDays)) {
        $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays . ' days ago'));
    }
    $is_western_name_order = api_is_western_name_order();
    $coach_id = api_get_user_id();
    $drhLoaded = false;
    if (api_is_drh()) {
        $column = 'u.user_id';
        if (api_drh_can_access_all_session_content()) {
            $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, $from, $limit, $column, $direction, $keyword, $active, $lastConnectionDate, null, null, api_is_student_boss() ? null : STUDENT);
            $drhLoaded = true;
        }
    }
    if ($drhLoaded == false) {
        $students = UserManager::getUsersFollowedByUser(api_get_user_id(), api_is_student_boss() ? null : STUDENT, false, false, false, $from, $limit, $column, $direction, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword);
    }
    $all_datas = array();
    foreach ($students as $student_data) {
        $student_id = $student_data['user_id'];
        if (isset($_GET['id_session'])) {
            $courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']);
        }
        $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0;
        $nb_courses_student = 0;
        if (!empty($courses)) {
            foreach ($courses as $course_code) {
                $courseInfo = api_get_course_info($course_code);
                $courseId = $courseInfo['real_id'];
                if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
                    $avg_time_spent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']);
                    $my_average = Tracking::get_avg_student_score($student_id, $course_code);
                    if (is_numeric($my_average)) {
                        $avg_student_score += $my_average;
                    }
                    $avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
                    $total_assignments += Tracking::count_student_assignments($student_id, $course_code);
                    $total_messages += Tracking::count_student_messages($student_id, $course_code);
                    $nb_courses_student++;
                }
            }
        }
        if ($nb_courses_student > 0) {
            $avg_time_spent = $avg_time_spent / $nb_courses_student;
            $avg_student_score = $avg_student_score / $nb_courses_student;
            $avg_student_progress = $avg_student_progress / $nb_courses_student;
        } else {
            $avg_time_spent = null;
            $avg_student_score = null;
            $avg_student_progress = null;
        }
        $row = array();
        if ($is_western_name_order) {
            $row[] = $student_data['firstname'];
            $row[] = $student_data['lastname'];
        } else {
            $row[] = $student_data['lastname'];
            $row[] = $student_data['firstname'];
        }
        $string_date = Tracking::get_last_connection_date($student_id, true);
        $first_date = Tracking::get_first_connection_date($student_id);
        $row[] = $first_date;
        $row[] = $string_date;
        if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '&id_coach=' . $coach_id . '&id_session=' . $_GET['id_session'] . '">
				          <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        } else {
            $detailsLink = '<a href="myStudents.php?student=' . $student_id . '">
				             <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        }
        $row[] = $detailsLink;
        $all_datas[] = $row;
    }
    return $all_datas;
}
コード例 #17
0
 /**
  * Get users followed by human resource manager
  * @param int $userId
  * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
  * @param bool $getOnlyUserId
  * @param bool $getSql
  * @param bool $getCount
  * @param int $from
  * @param int $numberItems
  * @param int $column
  * @param string $direction
  * @param int $active
  * @param string $lastConnectionDate
  * @param int $status the function is called by who? COURSEMANAGER, DRH?
  * @param string $keyword
  *
  * @return array user list
  */
 public static function getUsersFollowedByUser($userId, $userStatus = null, $getOnlyUserId = false, $getSql = false, $getCount = false, $from = null, $numberItems = null, $column = null, $direction = null, $active = null, $lastConnectionDate = null, $status = null, $keyword = null)
 {
     // Database Table Definitions
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_user_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
     $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
     $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
     $userId = intval($userId);
     $limitCondition = null;
     if (isset($from) && isset($numberItems)) {
         $from = intval($from);
         $numberItems = intval($numberItems);
         $limitCondition = "LIMIT {$from}, {$numberItems}";
     }
     $column = Database::escape_string($column);
     $direction = in_array(strtolower($direction), array('asc', 'desc')) ? $direction : null;
     $userConditions = '';
     if (!empty($userStatus)) {
         $userConditions .= ' AND u.status = ' . intval($userStatus);
     }
     $select = " SELECT DISTINCT u.id user_id, u.username, u.lastname, u.firstname, u.email ";
     if ($getOnlyUserId) {
         $select = " SELECT DISTINCT u.id user_id";
     }
     $masterSelect = "SELECT DISTINCT * FROM ";
     if ($getCount) {
         $masterSelect = "SELECT COUNT(DISTINCT(u.id)) as count FROM ";
         $select = " SELECT DISTINCT(u.id) user_id";
     }
     if (!is_null($active)) {
         $active = intval($active);
         $userConditions .= " AND u.active = {$active} ";
     }
     if (!empty($keyword)) {
         $keyword = Database::escape_string($keyword);
         $userConditions .= " AND (\n                u.username LIKE '%{$keyword}%' OR\n                u.firstname LIKE '%{$keyword}%' OR\n                u.lastname LIKE '%{$keyword}%' OR\n                u.official_code LIKE '%{$keyword}%' OR\n                u.email LIKE '%{$keyword}%'\n            )";
     }
     if (!empty($lastConnectionDate)) {
         if (isset($_configuration['save_user_last_login']) && $_configuration['save_user_last_login']) {
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
             $userConditions .= " AND u.last_login <= '{$lastConnectionDate}' ";
         }
     }
     $courseConditions = null;
     $sessionConditionsCoach = null;
     $sessionConditionsTeacher = null;
     $drhConditions = null;
     $teacherSelect = null;
     switch ($status) {
         case DRH:
             $drhConditions .= " AND\n                    friend_user_id = '{$userId}' AND\n                    relation_type = '" . USER_RELATION_TYPE_RRHH . "'\n                ";
             break;
         case COURSEMANAGER:
             $drhConditions .= " AND\n                    friend_user_id = '{$userId}' AND\n                    relation_type = '" . USER_RELATION_TYPE_RRHH . "'\n                ";
             $sessionConditionsCoach .= " AND\n                    (s.id_coach = '{$userId}')\n                ";
             $sessionConditionsTeacher .= " AND\n                    (scu.status = 2 AND scu.user_id = '{$userId}')\n                ";
             $teacherSelect = "UNION ALL (\n                        {$select}\n                        FROM {$tbl_user} u\n                        INNER JOIN {$tbl_session_rel_user} sru ON (sru.user_id = u.id)\n                        WHERE\n                            sru.session_id IN (\n                                SELECT DISTINCT(s.id) FROM {$tbl_session} s INNER JOIN\n                                {$tbl_session_rel_access_url}\n                                WHERE access_url_id = " . api_get_current_access_url_id() . "\n                                {$sessionConditionsCoach}\n                                UNION (\n                                    SELECT DISTINCT(s.id) FROM {$tbl_session} s\n                                    INNER JOIN {$tbl_session_rel_access_url} url\n                                    ON (url.session_id = s.id)\n                                    INNER JOIN {$tbl_session_rel_course_rel_user} scu\n                                    ON (scu.session_id = s.id)\n                                    WHERE access_url_id = " . api_get_current_access_url_id() . "\n                                    {$sessionConditionsTeacher}\n                                )\n                            )\n                            {$userConditions}\n                    )\n                    UNION ALL(\n                        {$select}\n                        FROM {$tbl_user} u\n                        INNER JOIN {$tbl_course_user} cu ON (cu.user_id = u.id)\n                        WHERE cu.c_id IN (\n                            SELECT DISTINCT(c_id) FROM {$tbl_course_user}\n                            WHERE user_id = {$userId} AND status = " . COURSEMANAGER . "\n                        )\n                        {$userConditions}\n                    )";
             break;
         case STUDENT_BOSS:
             $drhConditions = " AND friend_user_id = {$userId} AND " . "relation_type = " . USER_RELATION_TYPE_BOSS;
             break;
     }
     $join = null;
     $sql = " {$masterSelect}\n                (\n                    (\n                        {$select}\n                        FROM {$tbl_user} u\n                        INNER JOIN {$tbl_user_rel_user} uru ON (uru.user_id = u.id)\n                        LEFT JOIN {$tbl_user_rel_access_url} a ON (a.user_id = u.id)\n                        {$join}\n                        WHERE\n                            access_url_id = " . api_get_current_access_url_id() . "\n                            {$drhConditions}\n                            {$userConditions}\n                    )\n                    {$teacherSelect}\n\n                ) as t1";
     if ($getSql) {
         return $sql;
     }
     if ($getCount) {
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         return $row['count'];
     }
     $orderBy = null;
     if (api_is_western_name_order()) {
         $orderBy .= " ORDER BY firstname, lastname ";
     } else {
         $orderBy .= " ORDER BY lastname, firstname ";
     }
     if (!empty($column) && !empty($direction)) {
         // Fixing order due the UNIONs
         $column = str_replace('u.', '', $column);
         $orderBy = " ORDER BY {$column} {$direction} ";
     }
     $sql .= $orderBy;
     $sql .= $limitCondition;
     $result = Database::query($sql);
     $users = array();
     if (Database::num_rows($result) > 0) {
         while ($row = Database::fetch_array($result)) {
             $users[$row['user_id']] = $row;
         }
     }
     return $users;
 }
コード例 #18
0
ファイル: report.php プロジェクト: annickvdp/Chamilo1.9.10
/**
 * Get the users to display on the current page (fill the sortable-table)
 * @param   int     offset of first user to recover
 * @param   int     Number of users to get
 * @param   int     Column to sort on
 * @param   string  Order (ASC,DESC)
 * @see SortableTable#get_table_data($from)
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    $user_table = Database :: get_main_table(TABLE_MAIN_USER);

    if (api_is_western_name_order()) {
        $col34 = "u.firstname AS col3,
                  u.lastname AS col4,";
    } else {
        $col34 = "u.lastname AS col3,
                  u.firstname AS col4,";
    }

    $sql = "SELECT
                 u.user_id AS col0,
                 u.official_code AS col2,
		 $col34
                 u.username AS col5,
                 u.email AS col6,
                 u.status AS col7,
                 u.active AS col8,
                 u.user_id AS col9,
              u.expiration_date AS exp
           FROM $user_table u ";

    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR
                  u.lastname LIKE '%$keyword%' OR
                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%' OR
                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR
                  u.username LIKE '%$keyword%'  OR
                  u.official_code LIKE '%$keyword%'
                  OR u.email LIKE '%$keyword%' )";
    }
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    $column = intval($column);
    $from = intval($from);
    $number_of_items = intval($number_of_items);

    $sql .= " ORDER BY col$column $direction ";
    $sql .= " LIMIT $from,$number_of_items";

    $res = Database::query($sql);

    $users = array();
    $webPath = api_get_path(WEB_PATH);
    $selfPath = api_get_self();
    while ($user = Database::fetch_row($res)) {
        $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
        $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
        if (!api_is_anonymous()) {
            $photo = '<center><a href="' . $webPath . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '"  title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
        } else {
            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
        }
        $user_id = $user[0];
        $button = '<a href="' . $selfPath . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
        $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')">
					<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')"  src="' . $webPath . 'img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
					</a>&nbsp;&nbsp;';
        $users[] = array($photo, $user[1], $user[2], $user[3], $user[4], $user[5], $button);
    }
    return $users;
}
コード例 #19
0
ファイル: blog.lib.php プロジェクト: KRCM13/chamilo-lms
 /**
  * Displays the form to register users in a blog (in a course)
  * The listed users are users subcribed in the course.
  * @author Toon Keppens
  *
  * @param Integer $blog_id
  *
  * @return Html Form with sortable table with users to unsubcribe from a blog.
  */
 public static function display_form_user_unsubscribe($blog_id)
 {
     $_user = api_get_user_info();
     $is_western_name_order = api_is_western_name_order();
     // Init
     $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
     echo '<legend>' . get_lang('UnsubscribeMembers') . '</legend>';
     $properties["width"] = "100%";
     //table column titles
     $column_header[] = array('', false, '');
     if ($is_western_name_order) {
         $column_header[] = array(get_lang('FirstName'), true, '');
         $column_header[] = array(get_lang('LastName'), true, '');
     } else {
         $column_header[] = array(get_lang('LastName'), true, '');
         $column_header[] = array(get_lang('FirstName'), true, '');
     }
     $column_header[] = array(get_lang('Email'), false, '');
     $column_header[] = array(get_lang('TaskManager'), true, '');
     $column_header[] = array(get_lang('UnRegister'), false, '');
     $course_id = api_get_course_int_id();
     $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username\n                FROM {$tbl_users} user INNER JOIN {$tbl_blogs_rel_user} blogs_rel_user\n                ON user.user_id = blogs_rel_user.user_id\n                WHERE blogs_rel_user.c_id = {$course_id} AND  blogs_rel_user.blog_id = '" . (int) $blog_id . "'";
     if (!($sql_result = Database::query($sql))) {
         return false;
     }
     $user_data = array();
     while ($myrow = Database::fetch_array($sql_result)) {
         $row = array();
         $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" ' . (isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe" ? ' checked="checked" ' : '') . '/>';
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
         if ($is_western_name_order) {
             $row[] = $myrow["firstname"];
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
         } else {
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
             $row[] = $myrow["firstname"];
         }
         $row[] = Display::icon_mailto_link($myrow["email"]);
         $sql = "SELECT bt.title task\n\t\t\t\t\tFROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu\n\t\t\t\t\tINNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt\n\t\t\t\t\tON btu.task_id = bt.task_id\n\t\t\t\t\tWHERE \tbtu.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbt.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbtu.blog_id = {$blog_id} AND\n\t\t\t\t\t\t\tbtu.user_id = " . $myrow['user_id'];
         $sql_res = Database::query($sql);
         $task = '';
         while ($r = Database::fetch_array($sql_res)) {
             $task .= stripslashes($r['task']) . ', ';
         }
         //echo $task;
         $task = api_strlen(trim($task)) != 0 ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
         $row[] = $task;
         //Link to register users
         if ($myrow["user_id"] != $_user['user_id']) {
             $row[] = "<a class=\"btn btn-primary\" href=\"" . api_get_self() . "?action=manage_members&blog_id={$blog_id}&unregister=yes&user_id=" . $myrow['user_id'] . "\">" . get_lang('UnRegister') . "</a>";
         } else {
             $row[] = '';
         }
         $user_data[] = $row;
     }
     $query_vars['action'] = 'manage_members';
     $query_vars['blog_id'] = $blog_id;
     echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
     Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
     $link = '';
     $link .= isset($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
     $link .= "blog_id={$blog_id}&";
     echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
     echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
     echo get_lang('WithSelected') . ' : ';
     echo '<select name="action">';
     echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
     echo '</select>';
     echo '<input type="hidden" name="unregister" value="true" />';
     echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
     echo '</form>';
 }
コード例 #20
0
/**
 * Displays step 4 of the installation - configuration settings about Chamilo itself.
 */
function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm)
{
    if ($installType != 'update' && empty($languageForm)) {
        $languageForm = $_SESSION['install_language'];
    }
    echo '<div class="RequirementHeading">';
    echo "<h2>" . display_step_sequence() . translate("CfgSetting") . "</h2>";
    echo '</div>';
    echo '<div class="RequirementContent">';
    echo '<p>' . translate('ConfigSettingsInfo') . ' ' . Display::label('config/configuration.php', 'info') . '</p>';
    echo '</div>';
    echo '<fieldset>';
    echo '<legend>' . translate('Administrator') . '</legend>';
    echo '<table class="data_table_no_border">';
    //Parameter 1: administrator's login
    display_configuration_parameter($installType, translate('AdminLogin'), 'loginForm', $loginForm, $installType == 'update');
    //Parameter 2: administrator's password
    if ($installType != 'update') {
        display_configuration_parameter($installType, translate('AdminPass'), 'passForm', $passForm, false);
    }
    //Parameters 3 and 4: administrator's names
    if (api_is_western_name_order()) {
        display_configuration_parameter($installType, translate('AdminFirstName'), 'adminFirstName', $adminFirstName);
        display_configuration_parameter($installType, translate('AdminLastName'), 'adminLastName', $adminLastName);
    } else {
        display_configuration_parameter($installType, translate('AdminLastName'), 'adminLastName', $adminLastName);
        display_configuration_parameter($installType, translate('AdminFirstName'), 'adminFirstName', $adminFirstName);
    }
    //Parameter 3: administrator's email
    display_configuration_parameter($installType, translate('AdminEmail'), 'emailForm', $emailForm);
    //Parameter 6: administrator's telephone
    display_configuration_parameter($installType, translate('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
    echo '</table>';
    echo '</fieldset>';
    echo '<fieldset>';
    echo '<legend>' . translate('Platform') . '</legend>';
    echo '<table class="data_table_no_border">';
    //First parameter: language
    echo "<tr>";
    echo '<td>' . translate('MainLang') . "&nbsp;&nbsp;</td>";
    if ($installType == 'update') {
        echo '<td><input type="hidden" name="languageForm" value="' . api_htmlentities($languageForm, ENT_QUOTES) . '" />' . $languageForm . "</td>";
    } else {
        // new installation
        echo '<td>';
        display_language_selection_box('languageForm', $languageForm);
        echo "</td>\n";
    }
    echo "</tr>\n";
    //Second parameter: Chamilo URL
    echo "<tr>";
    echo '<td>' . translate('ChamiloURL') . ' (<font color="red">' . translate('ThisFieldIsRequired') . "</font>)&nbsp;&nbsp;</td>";
    if ($installType == 'update') {
        echo '<td>' . api_htmlentities($urlForm, ENT_QUOTES) . "</td>\n";
    } else {
        echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="' . api_htmlentities($urlForm, ENT_QUOTES) . '" />' . "</td>";
    }
    echo "</tr>";
    //Parameter 9: campus name
    display_configuration_parameter($installType, translate('CampusName'), 'campusForm', $campusForm);
    //Parameter 10: institute (short) name
    display_configuration_parameter($installType, translate('InstituteShortName'), 'institutionForm', $institutionForm);
    //Parameter 11: institute (short) name
    display_configuration_parameter($installType, translate('InstituteURL'), 'institutionUrlForm', $institutionUrlForm);
    ?>
<tr>
    <td><?php 
    echo translate("EncryptMethodUserPass");
    ?>
 :</td>
    <?php 
    if ($installType == 'update') {
        ?>
    <td><input type="hidden" name="encryptPassForm"
               value="<?php 
        echo $encryptPassForm;
        ?>
"/><?php 
        echo $encryptPassForm;
        ?>
</td>
    <?php 
    } else {
        ?>
    <td>
        <div class="control-group">
            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="encryptPassForm" value="sha1"
                       id="encryptPass1" <?php 
        echo $encryptPassForm == 'sha1' ? 'checked="checked" ' : '';
        ?>
/><?php 
        echo 'sha1';
        ?>
            </label>

            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="encryptPassForm" value="md5"
                       id="encryptPass0" <?php 
        echo $encryptPassForm == 1 ? 'checked="checked" ' : '';
        ?>
/><?php 
        echo 'md5';
        ?>
            </label>

            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="encryptPassForm" value="none"
                       id="encryptPass2" <?php 
        echo $encryptPassForm === '0' or $encryptPassForm === 0 ? 'checked="checked" ' : '';
        ?>
/><?php 
        echo translate('None');
        ?>
            </label>

        </div>
    </td>
    <?php 
    }
    ?>
</tr>
<tr>
    <td><?php 
    echo translate('AllowSelfReg');
    ?>
 :</td>

    <?php 
    if ($installType == 'update') {
        ?>
    <td><input type="hidden" name="allowSelfReg"
               value="<?php 
        echo $allowSelfReg;
        ?>
"/><?php 
        echo $allowSelfReg ? translate('Yes') : translate('No');
        ?>
    </td>
    <?php 
    } else {
        ?>
    <td>
        <div class="control-group">
            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="allowSelfReg" value="1"
                       id="allowSelfReg1" <?php 
        echo $allowSelfReg ? 'checked="checked" ' : '';
        ?>
/> <?php 
        echo translate('Yes');
        ?>
            </label>
            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="allowSelfReg" value="0"
                       id="allowSelfReg0" <?php 
        echo $allowSelfReg ? '' : 'checked="checked" ';
        ?>
/><?php 
        echo translate('No');
        ?>
            </label>
        </div>
    </td>
    <?php 
    }
    ?>

</tr>
<tr>
    <td><?php 
    echo translate('AllowSelfRegProf');
    ?>
 :</td>

    <?php 
    if ($installType == 'update') {
        ?>
    <td><input type="hidden" name="allowSelfRegProf"
               value="<?php 
        echo $allowSelfRegProf;
        ?>
"/><?php 
        echo $allowSelfRegProf ? translate('Yes') : translate('No');
        ?>
</td>
    <?php 
    } else {
        ?>
    <td>
        <div class="control-group">
            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="allowSelfRegProf" value="1"
                       id="allowSelfRegProf1" <?php 
        echo $allowSelfRegProf ? 'checked="checked" ' : '';
        ?>
/>
                <?php 
        echo translate('Yes');
        ?>
            </label>
            <label class="checkbox inline">
                <input class="checkbox" type="radio" name="allowSelfRegProf" value="0"
                       id="allowSelfRegProf0" <?php 
        echo $allowSelfRegProf ? '' : 'checked="checked" ';
        ?>
/>
                <?php 
        echo translate('No');
        ?>
            </label>
        </div>
    </td>
    <?php 
    }
    ?>

</tr>
<tr>
    <td>
        <button type="submit" class="btn back" name="step3" value="&lt; <?php 
    echo translate('Previous');
    ?>
"/>
            <?php 
    echo translate('Previous');
    ?>
</button>
    </td>
    <td align="right">
        <input type="hidden" name="is_executable" id="is_executable" value="-"/>
        <button class="btn next" type="submit" name="step5" value="<?php 
    echo translate('Next');
    ?>
 &gt;"/>
            <?php 
    echo translate('Next');
    ?>
</button></td>
</tr>
</fieldset>
</table>
    <?php 
}
コード例 #21
0
										date_start,
										date_end
								FROM $tbl_session as session
								WHERE session.id_coach = ".$_user['user_id']."
								ORDER BY date_start, date_end, name");
		while ($session = Database:: fetch_array($result)) {
			$session_is_coach[$session['id']] = $session;
		}

		$students_online = array();
		foreach ($session_is_coach as $session) {
			$sql = "SELECT 	DISTINCT last_access.access_user_id,
							last_access.access_date,
							last_access.access_cours_code,
							last_access.access_session_id,
							".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
							user.email
					FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
					INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
						ON user.user_id = last_access.access_user_id
					WHERE access_session_id='".$session['id']."'
					AND NOW()-access_date<1000 GROUP BY access_user_id";

			$result = Database::query($sql);

			while($user_list = Database::fetch_array($result)) {
				$students_online[$user_list['access_user_id']] = $user_list;
			}
		}

		if (count($students_online) > 0) {
コード例 #22
0
ファイル: new_ticket.php プロジェクト: KRCM13/chamilo-lms
/**
 * Get the users to display on the current page (fill the sortable-table)
 * @param   int     offset of first user to recover
 * @param   int     Number of users to get
 * @param   int     Column to sort on
 * @param   string  Order (ASC,DESC)
 * @return  array   A list of users with their data
 * @see SortableTable#get_table_data($from)
 */
function get_user_data($from, $number_of_items, $column, $direction)
{
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    if (api_is_western_name_order()) {
        $col34 = "u.firstname AS col3,\n                  u.lastname AS col4,";
    } else {
        $col34 = "u.lastname AS col3,\n                  u.firstname AS col4,";
    }
    $sql = "SELECT\n                u.user_id AS col0,\n                u.official_code AS col2,\n                {$col34}\n                u.username AS col5,\n                u.email AS col6,\n                u.status AS col7,\n                u.active AS col8,\n                u.user_id AS col9 ,\n                u.expiration_date AS exp\n            FROM {$user_table} u ";
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " WHERE (u.firstname LIKE '%{$keyword}%' OR\n                  u.lastname LIKE '%{$keyword}%' OR\n                  concat(u.firstname,' ',u.lastname) LIKE '%{$keyword}%' OR\n                  concat(u.lastname,' ',u.firstname) LIKE '%{$keyword}%' OR\n                  u.username LIKE '%{$keyword}%'  OR\n                  u.official_code LIKE '%{$keyword}%' OR\n                  u.email LIKE '%{$keyword}%' )";
    }
    if (!in_array($direction, array('ASC', 'DESC'))) {
        $direction = 'ASC';
    }
    $column = intval($column);
    $from = intval($from);
    $number_of_items = intval($number_of_items);
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from}, {$number_of_items}";
    $res = Database::query($sql);
    $users = array();
    while ($user = Database::fetch_row($res)) {
        $user_id = $user[0];
        $userPicture = UserManager::getUserPicture($user_id);
        $photo = '<img src="' . $userPicture . '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />';
        $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>&nbsp;&nbsp;';
        $users[] = array($photo, $user_id, $user[2], $user[3], $user[4], $user[5], $button);
    }
    return $users;
}
コード例 #23
0
function search_users($needle, $type)
{
    global $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id, $userStatus;
    $xajax_response = new xajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        $assigned_users_to_hrm = array();
        switch ($userStatus) {
            case DRH:
                //no break;
            //no break;
            case PLATFORM_ADMIN:
                $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
                break;
            case STUDENT_BOSS:
                $assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
                break;
        }
        $assigned_users_id = array_keys($assigned_users_to_hrm);
        $without_assigned_users = '';
        $westernOrder = api_is_western_name_order();
        if ($westernOrder) {
            $order_clause = " ORDER BY firstname, lastname";
        } else {
            $order_clause = " ORDER BY lastname, firstname";
        }
        if (count($assigned_users_id) > 0) {
            $without_assigned_users = " AND user.user_id NOT IN(" . implode(',', $assigned_users_id) . ")";
        }
        if (api_is_multiple_url_enabled()) {
            $sql = "SELECT user.user_id, username, lastname, firstname\n                    FROM {$tbl_user} user\n                    LEFT JOIN {$tbl_access_url_rel_user} au ON (au.user_id = user.user_id)\n                    WHERE\n                        " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND\n                        status NOT IN(" . DRH . ", " . SESSIONADMIN . ", " . STUDENT_BOSS . ") AND\n                        user.user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id})\n                        {$without_assigned_users} AND\n                        access_url_id = " . api_get_current_access_url_id() . "\n                    {$order_clause}\n                    ";
        } else {
            $sql = "SELECT user_id, username, lastname, firstname\n                    FROM {$tbl_user} user\n                    WHERE\n                        " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND\n                        status NOT IN(" . DRH . ", " . SESSIONADMIN . ", " . STUDENT_BOSS . ") AND\n                        user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id})\n                    {$without_assigned_users}\n                    {$order_clause}\n            ";
        }
        $rs = Database::query($sql);
        $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
        if ($type == 'single') {
            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
            $access_url_id = api_get_current_access_url_id();
            $sql = 'SELECT user.user_id, username, lastname, firstname
                    FROM ' . $tbl_user . ' user
                    INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id)
                    WHERE
                        access_url_id = ' . $access_url_id . '  AND
                        (
                            username LIKE "' . $needle . '%" OR
                            firstname LIKE "' . $needle . '%" OR
                            lastname LIKE "' . $needle . '%"
                        ) AND ';
            switch ($userStatus) {
                case DRH:
                    $sql .= " user.status <> 6 AND user.status <> " . DRH;
                    break;
                case STUDENT_BOSS:
                    $sql .= " user.status <> 6 AND user.status <> " . STUDENT_BOSS;
                    break;
            }
            $sql .= " {$order_clause} LIMIT 11";
            $rs = Database::query($sql);
            $i = 0;
            while ($user = Database::fetch_array($rs)) {
                $i++;
                if ($i <= 10) {
                    $person_name = api_get_person_name($user['firstname'], $user['lastname']);
                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_user(\'' . $user['user_id'] . '\',\'' . $person_name . ' (' . $user['username'] . ')' . '\')">' . $person_name . ' (' . $user['username'] . ')</a><br />';
                } else {
                    $return .= '...<br />';
                }
            }
            $xajax_response->addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return));
        } else {
            $return .= '<select id="origin" class="form-control" name="NoAssignedUsersList[]" multiple="multiple" size="15" ">';
            while ($user = Database::fetch_array($rs)) {
                $person_name = api_get_person_name($user['firstname'], $user['lastname']);
                $return .= '<option value="' . $user['user_id'] . '" title="' . htmlspecialchars($person_name, ENT_QUOTES) . '">' . $person_name . ' (' . $user['username'] . ')</option>';
            }
            $return .= '</select>';
            $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
        }
    }
    return $xajax_response;
}
コード例 #24
0
ファイル: survey.lib.php プロジェクト: jloguercio/chamilo-lms
 static function get_survey_data_for_coach($from, $number_of_items, $column, $direction)
 {
     $survey_tree = new SurveyTree();
     $last_version_surveys = $survey_tree->get_last_children_from_branch($survey_tree->surveylist);
     $list = array();
     foreach ($last_version_surveys as &$survey) {
         $list[] = $survey['id'];
     }
     if (count($list) > 0) {
         $list_condition = " AND survey.survey_id IN (" . implode(',', $list) . ") ";
     } else {
         $list_condition = '';
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $column = intval($column);
     if (!in_array(strtolower($direction), array('asc', 'desc'))) {
         $direction = 'asc';
     }
     $table_survey = Database::get_course_table(TABLE_SURVEY);
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $course_id = api_get_course_int_id();
     //IF(is_shared<>0,'V','-')	 					AS col6,
     $sql = "SELECT " . "survey.survey_id\t\t\t\t\t\t\tAS col0, " . "survey.title\t                            AS col1, " . "survey.code\t\t\t\t\t\t\t\t\tAS col2, " . "count(survey_question.question_id)\t\t\tAS col3, " . (api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)") . "\tAS col4, " . "survey.avail_from\t\t\t\t\t\t\tAS col5, " . "survey.avail_till\t\t\t\t\t\t\tAS col6, " . "CONCAT('<a href=\"survey_invitation.php?view=answered&survey_id=',survey.survey_id,'\">',survey.answered,'</a> / <a href=\"survey_invitation.php?view=invited&survey_id=',survey.survey_id,'\">',survey.invited, '</a>')\tAS col7, " . "survey.anonymous\t\t\t\t\t\t\tAS col8, " . "survey.survey_id\t\t\t\t\t\t\tAS col9  " . "FROM {$table_survey} survey " . "LEFT JOIN {$table_survey_question} survey_question\n             ON (survey.survey_id = survey_question.survey_id AND survey.c_id = survey_question.c_id) " . ", {$table_user} user\n               WHERE survey.author = user.user_id AND survey.c_id = {$course_id} {$list_condition} ";
     $sql .= " GROUP BY survey.survey_id";
     $sql .= " ORDER BY col{$column} {$direction} ";
     $sql .= " LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $surveys = array();
     while ($survey = Database::fetch_array($res)) {
         $surveys[] = $survey;
     }
     return $surveys;
 }
コード例 #25
0
 /**
  * Function used by SortableTable to generate the data to display
  */
 function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
 {
     $is_western_name_order = api_is_western_name_order();
     // create page navigation if needed
     $totalitems = $this->datagen->get_total_items_count();
     if ($this->limit_enabled && $totalitems > LIMIT) {
         $selectlimit = LIMIT;
     } else {
         $selectlimit = $totalitems;
     }
     if ($this->limit_enabled && $totalitems > LIMIT) {
         $calcprevious = LIMIT;
         $header .= '<table style="width: 100%; text-align: right; margin-left: auto; margin-right: auto;" border="0" cellpadding="2">' . '<tbody>' . '<tr>';
         // previous X
         $header .= '<td style="width:100%;">';
         if ($this->offset >= LIMIT) {
             $header .= '<a href="' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&offset=' . ($this->offset - LIMIT) . (isset($_GET['search']) ? '&search=' . Security::remove_XSS($_GET['search']) : '') . '">' . Display::return_icon('action_prev.png', get_lang('PreviousPage'), array(), 32) . '</a>';
         } else {
             $header .= Display::return_icon('action_prev_na.png', get_lang('PreviousPage'), array(), 32);
         }
         $header .= ' ';
         // next X
         $calcnext = $this->offset + 2 * LIMIT > $totalitems ? $totalitems - (LIMIT + $this->offset) : LIMIT;
         if ($calcnext > 0) {
             $header .= '<a href="' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&offset=' . ($this->offset + LIMIT) . (isset($_GET['search']) ? '&search=' . Security::remove_XSS($_GET['search']) : '') . '">' . Display::return_icon('action_next.png', get_lang('NextPage'), array(), 32) . '</a>';
         } else {
             $header .= Display::return_icon('action_next_na.png', get_lang('NextPage'), array(), 32);
         }
         $header .= '</td>';
         $header .= '</tbody></table>';
         echo $header;
     }
     // retrieve sorting type
     if ($is_western_name_order) {
         $users_sorting = $this->column == 0 ? FlatViewDataGenerator::FVDG_SORT_FIRSTNAME : FlatViewDataGenerator::FVDG_SORT_LASTNAME;
     } else {
         $users_sorting = $this->column == 0 ? FlatViewDataGenerator::FVDG_SORT_LASTNAME : FlatViewDataGenerator::FVDG_SORT_FIRSTNAME;
     }
     if ($this->direction == 'DESC') {
         $users_sorting |= FlatViewDataGenerator::FVDG_SORT_DESC;
     } else {
         $users_sorting |= FlatViewDataGenerator::FVDG_SORT_ASC;
     }
     // step 1: generate columns: evaluations and links
     $header_names = $this->datagen->get_header_names($this->offset, $selectlimit);
     $column = 0;
     if ($is_western_name_order) {
         $this->set_header($column++, $header_names[1]);
         $this->set_header($column++, $header_names[0]);
     } else {
         $this->set_header($column++, $header_names[0]);
         $this->set_header($column++, $header_names[1]);
     }
     while ($column < count($header_names)) {
         $this->set_header($column, $header_names[$column], false);
         $column++;
     }
     $data_array = $this->datagen->get_data($users_sorting, $from, $this->per_page, $this->offset, $selectlimit);
     $table_data = array();
     foreach ($data_array as $user_row) {
         $table_row = array();
         $count = 0;
         $user_id = $user_row[$count++];
         $lastname = $user_row[$count++];
         $firstname = $user_row[$count++];
         if ($is_western_name_order) {
             $table_row[] = $this->build_name_link($user_id, $firstname);
             $table_row[] = $this->build_name_link($user_id, $lastname);
         } else {
             $table_row[] = $this->build_name_link($user_id, $lastname);
             $table_row[] = $this->build_name_link($user_id, $firstname);
         }
         while ($count < count($user_row)) {
             $table_row[] = $user_row[$count++];
         }
         $table_data[] = $table_row;
     }
     return $table_data;
 }
コード例 #26
0
    /**
     * Builds a result form containing inputs for all students with a given course_code
     */
    protected function build_result_add_form()
    {
        $renderer =& $this->defaultRenderer();
        $renderer->setFormTemplate('<form{attributes}>
		      <table class="data_table">
              {content}
		      </table>
		   </form>');
        $tblusers = GradebookUtils::get_users_in_course($this->evaluation_object->get_course_code());
        $nr_users = 0;
        //extra field for check on maxvalue
        $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
        $this->addElement('hidden', 'minvalue', 0);
        $this->addElement('header', get_lang('AddResult'));
        if (api_is_western_name_order()) {
            $renderer->setHeaderTemplate('<tr>
                   <th>' . get_lang('OfficialCode') . '</th>
                  <th>' . get_lang('UserName') . '</th>
                  <th>' . get_lang('FirstName') . '</th>
                  <th>' . get_lang('LastName') . '</th>
                  <th>' . get_lang('Qualify') . '</th>
               </tr>');
        } else {
            $renderer->setHeaderTemplate('<tr>
                   <th>' . get_lang('OfficialCode') . '</th>
                  <th>' . get_lang('UserName') . '</th>
                  <th>' . get_lang('LastName') . '</th>
                  <th>' . get_lang('FirstName') . '</th>
                  <th>' . get_lang('Qualify') . '</th>
               </tr>');
        }
        $firstUser = true;
        foreach ($tblusers as $user) {
            $element_name = 'score[' . $user[0] . ']';
            $scoreColumnProperties = array('maxlength' => 5);
            if ($firstUser) {
                $scoreColumnProperties['autofocus'] = '';
                $firstUser = false;
            }
            //user_id, user.username, lastname, firstname
            $this->addText($element_name, $this->build_stud_label($user[0], $user[1], $user[2], $user[3]), false, $scoreColumnProperties);
            $this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric');
            $this->addRule(array($element_name, 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
            $this->addRule(array($element_name, 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
            if (api_is_western_name_order()) {
                $user_info = '<td align="left" >' . $user[3] . '</td>';
                $user_info .= '<td align="left" >' . $user[2] . '</td>';
            } else {
                $user_info = '<td align="left" >' . $user[2] . '</td>';
                $user_info .= '<td align="left" >' . $user[3] . '</td>';
            }
            $nr_users++;
            $template = '<tr>
		      <td align="left" >' . $user[4] . '</td>
		      <td align="left" >' . $user[1] . '</td>
		      ' . $user_info . '
		       <td align="left">{element} / ' . $this->evaluation_object->get_max() . '
		         <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
		      </td>
            </tr>';
            $renderer->setElementTemplate($template, $element_name);
        }
        $this->addElement('hidden', 'nr_users', $nr_users);
        $this->addElement('hidden', 'evaluation_id', $this->result_object->get_evaluation_id());
        $this->addButtonSave(get_lang('AddResult'), 'submit');
        $template_submit = '<tr>
                <td colspan="4" ></td>
                <td >
                {element}
                    <!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
                </td>
            </tr>';
        $renderer->setElementTemplate($template_submit, 'submit');
    }
コード例 #27
0
ファイル: courseLog.php プロジェクト: annickvdp/Chamilo1.9.10
    if ($export_csv) {
        $csv_content = array();
        //override the SortableTable "per page" limit if CSV
        $_GET['users_tracking_per_page'] = 1000000;
    }

    $all_datas = array();
    $course_code = $_course['id'];

    $user_ids = array_keys($a_students);

    $table = new SortableTable(
        'users_tracking',
        array('TrackingCourseLog', 'get_number_of_users'),
        array('TrackingCourseLog', 'get_user_data'),
        (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);

    $parameters['cidReq'] 		= Security::remove_XSS($_GET['cidReq']);
    $parameters['id_session'] 	= $session_id;
    $parameters['from'] 		= isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;

    $table->set_additional_parameters($parameters);
    $tab_table_header = array();
    // tab of header texts
    $table->set_header(0, get_lang('OfficialCode'), true);
    $tab_table_header[] = get_lang('OfficialCode');
    if ($is_western_name_order) {
        $table->set_header(1, get_lang('FirstName'), true);
        $tab_table_header[] = get_lang('FirstName');
        $table->set_header(2, get_lang('LastName'), true);
        $tab_table_header[] = get_lang('LastName');
コード例 #28
0
 /**
  * Gets the exam'data results
  * @todo this function should be moved in a library  + no global calls
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param int $exercise_id
  * @param null $extra_where_conditions
  * @param bool $get_count
  * @return array
  */
 public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
 {
     //@todo replace all this globals
     global $documentPath, $filter;
     $course_id = api_get_course_int_id();
     $sessionId = api_get_session_id();
     $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
     $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
     $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
     $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
     $TBL_GROUP = Database::get_course_table(TABLE_GROUP);
     $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
     $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
     $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
     $exercise_id = intval($exercise_id);
     $exercise_where = '';
     if (!empty($exercise_id)) {
         $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . '  ';
     }
     $hotpotatoe_where = '';
     if (!empty($_GET['path'])) {
         $hotpotatoe_path = Database::escape_string($_GET['path']);
         $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '"  ';
     }
     // sql for chamilo-type tests for teacher / tutor view
     $sql_inner_join_tbl_track_exercices = "\n        (\n            SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n            FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n            ON (ttte.exe_id = tr.exe_id)\n            WHERE\n                c_id = {$course_id} AND\n                exe_exo_id = {$exercise_id} AND\n                ttte.session_id = " . $sessionId . "\n        )";
     if ($is_allowedToEdit) {
         //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
         // Hack in order to filter groups
         $sql_inner_join_tbl_user = '';
         if (strpos($extra_where_conditions, 'group_id')) {
             $sql_inner_join_tbl_user = "******" . $course_id . ")\n                    INNER JOIN {$TBL_GROUP} g\n                    ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n                )";
         }
         if (strpos($extra_where_conditions, 'group_all')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_all'  )", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions);
             $sql_inner_join_tbl_user = "******";
             $sql_inner_join_tbl_user = null;
         }
         if (strpos($extra_where_conditions, 'group_none')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_none'  )", "AND (  group_id is null  )", $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND (  group_id is null  )", $extra_where_conditions);
             $sql_inner_join_tbl_user = "******" . $course_id . " )\n                LEFT OUTER JOIN {$TBL_GROUP} g\n                ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n            )";
         }
         // All
         $is_empty_sql_inner_join_tbl_user = false;
         if (empty($sql_inner_join_tbl_user)) {
             $is_empty_sql_inner_join_tbl_user = true;
             $sql_inner_join_tbl_user = "******" . api_get_users_status_ignored_in_reports('string') . ")\n            )";
         }
         $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru ";
         $sqlWhereOption = "  AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id ";
         $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
         if ($get_count) {
             $sql_select = "SELECT count(te.exe_id) ";
         } else {
             $sql_select = "SELECT DISTINCT\n                    user_id,\n                    {$first_and_last_name},\n                    official_code,\n                    ce.title,\n                    username,\n                    te.exe_result,\n                    te.exe_weighting,\n                    te.exe_date,\n                    te.exe_id,\n                    email as exemail,\n                    te.start_date,\n                    steps_counter,\n                    exe_user_id,\n                    te.exe_duration,\n                    propagate_neg,\n                    revised,\n                    group_name,\n                    group_id,\n                    orig_lp_id,\n                    te.user_ip";
         }
         $sql = " {$sql_select}\n                FROM {$TBL_EXERCICES} AS ce\n                INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n                ON (te.exe_exo_id = ce.id)\n                INNER JOIN {$sql_inner_join_tbl_user} AS user\n                ON (user.user_id = exe_user_id)\n                WHERE\n                    te.status != 'incomplete' AND\n                    te.c_id = " . $course_id . " {$session_id_and} AND\n                    ce.active <>-1 AND ce.c_id = " . $course_id . "\n                    {$exercise_where}\n                    {$extra_where_conditions}\n                ";
         // sql for hotpotatoes tests for teacher / tutor view
         if ($get_count) {
             $hpsql_select = "SELECT count(username)";
         } else {
             $hpsql_select = "SELECT\n                    {$first_and_last_name} ,\n                    username,\n                    official_code,\n                    tth.exe_name,\n                    tth.exe_result ,\n                    tth.exe_weighting,\n                    tth.exe_date";
         }
         $hpsql = " {$hpsql_select}\n                FROM\n                    {$TBL_TRACK_HOTPOTATOES} tth,\n                    {$TBL_USER} user\n                    {$sqlFromOption}\n                WHERE\n                    user.user_id=tth.exe_user_id\n                    AND tth.c_id = " . $course_id . "\n                    {$hotpotatoe_where}\n                    {$sqlWhereOption}\n                    AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n                ORDER BY\n                    tth.c_id ASC,\n                    tth.exe_date DESC";
     }
     if ($get_count) {
         $resx = Database::query($sql);
         $rowx = Database::fetch_row($resx, 'ASSOC');
         return $rowx[0];
     }
     $teacher_list = CourseManager::getTeacherListFromCourse(api_get_course_int_id());
     $teacher_id_list = array();
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher) {
             $teacher_id_list[] = $teacher['user_id'];
         }
     }
     $list_info = array();
     // Simple exercises
     if (empty($hotpotatoe_where)) {
         $column = !empty($column) ? Database::escape_string($column) : null;
         $from = intval($from);
         $number_of_items = intval($number_of_items);
         if (!empty($column)) {
             $sql .= " ORDER BY {$column} {$direction} ";
         }
         $sql .= " LIMIT {$from}, {$number_of_items}";
         $results = array();
         $resx = Database::query($sql);
         while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
             $results[] = $rowx;
         }
         $group_list = GroupManager::get_group_list();
         $clean_group_list = array();
         if (!empty($group_list)) {
             foreach ($group_list as $group) {
                 $clean_group_list[$group['id']] = $group['name'];
             }
         }
         $lp_list_obj = new LearnpathList(api_get_user_id());
         $lp_list = $lp_list_obj->get_flat_list();
         if (is_array($results)) {
             $users_array_id = array();
             $from_gradebook = false;
             if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
                 $from_gradebook = true;
             }
             $sizeof = count($results);
             $user_list_id = array();
             $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
             // Looping results
             for ($i = 0; $i < $sizeof; $i++) {
                 $revised = $results[$i]['revised'];
                 if ($from_gradebook && $is_allowedToEdit) {
                     if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) {
                         continue;
                     }
                     $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'];
                 }
                 $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null;
                 $lp_name = null;
                 if ($lp_obj) {
                     $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
                     $lp_name = Display::url($lp_obj['lp_name'], $url, array('target' => '_blank'));
                 }
                 //Add all groups by user
                 $group_name_list = null;
                 if ($is_empty_sql_inner_join_tbl_user) {
                     $group_list = GroupManager::get_group_ids(api_get_course_int_id(), $results[$i]['user_id']);
                     foreach ($group_list as $id) {
                         $group_name_list .= $clean_group_list[$id] . '<br/>';
                     }
                     $results[$i]['group_name'] = $group_name_list;
                 }
                 $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0;
                 $user_list_id[] = $results[$i]['exe_user_id'];
                 $id = $results[$i]['exe_id'];
                 $dt = api_convert_and_format_date($results[$i]['exe_weighting']);
                 // we filter the results if we have the permission to
                 if (isset($results[$i]['results_disabled'])) {
                     $result_disabled = intval($results[$i]['results_disabled']);
                 } else {
                     $result_disabled = 0;
                 }
                 if ($result_disabled == 0) {
                     $my_res = $results[$i]['exe_result'];
                     $my_total = $results[$i]['exe_weighting'];
                     $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']);
                     $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']);
                     if (!$results[$i]['propagate_neg'] && $my_res < 0) {
                         $my_res = 0;
                     }
                     $score = self::show_score($my_res, $my_total);
                     $actions = '';
                     if ($is_allowedToEdit) {
                         if (isset($teacher_id_list)) {
                             if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) {
                                 $actions .= Display::return_icon('teachers.gif', get_lang('Teacher'));
                             }
                         }
                         if ($revised) {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id={$id}'>" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL);
                             $actions .= '&nbsp;';
                         } else {
                             $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id={$id}'>" . Display::return_icon('quiz.gif', get_lang('Qualify'));
                             $actions .= '&nbsp;';
                         }
                         $actions .= "</a>";
                         if ($filter == 2) {
                             $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . Display::return_icon('history.gif', get_lang('ViewHistoryChange')) . '</a>';
                         }
                         //Admin can always delete the attempt
                         if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
                             $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false);
                             $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">';
                             $actions .= Display::return_icon('info.png', $ip, ['title' => $ip]);
                             $actions .= '</a>';
                             $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user='******'filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '"
                             onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $results[$i]['username'], $dt) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
                             $delete_link = utf8_encode($delete_link);
                             if (api_is_drh() && !api_is_platform_admin()) {
                                 $delete_link = null;
                             }
                             $actions .= $delete_link . '&nbsp;';
                         }
                     } else {
                         $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
                         $attempt_link = Display::url(get_lang('Show'), $attempt_url, ['class' => 'ajax btn btn-default', 'data-title' => get_lang('Show')]);
                         $actions .= $attempt_link;
                     }
                     if ($revised) {
                         $revised = Display::label(get_lang('Validated'), 'success');
                     } else {
                         $revised = Display::label(get_lang('NotValidated'), 'info');
                     }
                     if ($is_allowedToEdit) {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['lp'] = $lp_name;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     } else {
                         $results[$i]['status'] = $revised;
                         $results[$i]['score'] = $score;
                         $results[$i]['actions'] = $actions;
                         $list_info[] = $results[$i];
                     }
                 }
             }
         }
     } else {
         $hpresults = StatsUtils::getManyResultsXCol($hpsql, 6);
         // Print HotPotatoes test results.
         if (is_array($hpresults)) {
             for ($i = 0; $i < sizeof($hpresults); $i++) {
                 $hp_title = GetQuizName($hpresults[$i][3], $documentPath);
                 if ($hp_title == '') {
                     $hp_title = basename($hpresults[$i][3]);
                 }
                 $hp_date = api_get_local_time($hpresults[$i][6], null, date_default_timezone_get());
                 $hp_result = round($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1) * 100, 2) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')';
                 if ($is_allowedToEdit) {
                     $list_info[] = array($hpresults[$i][0], $hpresults[$i][1], $hpresults[$i][2], '', $hp_title, '-', $hp_date, $hp_result, '-');
                 } else {
                     $list_info[] = array($hp_title, '-', $hp_date, $hp_result, '-');
                 }
             }
         }
     }
     return $list_info;
 }
コード例 #29
0
 /**
  * Function used by SortableTable to generate the data to display
  */
 function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
 {
     $is_western_name_order = api_is_western_name_order();
     $scoredisplay = ScoreDisplay::instance();
     // determine sorting type
     $col_adjust = $this->iscourse == '1' ? 1 : 0;
     switch ($this->column) {
         // first name or last name
         case 0 + $col_adjust:
             if ($is_western_name_order) {
                 $sorting = ResultsDataGenerator::RDG_SORT_FIRSTNAME;
             } else {
                 $sorting = ResultsDataGenerator::RDG_SORT_LASTNAME;
             }
             break;
             // first name or last name
         // first name or last name
         case 1 + $col_adjust:
             if ($is_western_name_order) {
                 $sorting = ResultsDataGenerator::RDG_SORT_LASTNAME;
             } else {
                 $sorting = ResultsDataGenerator::RDG_SORT_FIRSTNAME;
             }
             break;
             //Score
         //Score
         case 2 + $col_adjust:
             $sorting = ResultsDataGenerator::RDG_SORT_SCORE;
             break;
         case 3 + $col_adjust:
             $sorting = ResultsDataGenerator::RDG_SORT_MASK;
             break;
     }
     if ($this->direction == 'DESC') {
         $sorting |= ResultsDataGenerator::RDG_SORT_DESC;
     } else {
         $sorting |= ResultsDataGenerator::RDG_SORT_ASC;
     }
     $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
     // generate the data to display
     $sortable_data = array();
     foreach ($data_array as $item) {
         $row = array();
         if ($this->iscourse == '1') {
             $row[] = $item['result_id'];
         }
         if ($is_western_name_order) {
             $row[] = $item['firstname'];
             $row[] = $item['lastname'];
         } else {
             $row[] = $item['lastname'];
             $row[] = $item['firstname'];
         }
         $row[] = Display::bar_progress($item['percentage_score'], false, $item['score']);
         //$row[] =  Display::bar_progress($item['percentage_score'], true);
         if ($scoredisplay->is_custom()) {
             $row[] = $item['display'];
         }
         if (!$this->forprint) {
             $row[] = $this->build_edit_column($item);
         }
         $sortable_data[] = $row;
     }
     return $sortable_data;
 }
コード例 #30
0
 /**
  * @param FormValidator $form
  * @param array $sendTo array('everyone' => false, 'users' => [1, 2], 'groups' => [3, 4])
  * @param array $attributes
  * @param bool $addOnlyItemsInSendTo
  * @param bool $required
  * @return bool
  */
 public function showToForm($form, $sendTo = array(), $attributes = array(), $addOnlyItemsInSendTo = false, $required = false)
 {
     if ($this->type != 'course') {
         return false;
     }
     $order = 'lastname';
     if (api_is_western_name_order()) {
         $order = 'firstname';
     }
     $userList = CourseManager::get_user_list_from_course_code(api_get_course_id(), $this->sessionId, null, $order);
     $groupList = CourseManager::get_group_list_of_course(api_get_course_id(), $this->sessionId);
     $this->setSendToSelect($form, $groupList, $userList, $sendTo, $attributes, $addOnlyItemsInSendTo, $required);
     return true;
 }