Juan Carlos Raña 14 роки тому
батько
коміт
0bdfc48cec

+ 3 - 2
documentation/changelog.html

@@ -25,8 +25,8 @@
    <li>New application of a drop-down menu to select where to save new documents created (Feature #1758)</li>
    <li>Added possibility to chose target in links even when not on homepage (Feature #1879)</li>
    <li>Now showing teachers results in exercises results list (was confusing for most teachers)</li>
-   <li>Update Google Maps plugin to 1.98 (Feature #1925)</li>
-   <li>Add a personal portfolio to Social Network. All users can easy copy some files from several courses in his/her personal portfolio (Feature #1853)</li>
+   <li>Updated Google Maps plugin to 1.98 (Feature #1925)</li>
+   <li>Added a personal portfolio to Social Network. All users can easy copy some files from several courses in his/her personal portfolio (Feature #1853)</li>
    <li>Students can edit, move and delete documents and drawings; create, move and delete subfolders, create user templates and make personal backups into a course inside his user shared folder (Features #2076, #2484)</li>
    <li>Learning Path: New LP exercises reports added for teachers and admins (Feature BT#1634)</li>
    <li>Support for displaying vector graphics files (SVG) and multimedia OGG files, facilitating the inclusion of videos and audios in HTML 5 (Feature #2244)</li>
@@ -48,6 +48,7 @@
    <li>Students also can export documents to pdf</li>
    <li>Easy enabled for spellcheck button on web editor (Feature #2207)</li>
    <li>Increased control by platform administrator on the visibility of the folders in the documents tool (Feature #2164,#2484)</li>
+   <li>Added admin feature to hide tools from all courses - BT#1942</li>
    <li>Mp3 audio files generation from a text. Mp3 audio files generation from a text. Teachers, students (into his/her user folder) and groups can create and save mp3 audio files from a text through external service support speech synthesis of Google (build and save) and vozMe (build and download)(Feature #2497)</li>
 </ul>
 <h3>Debugging</h3>

+ 6 - 6
main/auth/sso/sso.class.php

@@ -10,12 +10,12 @@
 /**
  * The SSO class allows for management or remote Single Sign On resources
  */
-public class sso {
-    public var $protocol; //    'http://',
-    public var $domain; //    'localhost/project/drupal5',
-    public var $auth_uri; //    '/?q=user',
-    public var $deauth_uri; //    '/?q=logout',
-    public var $referer; // http://my.chamilo.com/main/auth/profile.php
+class sso {
+    public $protocol; //    'http://',
+    public $domain; //    'localhost/project/drupal5',
+    public $auth_uri; //    '/?q=user',
+    public $deauth_uri; //    '/?q=logout',
+    public $referer; // http://my.chamilo.com/main/auth/profile.php
 
     /**
      * Instanciates the object, initializing all relevant URL strings

BIN
main/img/file_epub.gif


BIN
main/img/file_epub_small.gif


+ 5 - 96
main/inc/lib/career.lib.php

@@ -7,107 +7,16 @@
 *	@package chamilo.library
 */
 
-class Career {
+require_once 'model.lib.php';
+
+class Career extends Model {
     
     var $table;
-    var $columns = array('name','description');
+    var $columns = array('id', 'name','description');
     
 	public function __construct() {
         $this->table =  Database::get_main_table(TABLE_CAREER);
-	}
-    
-	/**
-	 * a little bit of javascript to display a prettier warning when deleting a note
-	 *
-	 * @return unknown
-	 *
-	 */
-	function javascript_notebook()
-	{
-		return "<script type=\"text/javascript\">
-				function confirmation (name)
-				{
-					if (confirm(\" ". get_lang("NoteConfirmDelete") ." \"+ name + \" ?\"))
-						{return true;}
-					else
-						{return false;}
-				}
-				</script>";
-	}
-
-	/**
-	 * Saves an element into the DB
-	 *
-	 * @param array $values
-	 * @return bool
-	 *
-	 */
-	function save($values) {
-		/*if (!is_array($values) or empty($values['note_title'])) { 
-			return false; 
-		}*/		        
-        unset($values['submit']);
-        $id = Database::insert($this->table, $values);        
-		if (is_numeric($id)){
-			return $id;
-		}
-	}
-    
-    /**
-     * Gets an element
-     */
-	function get($id) {
-		if (empty($id)) { return array(); }		
-        $result = Database::select('*',$this->table, array('where'=>array('id = ?'=>intval($id))),'first');
-        return $result;
-	}
-    
-    function get_all() {
-    	return $careers = Database::select('*',$this->table);
-    }
-    
-    /**
-     * Get the count of elements
-     */
-    function get_count() {        
-        $row = Database::select('count(*) as count', $this->table, array(),'first');
-        return $row['count'];
-    }
-    
-
-	/**
-	 * Updates the obj in the database
-	 *
-	 * @param array $values
-	 *
-	 */
-	function update($values) {
-		/*if (!is_array($values) or empty($values['note_title'])) {
-			return false;
-		}*/
-        unset($values['submit']);
-		$table = Database :: get_main_table(TABLE_CAREER);
-        $id = $values['id'];
-        unset($values['id']);
-        $result = Database::update($this->table, $values, array('id = ?'=>$id));		
-        if ($result != 1){
-            return false;
-        }       
-        return true;
-	}
-    
-    /**
-     * Delets an item
-     */
-	function delete($id) {
-		if (empty($id) or $id != strval(intval($id))) { return false; }
-		// Database table definition
-		$result = Database :: delete($this->table, array('id = ?' => $id));        
-        if ($result != 1){
-        	return false;
-        }		
-		return true;
-	}
+	}    
     
     /**
      * Displays the title + grid

+ 20 - 1
main/inc/lib/course_home.lib.php

@@ -473,8 +473,27 @@ class CourseHome {
 					break;
 		}
 
+        //Get the list of hidden tools - this might imply performance slowdowns
+        // if the course homepage is loaded many times, so the list of hidden
+        // tools might benefit from a shared memory storage later on 
+        $list = api_get_settings('Tools','list',api_get_current_access_url_id());
+        $hide_list = array();
+        $check = false;
+        foreach ($list as $line) {
+        	if ($line['variable'] == 'course_hide_tools' and $line['selected_value'] == 'true') {
+        		$hide_list[] = $line['subkey'];
+                $check = true;
+        	}
+        }
 		while ($temp_row = Database::fetch_assoc($result)) {
-			$all_tools_list[] = $temp_row;
+            if ($check) {
+            	if (!in_array($temp_row['name'],$hide_list)) {
+                    $all_tools_list[] = $temp_row;        		
+            	} else {
+            	}
+            } else {
+                    $all_tools_list[] = $temp_row;
+            }
 		}
 
 		/*if(api_is_course_coach()) {

Різницю між файлами не показано, бо вона завелика
+ 914 - 913
main/inc/lib/document.lib.php


+ 152 - 151
main/inc/lib/fileDisplay.lib.php

@@ -11,27 +11,27 @@
 /*	GENERIC FUNCTIONS : FOR OLDER PHP VERSIONS */
 if ( ! function_exists('array_search') )
 {
-	/**
-	 * Searches haystack for needle and returns the key
-	 * if it is found in the array, FALSE otherwise.
-	 *
-	 * Natively implemented in PHP since 4.0.5 version.
-	 * This function is intended for previous version.
-	 *
-	 * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
-	 * @param  - needle (mixed)
-	 * @param  - haystack (array)
-	 * @return - array key or FALSE
-	 *
-	 * @see    - http://www.php.net/array_search
-	 */
-	function array_search($needle, $haystack)
-	{
-		while (list($key, $val) = each($haystack))
-			if ($val == $needle)
-				return $key;
-		return false;
-	}
+    /**
+     * Searches haystack for needle and returns the key
+     * if it is found in the array, FALSE otherwise.
+     *
+     * Natively implemented in PHP since 4.0.5 version.
+     * This function is intended for previous version.
+     *
+     * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
+     * @param  - needle (mixed)
+     * @param  - haystack (array)
+     * @return - array key or FALSE
+     *
+     * @see    - http://www.php.net/array_search
+     */
+    function array_search($needle, $haystack)
+    {
+        while (list($key, $val) = each($haystack))
+            if ($val == $needle)
+                return $key;
+        return false;
+    }
 }
 
 /* FILE DISPLAY FUNCTIONS */
@@ -45,65 +45,66 @@ if ( ! function_exists('array_search') )
  */
 function choose_image($file_name)
 {
-	static $type, $image;
+    static $type, $image;
+
+    /* TABLES INITIALISATION */
+    if (!$type || !$image)
+    {
+        $type['word'      ] = array('doc', 'dot',  'rtf', 'mcw',  'wps', 'psw', 'docm', 'docx', 'dotm',  'dotx');
+        $type['web'       ] = array('htm', 'html', 'htx', 'xml',  'xsl',  'php', 'xhtml');
+        $type['image'     ] = array('gif', 'jpg',  'png', 'bmp',  'jpeg');
+        $type['image_vect'] = array('svg','svgz');
+        $type['audio'     ] = array('wav', 'mid',  'mp2', 'mp3',  'midi', 'sib', 'amr', 'kar', 'oga');
+        $type['video'     ] = array('mp4', 'mov',  'rm',  'pls',  'mpg',  'mpeg', 'au', 'flv', 'avi', 'wmv', 'asf', '3gp','ogv','ogg','ogx');
+        $type['excel'     ] = array('xls', 'xlt',  'xls', 'xlt', 'pxl', 'xlsx', 'xlsm', 'xlam', 'xlsb', 'xltm', 'xltx');
+        $type['compressed'] = array('zip', 'tar',  'rar', 'gz');
+        $type['code'      ] = array('js',  'cpp',  'c',   'java', 'phps');
+        $type['acrobat'   ] = array('pdf');
+        $type['powerpoint'] = array('ppt', 'pps', 'pptm', 'pptx', 'potm', 'potx', 'ppam', 'ppsm', 'ppsx');
+        $type['flash'     ] = array('fla', 'swf');
+        $type['text'      ] = array('txt','log');
+        $type['oo_writer' ] = array('odt', 'ott', 'sxw', 'stw');
+        $type['oo_calc'   ] = array('ods', 'ots', 'sxc', 'stc');
+        $type['oo_impress'] = array('odp', 'otp', 'sxi', 'sti');
+        $type['oo_draw'   ] = array('odg', 'otg', 'sxd', 'std');
+        $type['epub'      ] = array('epub');
 
-	/* TABLES INITIALISATION */
-	if (!$type || !$image)
-	{
-		$type['word'      ] = array('doc', 'dot',  'rtf', 'mcw',  'wps', 'psw', 'docm', 'docx', 'dotm',  'dotx');
-		$type['web'       ] = array('htm', 'html', 'htx', 'xml',  'xsl',  'php', 'xhtml');
-		$type['image'     ] = array('gif', 'jpg',  'png', 'bmp',  'jpeg');
-		$type['image_vect'] = array('svg','svgz');
-		$type['audio'     ] = array('wav', 'mid',  'mp2', 'mp3',  'midi', 'sib', 'amr', 'kar', 'oga');
-		$type['video'     ] = array('mp4', 'mov',  'rm',  'pls',  'mpg',  'mpeg', 'au', 'flv', 'avi', 'wmv', 'asf', '3gp','ogv','ogg','ogx');
-		$type['excel'     ] = array('xls', 'xlt',  'xls', 'xlt', 'pxl', 'xlsx', 'xlsm', 'xlam', 'xlsb', 'xltm', 'xltx');
-		$type['compressed'] = array('zip', 'tar',  'rar', 'gz');
-		$type['code'      ] = array('js',  'cpp',  'c',   'java', 'phps');
-		$type['acrobat'   ] = array('pdf');
-		$type['powerpoint'] = array('ppt', 'pps', 'pptm', 'pptx', 'potm', 'potx', 'ppam', 'ppsm', 'ppsx');
-		$type['flash'     ] = array('fla', 'swf');
-		$type['text'      ] = array('txt','log');
-		$type['oo_writer' ] = array('odt', 'ott', 'sxw', 'stw');
-		$type['oo_calc'   ] = array('ods', 'ots', 'sxc', 'stc');
-		$type['oo_impress'] = array('odp', 'otp', 'sxi', 'sti');
-		$type['oo_draw'   ] = array('odg', 'otg', 'sxd', 'std');
-		
+        $image['word'      ] = 'word.gif';
+        $image['web'       ] = 'file_html.gif';
+        $image['image'     ] = 'file_image.gif';
+        $image['image_vect'] = 'file_svg.png';
+        $image['audio'     ] = 'file_sound.gif';
+        $image['video'     ] = 'film.gif';
+        $image['excel'     ] = 'excel.gif';
+        $image['compressed'] = 'file_zip.gif';
+        $image['code'      ] = 'file_txt.gif';
+        $image['acrobat'   ] = 'file_pdf.gif';
+        $image['powerpoint'] = 'powerpoint.gif';
+        $image['flash'     ] = 'file_flash.gif';
+        $image['text'      ] = 'file_txt.gif';
+        $image['oo_writer' ] = 'file_oo_writer.gif';
+        $image['oo_calc'   ] = 'file_oo_calc.gif';
+        $image['oo_impress'] = 'file_oo_impress.gif';
+        $image['oo_draw'   ] = 'file_oo_draw.gif';
+        $image['epub'      ] = 'file_epub.gif';
+    }
 
-		$image['word'      ] = 'word.gif';
-		$image['web'       ] = 'file_html.gif';
-		$image['image'     ] = 'file_image.gif';
-		$image['image_vect'] = 'file_svg.png';
-		$image['audio'     ] = 'file_sound.gif';
-		$image['video'     ] = 'film.gif';
-		$image['excel'     ] = 'excel.gif';
-		$image['compressed'] = 'file_zip.gif';
-		$image['code'      ] = 'file_txt.gif';
-		$image['acrobat'   ] = 'file_pdf.gif';
-		$image['powerpoint'] = 'powerpoint.gif';
-		$image['flash'     ] = 'file_flash.gif';
-		$image['text'      ] = 'file_txt.gif';
-		$image['oo_writer' ] = 'file_oo_writer.gif';
-		$image['oo_calc'   ] = 'file_oo_calc.gif';
-		$image['oo_impress'] = 'file_oo_impress.gif';
-		$image['oo_draw'   ] = 'file_oo_draw.gif';
-	}
+    /* FUNCTION CORE */
+    $extension = array();
+    if (!is_array($file_name)) {
+        if (ereg('\.([[:alnum:]]+)(\?|$)', $file_name, $extension)) {
+            $extension[1] = strtolower($extension[1]);
 
-	/* FUNCTION CORE */
-	$extension = array();
-	if (!is_array($file_name)) {
-		if (ereg('\.([[:alnum:]]+)$', $file_name, $extension)) {
-			$extension[1] = strtolower($extension[1]);
-	
-			foreach ($type as $generic_type => $extension_list)
-			{
-				if (in_array($extension[1], $extension_list))
-				{
-					return $image[$generic_type];
-				}
-			}
-		}
-	}
-	return 'defaut.gif';
+            foreach ($type as $generic_type => $extension_list)
+            {
+                if (in_array($extension[1], $extension_list))
+                {
+                    return $image[$generic_type];
+                }
+            }
+        }
+    }
+    return 'defaut.gif';
 }
 
 /**
@@ -114,24 +115,24 @@ function choose_image($file_name)
  */
 function format_file_size($file_size)
 {
-	if($file_size >= 1073741824)
-	{
-		$file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
-	}
-	elseif($file_size >= 1048576)
-	{
-		$file_size = round($file_size / 1048576 * 100) / 100 . 'M';
-	}
-	elseif($file_size >= 1024)
-	{
-		$file_size = round($file_size / 1024 * 100) / 100 . 'k';
-	}
-	else
-	{
-		$file_size = $file_size . 'B';
-	}
+    if($file_size >= 1073741824)
+    {
+        $file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
+    }
+    elseif($file_size >= 1048576)
+    {
+        $file_size = round($file_size / 1048576 * 100) / 100 . 'M';
+    }
+    elseif($file_size >= 1024)
+    {
+        $file_size = round($file_size / 1024 * 100) / 100 . 'k';
+    }
+    else
+    {
+        $file_size = $file_size . 'B';
+    }
 
-	return $file_size;
+    return $file_size;
 }
 
 /**
@@ -143,7 +144,7 @@ function format_file_size($file_size)
  */
 function format_date($date)
 {
-	return date('d.m.Y', $date);
+    return date('d.m.Y', $date);
 }
 
 /**
@@ -154,11 +155,11 @@ function format_date($date)
  */
 function format_url($file_path)
 {
-	$path_component = explode('/', $file_path);
+    $path_component = explode('/', $file_path);
 
-	$path_component = array_map('rawurlencode', $path_component);
+    $path_component = array_map('rawurlencode', $path_component);
 
-	return implode('/', $path_component);
+    return implode('/', $path_component);
 }
 
 /**
@@ -171,29 +172,29 @@ function format_url($file_path)
 function recent_modified_file_time($dir_name, $do_recursive = true)
 {
 
-	$dir = dir($dir_name);
-	$last_modified = 0;
-	$return = 0;
-	if (is_dir($dir)) {
-		while(($entry = $dir->read()) !== false)
-		{
-			if ($entry != '.' && $entry != '..')
-				continue;
+    $dir = dir($dir_name);
+    $last_modified = 0;
+    $return = 0;
+    if (is_dir($dir)) {
+        while(($entry = $dir->read()) !== false)
+        {
+            if ($entry != '.' && $entry != '..')
+                continue;
 
-			if (!is_dir($dir_name.'/'.$entry))
-				$current_modified = filemtime($dir_name.'/'.$entry);
-			elseif ($do_recursive)
-				$current_modified = recent_modified_file_time($dir_name.'/'.$entry, true);
+            if (!is_dir($dir_name.'/'.$entry))
+                $current_modified = filemtime($dir_name.'/'.$entry);
+            elseif ($do_recursive)
+                $current_modified = recent_modified_file_time($dir_name.'/'.$entry, true);
 
-			if ($current_modified > $last_modified)
-				$last_modified = $current_modified;
-		}
+            if ($current_modified > $last_modified)
+                $last_modified = $current_modified;
+        }
 
-		$dir->close();
-		//prevents returning 0 (for empty directories)
-		$return = ($last_modified == 0) ? filemtime($dir_name) : $last_modified;
-	}
-	return $return;
+        $dir->close();
+        //prevents returning 0 (for empty directories)
+        $return = ($last_modified == 0) ? filemtime($dir_name) : $last_modified;
+    }
+    return $return;
 }
 
 /**
@@ -204,22 +205,22 @@ function recent_modified_file_time($dir_name, $do_recursive = true)
  */
 function folder_size($dir_name)
 {
-	$size = 0;
+    $size = 0;
 
-	if ($dir_handle = opendir($dir_name))
-	{
-		while (($entry = readdir($dir_handle)) !== false)
-		{
-			if($entry == '.' || $entry == '..')
-				continue;
+    if ($dir_handle = opendir($dir_name))
+    {
+        while (($entry = readdir($dir_handle)) !== false)
+        {
+            if($entry == '.' || $entry == '..')
+                continue;
 
-        	if(is_dir($dir_name.'/'.$entry))
-        		$size += folder_size($dir_name.'/'.$entry);
-        	else
-        		$size += filesize($dir_name.'/'.$entry);
-		}
+            if(is_dir($dir_name.'/'.$entry))
+                $size += folder_size($dir_name.'/'.$entry);
+            else
+                $size += filesize($dir_name.'/'.$entry);
+        }
 
-		closedir($dir_handle);
+        closedir($dir_handle);
     }
 
     return $size;
@@ -235,31 +236,31 @@ function folder_size($dir_name)
  */
 function get_total_folder_size($path, $can_see_invisible = false)
 {
-	$table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
-	$table_document = Database::get_course_table(TABLE_DOCUMENT);
-	$tool_document = TOOL_DOCUMENT;
+    $table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
+    $table_document = Database::get_course_table(TABLE_DOCUMENT);
+    $tool_document = TOOL_DOCUMENT;
 
-	$visibility_rule = 'props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1');
+    $visibility_rule = 'props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1');
 
-	$sql = <<<EOQ
+    $sql = <<<EOQ
 SELECT SUM(size)
-	FROM $table_itemproperty AS props, $table_document AS docs
-	WHERE docs.id = props.ref
-		AND props.tool = '$tool_document'
-		AND path LIKE '$path/%'
-		AND $visibility_rule
+    FROM $table_itemproperty AS props, $table_document AS docs
+    WHERE docs.id = props.ref
+        AND props.tool = '$tool_document'
+        AND path LIKE '$path/%'
+        AND $visibility_rule
 EOQ;
 
-	$result = Database::query($sql);
+    $result = Database::query($sql);
 
-	if($result && Database::num_rows($result) != 0)
-	{
-		$row = Database::fetch_row($result);
-		return $row[0] == null ? 0 : $row[0];
-	}
-	else
-	{
-		return 0;
-	}
+    if($result && Database::num_rows($result) != 0)
+    {
+        $row = Database::fetch_row($result);
+        return $row[0] == null ? 0 : $row[0];
+    }
+    else
+    {
+        return 0;
+    }
 }
 ?>

+ 5 - 1
main/inc/lib/main_api.lib.php

@@ -4122,7 +4122,11 @@ function api_get_current_access_url_id() {
         $access_url_id = Database::result($result, 0, 0);
         return $access_url_id;
     }
-    return -1;
+    //if the url in WEB_PATH was not found, it can only mean that there is
+    // either a configuration problem or the first URL has not been defined yet
+    // (by default it is http://localhost/). Thus the more sensible thing we can
+    // do is return 1 (the main URL) as the user cannot hack this value anyway 
+    return 1;
 }
 
 /**

+ 122 - 0
main/inc/lib/model.lib.php

@@ -0,0 +1,122 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+*	This class provides methods for the notebook management.
+*	Include/require it in your code to use its features.
+*	@package chamilo.library
+*/
+
+class Model {
+    
+    var $table;
+    var $columns;
+    
+	public function __construct() {
+	}
+    
+    
+    /**
+     * Delets an item
+     */
+    function delete($id) {
+        if (empty($id) or $id != strval(intval($id))) { return false; }
+        // Database table definition
+        $result = Database :: delete($this->table, array('id = ?' => $id));        
+        if ($result != 1){
+            return false;
+        }       
+        return true;
+    }
+    
+    private function clean_parameters($params){
+        $clean_params = array();
+        if (!empty($params)) {
+            foreach($params as $key=>$value) {
+                if (in_array($key, $this->columns)) {
+                    $clean_params[$key] = $value;
+                }           
+            }
+        }
+        return $clean_params;
+    }
+    
+    /**
+     * Displays the title + grid
+     */
+    function display() { 
+    }    
+    
+
+     
+    /**
+     * Gets an element
+     */
+    function get($id) {
+        if (empty($id)) { return array(); }     
+        $result = Database::select('*',$this->table, array('where'=>array('id = ?'=>intval($id))),'first');
+        return $result;
+    }
+    
+    function get_all() {
+        return $careers = Database::select('*',$this->table);
+    }
+    
+    /**
+     * Get the count of elements
+     */
+    function get_count() {        
+        $row = Database::select('count(*) as count', $this->table, array(),'first');
+        return $row['count'];
+    }
+        
+    /**
+     * a little bit of javascript to display a prettier warning when deleting a note
+     *
+     * @return unknown
+     *
+     */
+	function javascript()
+	{
+		
+	}
+
+	/**
+	 * Saves an element into the DB
+	 *
+	 * @param array $values
+	 * @return bool
+	 *
+	 */
+	function save($values) {
+        $values = $this->clean_parameters($values);
+        if (!empty($values)) {
+            $id = Database::insert($this->table, $values);        
+    		if (is_numeric($id)){
+    			return $id;
+    		}
+        }
+        return false;
+	}
+    
+    /**
+     * Updates the obj in the database
+     *
+     * @param array $values
+     *
+     */
+    function update($values) {
+        $values = $this->clean_parameters($values);
+        if (!empty($values)) {
+            $id = $values['id'];
+            unset($values['id']);
+            $result = Database::update($this->table, $values, array('id = ?'=>$id));        
+            if ($result){
+                return true;
+            }       
+        }
+        return false;
+    }
+   
+    
+}

+ 6 - 89
main/inc/lib/promotion.lib.php

@@ -7,104 +7,21 @@
 *	@package chamilo.library
 */
 
-class Promotion {
+require_once 'model.lib.php';
+
+class Promotion extends Model {
     
     var $table;
-    var $columns = array('name','description');
+    var $columns = array('id','name','description','career_id');
     
 	public function __construct() {
         $this->table =  Database::get_main_table(TABLE_PROMOTION);
 	}
     
-	/**
-	 * a little bit of javascript to display a prettier warning when deleting a note
-	 *
-     *	 */
-	function javascript_notebook()
-	{
-		return "<script type=\"text/javascript\">
-				function confirmation (name)
-				{
-					if (confirm(\" ". get_lang("NoteConfirmDelete") ." \"+ name + \" ?\"))
-						{return true;}
-					else
-						{return false;}
-				}
-				</script>";
-	}
-
-
-    /**
-     * Saves an element into the DB
-     *
-     * @param array $values
-     * @return bool
-     *
-     */
-	function save($values) {
-		/*if (!is_array($values) or empty($values['note_title'])) { 
-			return false; 
-		}*/		        
-        unset($values['submit']);
-        $id = Database::insert($this->table, $values);        
-		if (is_numeric($id)){
-			return $id;
-		}
-	}
-     /**
-     * Gets an element
-     */
-	function get($id) {
-		if (empty($id)) { return array(); }		
-        $result = Database::select('*',$this->table, array('where'=>array('id = ?'=>intval($id))),'first');
-		return $result;
-	}
-    
-     /**
-     * Get the count of elements
-     */
-    function get_count() {        
-        $row = Database::select('count(*) as count', $this->table, array(),'first');
-        return $row['count'];
-    }
-    
     function get_all_promotions_by_career_id($career_id) {        
         return Database::select('*', $this->table, array('where'=>array('career_id = ?'=>$career_id)));
-    }
-    
-    /**
-     * Updates the obj in the database
-     *
-     * @param array $values
-     *
-     */
-	function update($values) {
-		/*if (!is_array($values) or empty($values['note_title'])) {
-			return false;
-		}*/
-        unset($values['submit']);
-        $id = $values['id'];		
-        unset($values['id']);        
-        $result = Database::update($this->table, $values, array('id =  ?'=>$id));		
-        if ($result != 1){
-            return false;
-        }       
-        return true;
-	}
-    
-    /**
-     * Delets an item
-     */
-	function delete($id) {
-		if (empty($id) or $id != strval(intval($id))) { return false; }
-		// Database table definition
-		$result = Database :: delete($this->table, array('id = ?' => $id));        
-        if ($result != 1){
-        	return false;
-        }		
-		return true;
-	}
-    
+    }    
+   
     /**
      * Displays the title + grid
      */

+ 25 - 1
main/install/db_main.sql

@@ -791,7 +791,31 @@ VALUES
 ('show_default_folders',				NULL,'radio',		'Tools',	'true',	'ShowDefaultFoldersTitle','ShowDefaultFoldersComment',NULL,NULL, 0),
 ('show_chat_folder',				NULL,'radio',		'Tools',	'true',	'ShowChatFolderTitle','ShowChatFolderComment',NULL,NULL, 0),
 ('enabled_text2audio',				NULL,'radio',		'Tools',	'false',	'Text2AudioTitle','Text2AudioComment',NULL,NULL, 0),
-('chamilo_database_version', 		NULL,'textfield', 	NULL, '1.8.8.13309','DokeosDatabaseVersion','', NULL, NULL, 0);
+('course_hide_tools','course_description','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseDescription', 1),
+('course_hide_tools','calendar_event','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Agenda', 1),
+('course_hide_tools','document','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Documents', 1),
+('course_hide_tools','learnpath','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'LearningPath', 1),
+('course_hide_tools','link','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Links', 1),
+('course_hide_tools','announcement','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Announcements', 1),
+('course_hide_tools','forum','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Forums', 1),
+('course_hide_tools','dropbox','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Dropbox', 1),
+('course_hide_tools','quiz','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Quiz', 1),
+('course_hide_tools','user','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Users', 1),
+('course_hide_tools','group','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Groups', 1),
+('course_hide_tools','chat','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Chat', 1),
+('course_hide_tools','student_publication','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'StudentPublications', 1),
+('course_hide_tools','wiki','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Wiki', 1),
+('course_hide_tools','gradebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Gradebook', 1),
+('course_hide_tools','survey','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Survey', 1),
+('course_hide_tools','glossary','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Glossary', 1),
+('course_hide_tools','notebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Notebook', 1),
+('course_hide_tools','attendance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Attendances', 1),
+('course_hide_tools','course_progress','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseProgress', 1),
+('course_hide_tools','blog_management','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Blog',1),
+('course_hide_tools','tracking','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Stats',1),
+('course_hide_tools','course_maintenance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Maintenance',1),
+('course_hide_tools','course_setting','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseSettings',1),
+('chamilo_database_version', 		NULL,'textfield', 	NULL, '1.8.8.13330','DokeosDatabaseVersion','', NULL, NULL, 0);
 
 
 UNLOCK TABLES;

+ 26 - 2
main/install/migrate-db-1.8.7-1.8.8-pre.sql

@@ -25,7 +25,6 @@ ALTER TABLE settings_options CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_
 ALTER TABLE user MODIFY COLUMN username VARCHAR(40) NOT NULL;
 
 UPDATE settings_current SET variable='chamilo_database_version' WHERE variable='dokeos_database_version';
-UPDATE settings_current SET selected_value = '1.8.8.13309' WHERE variable = 'chamilo_database_version';
 
 ALTER TABLE sys_announcement ADD COLUMN access_url_id INT  NOT NULL default 1;
 ALTER TABLE sys_calendar ADD COLUMN access_url_id INT  NOT NULL default 1;
@@ -87,7 +86,6 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('pdf_export
 
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('pdf_export_watermark_text',		NULL,'textfield',	'Platform',	'',		'PDFExportWatermarkTextTitle','PDFExportWatermarkTextComment','platform',NULL, 	1);
 
-
 ALTER TABLE personal_agenda ADD PRIMARY KEY (id);
 
 UPDATE settings_current SET selected_value='1' WHERE variable='more_buttons_maximized_mode';
@@ -119,6 +117,32 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
 INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_text2audio', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_text2audio', 'false', 'No');
 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_description','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseDescription', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','calendar_event','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Agenda', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','document','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Documents', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','learnpath','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'LearningPath', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','link','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Links', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','announcement','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Announcements', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','forum','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Forums', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','dropbox','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Dropbox', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','quiz','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Quiz', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','user','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Users', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','group','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Groups', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','chat','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Chat', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','student_publication','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'StudentPublications', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','wiki','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Wiki', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','gradebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Gradebook', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','survey','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Survey', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','glossary','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Glossary', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','notebook','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Notebook', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','attendance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Attendances', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_progress','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseProgress', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','blog_management','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Blog',1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','tracking','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Stats',1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_maintenance','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'Maintenance',1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_hide_tools','course_setting','checkbox','Tools','false','CourseHideToolsTitle','CourseHideToolsComment',NULL,'CourseSettings',1);
+
+UPDATE settings_current SET selected_value = '1.8.8.13330' WHERE variable = 'chamilo_database_version';
 
 -- xxSTATSxx
 ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;

+ 1 - 1
main/newscorm/learnpath.class.php

@@ -8667,7 +8667,7 @@ EOD;
             //Setting my lp_id to autolunch = 1        
             $attributes['autolunch'] = 1;
             $where = array('id = ? AND session_id = ? '=> array($lp_id, api_get_session_id()));
-            Database::update_query($lp_table, $attributes, $where );
+            Database::update($lp_table, $attributes, $where );
         }
     }
     

Деякі файли не було показано, через те що забагато файлів було змінено