30 => '30 '.get_lang('Days'), 'never' => get_lang('Never') ); $el = $form->addElement( 'select', 'since', '<img width="ICON_SIZE_SMALL" align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.get_lang('RemindInactivesLearnersSince'), $options ); $el->setSelected(7); $form->addElement('hidden', 'action', 'add'); $form->addElement('hidden', 'remindallinactives', 'true'); $extra_field_select = TrackingCourseLog::display_additional_profile_fields(); if (!empty($extra_field_select)) { echo $extra_field_select; } $form->display(); 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'];
/** * @param $from * @param $number_of_items * @param $column * @param $direction * @return array */ public static function get_item_resources_data($from, $number_of_items, $column, $direction) { $session_id = api_get_session_id(); $course_id = api_get_course_int_id(); $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $table_user = Database::get_main_table(TABLE_MAIN_USER); $table_session = Database::get_main_table(TABLE_MAIN_SESSION); $session_id = intval($session_id); $sql = "SELECT\n tool as col0,\n lastedit_type as col1,\n ref as ref,\n user.username as col3,\n insert_date as col5,\n visibility as col6,\n user.user_id as user_id\n FROM {$table_item_property} track_resource, {$table_user} user\n WHERE\n track_resource.c_id = {$course_id} AND\n track_resource.insert_user_id = user.user_id AND\n session_id = {$session_id} "; if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (\n \t\t user.username LIKE '%" . $keyword . "%' OR\n \t\t lastedit_type LIKE '%" . $keyword . "%' OR\n \t\t tool LIKE '%" . $keyword . "%'\n ) "; } $sql .= " AND tool IN (\n \t 'document',\n \t 'learnpath',\n \t 'quiz',\n \t 'glossary',\n \t 'link',\n \t 'course_description',\n \t 'announcement',\n \t 'thematic',\n \t 'thematic_advance',\n \t 'thematic_plan'\n )"; if ($column == 0) { $column = '0'; } if ($column != '' && $direction != '') { if ($column != 2 && $column != 4) { $sql .= " ORDER BY col{$column} {$direction}"; } } else { $sql .= " ORDER BY col5 DESC "; } $from = intval($from); $number_of_items = intval($number_of_items); $sql .= " LIMIT {$from}, {$number_of_items} "; $res = Database::query($sql); $resources = array(); $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan'); while ($row = Database::fetch_array($res)) { $ref = $row['ref']; $table_name = TrackingCourseLog::get_tool_name_table($row['col0']); $table_tool = Database::get_course_table($table_name['table_name']); $id = $table_name['id_tool']; $recorset = false; if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { $tbl_thematic = Database::get_course_table(TABLE_THEMATIC); $sql = "SELECT thematic_id FROM {$table_tool}\n \t\t\t WHERE c_id = {$course_id} AND id = {$ref}"; $rs_thematic = Database::query($sql); if (Database::num_rows($rs_thematic)) { $row_thematic = Database::fetch_array($rs_thematic); $thematic_id = $row_thematic['thematic_id']; $sql = "SELECT session.id, session.name, user.username\n FROM {$tbl_thematic} t, {$table_session} session, {$table_user} user\n WHERE\n t.c_id = {$course_id} AND\n t.session_id = session.id AND\n session.id_coach = user.user_id AND\n t.id = {$thematic_id}"; $recorset = Database::query($sql); } } else { $sql = "SELECT session.id, session.name, user.username\n FROM {$table_tool} tool, {$table_session} session, {$table_user} user\n \t\t\t WHERE\n \t\t\t tool.c_id = {$course_id} AND\n \t\t\t tool.session_id = session.id AND\n \t\t\t session.id_coach = user.user_id AND\n \t\t\t tool.{$id} = {$ref}"; $recorset = Database::query($sql); } if (!empty($recorset)) { $obj = Database::fetch_object($recorset); $name_session = ''; $coach_name = ''; if (!empty($obj)) { $name_session = $obj->name; $coach_name = $obj->username; } $url_tool = api_get_path(WEB_CODE_PATH) . $table_name['link_tool']; $row[0] = ''; if ($row['col6'] != 2) { if (in_array($row['col0'], $thematic_tools)) { $exp_thematic_tool = explode('_', $row['col0']); $thematic_tool_title = ''; if (is_array($exp_thematic_tool)) { foreach ($exp_thematic_tool as $exp) { $thematic_tool_title .= api_ucfirst($exp); } } else { $thematic_tool_title = api_ucfirst($row['col0']); } $row[0] = '<a href="' . $url_tool . '?' . api_get_cidreq() . '&action=thematic_details">' . get_lang($thematic_tool_title) . '</a>'; } else { $row[0] = '<a href="' . $url_tool . '?' . api_get_cidreq() . '">' . get_lang('Tool' . api_ucfirst($row['col0'])) . '</a>'; } } else { $row[0] = api_ucfirst($row['col0']); } $row[1] = get_lang($row[1]); $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get()); $row[5] = ''; //@todo Improve this code please switch ($table_name['table_name']) { case 'document': $sql = "SELECT tool.title as title FROM {$table_tool} tool\n WHERE c_id = {$course_id} AND id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); $row[5] = $obj_document->title; break; case 'announcement': $sql = "SELECT title FROM {$table_tool}\n WHERE c_id = {$course_id} AND id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); if ($obj_document) { $row[5] = $obj_document->title; } break; case 'glossary': $sql = "SELECT name FROM {$table_tool}\n \t\t\t\t\t WHERE c_id = {$course_id} AND glossary_id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); if ($obj_document) { $row[5] = $obj_document->name; } break; case 'lp': $sql = "SELECT name\n FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); $row[5] = $obj_document->name; break; case 'quiz': $sql = "SELECT title FROM {$table_tool}\n WHERE c_id = {$course_id} AND id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); if ($obj_document) { $row[5] = $obj_document->title; } break; case 'course_description': $sql = "SELECT title FROM {$table_tool}\n WHERE c_id = {$course_id} AND id = {$ref}"; $rs_document = Database::query($sql); $obj_document = Database::fetch_object($rs_document); if ($obj_document) { $row[5] = $obj_document->title; } break; case 'thematic': $rs = Database::query("SELECT title FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}"); if (Database::num_rows($rs) > 0) { $obj = Database::fetch_object($rs); $row[5] = $obj->title; } break; case 'thematic_advance': $rs = Database::query("SELECT content FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}"); if (Database::num_rows($rs) > 0) { $obj = Database::fetch_object($rs); $row[5] = $obj->content; } break; case 'thematic_plan': $rs = Database::query("SELECT title FROM {$table_tool} WHERE c_id = {$course_id} AND id = {$ref}"); if (Database::num_rows($rs) > 0) { $obj = Database::fetch_object($rs); $row[5] = $obj->title; } break; default: break; } $row2 = $name_session; if (!empty($coach_name)) { $row2 .= '<br />' . get_lang('Coach') . ': ' . $coach_name; } $row[2] = $row2; if (!empty($row['col3'])) { $userInfo = api_get_user_info($row['user_id']); $row['col3'] = Display::url($row['col3'], $userInfo['profile_url']); $row[3] = $row['col3']; $ip = TrackingUserLog::get_ip_from_user_event($row['user_id'], $row['col5'], true); if (empty($ip)) { $ip = get_lang('Unknown'); } $row[4] = $ip; } $resources[] = $row; } } return $resources; }