Browse Source

[svn r22400] Added session fetcher method
Added session name in title for session edition pages (partially fixes private FS#4436)

Yannick Warnier 15 years ago
parent
commit
9957badf43

+ 3 - 2
main/admin/add_courses_to_session.php

@@ -280,8 +280,9 @@ echo '<div class="actions">';
 echo $link_add_type_unique.$link_add_type_multiple;
 echo '</div>';
 
-// the form header 
-echo '<div class="row"><div class="form_header">'.$tool_name.'</div></div>';
+// the form header
+$session_info = SessionManager::fetch($id_session);
+echo '<div class="row"><div class="form_header">'.$tool_name.' ('.$session_info['name'].')</div></div>';
 
 
 /*$sql = 'SELECT COUNT(1) FROM '.$tbl_course;

+ 4 - 24
main/admin/add_users_to_session.php

@@ -1,26 +1,5 @@
-<?php
-/*
-==============================================================================
-	Dokeos - elearning and course management software
-
-	Copyright (c) 2004-2009 Dokeos SPRL
-	Copyright (c) 2003 Ghent University (UGent)
-	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	Copyright (c) Olivier Brouckaert
-
-	For a full list of contributors, see "credits.txt".
-	The full license can be read in "license.txt".
-
-	This program is free software; you can redistribute it and/or
-	modify it under the terms of the GNU General Public License
-	as published by the Free Software Foundation; either version 2
-	of the License, or (at your option) any later version.
-
-	See the GNU General Public License for more details.
-
-	Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
-==============================================================================
-*/
+<?php //$id: $
+/* For licensing terms, see /dokeos_license.txt */
 /**
 ==============================================================================
 *	@package dokeos.admin
@@ -275,8 +254,9 @@ if($_POST['form_sent']) {
 	}
 }
 
+$session_info = SessionManager::fetch($id_session);
 Display::display_header($tool_name);
-api_display_tool_title($tool_name);
+api_display_tool_title($tool_name.' ('.$session_info['name'].')');
 
 $nosessionUsersList = $sessionUsersList = array();
 /*$sql = 'SELECT COUNT(1) FROM '.$tbl_user;

+ 14 - 1
main/inc/lib/sessionmanager.lib.php

@@ -1,4 +1,4 @@
-<?php
+<?php //$id: $
 /* For licensing terms, see /dokeos_license.txt */
 /**
 ==============================================================================
@@ -13,6 +13,19 @@ class SessionManager {
 	private function __construct() {
 		
 	}
+    /**
+     * Fetches a session from the database
+     * @param   int     Session ID
+     * @return  array   Session details (id, id_coach, name, nbr_courses, nbr_users, nbr_classes, date_start, date_end, nb_days_access_before_beginning,nb_days_access_after_end, session_admin_id)
+     */
+    public static function fetch($id) {
+    	$t = Database::get_main_table(TABLE_MAIN_SESSION);
+        if ($id != strval(intval($id))) { return array(); }
+        $s = "SELECT * FROM $t WHERE id = $id";
+        $r = Database::query($s,__FILE__,__LINE__);
+        if (Database::num_rows($r) != 1) { return array(); }
+        return Database::fetch_array($r,'ASSOC');
+    }
 	 /** 
 	  * Create a session 
 	  * @author Carlos Vargas <carlos.vargas@dokeos.com>,from existing code