@@ -15,6 +15,10 @@ |
||
15 | 15 | |
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | + |
|
19 | + /** |
|
20 | + * @param string $handler |
|
21 | + */ |
|
18 | 22 | public static function hasRight($handler) { |
19 | 23 | if (array_key_exists($handler, self::$rights_cache)) |
20 | 24 | return self::$rights_cache[$handler]; |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | */ |
7 | 7 | class Rights { |
8 | 8 | private static $rights_cache = array(); |
9 | - private static $rights = array ( |
|
9 | + private static $rights = array( |
|
10 | 10 | 'show_tabs:reports' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'type' => 'const', |
13 | 13 | 'const' => 'true' ) |
14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | 18 | public static function hasRight($handler) { |
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | + } |
|
21 | 22 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
23 | + if (!array_key_exists($handler, self::$rights)) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + // handler does not exists |
|
24 | 27 | |
25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
30 | + if (Database::num_rows($result) > 0) { |
|
31 | + $result = true; |
|
32 | + } else { |
|
33 | + $result = false; |
|
34 | + } |
|
35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
36 | + $result = self::$rights[$handler]['const']; |
|
37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
38 | + $result = self::$rights[$handler]['func'](); |
|
39 | + } else { |
|
40 | + // handler type not implemented |
|
36 | 41 | return true; |
42 | + } |
|
37 | 43 | self::$rights_cache[$handler] = $result; |
38 | 44 | return $result; |
39 | 45 | } |
40 | 46 | |
41 | 47 | public static function hasRightClosePageWithError($handler) { |
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
48 | + if (hasRight($handler) == false) { |
|
49 | + die("You are not allowed here"); |
|
50 | + } |
|
51 | + //FIXME |
|
44 | 52 | } |
45 | 53 | |
46 | 54 | } |
@@ -71,6 +71,10 @@ |
||
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Get the terms stored at database |
74 | + * @param string $prefix |
|
75 | + * @param string $course_code |
|
76 | + * @param string $tool_id |
|
77 | + * @param integer $ref_id |
|
74 | 78 | * @return array Array of terms |
75 | 79 | */ |
76 | 80 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * code |
9 | 9 | */ |
10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
12 | 12 | |
13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
40 | 40 | return FALSE; |
41 | 41 | |
42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
43 | 43 | |
44 | 44 | // compare terms |
45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | // save it to search engine |
57 | 57 | foreach ($missing_terms as $term) { |
58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
59 | 59 | } |
60 | 60 | foreach ($deprecated_terms as $term) { |
61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return array Array of terms |
75 | 75 | */ |
76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
79 | 79 | $prefix_terms = array(); |
80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
37 | 37 | |
38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
40 | - return FALSE; |
|
39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
40 | + return FALSE; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | $doc = $this->get_document($search_did); |
46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
47 | 48 | $xterms = array(); |
48 | - foreach ($xapian_terms as $xapian_term) |
|
49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
49 | + foreach ($xapian_terms as $xapian_term) { |
|
50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $dterms = $terms; |
52 | 54 |
@@ -23,6 +23,9 @@ discard block |
||
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | +/** |
|
27 | + * @param string $query_string |
|
28 | + */ |
|
26 | 29 | function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
27 | 30 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 31 | } |
@@ -30,7 +33,7 @@ discard block |
||
30 | 33 | /** |
31 | 34 | * Wrapper for getting boolean queries |
32 | 35 | * |
33 | - * @param string $query_string The term string |
|
36 | + * @param string $term |
|
34 | 37 | */ |
35 | 38 | function chamilo_get_boolean_query($term) { |
36 | 39 | return xapian_get_boolean_query($term); |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | * @param array extra Extra queries to join with. Optional |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function chamilo_query_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
21 | +function chamilo_query_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
22 | 22 | list($count, $results) = xapian_query($query_string, NULL, $offset, $length, $extra); |
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | -function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
26 | +function chamilo_query_simple_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
27 | 27 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 28 | } |
29 | 29 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function chamilo_preprocess_results($results) { |
43 | 43 | // group by toolid |
44 | 44 | $results_by_tool = array(); |
45 | - if (count($results)>0) { |
|
45 | + if (count($results) > 0) { |
|
46 | 46 | |
47 | 47 | foreach ($results as $key => $row) { |
48 | 48 | $results_by_tool[$row['toolid']][] = $row; |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $processed_results = array(); |
52 | 52 | foreach ($results_by_tool as $toolid => $rows) { |
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
53 | + $tool_processor_class = $toolid.'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH).'search/tool_processors/'.$tool_processor_class.'.class.php'; |
|
55 | 55 | if (file_exists($tool_processor_path)) { |
56 | 56 | require_once($tool_processor_path); |
57 | 57 | $tool_processor = new $tool_processor_class($rows); |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | * @param string $op |
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | -function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
|
74 | +function chamilo_join_queries($query1, $query2 = NULL, $op = 'or') { |
|
75 | 75 | return xapian_join_queries($query1, $query2, $op); |
76 | 76 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $query_string The term string |
34 | 34 | */ |
35 | 35 | function chamilo_get_boolean_query($term) { |
36 | - return xapian_get_boolean_query($term); |
|
36 | + return xapian_get_boolean_query($term); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $results_by_tool = array(); |
45 | 45 | if (count($results)>0) { |
46 | 46 | |
47 | - foreach ($results as $key => $row) { |
|
48 | - $results_by_tool[$row['toolid']][] = $row; |
|
49 | - } |
|
47 | + foreach ($results as $key => $row) { |
|
48 | + $results_by_tool[$row['toolid']][] = $row; |
|
49 | + } |
|
50 | 50 | |
51 | - $processed_results = array(); |
|
52 | - foreach ($results_by_tool as $toolid => $rows) { |
|
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | - if (file_exists($tool_processor_path)) { |
|
56 | - require_once($tool_processor_path); |
|
57 | - $tool_processor = new $tool_processor_class($rows); |
|
58 | - $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | - } |
|
60 | - } |
|
51 | + $processed_results = array(); |
|
52 | + foreach ($results_by_tool as $toolid => $rows) { |
|
53 | + $tool_processor_class = $toolid .'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | + if (file_exists($tool_processor_path)) { |
|
56 | + require_once($tool_processor_path); |
|
57 | + $tool_processor = new $tool_processor_class($rows); |
|
58 | + $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return array(count($processed_results), $processed_results); |
|
62 | + return array(count($processed_results), $processed_results); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | 74 | function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
75 | - return xapian_join_queries($query1, $query2, $op); |
|
75 | + return xapian_join_queries($query1, $query2, $op); |
|
76 | 76 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Simple getter for the db attribute |
101 | - * @return object The db attribute |
|
101 | + * @return null|XapianWritableDatabase The db attribute |
|
102 | 102 | */ |
103 | 103 | function getDb() |
104 | 104 | { |
@@ -108,6 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Add this chunk to the chunk array attribute |
110 | 110 | * @param string Chunk of text |
111 | + * @param IndexableChunk $chunk |
|
111 | 112 | * @return void |
112 | 113 | */ |
113 | 114 | function addChunk($chunk) |
@@ -179,7 +180,7 @@ discard block |
||
179 | 180 | * Get document data on a xapian document |
180 | 181 | * |
181 | 182 | * @param XapianDocument $doc xapian document to push into the db |
182 | - * @return mixed xapian document data or FALSE if error |
|
183 | + * @return string xapian document data or FALSE if error |
|
183 | 184 | */ |
184 | 185 | function get_document_data($doc) |
185 | 186 | { |
@@ -286,7 +287,7 @@ discard block |
||
286 | 287 | * Replace a document in the actual db |
287 | 288 | * |
288 | 289 | * @param XapianDocument $doc xapian document to push into the db |
289 | - * @param Xapian::docid $did xapian document id of the document to replace |
|
290 | + * @param integer $did xapian document id of the document to replace |
|
290 | 291 | */ |
291 | 292 | function replace_document($doc, $did) |
292 | 293 | { |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | require_once 'xapian.php'; |
9 | -require_once dirname(__FILE__) . '/../IndexableChunk.class.php'; |
|
9 | +require_once dirname(__FILE__).'/../IndexableChunk.class.php'; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Abstract helper class |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (!empty($chunk->terms)) { |
131 | 131 | foreach ($chunk->terms as $term) { |
132 | 132 | /* FIXME: think of getting weight */ |
133 | - $doc->add_term($term['flag'] . $term['name'], 1); |
|
133 | + $doc->add_term($term['flag'].$term['name'], 1); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $doc->clear_terms(); |
216 | 216 | foreach ($terms as $term) { |
217 | 217 | //add directly |
218 | - $doc->add_term($prefix . $term, 1); |
|
218 | + $doc->add_term($prefix.$term, 1); |
|
219 | 219 | } |
220 | 220 | $this->db->replace_document($did, $doc); |
221 | 221 | $this->db->flush(); |
@@ -70,13 +70,16 @@ |
||
70 | 70 | */ |
71 | 71 | function connectDb($path = null, $dbMode = null, $lang = 'english') |
72 | 72 | { |
73 | - if ($this->db != null) |
|
74 | - return $this->db; |
|
75 | - if ($dbMode == null) |
|
76 | - $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
73 | + if ($this->db != null) { |
|
74 | + return $this->db; |
|
75 | + } |
|
76 | + if ($dbMode == null) { |
|
77 | + $dbMode = Xapian::DB_CREATE_OR_OPEN; |
|
78 | + } |
|
77 | 79 | |
78 | - if ($path == null) |
|
79 | - $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
80 | + if ($path == null) { |
|
81 | + $path = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb/'; |
|
82 | + } |
|
80 | 83 | |
81 | 84 | try { |
82 | 85 | $this->db = new XapianWritableDatabase($path, $dbMode); |
@@ -45,6 +45,8 @@ discard block |
||
45 | 45 | * checker path (directory) |
46 | 46 | * @param string Absolute path to be checked (with trailing slash) |
47 | 47 | * @param string Checker path under which the path should be (absolute path, with trailing slash, get it from api_get_path(SYS_COURSE_PATH)) |
48 | + * @param string $abs_path |
|
49 | + * @param string $checker_path |
|
48 | 50 | * @return bool True if the path is under the checker, false otherwise |
49 | 51 | */ |
50 | 52 | public static function check_abs_path($abs_path, $checker_path) |
@@ -300,6 +302,7 @@ discard block |
||
300 | 302 | * @param string The variable to filter for XSS, this params can be a string or an array (example : array(x,y)) |
301 | 303 | * @param int The user status,constant allowed (STUDENT, COURSEMANAGER, ANONYMOUS, COURSEMANAGERLOWSECURITY) |
302 | 304 | * @param bool $filter_terms |
305 | + * @param integer $user_status |
|
303 | 306 | * @return mixed Filtered string or array |
304 | 307 | */ |
305 | 308 | public static function remove_XSS($var, $user_status = null, $filter_terms = false) |
@@ -453,7 +456,7 @@ discard block |
||
453 | 456 | * This method provides specific protection (against XSS and other kinds of attacks) for static images (icons) used by the system. |
454 | 457 | * Image paths are supposed to be given by programmers - people who know what they do, anyway, this method encourages |
455 | 458 | * a safe practice for generating icon paths, without using heavy solutions based on HTMLPurifier for example. |
456 | - * @param string $img_path The input path of the image, it could be relative or absolute URL. |
|
459 | + * @param string $image_path The input path of the image, it could be relative or absolute URL. |
|
457 | 460 | * @return string Returns sanitized image path or an empty string when the image path is not secure. |
458 | 461 | * @author Ivan Tcholakov, March 2011 |
459 | 462 | */ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $rel_path = '/'.$rel_path; |
92 | 92 | } |
93 | 93 | $abs_path = $current_path.$rel_path; |
94 | - $true_path=str_replace("\\", '/', realpath($abs_path)); |
|
94 | + $true_path = str_replace("\\", '/', realpath($abs_path)); |
|
95 | 95 | $found = strpos($true_path.'/', $checker_path); |
96 | 96 | if ($found === 0) { |
97 | 97 | return true; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | if ($user_status == COURSEMANAGERLOWSECURITY) { |
324 | - return $var; // No filtering. |
|
324 | + return $var; // No filtering. |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | static $purifier = array(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Shows _target attribute in anchors |
347 | - $config->set('Attr.AllowedFrameTargets', array('_blank','_top','_self', '_parent')); |
|
347 | + $config->set('Attr.AllowedFrameTargets', array('_blank', '_top', '_self', '_parent')); |
|
348 | 348 | |
349 | 349 | if ($user_status == STUDENT) { |
350 | 350 | global $allowed_html_student; |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public static function remove_XSS($var, $user_status = null, $filter_terms = false) |
306 | 306 | { |
307 | - if ($filter_terms) { |
|
308 | - $var = self::filter_terms($var); |
|
309 | - } |
|
307 | + if ($filter_terms) { |
|
308 | + $var = self::filter_terms($var); |
|
309 | + } |
|
310 | 310 | |
311 | 311 | if (empty($user_status)) { |
312 | 312 | if (api_is_anonymous()) { |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public static function filter_terms($text) |
403 | 403 | { |
404 | - static $bad_terms = array(); |
|
404 | + static $bad_terms = array(); |
|
405 | 405 | |
406 | 406 | if (empty($bad_terms)) { |
407 | 407 | $list = api_get_setting('filter_terms'); |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - $replace = '***'; |
|
426 | - if (!empty($bad_terms)) { |
|
427 | - // Fast way |
|
428 | - $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | - $text = $new_text; |
|
430 | - } |
|
425 | + $replace = '***'; |
|
426 | + if (!empty($bad_terms)) { |
|
427 | + // Fast way |
|
428 | + $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | + $text = $new_text; |
|
430 | + } |
|
431 | 431 | |
432 | - return $text; |
|
432 | + return $text; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 |
@@ -326,6 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Gets an element |
329 | + * @param integer $gradebook_id |
|
329 | 330 | */ |
330 | 331 | public function get_skill_info($skill_id, $gradebook_id) |
331 | 332 | { |
@@ -544,7 +545,7 @@ discard block |
||
544 | 545 | * Gets an element |
545 | 546 | * @param int $id |
546 | 547 | * |
547 | - * @return array|mixed |
|
548 | + * @return integer |
|
548 | 549 | */ |
549 | 550 | public function get($id) |
550 | 551 | { |
@@ -885,7 +886,7 @@ discard block |
||
885 | 886 | /** |
886 | 887 | * Get user's skills |
887 | 888 | * |
888 | - * @param int $userId User's id |
|
889 | + * @param integer $user_id User's id |
|
889 | 890 | * @param bool $get_skill_data |
890 | 891 | */ |
891 | 892 | public function get_user_skills($user_id, $get_skill_data = false) |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * This function is for editing profile info from profile_id. |
|
37 | - * @param int $profileId |
|
38 | - * @param string $name |
|
39 | - * @param string $description |
|
40 | - */ |
|
36 | + * This function is for editing profile info from profile_id. |
|
37 | + * @param int $profileId |
|
38 | + * @param string $name |
|
39 | + * @param string $description |
|
40 | + */ |
|
41 | 41 | public function updateProfileInfo($profileId, $name, $description) |
42 | 42 | { |
43 | 43 | $profileId = intval($profileId); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * This function is for getting profile info from profile_id. |
|
132 | - * @param int $profileId |
|
133 | - */ |
|
131 | + * This function is for getting profile info from profile_id. |
|
132 | + * @param int $profileId |
|
133 | + */ |
|
134 | 134 | |
135 | 135 | public function getProfileInfo($profileId) |
136 | 136 | { |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $attributes = array( |
804 | 804 | 'skill_id' => $skill_id, |
805 | 805 | 'parent_id' => $parent_id, |
806 | - 'relation_type' => (isset($params['relation_type'])?$params['relation_type']:0), |
|
806 | + 'relation_type' => (isset($params['relation_type']) ? $params['relation_type'] : 0), |
|
807 | 807 | //'level' => $params['level'], |
808 | 808 | ); |
809 | 809 | $skill_rel_skill->save($attributes); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $skills[$skill_id] = $skill_info; |
1013 | 1013 | // Uncomment code below to hide the searched skill |
1014 | 1014 | $skills[$skill_id]['data']['parent_id'] = $skill_info['extra']['parent_id']; |
1015 | - $skills[$skill_id]['parent_id'] = 1; |
|
1015 | + $skills[$skill_id]['parent_id'] = 1; |
|
1016 | 1016 | } |
1017 | 1017 | } |
1018 | 1018 | } |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | $skill['data']['skill_has_gradebook'] = true; |
1078 | 1078 | } |
1079 | 1079 | $refs[$skill['id']] = &$skill; |
1080 | - $flat_array[$skill['id']] = &$skill; |
|
1080 | + $flat_array[$skill['id']] = &$skill; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | // Checking family value |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | $refs['root']['children'][0] = $skills[1]; |
1099 | 1099 | $skills[$skill_id]['data']['family_id'] = 1; |
1100 | 1100 | $refs['root']['children'][0]['children'][0] = $skills[$skill_id]; |
1101 | - $flat_array[$skill_id] = $skills[$skill_id]; |
|
1101 | + $flat_array[$skill_id] = $skills[$skill_id]; |
|
1102 | 1102 | } else { |
1103 | 1103 | // Moving node to the children index of their parents |
1104 | 1104 | |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | $skill['data']['family_id'] = $new_family_array[$skill['id']]; |
1108 | 1108 | } |
1109 | 1109 | $refs[$skill['parent_id']]['children'][] = &$skill; |
1110 | - $flat_array[$my_skill_id] = $skill; |
|
1110 | + $flat_array[$my_skill_id] = $skill; |
|
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | INNER JOIN {$this->table_skill_rel_user} su |
1220 | 1220 | ON (s.id = su.skill_id) |
1221 | 1221 | WHERE user_id = $user_id"; |
1222 | - $result = Database::query($sql); |
|
1222 | + $result = Database::query($sql); |
|
1223 | 1223 | if (Database::num_rows($result)) { |
1224 | 1224 | $result = Database::fetch_row($result); |
1225 | 1225 | return $result[0]; |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | */ |
1262 | 1262 | public function get_user_list_skill_ranking_count() |
1263 | 1263 | { |
1264 | - $sql = "SELECT count(*) FROM ( |
|
1264 | + $sql = "SELECT count(*) FROM ( |
|
1265 | 1265 | SELECT count(distinct 1) |
1266 | 1266 | FROM {$this->table} s |
1267 | 1267 | INNER JOIN {$this->table_skill_rel_user} su |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | ON c.code = g.course_code |
1317 | 1317 | WHERE sg.skill_id = $skill_id |
1318 | 1318 | AND (g.session_id IS NULL OR g.session_id = 0)"; |
1319 | - $result = Database::query($sql); |
|
1319 | + $result = Database::query($sql); |
|
1320 | 1320 | |
1321 | 1321 | return Database::store_result($result, 'ASSOC'); |
1322 | 1322 | } |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | WHERE sg.skill_id = $skillId |
1506 | 1506 | AND g.session_id > 0"; |
1507 | 1507 | |
1508 | - $result = Database::query($sql); |
|
1508 | + $result = Database::query($sql); |
|
1509 | 1509 | |
1510 | 1510 | return Database::store_result($result, 'ASSOC'); |
1511 | 1511 | } |
@@ -30,6 +30,9 @@ |
||
30 | 30 | $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); |
31 | 31 | } |
32 | 32 | |
33 | + /** |
|
34 | + * @param string $class |
|
35 | + */ |
|
33 | 36 | function prepare_skill_box($skill, $position, $class) |
34 | 37 | { |
35 | 38 | $block_id = $skill['id']; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->skills = $skills; |
29 | 29 | $this->type = $type; |
30 | - $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); |
|
30 | + $this->center_x = intval($offset_x + $this->canvas_x / 2 - $this->block_size / 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function prepare_skill_box($skill, $position, $class) |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $extra_class = 'second_window'; |
40 | 40 | } |
41 | 41 | |
42 | - $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">'; |
|
42 | + $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:'.$position['y'].'px; left:'.$position['x'].'px;">'; |
|
43 | 43 | |
44 | - $content = $skill['name']; |
|
44 | + $content = $skill['name']; |
|
45 | 45 | $content .= '<div class="btn-group">'; |
46 | 46 | $content .= Display::url(get_lang('Edit'), '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
47 | 47 | $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | } |
88 | 88 | //default_arrow_color |
89 | 89 | |
90 | - $this->js .= 'var e'.$block_id.' = prepare("block_' . $block_id.'", '.$end_point.');'."\n"; |
|
91 | - $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | - $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n";; |
|
90 | + $this->js .= 'var e'.$block_id.' = prepare("block_'.$block_id.'", '.$end_point.');'."\n"; |
|
91 | + $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_'.$skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | + $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n"; ; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $brothers = array(); |
126 | 126 | |
127 | 127 | foreach ($this->skills as &$skill) { |
128 | - if (!in_array($skill['parent_id'], array(0,1))) { |
|
128 | + if (!in_array($skill['parent_id'], array(0, 1))) { |
|
129 | 129 | continue; |
130 | 130 | } |
131 | - $childs = isset($skill['children']) ? count($skill['children']) : 0 ; |
|
131 | + $childs = isset($skill['children']) ? count($skill['children']) : 0; |
|
132 | 132 | |
133 | 133 | //$x = round($this->offsetX * sin(deg2rad($corner * $count))); |
134 | 134 | //$y = round($this->offsetY * cos(deg2rad($corner * $count))); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | if ($skill['parent_id'] == 0) { |
145 | 145 | //$x = 130*$childs/2; |
146 | 146 | //$x = $this->space_between_blocks_x*$childs/2; |
147 | - $x = $this->canvas_x/2 - $this->block_size/2; |
|
147 | + $x = $this->canvas_x / 2 - $this->block_size / 2; |
|
148 | 148 | } else { |
149 | 149 | $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0; |
150 | - foreach($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
150 | + foreach ($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
151 | 151 | if ($skill['id'] == $sk['id']) { |
152 | 152 | break; |
153 | 153 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | } |
156 | 156 | $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0; |
157 | 157 | //$x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->space_between_blocks_x*$max/2) ; |
158 | - $x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x/2 ) ; |
|
158 | + $x = $my_count * $this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x / 2); |
|
159 | 159 | } |
160 | 160 | |
161 | - $y = $skill['level']*$this->space_between_blocks_y; |
|
161 | + $y = $skill['level'] * $this->space_between_blocks_y; |
|
162 | 162 | |
163 | 163 | $skill['x'] = $x; |
164 | 164 | $skill['y'] = $y; |
165 | 165 | |
166 | 166 | //$skill['description'] = "{$brothers[$skill['parent_id']]} $x - $y"; |
167 | 167 | //$skill['name'] = $skill['name']." | $x = $my_count * 150 + $parent_x - (150* $max/2) - 10*$childs "; |
168 | - $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y)); |
|
168 | + $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y + $y)); |
|
169 | 169 | } |
170 | 170 | return $this->get_html(); |
171 | 171 | } |
@@ -443,6 +443,7 @@ |
||
443 | 443 | * @param bool hide navigation optionally |
444 | 444 | * @param int content per page when show navigation (optional) |
445 | 445 | * @param bool sort data optionally |
446 | + * @param boolean $visibility_options |
|
446 | 447 | * @return string grid html |
447 | 448 | */ |
448 | 449 | public function display_simple_grid($visibility_options, $hide_navigation = true, $per_page = 20, $sort_data = true, $grid_class = array()) |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * This function shows the content of a table in a grid. |
|
343 | - * Should not be use to edit information (edit/delete rows) only. |
|
344 | - **/ |
|
342 | + * This function shows the content of a table in a grid. |
|
343 | + * Should not be use to edit information (edit/delete rows) only. |
|
344 | + **/ |
|
345 | 345 | public function display_grid() |
346 | 346 | { |
347 | 347 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | //$param[$tablename.'_direction'] = $_GET[$tablename.'_direction']; |
791 | 791 | $my_get_direction = $_GET[$tablename.'_direction']; |
792 | 792 | if (!in_array($my_get_direction, array('ASC', 'DESC'))) { |
793 | - $param[$tablename.'_direction'] = 'ASC'; |
|
793 | + $param[$tablename.'_direction'] = 'ASC'; |
|
794 | 794 | } else { |
795 | 795 | $param[$tablename.'_direction'] = $my_get_direction; |
796 | 796 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | if (is_array($row)) { |
918 | 918 | foreach ($row as & $value) { |
919 | 919 | if (empty($value)) { |
920 | - $value = '-'; |
|
920 | + $value = '-'; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $params['spacesBeforeSeparator'] = ''; |
216 | 216 | $params['spacesAfterSeparator'] = ''; |
217 | 217 | $query_vars = array_keys($_GET); |
218 | - $query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); |
|
218 | + $query_vars_needed = array($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); |
|
219 | 219 | if (count($this->additional_parameters) > 0) { |
220 | 220 | $query_vars_needed = array_merge($query_vars_needed, array_keys($this->additional_parameters)); |
221 | 221 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | if (!$empty_table) { |
287 | 287 | if (!empty($this->additional_parameters)) { |
288 | - foreach($this->additional_parameters as $key => $value) { |
|
288 | + foreach ($this->additional_parameters as $key => $value) { |
|
289 | 289 | $html .= '<input type="hidden" name ="'.Security::remove_XSS($key).'" value ="'.Security::remove_XSS($value).'" />'; |
290 | 290 | } |
291 | 291 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $html .= '<li><a data-action ="'.$action.'" href="#" onclick="javascript:action_click(this, \''.$table_id.'\');">'.$label.'</a></li>'; |
311 | 311 | } |
312 | 312 | $html .= '</ul>'; |
313 | - $html .= '</div>';//btn-group |
|
313 | + $html .= '</div>'; //btn-group |
|
314 | 314 | $html .= '</div>'; //toolbar |
315 | 315 | } else { |
316 | 316 | $html .= $form; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | - return '<div class="table-responsive">' . $html . '</div>'; |
|
337 | + return '<div class="table-responsive">'.$html.'</div>'; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | $html .= '<div class="clear"></div>'; |
390 | 390 | if (count($this->form_actions) > 0) { |
391 | - $script= '<script> |
|
391 | + $script = '<script> |
|
392 | 392 | /*<![CDATA[*/ |
393 | 393 | function setCheckbox(value) { |
394 | 394 | d = document.form_'.$this->table_name.'; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | } |
411 | 411 | } |
412 | 412 | // Getting the items of the table |
413 | - $items = $this->get_clean_html(false); //no sort |
|
413 | + $items = $this->get_clean_html(false); //no sort |
|
414 | 414 | |
415 | 415 | // Generation of style classes must be improved. Maybe we need a a table name to create style on the fly: |
416 | 416 | // i.e: .whoisonline_table_grid_container instead of .grid_container |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | $html .= '<div class="clear"></div>'; |
480 | 480 | if (count($this->form_actions) > 0) { |
481 | - $script= '<script> |
|
481 | + $script = '<script> |
|
482 | 482 | /*<![CDATA[*/ |
483 | 483 | function setCheckbox(value) { |
484 | 484 | d = document.form_'.$this->table_name.'; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $counter = 0; |
587 | 587 | foreach ($row as $index => $rowInfo) { |
588 | 588 | if (!isset($this->columnsToHide[$index])) { |
589 | - $newRow[$counter] = $rowInfo ; |
|
589 | + $newRow[$counter] = $rowInfo; |
|
590 | 590 | $counter++; |
591 | 591 | } |
592 | 592 | } |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($this->odd_even_rows_enabled == true) { |
604 | - $this->altRowAttributes(0, array ('class' => 'row_odd'), array ('class' => 'row_even'), true); |
|
604 | + $this->altRowAttributes(0, array('class' => 'row_odd'), array('class' => 'row_even'), true); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | foreach ($this->th_attributes as $column => $attributes) { |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | } |
664 | 664 | $result[] = '<select name="'.$this->param_prefix.'per_page" onchange="javascript: this.form.submit();">'; |
665 | 665 | for ($nr = 10; $nr <= min(50, $total_number_of_items); $nr += 10) { |
666 | - $result[] = '<option value="'.$nr.'" '. ($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>'; |
|
666 | + $result[] = '<option value="'.$nr.'" '.($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>'; |
|
667 | 667 | } |
668 | 668 | // @todo no limits |
669 | 669 | //if ($total_number_of_items < 500) { |
670 | - $result[] = '<option value="'.$total_number_of_items.'" '. ($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>'; |
|
670 | + $result[] = '<option value="'.$total_number_of_items.'" '.($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>'; |
|
671 | 671 | //} |
672 | 672 | $result[] = '</select>'; |
673 | 673 | $result[] = '<noscript>'; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | */ |
786 | 786 | public function get_additional_url_paramstring() |
787 | 787 | { |
788 | - $param_string_parts = array (); |
|
788 | + $param_string_parts = array(); |
|
789 | 789 | if (is_array($this->additional_parameters) && count($this->additional_parameters) > 0) { |
790 | 790 | foreach ($this->additional_parameters as $key => & $value) { |
791 | 791 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | //$param[$tablename.'_direction'] = $_GET[$tablename.'_direction']; |
799 | 799 | $my_get_direction = $_GET[$tablename.'_direction']; |
800 | 800 | if (!in_array($my_get_direction, array('ASC', 'DESC'))) { |
801 | - $param[$tablename.'_direction'] = 'ASC'; |
|
801 | + $param[$tablename.'_direction'] = 'ASC'; |
|
802 | 802 | } else { |
803 | 803 | $param[$tablename.'_direction'] = $my_get_direction; |
804 | 804 | } |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | if (isset($_GET[$tablename.'_column'])) { |
813 | 813 | $param[$tablename.'_column'] = intval($_GET[$tablename.'_column']); |
814 | 814 | } |
815 | - $param_string_parts = array (); |
|
815 | + $param_string_parts = array(); |
|
816 | 816 | foreach ($param as $key => & $value) { |
817 | 817 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
818 | 818 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | $param[$this->param_prefix.'page_nr'] = $this->page_nr; |
834 | 834 | $param[$this->param_prefix.'per_page'] = $this->per_page; |
835 | 835 | $param[$this->param_prefix.'column'] = $this->column; |
836 | - $param_string_parts = array (); |
|
836 | + $param_string_parts = array(); |
|
837 | 837 | foreach ($param as $key => & $value) { |
838 | 838 | $param_string_parts[] = urlencode($key).'='.urlencode($value); |
839 | 839 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param array $conditions a list of condition (exemple : status=>STUDENT) |
103 | - * @param array $order_by a list of fields on which sort |
|
103 | + * @param string[] $order_by a list of fields on which sort |
|
104 | 104 | * @return array An array with all users of the platform. |
105 | 105 | */ |
106 | 106 | function get_specific_field_values_list( |
@@ -235,6 +235,7 @@ discard block |
||
235 | 235 | * @param string Course code |
236 | 236 | * @param string Tool ID |
237 | 237 | * @param int Internal ID used in specific tool table |
238 | + * @param string $tool_id |
|
238 | 239 | */ |
239 | 240 | function delete_all_values_for_item($course_id, $tool_id, $ref_id) { |
240 | 241 | $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
@@ -248,6 +249,7 @@ discard block |
||
248 | 249 | * Defaults to the first letter of the name, otherwise iterate through available |
249 | 250 | * letters |
250 | 251 | * @param string Name |
252 | + * @param string $name |
|
251 | 253 | * @return string One-letter code, upper-case |
252 | 254 | */ |
253 | 255 | function get_specific_field_code_from_name($name) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function delete_specific_field($id) |
43 | 43 | { |
44 | 44 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
45 | - $id = (int)$id; |
|
45 | + $id = (int) $id; |
|
46 | 46 | if (!is_numeric($id)) { |
47 | 47 | return false; |
48 | 48 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | function edit_specific_field($id, $name) |
61 | 61 | { |
62 | 62 | $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD); |
63 | - $id = (int)$id; |
|
63 | + $id = (int) $id; |
|
64 | 64 | if (!is_numeric($id)) { |
65 | 65 | return false; |
66 | 66 | } |
@@ -237,10 +237,10 @@ |
||
237 | 237 | * @param int Internal ID used in specific tool table |
238 | 238 | */ |
239 | 239 | function delete_all_values_for_item($course_id, $tool_id, $ref_id) { |
240 | - $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
241 | - $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s'; |
|
242 | - $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id); |
|
243 | - Database::query($sql); |
|
240 | + $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
241 | + $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s'; |
|
242 | + $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id); |
|
243 | + Database::query($sql); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |