Completed
Push — 1.10.x ( bceff1...b561e6 )
by Yannick
559:18 queued 509:08
created
main/inc/lib/svg-edit/extensions/imagelib/users.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 //get all files and folders
17 17
 $scan_files = [];
18 18
 if (is_dir($user_disk_path)) {
19
-	$scan_files = scandir($user_disk_path);
19
+    $scan_files = scandir($user_disk_path);
20 20
 }
21 21
 //get all svg and png files
22 22
 $accepted_extensions = array('.svg', '.png');
23 23
 
24 24
 if (is_array($scan_files) && count($scan_files) > 0) {
25
-	foreach ($scan_files as & $file) {
26
-		$slideshow_extension = strrchr($file, '.');
27
-		$slideshow_extension = strtolower($slideshow_extension);
28
-		if (in_array($slideshow_extension, $accepted_extensions)) {
29
-			$png_svg_files[] =$file;
30
-		}
31
-	}
25
+    foreach ($scan_files as & $file) {
26
+        $slideshow_extension = strrchr($file, '.');
27
+        $slideshow_extension = strtolower($slideshow_extension);
28
+        if (in_array($slideshow_extension, $accepted_extensions)) {
29
+            $png_svg_files[] =$file;
30
+        }
31
+    }
32 32
 }
33 33
 $style = '<style>';
34 34
 $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
 echo '<h2>'.get_lang('SocialNetwork').': '.get_lang('MyFiles').'</h2>';
48 48
 
49 49
 if (!empty($png_svg_files)) {
50
-	echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
51
-	echo '<ul>';
52
-	foreach($png_svg_files as $filename) {
53
-		$image = $user_disk_path.$filename;
50
+    echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
51
+    echo '<ul>';
52
+    foreach($png_svg_files as $filename) {
53
+        $image = $user_disk_path.$filename;
54 54
 
55
-		if (strpos($filename, "svg")){
56
-			$new_sizes['width'] = 60;
57
-			$new_sizes['height'] = 60;
58
-		} else {
59
-			$new_sizes = api_resize_image($image, 60, 60);
60
-		}
55
+        if (strpos($filename, "svg")){
56
+            $new_sizes['width'] = 60;
57
+            $new_sizes['height'] = 60;
58
+        } else {
59
+            $new_sizes = api_resize_image($image, 60, 60);
60
+        }
61 61
 
62
-			echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
63
-	}
64
-	echo '</ul>';
62
+            echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
63
+    }
64
+    echo '</ul>';
65 65
 } else {
66
-	Display::display_warning_message(get_lang('NoSVGImages'));
66
+    Display::display_warning_message(get_lang('NoSVGImages'));
67 67
 }
68 68
 ?>
69 69
 </body>
Please login to merge, or discard this patch.
main/document/edit_draw.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -59,44 +59,44 @@  discard block
 block discarded – undo
59 59
 /* Please, do not modify this dirname formatting */
60 60
 
61 61
 if (strstr($dir, '..')) {
62
-	$dir = '/';
62
+    $dir = '/';
63 63
 }
64 64
 
65 65
 if ($dir[0] == '.') {
66
-	$dir = substr($dir, 1);
66
+    $dir = substr($dir, 1);
67 67
 }
68 68
 
69 69
 if ($dir[0] != '/') {
70
-	$dir = '/'.$dir;
70
+    $dir = '/'.$dir;
71 71
 }
72 72
 
73 73
 if ($dir[strlen($dir) - 1] != '/') {
74
-	$dir .= '/';
74
+    $dir .= '/';
75 75
 }
76 76
 
77 77
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
78 78
 
79 79
 if (!is_dir($filepath)) {
80
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
81
-	$dir = '/';
80
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
81
+    $dir = '/';
82 82
 }
83 83
 
84 84
 //groups //TODO:clean
85 85
 if (!empty($group_id)) {
86
-	$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
87
-	$group_document = true;
88
-	$noPHP_SELF = true;
86
+    $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
87
+    $group_document = true;
88
+    $noPHP_SELF = true;
89 89
 }
90 90
 
91 91
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
92 92
 
93 93
 if (!$is_certificate_mode)
94
-	$interbreadcrumb[] = array(
95
-		"url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
96
-		"name" => get_lang('Documents')
97
-	);
94
+    $interbreadcrumb[] = array(
95
+        "url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
96
+        "name" => get_lang('Documents')
97
+    );
98 98
 else
99
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
99
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
100 100
 
101 101
 // Interbreadcrumb for the current directory root path
102 102
 if (empty($document_data['parents'])) {
@@ -111,28 +111,28 @@  discard block
 block discarded – undo
111 111
 }
112 112
 
113 113
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
114
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
114
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
115 115
 
116 116
 if (!$is_allowedToEdit) {
117
-	api_not_allowed(true);
117
+    api_not_allowed(true);
118 118
 }
119 119
 
120 120
 Event::event_access_tool(TOOL_DOCUMENT);
121 121
 
122 122
 Display :: display_header($nameTools, 'Doc');
123 123
 echo '<div class="actions">';
124
-		echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
125
-		echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
124
+        echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
125
+        echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
126 126
 echo '</div>';
127 127
 
128 128
 if (api_browser_support('svg')) {
129
-	// Automatic loading the course language
130
-	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
131
-	$langsvgedit = api_get_language_isocode();
132
-	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
133
-	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
134
-	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
135
-	?>
129
+    // Automatic loading the course language
130
+    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
131
+    $langsvgedit = api_get_language_isocode();
132
+    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
133
+    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
134
+    $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
135
+    ?>
136 136
 	<script>
137 137
 	document.write('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo  $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
138 138
 	function resizeIframe() {
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
     <?php
152 152
     echo '<noscript>';
153
-	echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
154
-	echo '</noscript>';
153
+    echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
154
+    echo '</noscript>';
155 155
 } else {
156
-	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
156
+    Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
157 157
 }
158 158
 Display::display_footer();
Please login to merge, or discard this patch.
main/document/create_draw.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -46,59 +46,59 @@  discard block
 block discarded – undo
46 46
 // Please, do not modify this dirname formatting
47 47
 
48 48
 if (strstr($dir, '..')) {
49
-	$dir = '/';
49
+    $dir = '/';
50 50
 }
51 51
 
52 52
 if ($dir[0] == '.') {
53
-	$dir = substr($dir, 1);
53
+    $dir = substr($dir, 1);
54 54
 }
55 55
 
56 56
 if ($dir[0] != '/') {
57
-	$dir = '/'.$dir;
57
+    $dir = '/'.$dir;
58 58
 }
59 59
 
60 60
 if ($dir[strlen($dir) - 1] != '/') {
61
-	$dir .= '/';
61
+    $dir .= '/';
62 62
 }
63 63
 
64 64
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
65 65
 
66 66
 if (!is_dir($filepath)) {
67
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
68
-	$dir = '/';
67
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
68
+    $dir = '/';
69 69
 }
70 70
 
71 71
 $groupId = api_get_group_id();
72 72
 
73 73
 if (!empty($groupId)) {
74
-	$interbreadcrumb[] = array (
74
+    $interbreadcrumb[] = array (
75 75
         "url" => "../group/group_space.php?".api_get_cidreq(),
76 76
         "name" => get_lang('GroupSpace')
77 77
     );
78
-	$noPHP_SELF = true;
79
-	$group = GroupManager :: get_group_properties($groupId);
80
-	$path = explode('/', $dir);
81
-	if ('/'.$path[1] != $group['directory']) {
82
-		api_not_allowed(true);
83
-	}
78
+    $noPHP_SELF = true;
79
+    $group = GroupManager :: get_group_properties($groupId);
80
+    $path = explode('/', $dir);
81
+    if ('/'.$path[1] != $group['directory']) {
82
+        api_not_allowed(true);
83
+    }
84 84
 }
85 85
 
86 86
 $interbreadcrumb[] = array(
87
-	"url" => "./document.php?".api_get_cidreq(),
88
-	"name" => get_lang('Documents')
87
+    "url" => "./document.php?".api_get_cidreq(),
88
+    "name" => get_lang('Documents')
89 89
 );
90 90
 
91 91
 if (!$is_allowed_in_course) {
92
-	api_not_allowed(true);
92
+    api_not_allowed(true);
93 93
 }
94 94
 
95 95
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
96
-	DocumentManager::is_my_shared_folder(
97
-		api_get_user_id(),
98
-		Security::remove_XSS($dir),
99
-		api_get_session_id()))
96
+    DocumentManager::is_my_shared_folder(
97
+        api_get_user_id(),
98
+        Security::remove_XSS($dir),
99
+        api_get_session_id()))
100 100
 ) {
101
-	api_not_allowed(true);
101
+    api_not_allowed(true);
102 102
 }
103 103
 
104 104
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 Event::event_access_tool(TOOL_DOCUMENT);
107 107
 $display_dir = $dir;
108 108
 if (isset ($group)) {
109
-	$display_dir = explode('/', $dir);
110
-	unset ($display_dir[0]);
111
-	unset ($display_dir[1]);
112
-	$display_dir = implode('/', $display_dir);
109
+    $display_dir = explode('/', $dir);
110
+    unset ($display_dir[0]);
111
+    unset ($display_dir[1]);
112
+    $display_dir = implode('/', $display_dir);
113 113
 }
114 114
 
115 115
 // Interbreadcrumb for the current directory root path
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 } else {
124 124
     foreach ($document_data['parents'] as $document_sub_data) {
125 125
         $interbreadcrumb[] = array(
126
-			'url' => $document_sub_data['document_url'],
127
-			'name' => $document_sub_data['title']
128
-		);
126
+            'url' => $document_sub_data['document_url'],
127
+            'name' => $document_sub_data['title']
128
+        );
129 129
     }
130 130
 }
131 131
 Display :: display_header($nameTools, 'Doc');
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 
138 138
 if (api_browser_support('svg')) {
139 139
 
140
-	//automatic loading the course language
141
-	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
142
-	$langsvgedit = api_get_language_isocode();
143
-	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
144
-	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
145
-	$svg_url= api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?lang='.$langsvgedit;
146
-	?>
140
+    //automatic loading the course language
141
+    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
142
+    $langsvgedit = api_get_language_isocode();
143
+    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
144
+    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
145
+    $svg_url= api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?lang='.$langsvgedit;
146
+    ?>
147 147
 	<script>
148 148
 		document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo  $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
149 149
         function resizeIframe() {
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 
162 162
     <?php
163 163
     echo '<noscript>';
164
-	echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
165
-	echo '</noscript>';
164
+    echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
165
+    echo '</noscript>';
166 166
 } else {
167
-	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
167
+    Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
168 168
 }
169 169
 
170 170
 Display :: display_footer();
Please login to merge, or discard this patch.
app/Migrations/Schema/V110/Version110.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
         $this->addSql("ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''");
124 124
         $this->addSql("ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''");
125 125
 
126
-		$this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned NOT NULL");
126
+        $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned NOT NULL");
127 127
         $this->addSql("ALTER TABLE user DROP PRIMARY KEY");
128 128
         $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT NULL");
129 129
         $this->addSql("ALTER TABLE user ADD COLUMN id INT DEFAULT NULL");
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 1 patch
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     public $name;
14 14
     public $description;
15 15
 
16
-	/**
17
-	 * Constructor of the class Category
18
-	 * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
-	 * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
-	 *
16
+    /**
17
+     * Constructor of the class Category
18
+     * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
+     * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
+     *
21 21
      * @param int    $id
22 22
      * @param string $name
23 23
      * @param string $description
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
     }
63 63
 
64
-	/**
64
+    /**
65 65
      * add TestCategory in the database if name doesn't already exists
66
-	 */
66
+     */
67 67
     public function addCategoryInBDD()
68 68
     {
69 69
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
             return false;
110 110
         }
111
-	}
111
+    }
112 112
 
113
-	/**
113
+    /**
114 114
      * Removes the category from the database
115 115
      * if there were question in this category, the link between question and category is removed
116
-	 */
116
+     */
117 117
     public function removeCategory()
118 118
     {
119 119
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
             return true;
145 145
         }
146
-	}
146
+    }
147 147
 
148
-	/**
148
+    /**
149 149
      * Modify category name or description of category with id=in_id
150
-	 */
150
+     */
151 151
     public function modifyCategory()
152 152
     {
153 153
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -175,40 +175,40 @@  discard block
 block discarded – undo
175 175
 
176 176
             return true;
177 177
         }
178
-	}
178
+    }
179 179
 
180
-	/**
180
+    /**
181 181
      * Gets the number of question of category id=in_id
182
-	 */
182
+     */
183 183
     public function getCategoryQuestionsNumber()
184 184
     {
185
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
-		$in_id = intval($this->id);
187
-		$sql = "SELECT count(*) AS nb
185
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
+        $in_id = intval($this->id);
187
+        $sql = "SELECT count(*) AS nb
188 188
 		        FROM $table
189 189
 		        WHERE category_id=$in_id AND c_id=".api_get_course_int_id();
190
-		$res = Database::query($sql);
191
-		$row = Database::fetch_array($res);
190
+        $res = Database::query($sql);
191
+        $row = Database::fetch_array($res);
192 192
 
193
-		return $row['nb'];
194
-	}
193
+        return $row['nb'];
194
+    }
195 195
 
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199 199
     public function display($in_color="#E0EBF5")
200 200
     {
201
-		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
-		print_r($this);
203
-		echo "</textarea>";
204
-	}
201
+        echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
+        print_r($this);
203
+        echo "</textarea>";
204
+    }
205 205
 
206
-	/**
206
+    /**
207 207
      * Return an array of all Category objects in the database
208
-	 * If in_field=="" Return an array of all category objects in the database
209
-	 * Otherwise, return an array of all in_field value
210
-	 * in the database (in_field = id or name or description)
211
-	 */
208
+     * If in_field=="" Return an array of all category objects in the database
209
+     * Otherwise, return an array of all in_field value
210
+     * in the database (in_field = id or name or description)
211
+     */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214 214
         if (empty($courseId) || $courseId=="") {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             }
240 240
         }
241 241
 
242
-		return $tabres;
243
-	}
242
+        return $tabres;
243
+    }
244 244
 
245 245
     /**
246 246
      * Return the TestCategory id for question with question_id = $questionId
@@ -251,210 +251,210 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+    public static function getCategoryForQuestion($questionId, $courseId ="")
255 255
     {
256
-		$result = 0;
256
+        $result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
258 258
             $courseId = api_get_course_int_id();
259 259
         }
260
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
260
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
261 261
         $questionId = intval($questionId);
262
-		$sql = "SELECT category_id
262
+        $sql = "SELECT category_id
263 263
 		        FROM $table
264 264
 		        WHERE question_id = $questionId AND c_id = $courseId";
265
-		$res = Database::query($sql);
266
-		if (Database::num_rows($res) > 0) {
265
+        $res = Database::query($sql);
266
+        if (Database::num_rows($res) > 0) {
267 267
             $data = Database::fetch_array($res);
268
-			$result = $data['category_id'];
269
-		}
268
+            $result = $data['category_id'];
269
+        }
270 270
 
271
-		return $result;
272
-	}
271
+        return $result;
272
+    }
273 273
 
274
-	/**
275
-	 * true if question id has a category
276
-	 */
277
-	public static function isQuestionHasCategory($questionId)
274
+    /**
275
+     * true if question id has a category
276
+     */
277
+    public static function isQuestionHasCategory($questionId)
278 278
     {
279
-		if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
-			return true;
281
-		}
282
-		return false;
283
-	}
279
+        if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
+            return true;
281
+        }
282
+        return false;
283
+    }
284 284
 
285
-	/**
285
+    /**
286 286
 	 Return the category name for question with question_id = $questionId
287 287
 	 In this version, a question has only 1 category.
288 288
 	 Return the category id, "" if none
289
-	 */
289
+     */
290 290
     public static function getCategoryNameForQuestion(
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
295
-			$courseId = api_get_course_int_id();
296
-		}
297
-		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
299
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
-		$catid = intval($catid);
301
-		$sql = "SELECT title FROM $table
294
+        if (empty($courseId) || $courseId=="") {
295
+            $courseId = api_get_course_int_id();
296
+        }
297
+        $catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
+        $result = "";	// result
299
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
+        $catid = intval($catid);
301
+        $sql = "SELECT title FROM $table
302 302
 		        WHERE id = $catid  AND c_id = $courseId";
303
-		$res = Database::query($sql);
304
-		$data = Database::fetch_array($res);
305
-		if (Database::num_rows($res) > 0) {
306
-			$result = $data['title'];
307
-		}
308
-
309
-		return $result;
310
-	}
311
-
312
-	/**
313
-	 * Return the list of differents categories ID for a test in the current course
314
-	 * input : test_id
315
-	 * return : array of category id (integer)
316
-	 * hubert.borderiou 07-04-2011
317
-	 * @param int $exerciseId
318
-	 */
319
-	public static function getListOfCategoriesIDForTest($exerciseId)
303
+        $res = Database::query($sql);
304
+        $data = Database::fetch_array($res);
305
+        if (Database::num_rows($res) > 0) {
306
+            $result = $data['title'];
307
+        }
308
+
309
+        return $result;
310
+    }
311
+
312
+    /**
313
+     * Return the list of differents categories ID for a test in the current course
314
+     * input : test_id
315
+     * return : array of category id (integer)
316
+     * hubert.borderiou 07-04-2011
317
+     * @param int $exerciseId
318
+     */
319
+    public static function getListOfCategoriesIDForTest($exerciseId)
320 320
     {
321
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
322
-		$exercise = new Exercise();
323
-		$exercise->read($exerciseId, false);
324
-		$categoriesInExercise = $exercise->getQuestionWithCategories();
325
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		$categories = array();
321
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
322
+        $exercise = new Exercise();
323
+        $exercise->read($exerciseId, false);
324
+        $categoriesInExercise = $exercise->getQuestionWithCategories();
325
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
+        $categories = array();
327 327
         if (!empty($categoriesInExercise)) {
328
-			foreach ($categoriesInExercise as $category) {
329
-				//$category['id'] = $category['iid'];
330
-				$categories[$category['id']] = $category;
331
-			}
332
-		}
333
-
334
-		return $categories;
335
-	}
336
-
337
-	/**
338
-	 * @param Exercise $exercise_obj
339
-	 * @return array
340
-	 */
341
-	public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
-	{
343
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
344
-		$categories_in_exercise = array();
345
-		// $question_list = $exercise_obj->getQuestionList();
346
-		$question_list = $exercise_obj->getQuestionOrderedListByName();
347
-
348
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
-		foreach ($question_list as $questionInfo) {
350
-			$question_id = $questionInfo['question_id'];
351
-			$category_list = self::getCategoryForQuestion($question_id);
352
-			if (is_numeric($category_list)) {
353
-				$category_list = array($category_list);
354
-			}
355
-
356
-			if (!empty($category_list)) {
357
-				$categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
-			}
359
-		}
360
-		if (!empty($categories_in_exercise)) {
361
-			$categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
-		}
363
-		return $categories_in_exercise;
364
-	}
365
-
366
-	/**
367
-	 * Return the list of differents categories NAME for a test
368
-	 * @param int exercise id
369
-	 * @param bool
370
-	 * @return array of string
371
-	 *
328
+            foreach ($categoriesInExercise as $category) {
329
+                //$category['id'] = $category['iid'];
330
+                $categories[$category['id']] = $category;
331
+            }
332
+        }
333
+
334
+        return $categories;
335
+    }
336
+
337
+    /**
338
+     * @param Exercise $exercise_obj
339
+     * @return array
340
+     */
341
+    public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
+    {
343
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
344
+        $categories_in_exercise = array();
345
+        // $question_list = $exercise_obj->getQuestionList();
346
+        $question_list = $exercise_obj->getQuestionOrderedListByName();
347
+
348
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
+        foreach ($question_list as $questionInfo) {
350
+            $question_id = $questionInfo['question_id'];
351
+            $category_list = self::getCategoryForQuestion($question_id);
352
+            if (is_numeric($category_list)) {
353
+                $category_list = array($category_list);
354
+            }
355
+
356
+            if (!empty($category_list)) {
357
+                $categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
+            }
359
+        }
360
+        if (!empty($categories_in_exercise)) {
361
+            $categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
+        }
363
+        return $categories_in_exercise;
364
+    }
365
+
366
+    /**
367
+     * Return the list of differents categories NAME for a test
368
+     * @param int exercise id
369
+     * @param bool
370
+     * @return array of string
371
+     *
372 372
      * @author function rewrote by jmontoya
373
-	 */
374
-	public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
373
+     */
374
+    public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
375 375
     {
376
-		$result = array();
377
-		$categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
376
+        $result = array();
377
+        $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
378 378
 
379
-		foreach ($categories as $catInfo) {
380
-			$categoryId = $catInfo['id'];
381
-			if (!empty($categoryId)) {
382
-				$result[$categoryId] = array(
379
+        foreach ($categories as $catInfo) {
380
+            $categoryId = $catInfo['id'];
381
+            if (!empty($categoryId)) {
382
+                $result[$categoryId] = array(
383 383
                     'title' => $catInfo['title'],
384 384
                     //'parent_id' =>  $catInfo['parent_id'],
385
-					'parent_id' => '',
385
+                    'parent_id' => '',
386 386
                     'c_id' => $catInfo['c_id']
387 387
                 );
388
-		}
389
-		}
390
-
391
-		return $result;
392
-	}
393
-
394
-	/**
395
-	 * @param Exercise $exercise_obj
396
-	 * @return array
397
-	 */
398
-	public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
-	{
400
-		$result = array();
401
-		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
-		foreach ($categories as $cat_id) {
403
-			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
405
-			$cat['iid'] = $cat['id'];
406
-			$cat['title'] = $cat['name'];
407
-			$result[$cat['id']] = $cat;
408
-		}
409
-		return $result;
410
-	}
411
-
412
-	/**
413
-	 * return the number of differents categories for a test
414
-	 * input : test_id
415
-	 * return : integer
416
-	 * hubert.borderiou 07-04-2011
417
-	 */
418
-	public static function getNumberOfCategoriesForTest($id)
388
+        }
389
+        }
390
+
391
+        return $result;
392
+    }
393
+
394
+    /**
395
+     * @param Exercise $exercise_obj
396
+     * @return array
397
+     */
398
+    public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
+    {
400
+        $result = array();
401
+        $categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
+        foreach ($categories as $cat_id) {
403
+            $cat = new TestCategory($cat_id);
404
+            $cat = (array)$cat;
405
+            $cat['iid'] = $cat['id'];
406
+            $cat['title'] = $cat['name'];
407
+            $result[$cat['id']] = $cat;
408
+        }
409
+        return $result;
410
+    }
411
+
412
+    /**
413
+     * return the number of differents categories for a test
414
+     * input : test_id
415
+     * return : integer
416
+     * hubert.borderiou 07-04-2011
417
+     */
418
+    public static function getNumberOfCategoriesForTest($id)
419 419
     {
420
-		return count(TestCategory::getListOfCategoriesIDForTest($id));
421
-	}
420
+        return count(TestCategory::getListOfCategoriesIDForTest($id));
421
+    }
422 422
 
423
-	/**
424
-	 * return the number of question of a category id in a test
425
-	 * @param int $exerciseId
423
+    /**
424
+     * return the number of question of a category id in a test
425
+     * @param int $exerciseId
426 426
      * @param int $categoryId
427 427
      *
428
-	 * @return integer
428
+     * @return integer
429 429
      *
430
-	 * @author hubert.borderiou 07-04-2011
431
-	 */
432
-	public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
430
+     * @author hubert.borderiou 07-04-2011
431
+     */
432
+    public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
433 433
     {
434
-		$nbCatResult = 0;
435
-		$quiz = new Exercise();
436
-		$quiz->read($exerciseId);
437
-		$tabQuestionList = $quiz->selectQuestionList();
438
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
440
-			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
-				$nbCatResult++;
442
-			}
443
-		}
444
-
445
-		return $nbCatResult;
446
-	}
447
-
448
-	/**
449
-	 * return the number of question for a test using random by category
450
-	 * input  : test_id, number of random question (min 1)
451
-	 * hubert.borderiou 07-04-2011
452
-	 * question without categories are not counted
453
-	 */
454
-	public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
434
+        $nbCatResult = 0;
435
+        $quiz = new Exercise();
436
+        $quiz->read($exerciseId);
437
+        $tabQuestionList = $quiz->selectQuestionList();
438
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
440
+            if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
+                $nbCatResult++;
442
+            }
443
+        }
444
+
445
+        return $nbCatResult;
446
+    }
447
+
448
+    /**
449
+     * return the number of question for a test using random by category
450
+     * input  : test_id, number of random question (min 1)
451
+     * hubert.borderiou 07-04-2011
452
+     * question without categories are not counted
453
+     */
454
+    public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
455 455
     {
456
-		$nbquestionresult = 0;
457
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
456
+        $nbquestionresult = 0;
457
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458 458
 
459 459
         foreach ($tabcatid as $category) {
460 460
             if (empty($category['id'])) {
@@ -470,30 +470,30 @@  discard block
 block discarded – undo
470 470
             }
471 471
         }
472 472
 
473
-		return $nbquestionresult;
474
-	}
473
+        return $nbquestionresult;
474
+    }
475 475
 
476
-	/**
477
-	 * Return an array (id=>name)
478
-	 * tabresult[0] = get_lang('NoCategory');
476
+    /**
477
+     * Return an array (id=>name)
478
+     * tabresult[0] = get_lang('NoCategory');
479 479
      *
480 480
      * @param int $courseId
481 481
      *
482 482
      * @return array
483
-	 *
484
-	 */
483
+     *
484
+     */
485 485
     public static function getCategoriesIdAndName($courseId = "")
486 486
     {
487
-		if (empty($courseId)) {
488
-			$courseId = api_get_course_int_id();
489
-		}
490
-	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
491
-	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
492
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
493
-	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
494
-	 	}
495
-	 	return $tabresult;
496
-	}
487
+        if (empty($courseId)) {
488
+            $courseId = api_get_course_int_id();
489
+        }
490
+            $tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
491
+            $tabresult = array("0"=>get_lang('NoCategorySelected'));
492
+            for ($i=0; $i < count($tabcatobject); $i++) {
493
+                $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
494
+            }
495
+            return $tabresult;
496
+    }
497 497
 
498 498
     /**
499 499
      * Returns an array of question ids for each category
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
      * @param int exercise
503 503
      * @param array $check_in_question_list
504 504
      * @param array $categoriesAddedInExercise
505
-    *
506
-    * @param int $exerciseId
507
-    * @return array
508
-    */
505
+     *
506
+     * @param int $exerciseId
507
+     * @return array
508
+     */
509 509
     static function getQuestionsByCat(
510 510
         $exerciseId,
511 511
         $check_in_question_list = array(),
@@ -583,28 +583,28 @@  discard block
 block discarded – undo
583 583
         }
584 584
 
585 585
         return $categories;
586
-	}
586
+    }
587 587
 
588
-	/**
589
-	 * return a tab of $in_number random elements of $in_tab
590
-	 */
588
+    /**
589
+     * return a tab of $in_number random elements of $in_tab
590
+     */
591 591
     public static function getNElementsFromArray($in_tab, $in_number)
592 592
     {
593
-		$tabres = $in_tab;
594
-		shuffle($tabres);
595
-		if ($in_number < count($tabres)) {
596
-			$tabres = array_slice($tabres, 0, $in_number);
597
-		}
598
-		return $tabres;
599
-	}
600
-
601
-	/**
602
-	 * display the category
603
-	 */
604
-	public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
593
+        $tabres = $in_tab;
594
+        shuffle($tabres);
595
+        if ($in_number < count($tabres)) {
596
+            $tabres = array_slice($tabres, 0, $in_number);
597
+        }
598
+        return $tabres;
599
+    }
600
+
601
+    /**
602
+     * display the category
603
+     */
604
+    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
605 605
     {
606 606
         echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
607
-	}
607
+    }
608 608
 
609 609
     /**
610 610
      * @param int $questionId
@@ -620,90 +620,90 @@  discard block
 block discarded – undo
620 620
             $in_display_category_name = $objExercise->display_category_name;
621 621
         }
622 622
         $content = null;
623
-		if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
623
+        if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
624 624
             $content .= '<div class="page-header">';
625 625
             $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>';
626 626
             $content .= "</div>";
627
-		}
627
+        }
628 628
         return $content;
629
-	}
629
+    }
630 630
 
631 631
     /**
632
-    * Display signs [+] and/or (>0) after question title if question has options
633
-    * scoreAlwaysPositive and/or uncheckedMayScore
634
-    */
632
+     * Display signs [+] and/or (>0) after question title if question has options
633
+     * scoreAlwaysPositive and/or uncheckedMayScore
634
+     */
635 635
     public function displayQuestionOption($in_objQuestion)
636 636
     {
637
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
638
-			echo "<span style='font-size:75%'> (>0)</span>";
639
-		}
640
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
641
-			echo "<span style='font-size:75%'> [+]</span>";
642
-		}
643
-	}
644
-
645
-	/**
646
-	 * sortTabByBracketLabel ($tabCategoryQuestions)
647
-	 * key of $tabCategoryQuestions are the category id (0 for not in a category)
648
-	 * value is the array of question id of this category
649
-	 * Sort question by Category
650
-	*/
637
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
638
+            echo "<span style='font-size:75%'> (>0)</span>";
639
+        }
640
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
641
+            echo "<span style='font-size:75%'> [+]</span>";
642
+        }
643
+    }
644
+
645
+    /**
646
+     * sortTabByBracketLabel ($tabCategoryQuestions)
647
+     * key of $tabCategoryQuestions are the category id (0 for not in a category)
648
+     * value is the array of question id of this category
649
+     * Sort question by Category
650
+     */
651 651
     public static function sortTabByBracketLabel($in_tab)
652 652
     {
653
-		$tabResult = array();
654
-		$tabCatName = array();	// tab of category name
655
-		while (list($cat_id, $tabquestion) = each($in_tab)) {
656
-			$catTitle = new TestCategory($cat_id);
657
-			$tabCatName[$cat_id] = $catTitle->name;
658
-		}
659
-		reset($in_tab);
660
-		// sort table by value, keeping keys as they are
661
-		asort($tabCatName);
662
-		// keys of $tabCatName are keys order for $in_tab
663
-		while (list($key, $val) = each($tabCatName)) {
664
-			$tabResult[$key] = $in_tab[$key];
665
-		}
666
-		return $tabResult;
667
-	}
653
+        $tabResult = array();
654
+        $tabCatName = array();	// tab of category name
655
+        while (list($cat_id, $tabquestion) = each($in_tab)) {
656
+            $catTitle = new TestCategory($cat_id);
657
+            $tabCatName[$cat_id] = $catTitle->name;
658
+        }
659
+        reset($in_tab);
660
+        // sort table by value, keeping keys as they are
661
+        asort($tabCatName);
662
+        // keys of $tabCatName are keys order for $in_tab
663
+        while (list($key, $val) = each($tabCatName)) {
664
+            $tabResult[$key] = $in_tab[$key];
665
+        }
666
+        return $tabResult;
667
+    }
668 668
 
669 669
     /**
670
-	 * return total score for test exe_id for all question in the category $in_cat_id for user
671
-	 * If no question for this category, return ""
672
-	 */
673
-	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
674
-	{
675
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
676
-		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
677
-		$in_cat_id = intval($in_cat_id);
678
-		$in_exe_id = intval($in_exe_id);
679
-		$in_user_id = intval($in_user_id);
680
-
681
-		$query = "SELECT DISTINCT
670
+     * return total score for test exe_id for all question in the category $in_cat_id for user
671
+     * If no question for this category, return ""
672
+     */
673
+    public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
674
+    {
675
+        $tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
676
+        $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
677
+        $in_cat_id = intval($in_cat_id);
678
+        $in_exe_id = intval($in_exe_id);
679
+        $in_user_id = intval($in_user_id);
680
+
681
+        $query = "SELECT DISTINCT
682 682
 		            marks, exe_id, user_id, ta.question_id, category_id
683 683
                   FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc
684 684
                   WHERE
685 685
                     ta.question_id=qrc.question_id AND
686 686
                     qrc.category_id=$in_cat_id AND
687 687
                     exe_id=$in_exe_id AND user_id=$in_user_id";
688
-		$res = Database::query($query);
689
-		$totalcatscore = "";
690
-		while ($data = Database::fetch_array($res)) {
691
-			$totalcatscore += $data['marks'];
692
-		}
693
-		return $totalcatscore;
694
-	}
695
-
696
-	/**
688
+        $res = Database::query($query);
689
+        $totalcatscore = "";
690
+        while ($data = Database::fetch_array($res)) {
691
+            $totalcatscore += $data['marks'];
692
+        }
693
+        return $totalcatscore;
694
+    }
695
+
696
+    /**
697 697
      * return the number max of question in a category
698 698
      * count the number of questions in all categories, and return the max
699 699
      * @param int $exerciseId
700 700
      * @author - hubert borderiou
701
-    */
701
+     */
702 702
     public static function getNumberMaxQuestionByCat($exerciseId)
703 703
     {
704 704
         $res_num_max = 0;
705 705
         // foreach question
706
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
706
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
707 707
 
708 708
         foreach ($tabcatid as $category) {
709 709
             if (empty($category['id'])) {
@@ -775,34 +775,34 @@  discard block
 block discarded – undo
775 775
     }
776 776
 
777 777
     /**
778
-	 * @return array
779
-	 */
780
-	function get_all_categories()
781
-	{
782
-		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
783
-		$sql = "SELECT * FROM $table ORDER BY title ASC";
784
-		$res = Database::query($sql);
785
-		while ($row = Database::fetch_array($res,'ASSOC')) {
786
-			$array[] = $row;
787
-		}
788
-		return $array;
789
-	}
790
-
791
-	/**
792
-	 * @param Exercise $exercise
793
-	 * @param int $course_id
794
-	 * @param string $order
795
-	 * @param bool $shuffle
796
-	 * @param bool $excludeCategoryWithNoQuestions
797
-	 * @return array|bool
798
-	 */
799
-	public function getCategoryExerciseTree(
800
-		$exercise,
801
-		$course_id,
802
-		$order = null,
803
-		$shuffle = false,
804
-		$excludeCategoryWithNoQuestions = true
805
-	) {
778
+     * @return array
779
+     */
780
+    function get_all_categories()
781
+    {
782
+        $table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
783
+        $sql = "SELECT * FROM $table ORDER BY title ASC";
784
+        $res = Database::query($sql);
785
+        while ($row = Database::fetch_array($res,'ASSOC')) {
786
+            $array[] = $row;
787
+        }
788
+        return $array;
789
+    }
790
+
791
+    /**
792
+     * @param Exercise $exercise
793
+     * @param int $course_id
794
+     * @param string $order
795
+     * @param bool $shuffle
796
+     * @param bool $excludeCategoryWithNoQuestions
797
+     * @return array|bool
798
+     */
799
+    public function getCategoryExerciseTree(
800
+        $exercise,
801
+        $course_id,
802
+        $order = null,
803
+        $shuffle = false,
804
+        $excludeCategoryWithNoQuestions = true
805
+    ) {
806 806
         if (empty($exercise)) {
807 807
             return array();
808 808
         }
@@ -812,165 +812,165 @@  discard block
 block discarded – undo
812 812
         }
813 813
 
814 814
         $course_id = intval($course_id);
815
-		$table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
815
+        $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
816 816
         $categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
817
-		$sql = "SELECT * FROM $table qc
817
+        $sql = "SELECT * FROM $table qc
818 818
               	LEFT JOIN $categoryTable c
819 819
                 ON (qc.c_id = c.c_id AND c.id = qc.category_id)
820 820
                 WHERE qc.c_id = $course_id AND exercise_id = {$exercise->id} ";
821 821
 
822
-		if (!empty($order)) {
823
-			$sql .= "ORDER BY $order";
824
-		}
825
-
826
-		$categories = array();
827
-
828
-		$result = Database::query($sql);
829
-		if (Database::num_rows($result)) {
830
-			while ($row = Database::fetch_array($result, 'ASSOC')) {
831
-				if ($excludeCategoryWithNoQuestions) {
832
-					if ($row['count_questions'] == 0) {
833
-						continue;
834
-					}
835
-				}
836
-				if (empty($row['title']) && empty($row['category_id'])) {
837
-					$row['title'] = get_lang('NoCategory');
838
-				}
822
+        if (!empty($order)) {
823
+            $sql .= "ORDER BY $order";
824
+        }
825
+
826
+        $categories = array();
827
+
828
+        $result = Database::query($sql);
829
+        if (Database::num_rows($result)) {
830
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
831
+                if ($excludeCategoryWithNoQuestions) {
832
+                    if ($row['count_questions'] == 0) {
833
+                        continue;
834
+                    }
835
+                }
836
+                if (empty($row['title']) && empty($row['category_id'])) {
837
+                    $row['title'] = get_lang('NoCategory');
838
+                }
839 839
                 $categories[$row['category_id']] = $row;
840
-			}
841
-		}
842
-
843
-		if ($shuffle) {
844
-			shuffle_assoc($categories);
845
-		}
846
-
847
-		return $categories;
848
-	}
849
-
850
-	public function getForm(& $form, $action = 'new')
851
-	{
852
-		switch($action) {
853
-			case 'new':
854
-				$header = get_lang('AddACategory');
855
-				$submit = get_lang('AddTestCategory');
856
-				break;
857
-			case 'edit':
858
-				$header = get_lang('EditCategory');
859
-				$submit = get_lang('ModifyCategory');
860
-				break;
861
-		}
862
-
863
-		// settting the form elements
864
-		$form->addElement('header', $header);
865
-		$form->addElement('hidden', 'category_id');
866
-		$form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
867
-		$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
868
-		$category_parent_list = array();
869
-
870
-		$options = array(
871
-				'1' => get_lang('Visible'),
872
-				'0' => get_lang('Hidden')
873
-		);
874
-		$form->addElement('select', 'visibility', get_lang('Visibility'), $options);
875
-		$script = null;
876
-		if (!empty($this->parent_id)) {
877
-			$parent_cat = new TestCategory($this->parent_id);
878
-			$category_parent_list = array($parent_cat->id => $parent_cat->name);
879
-			$script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
880
-		}
881
-		$form->addElement('html', $script);
882
-
883
-		$form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
884
-		$form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
885
-
886
-		// setting the defaults
887
-		$defaults = array();
888
-		$defaults["category_id"] = $this->id;
889
-		$defaults["category_name"] = $this->name;
890
-		$defaults["category_description"] = $this->description;
891
-		$defaults["parent_id"] = $this->parent_id;
892
-		$defaults["visibility"] = $this->visibility;
893
-		$form->setDefaults($defaults);
894
-
895
-		// setting the rules
896
-		$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
897
-	}
898
-
899
-	/**
900
-	 * Returns the category form.
901
-	 * @param Exercise $exercise_obj
902
-	 * @return string
903
-	 */
904
-	public function returnCategoryForm(Exercise $exercise_obj)
905
-	{
906
-		$categories = $this->getListOfCategoriesForTest($exercise_obj);
907
-
908
-		$saved_categories = $exercise_obj->get_categories_in_exercise();
909
-		$return = null;
910
-
911
-		if (!empty($categories)) {
912
-			$nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
913
-			$exercise_obj->setCategoriesGrouping(true);
914
-			$real_question_count = count($exercise_obj->getQuestionList());
915
-
916
-			$warning = null;
917
-			if ($nbQuestionsTotal != $real_question_count) {
918
-				$warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
919
-			}
920
-
921
-			$return .= $warning;
922
-			$return .= '<table class="data_table">';
923
-			$return .= '<tr>';
924
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
925
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
926
-
927
-			$emptyCategory = array(
928
-				'id' => '0',
929
-				'name' => get_lang('NoCategory'),
930
-				'description' => '',
931
-				'iid' => '0',
932
-				'title' => get_lang('NoCategory')
933
-			);
934
-
935
-			$categories[] = $emptyCategory;
936
-
937
-			foreach ($categories as $category) {
938
-				$cat_id = $category['iid'];
939
-				$return .= '<tr>';
940
-				$return .= '<td>';
941
-				//$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
942
-				$return .= Display::div($category['name']);
943
-				$return .= '</td>';
944
-				$return .= '<td>';
945
-				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
946
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
947
-				$return .= '</td>';
948
-				$return .= '</tr>';
949
-			}
950
-
951
-			$return .= '</table>';
952
-			$return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
953
-			return $return;
954
-		}
955
-	}
956
-
957
-	/**
958
-	 * Sorts an array
959
-	 * @param $array
960
-	 * @return mixed
961
-	 */
962
-	public function sort_tree_array($array)
963
-	{
964
-		foreach ($array as $key => $row) {
965
-			$parent[$key] = $row['parent_id'];
966
-		}
967
-		if (count($array) > 0) {
968
-			array_multisort($parent, SORT_ASC, $array);
969
-		}
970
-		return $array;
971
-	}
972
-
973
-	/**
840
+            }
841
+        }
842
+
843
+        if ($shuffle) {
844
+            shuffle_assoc($categories);
845
+        }
846
+
847
+        return $categories;
848
+    }
849
+
850
+    public function getForm(& $form, $action = 'new')
851
+    {
852
+        switch($action) {
853
+            case 'new':
854
+                $header = get_lang('AddACategory');
855
+                $submit = get_lang('AddTestCategory');
856
+                break;
857
+            case 'edit':
858
+                $header = get_lang('EditCategory');
859
+                $submit = get_lang('ModifyCategory');
860
+                break;
861
+        }
862
+
863
+        // settting the form elements
864
+        $form->addElement('header', $header);
865
+        $form->addElement('hidden', 'category_id');
866
+        $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
867
+        $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
868
+        $category_parent_list = array();
869
+
870
+        $options = array(
871
+                '1' => get_lang('Visible'),
872
+                '0' => get_lang('Hidden')
873
+        );
874
+        $form->addElement('select', 'visibility', get_lang('Visibility'), $options);
875
+        $script = null;
876
+        if (!empty($this->parent_id)) {
877
+            $parent_cat = new TestCategory($this->parent_id);
878
+            $category_parent_list = array($parent_cat->id => $parent_cat->name);
879
+            $script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
880
+        }
881
+        $form->addElement('html', $script);
882
+
883
+        $form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
884
+        $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
885
+
886
+        // setting the defaults
887
+        $defaults = array();
888
+        $defaults["category_id"] = $this->id;
889
+        $defaults["category_name"] = $this->name;
890
+        $defaults["category_description"] = $this->description;
891
+        $defaults["parent_id"] = $this->parent_id;
892
+        $defaults["visibility"] = $this->visibility;
893
+        $form->setDefaults($defaults);
894
+
895
+        // setting the rules
896
+        $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
897
+    }
898
+
899
+    /**
900
+     * Returns the category form.
901
+     * @param Exercise $exercise_obj
902
+     * @return string
903
+     */
904
+    public function returnCategoryForm(Exercise $exercise_obj)
905
+    {
906
+        $categories = $this->getListOfCategoriesForTest($exercise_obj);
907
+
908
+        $saved_categories = $exercise_obj->get_categories_in_exercise();
909
+        $return = null;
910
+
911
+        if (!empty($categories)) {
912
+            $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
913
+            $exercise_obj->setCategoriesGrouping(true);
914
+            $real_question_count = count($exercise_obj->getQuestionList());
915
+
916
+            $warning = null;
917
+            if ($nbQuestionsTotal != $real_question_count) {
918
+                $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
919
+            }
920
+
921
+            $return .= $warning;
922
+            $return .= '<table class="data_table">';
923
+            $return .= '<tr>';
924
+            $return .= '<th height="24">' . get_lang('Categories') . '</th>';
925
+            $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
926
+
927
+            $emptyCategory = array(
928
+                'id' => '0',
929
+                'name' => get_lang('NoCategory'),
930
+                'description' => '',
931
+                'iid' => '0',
932
+                'title' => get_lang('NoCategory')
933
+            );
934
+
935
+            $categories[] = $emptyCategory;
936
+
937
+            foreach ($categories as $category) {
938
+                $cat_id = $category['iid'];
939
+                $return .= '<tr>';
940
+                $return .= '<td>';
941
+                //$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
942
+                $return .= Display::div($category['name']);
943
+                $return .= '</td>';
944
+                $return .= '<td>';
945
+                $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
946
+                $return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
947
+                $return .= '</td>';
948
+                $return .= '</tr>';
949
+            }
950
+
951
+            $return .= '</table>';
952
+            $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
953
+            return $return;
954
+        }
955
+    }
956
+
957
+    /**
958
+     * Sorts an array
959
+     * @param $array
960
+     * @return mixed
961
+     */
962
+    public function sort_tree_array($array)
963
+    {
964
+        foreach ($array as $key => $row) {
965
+            $parent[$key] = $row['parent_id'];
966
+        }
967
+        if (count($array) > 0) {
968
+            array_multisort($parent, SORT_ASC, $array);
969
+        }
970
+        return $array;
971
+    }
972
+
973
+    /**
974 974
      * Return true if a category already exists with the same name
975 975
      * @param string $in_name
976 976
      *
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
      * @param int $categoryId
1018 1018
      * @param int $questionId
1019 1019
      * @param int $courseId
1020
-	 *
1021
-	 * @return int
1020
+     *
1021
+     * @return int
1022 1022
      */
1023 1023
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
1024 1024
     {
@@ -1026,18 +1026,18 @@  discard block
 block discarded – undo
1026 1026
         // if question doesn't have a category
1027 1027
         // @todo change for 1.10 when a question can have several categories
1028 1028
         if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
1029
-			$questionId > 0 &&
1030
-			$courseId > 0
1029
+            $questionId > 0 &&
1030
+            $courseId > 0
1031 1031
         ) {
1032 1032
             $sql = "INSERT INTO $table (c_id, question_id, category_id)
1033 1033
                     VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
1034 1034
             Database::query($sql);
1035
-			$id = Database::insert_id();
1035
+            $id = Database::insert_id();
1036 1036
 
1037
-			return $id;
1037
+            return $id;
1038 1038
         }
1039 1039
 
1040
-		return false;
1040
+        return false;
1041 1041
     }
1042 1042
 
1043 1043
     /**
Please login to merge, or discard this patch.
main/inc/lib/icalcreator/iCalcreator.class.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
  * @author Patrick Cool
17 17
  * @author René Haentjens, added CSV file import (October 2004)
18 18
  * @package chamilo.link
19
-
20 19
  */
21 20
 
22 21
 // Including libraries
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-main.php 1 patch
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -44,167 +44,167 @@
 block discarded – undo
44 44
 
45 45
 class PGTStorage
46 46
 {
47
-  /** 
48
-   * @addtogroup internalPGTStorage
49
-   * @{ 
50
-   */
51
-
52
-  // ########################################################################
53
-  //  CONSTRUCTOR
54
-  // ########################################################################
47
+    /** 
48
+     * @addtogroup internalPGTStorage
49
+     * @{ 
50
+     */
51
+
52
+    // ########################################################################
53
+    //  CONSTRUCTOR
54
+    // ########################################################################
55 55
   
56
-  /**
57
-   * The constructor of the class, should be called only by inherited classes.
58
-   *
59
-   * @param $cas_parent the CASclient instance that creates the current object.
60
-   *
61
-   * @protected
62
-   */
63
-  function PGTStorage($cas_parent)
56
+    /**
57
+     * The constructor of the class, should be called only by inherited classes.
58
+     *
59
+     * @param $cas_parent the CASclient instance that creates the current object.
60
+     *
61
+     * @protected
62
+     */
63
+    function PGTStorage($cas_parent)
64 64
     {
65
-      phpCAS::traceBegin();
66
-      if ( !$cas_parent->isProxy() ) {
67
-	phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68
-      }
69
-      phpCAS::traceEnd();
65
+        phpCAS::traceBegin();
66
+        if ( !$cas_parent->isProxy() ) {
67
+    phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68
+        }
69
+        phpCAS::traceEnd();
70 70
     }
71 71
 
72
-  // ########################################################################
73
-  //  DEBUGGING
74
-  // ########################################################################
72
+    // ########################################################################
73
+    //  DEBUGGING
74
+    // ########################################################################
75 75
   
76
-  /**
77
-   * This virtual method returns an informational string giving the type of storage
78
-   * used by the object (used for debugging purposes).
79
-   *
80
-   * @public
81
-   */
82
-  function getStorageType()
76
+    /**
77
+     * This virtual method returns an informational string giving the type of storage
78
+     * used by the object (used for debugging purposes).
79
+     *
80
+     * @public
81
+     */
82
+    function getStorageType()
83 83
     {
84
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
84
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
85 85
     }
86 86
 
87
-  /**
88
-   * This virtual method returns an informational string giving informations on the
89
-   * parameters of the storage.(used for debugging purposes).
90
-   *
91
-   * @public
92
-   */
93
-  function getStorageInfo()
87
+    /**
88
+     * This virtual method returns an informational string giving informations on the
89
+     * parameters of the storage.(used for debugging purposes).
90
+     *
91
+     * @public
92
+     */
93
+    function getStorageInfo()
94 94
     {
95
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
95
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
96 96
     }
97 97
 
98
-  // ########################################################################
99
-  //  ERROR HANDLING
100
-  // ########################################################################
98
+    // ########################################################################
99
+    //  ERROR HANDLING
100
+    // ########################################################################
101 101
   
102
-  /**
103
-   * string used to store an error message. Written by PGTStorage::setErrorMessage(),
104
-   * read by PGTStorage::getErrorMessage().
105
-   *
106
-   * @hideinitializer
107
-   * @private
108
-   * @deprecated not used.
109
-   */
110
-  var $_error_message=FALSE;
111
-
112
-  /**
113
-   * This method sets en error message, which can be read later by 
114
-   * PGTStorage::getErrorMessage().
115
-   *
116
-   * @param $error_message an error message
117
-   *
118
-   * @protected
119
-   * @deprecated not used.
120
-   */
121
-  function setErrorMessage($error_message)
102
+    /**
103
+     * string used to store an error message. Written by PGTStorage::setErrorMessage(),
104
+     * read by PGTStorage::getErrorMessage().
105
+     *
106
+     * @hideinitializer
107
+     * @private
108
+     * @deprecated not used.
109
+     */
110
+    var $_error_message=FALSE;
111
+
112
+    /**
113
+     * This method sets en error message, which can be read later by 
114
+     * PGTStorage::getErrorMessage().
115
+     *
116
+     * @param $error_message an error message
117
+     *
118
+     * @protected
119
+     * @deprecated not used.
120
+     */
121
+    function setErrorMessage($error_message)
122 122
     {
123
-      $this->_error_message = $error_message;
123
+        $this->_error_message = $error_message;
124 124
     }
125 125
 
126
-  /**
127
-   * This method returns an error message set by PGTStorage::setErrorMessage().
128
-   *
129
-   * @return boolean error message when set by PGTStorage::setErrorMessage(), FALSE
130
-   * otherwise.
131
-   *
132
-   * @public
133
-   * @deprecated not used.
134
-   */
135
-  function getErrorMessage()
126
+    /**
127
+     * This method returns an error message set by PGTStorage::setErrorMessage().
128
+     *
129
+     * @return boolean error message when set by PGTStorage::setErrorMessage(), FALSE
130
+     * otherwise.
131
+     *
132
+     * @public
133
+     * @deprecated not used.
134
+     */
135
+    function getErrorMessage()
136 136
     {
137
-      return $this->_error_message;
137
+        return $this->_error_message;
138 138
     }
139 139
 
140
-  // ########################################################################
141
-  //  INITIALIZATION
142
-  // ########################################################################
143
-
144
-  /**
145
-   * a boolean telling if the storage has already been initialized. Written by 
146
-   * PGTStorage::init(), read by PGTStorage::isInitialized().
147
-   *
148
-   * @hideinitializer
149
-   * @private
150
-   */
151
-  var $_initialized = FALSE;
152
-
153
-  /**
154
-   * This method tells if the storage has already been intialized.
155
-   *
156
-   * @return boolean boolean
157
-   *
158
-   * @protected
159
-   */
160
-  function isInitialized()
140
+    // ########################################################################
141
+    //  INITIALIZATION
142
+    // ########################################################################
143
+
144
+    /**
145
+     * a boolean telling if the storage has already been initialized. Written by 
146
+     * PGTStorage::init(), read by PGTStorage::isInitialized().
147
+     *
148
+     * @hideinitializer
149
+     * @private
150
+     */
151
+    var $_initialized = FALSE;
152
+
153
+    /**
154
+     * This method tells if the storage has already been intialized.
155
+     *
156
+     * @return boolean boolean
157
+     *
158
+     * @protected
159
+     */
160
+    function isInitialized()
161 161
     {
162
-      return $this->_initialized;
162
+        return $this->_initialized;
163 163
     }
164 164
 
165
-  /**
166
-   * This virtual method initializes the object.
167
-   *
168
-   * @protected
169
-   */
170
-  function init()
165
+    /**
166
+     * This virtual method initializes the object.
167
+     *
168
+     * @protected
169
+     */
170
+    function init()
171 171
     {
172
-      $this->_initialized = TRUE;
172
+        $this->_initialized = TRUE;
173 173
     }
174 174
 
175
-  // ########################################################################
176
-  //  PGT I/O
177
-  // ########################################################################
178
-
179
-  /**
180
-   * This virtual method stores a PGT and its corresponding PGT Iuo.
181
-   * @note Should never be called.
182
-   *
183
-   * @param $pgt the PGT
184
-   * @param $pgt_iou the PGT iou
185
-   *
186
-   * @protected
187
-   */
188
-  function write($pgt,$pgt_iou)
175
+    // ########################################################################
176
+    //  PGT I/O
177
+    // ########################################################################
178
+
179
+    /**
180
+     * This virtual method stores a PGT and its corresponding PGT Iuo.
181
+     * @note Should never be called.
182
+     *
183
+     * @param $pgt the PGT
184
+     * @param $pgt_iou the PGT iou
185
+     *
186
+     * @protected
187
+     */
188
+    function write($pgt,$pgt_iou)
189 189
     {
190
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
190
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
191 191
     }
192 192
 
193
-  /**
194
-   * This virtual method reads a PGT corresponding to a PGT Iou and deletes
195
-   * the corresponding storage entry.
196
-   * @note Should never be called.
197
-   *
198
-   * @param $pgt_iou the PGT iou
199
-   *
200
-   * @protected
201
-   */
202
-  function read($pgt_iou)
193
+    /**
194
+     * This virtual method reads a PGT corresponding to a PGT Iou and deletes
195
+     * the corresponding storage entry.
196
+     * @note Should never be called.
197
+     *
198
+     * @param $pgt_iou the PGT iou
199
+     *
200
+     * @protected
201
+     */
202
+    function read($pgt_iou)
203 203
     {
204
-      phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
204
+        phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
205 205
     }
206 206
 
207
-  /** @} */
207
+    /** @} */
208 208
   
209 209
 } 
210 210
 
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-file.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -44,231 +44,231 @@
 block discarded – undo
44 44
 
45 45
 class PGTStorageFile extends PGTStorage
46 46
 {
47
-  /** 
48
-   * @addtogroup internalPGTStorageFile 
49
-   * @{ 
50
-   */
47
+    /** 
48
+     * @addtogroup internalPGTStorageFile 
49
+     * @{ 
50
+     */
51 51
 
52
-  /**
53
-   * a string telling where PGT's should be stored on the filesystem. Written by
54
-   * PGTStorageFile::PGTStorageFile(), read by getPath().
55
-   *
56
-   * @private
57
-   */
58
-  var $_path;
52
+    /**
53
+     * a string telling where PGT's should be stored on the filesystem. Written by
54
+     * PGTStorageFile::PGTStorageFile(), read by getPath().
55
+     *
56
+     * @private
57
+     */
58
+    var $_path;
59 59
 
60
-  /**
61
-   * This method returns the name of the directory where PGT's should be stored 
62
-   * on the filesystem.
63
-   *
64
-   * @return the name of a directory (with leading and trailing '/')
65
-   *
66
-   * @private
67
-   */
68
-  function getPath()
60
+    /**
61
+     * This method returns the name of the directory where PGT's should be stored 
62
+     * on the filesystem.
63
+     *
64
+     * @return the name of a directory (with leading and trailing '/')
65
+     *
66
+     * @private
67
+     */
68
+    function getPath()
69 69
     {
70
-      return $this->_path;
70
+        return $this->_path;
71 71
     }
72 72
 
73
-  /**
74
-   * a string telling the format to use to store PGT's (plain or xml). Written by
75
-   * PGTStorageFile::PGTStorageFile(), read by getFormat().
76
-   *
77
-   * @private
78
-   */
79
-  var $_format;
73
+    /**
74
+     * a string telling the format to use to store PGT's (plain or xml). Written by
75
+     * PGTStorageFile::PGTStorageFile(), read by getFormat().
76
+     *
77
+     * @private
78
+     */
79
+    var $_format;
80 80
 
81
-  /**
82
-   * This method returns the format to use when storing PGT's on the filesystem.
83
-   *
84
-   * @return a string corresponding to the format used (plain or xml).
85
-   *
86
-   * @private
87
-   */
88
-  function getFormat()
81
+    /**
82
+     * This method returns the format to use when storing PGT's on the filesystem.
83
+     *
84
+     * @return a string corresponding to the format used (plain or xml).
85
+     *
86
+     * @private
87
+     */
88
+    function getFormat()
89 89
     {
90
-      return $this->_format;
90
+        return $this->_format;
91 91
     }
92 92
 
93
-  // ########################################################################
94
-  //  DEBUGGING
95
-  // ########################################################################
93
+    // ########################################################################
94
+    //  DEBUGGING
95
+    // ########################################################################
96 96
   
97
-  /**
98
-   * This method returns an informational string giving the type of storage
99
-   * used by the object (used for debugging purposes).
100
-   *
101
-   * @return string informational string.
102
-   * @public
103
-   */
104
-  function getStorageType()
97
+    /**
98
+     * This method returns an informational string giving the type of storage
99
+     * used by the object (used for debugging purposes).
100
+     *
101
+     * @return string informational string.
102
+     * @public
103
+     */
104
+    function getStorageType()
105 105
     {
106
-      return "file";
106
+        return "file";
107 107
     }
108 108
 
109
-  /**
110
-   * This method returns an informational string giving informations on the
111
-   * parameters of the storage.(used for debugging purposes).
112
-   *
113
-   * @return string informational string.
114
-   * @public
115
-   */
116
-  function getStorageInfo()
109
+    /**
110
+     * This method returns an informational string giving informations on the
111
+     * parameters of the storage.(used for debugging purposes).
112
+     *
113
+     * @return string informational string.
114
+     * @public
115
+     */
116
+    function getStorageInfo()
117 117
     {
118
-      return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
118
+        return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
119 119
     }
120 120
 
121
-  // ########################################################################
122
-  //  CONSTRUCTOR
123
-  // ########################################################################
121
+    // ########################################################################
122
+    //  CONSTRUCTOR
123
+    // ########################################################################
124 124
   
125
-  /**
126
-   * The class constructor, called by CASClient::SetPGTStorageFile().
127
-   *
128
-   * @param CASClient $cas_parent the CASClient instance that creates the object.
129
-   * @param string $format the format used to store the PGT's (`plain' and `xml' allowed).
130
-   * @param string $path the path where the PGT's should be stored
131
-   *
132
-   * @public
133
-   */
134
-  function PGTStorageFile($cas_parent,$format,$path)
125
+    /**
126
+     * The class constructor, called by CASClient::SetPGTStorageFile().
127
+     *
128
+     * @param CASClient $cas_parent the CASClient instance that creates the object.
129
+     * @param string $format the format used to store the PGT's (`plain' and `xml' allowed).
130
+     * @param string $path the path where the PGT's should be stored
131
+     *
132
+     * @public
133
+     */
134
+    function PGTStorageFile($cas_parent,$format,$path)
135 135
     {
136
-      phpCAS::traceBegin();
137
-      // call the ancestor's constructor
138
-      $this->PGTStorage($cas_parent);
136
+        phpCAS::traceBegin();
137
+        // call the ancestor's constructor
138
+        $this->PGTStorage($cas_parent);
139 139
 
140
-      if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
-      if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
140
+        if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
+        if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
142 142
 
143
-      // check that the path is an absolute path
144
-      if (getenv("OS")=="Windows_NT"){
143
+        // check that the path is an absolute path
144
+        if (getenv("OS")=="Windows_NT"){
145 145
       	
146
-      	 if (!preg_match('`^[a-zA-Z]:`', $path)) {
147
-	     	phpCAS::error('an absolute path is needed for PGT storage to file');
148
-      	}
146
+            if (!preg_match('`^[a-zA-Z]:`', $path)) {
147
+                phpCAS::error('an absolute path is needed for PGT storage to file');
148
+            }
149 149
       	
150
-      }
151
-      else
152
-      {
150
+        }
151
+        else
152
+        {
153 153
       
154
-      	if ( $path[0] != '/' ) {
155
-			phpCAS::error('an absolute path is needed for PGT storage to file');
156
-      	}
154
+            if ( $path[0] != '/' ) {
155
+            phpCAS::error('an absolute path is needed for PGT storage to file');
156
+            }
157 157
 
158
-      	// store the path (with a leading and trailing '/')      
159
-      	$path = preg_replace('|[/]*$|','/',$path);
160
-      	$path = preg_replace('|^[/]*|','/',$path);
161
-      }
158
+            // store the path (with a leading and trailing '/')      
159
+            $path = preg_replace('|[/]*$|','/',$path);
160
+            $path = preg_replace('|^[/]*|','/',$path);
161
+        }
162 162
       
163
-      $this->_path = $path;
164
-      // check the format and store it
165
-      switch ($format) {
166
-      case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
163
+        $this->_path = $path;
164
+        // check the format and store it
165
+        switch ($format) {
166
+        case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN:
167 167
       case CAS_PGT_STORAGE_FILE_FORMAT_XML:
168
-	$this->_format = $format;
169
-	break;
170
-      default:
171
-	phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172
-      }
173
-      phpCAS::traceEnd();      
168
+    $this->_format = $format;
169
+    break;
170
+        default:
171
+    phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172
+        }
173
+        phpCAS::traceEnd();      
174 174
     }
175 175
 
176
-  // ########################################################################
177
-  //  INITIALIZATION
178
-  // ########################################################################
176
+    // ########################################################################
177
+    //  INITIALIZATION
178
+    // ########################################################################
179 179
   
180
-  /**
181
-   * This method is used to initialize the storage. Halts on error.
182
-   *
183
-   * @public
184
-   */
185
-  function init()
180
+    /**
181
+     * This method is used to initialize the storage. Halts on error.
182
+     *
183
+     * @public
184
+     */
185
+    function init()
186 186
     {
187
-      phpCAS::traceBegin();
188
-      // if the storage has already been initialized, return immediatly
189
-      if ( $this->isInitialized() )
190
-	return;
191
-      // call the ancestor's method (mark as initialized)
192
-      parent::init();
193
-      phpCAS::traceEnd();      
187
+        phpCAS::traceBegin();
188
+        // if the storage has already been initialized, return immediatly
189
+        if ( $this->isInitialized() )
190
+    return;
191
+        // call the ancestor's method (mark as initialized)
192
+        parent::init();
193
+        phpCAS::traceEnd();      
194 194
     }
195 195
 
196
-  // ########################################################################
197
-  //  PGT I/O
198
-  // ########################################################################
196
+    // ########################################################################
197
+    //  PGT I/O
198
+    // ########################################################################
199 199
 
200
-  /**
201
-   * This method returns the filename corresponding to a PGT Iou.
202
-   *
203
-   * @param $pgt_iou the PGT iou.
204
-   *
205
-   * @return string filename
206
-   * @private
207
-   */
208
-  function getPGTIouFilename($pgt_iou)
200
+    /**
201
+     * This method returns the filename corresponding to a PGT Iou.
202
+     *
203
+     * @param $pgt_iou the PGT iou.
204
+     *
205
+     * @return string filename
206
+     * @private
207
+     */
208
+    function getPGTIouFilename($pgt_iou)
209 209
     {
210
-      phpCAS::traceBegin();
211
-      $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
212
-      phpCAS::traceEnd($filename);
213
-      return $filename;
210
+        phpCAS::traceBegin();
211
+        $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
212
+        phpCAS::traceEnd($filename);
213
+        return $filename;
214 214
     }
215 215
   
216
-  /**
217
-   * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
218
-   * warning on error.
219
-   *
220
-   * @param $pgt the PGT
221
-   * @param $pgt_iou the PGT iou
222
-   *
223
-   * @public
224
-   */
225
-  function write($pgt,$pgt_iou)
216
+    /**
217
+     * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a
218
+     * warning on error.
219
+     *
220
+     * @param $pgt the PGT
221
+     * @param $pgt_iou the PGT iou
222
+     *
223
+     * @public
224
+     */
225
+    function write($pgt,$pgt_iou)
226 226
     {
227
-      phpCAS::traceBegin();
228
-      $fname = $this->getPGTIouFilename($pgt_iou);
229
-      if ( $f=fopen($fname,"w") ) {
230
-	if ( fputs($f,$pgt) === FALSE ) {
231
-	  phpCAS::error('could not write PGT to `'.$fname.'\'');
232
-	}
233
-	fclose($f);
234
-      } else {
235
-	phpCAS::error('could not open `'.$fname.'\'');
236
-      }
237
-      phpCAS::traceEnd();      
227
+        phpCAS::traceBegin();
228
+        $fname = $this->getPGTIouFilename($pgt_iou);
229
+        if ( $f=fopen($fname,"w") ) {
230
+    if ( fputs($f,$pgt) === FALSE ) {
231
+        phpCAS::error('could not write PGT to `'.$fname.'\'');
232
+    }
233
+    fclose($f);
234
+        } else {
235
+    phpCAS::error('could not open `'.$fname.'\'');
236
+        }
237
+        phpCAS::traceEnd();      
238 238
     }
239 239
 
240
-  /**
241
-   * This method reads a PGT corresponding to a PGT Iou and deletes the 
242
-   * corresponding file.
243
-   *
244
-   * @param $pgt_iou the PGT iou
245
-   *
246
-   * @return false|string corresponding PGT, or FALSE on error
247
-   *
248
-   * @public
249
-   */
250
-  function read($pgt_iou)
240
+    /**
241
+     * This method reads a PGT corresponding to a PGT Iou and deletes the 
242
+     * corresponding file.
243
+     *
244
+     * @param $pgt_iou the PGT iou
245
+     *
246
+     * @return false|string corresponding PGT, or FALSE on error
247
+     *
248
+     * @public
249
+     */
250
+    function read($pgt_iou)
251 251
     {
252
-      phpCAS::traceBegin();
253
-      $pgt = FALSE;
254
-      $fname = $this->getPGTIouFilename($pgt_iou);
255
-      if ( !($f=fopen($fname,"r")) ) {
256
-	phpCAS::trace('could not open `'.$fname.'\'');
257
-      } else {
258
-	if ( ($pgt=fgets($f)) === FALSE ) {
259
-	  phpCAS::trace('could not read PGT from `'.$fname.'\'');
260
-	} 
261
-	fclose($f);
262
-      }
252
+        phpCAS::traceBegin();
253
+        $pgt = FALSE;
254
+        $fname = $this->getPGTIouFilename($pgt_iou);
255
+        if ( !($f=fopen($fname,"r")) ) {
256
+    phpCAS::trace('could not open `'.$fname.'\'');
257
+        } else {
258
+    if ( ($pgt=fgets($f)) === FALSE ) {
259
+        phpCAS::trace('could not read PGT from `'.$fname.'\'');
260
+    } 
261
+    fclose($f);
262
+        }
263 263
 
264
-      // delete the PGT file
265
-      @unlink($fname);
264
+        // delete the PGT file
265
+        @unlink($fname);
266 266
 
267
-      phpCAS::traceEnd($pgt);
268
-      return $pgt;
267
+        phpCAS::traceEnd($pgt);
268
+        return $pgt;
269 269
     }
270 270
   
271
-  /** @} */
271
+    /** @} */
272 272
   
273 273
 }
274 274
 
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-db.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,175 +45,175 @@
 block discarded – undo
45 45
 
46 46
 class PGTStorageDB extends PGTStorage
47 47
 {
48
-  /** 
49
-   * @addtogroup internalPGTStorageDB
50
-   * @{ 
51
-   */
52
-
53
-  /**
54
-   * a string representing a PEAR DB URL to connect to the database. Written by
55
-   * PGTStorageDB::PGTStorageDB(), read by getURL().
56
-   *
57
-   * @hideinitializer
58
-   * @private
59
-   */
60
-  var $_url='';
61
-
62
-  /**
63
-   * This method returns the PEAR DB URL to use to connect to the database.
64
-   *
65
-   * @return string PEAR DB URL
66
-   *
67
-   * @private
68
-   */
69
-  function getURL()
48
+    /** 
49
+     * @addtogroup internalPGTStorageDB
50
+     * @{ 
51
+     */
52
+
53
+    /**
54
+     * a string representing a PEAR DB URL to connect to the database. Written by
55
+     * PGTStorageDB::PGTStorageDB(), read by getURL().
56
+     *
57
+     * @hideinitializer
58
+     * @private
59
+     */
60
+    var $_url='';
61
+
62
+    /**
63
+     * This method returns the PEAR DB URL to use to connect to the database.
64
+     *
65
+     * @return string PEAR DB URL
66
+     *
67
+     * @private
68
+     */
69
+    function getURL()
70 70
     {
71
-      return $this->_url;
71
+        return $this->_url;
72 72
     }
73 73
 
74
-  /**
75
-   * The handle of the connection to the database where PGT's are stored. Written by
76
-   * PGTStorageDB::init(), read by getLink().
77
-   *
78
-   * @hideinitializer
79
-   * @private
80
-   */
81
-  var $_link = null;
82
-
83
-  /**
84
-   * This method returns the handle of the connection to the database where PGT's are 
85
-   * stored.
86
-   *
87
-   * @return a handle of connection.
88
-   *
89
-   * @private
90
-   */
91
-  function getLink()
74
+    /**
75
+     * The handle of the connection to the database where PGT's are stored. Written by
76
+     * PGTStorageDB::init(), read by getLink().
77
+     *
78
+     * @hideinitializer
79
+     * @private
80
+     */
81
+    var $_link = null;
82
+
83
+    /**
84
+     * This method returns the handle of the connection to the database where PGT's are 
85
+     * stored.
86
+     *
87
+     * @return a handle of connection.
88
+     *
89
+     * @private
90
+     */
91
+    function getLink()
92 92
     {
93
-      return $this->_link;
93
+        return $this->_link;
94 94
     }
95 95
 
96
-  /**
97
-   * The name of the table where PGT's are stored. Written by 
98
-   * PGTStorageDB::PGTStorageDB(), read by getTable().
99
-   *
100
-   * @hideinitializer
101
-   * @private
102
-   */
103
-  var $_table = '';
104
-
105
-  /**
106
-   * This method returns the name of the table where PGT's are stored.
107
-   *
108
-   * @return string name of a table.
109
-   *
110
-   * @private
111
-   */
112
-  function getTable()
96
+    /**
97
+     * The name of the table where PGT's are stored. Written by 
98
+     * PGTStorageDB::PGTStorageDB(), read by getTable().
99
+     *
100
+     * @hideinitializer
101
+     * @private
102
+     */
103
+    var $_table = '';
104
+
105
+    /**
106
+     * This method returns the name of the table where PGT's are stored.
107
+     *
108
+     * @return string name of a table.
109
+     *
110
+     * @private
111
+     */
112
+    function getTable()
113 113
     {
114
-      return $this->_table;
114
+        return $this->_table;
115 115
     }
116 116
 
117
-  // ########################################################################
118
-  //  DEBUGGING
119
-  // ########################################################################
117
+    // ########################################################################
118
+    //  DEBUGGING
119
+    // ########################################################################
120 120
   
121
-  /**
122
-   * This method returns an informational string giving the type of storage
123
-   * used by the object (used for debugging purposes).
124
-   *
125
-   * @return string informational string.
126
-   * @public
127
-   */
128
-  function getStorageType()
121
+    /**
122
+     * This method returns an informational string giving the type of storage
123
+     * used by the object (used for debugging purposes).
124
+     *
125
+     * @return string informational string.
126
+     * @public
127
+     */
128
+    function getStorageType()
129 129
     {
130
-      return "database";
130
+        return "database";
131 131
     }
132 132
 
133
-  /**
134
-   * This method returns an informational string giving informations on the
135
-   * parameters of the storage.(used for debugging purposes).
136
-   *
137
-   * @public
138
-   */
139
-  function getStorageInfo()
133
+    /**
134
+     * This method returns an informational string giving informations on the
135
+     * parameters of the storage.(used for debugging purposes).
136
+     *
137
+     * @public
138
+     */
139
+    function getStorageInfo()
140 140
     {
141
-      return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
141
+        return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
142 142
     }
143 143
 
144
-  // ########################################################################
145
-  //  CONSTRUCTOR
146
-  // ########################################################################
144
+    // ########################################################################
145
+    //  CONSTRUCTOR
146
+    // ########################################################################
147 147
   
148
-  /**
149
-   * The class constructor, called by CASClient::SetPGTStorageDB().
150
-   *
151
-   * @param CASClient $cas_parent the CASClient instance that creates the object.
152
-   * @param $user the user to access the data with
153
-   * @param $password the user's password
154
-   * @param $database_type the type of the database hosting the data
155
-   * @param $hostname the server hosting the database
156
-   * @param $port the port the server is listening on
157
-   * @param $database the name of the database
158
-   * @param $table the name of the table storing the data
159
-   *
160
-   * @public
161
-   */
162
-  function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
148
+    /**
149
+     * The class constructor, called by CASClient::SetPGTStorageDB().
150
+     *
151
+     * @param CASClient $cas_parent the CASClient instance that creates the object.
152
+     * @param $user the user to access the data with
153
+     * @param $password the user's password
154
+     * @param $database_type the type of the database hosting the data
155
+     * @param $hostname the server hosting the database
156
+     * @param $port the port the server is listening on
157
+     * @param $database the name of the database
158
+     * @param $table the name of the table storing the data
159
+     *
160
+     * @public
161
+     */
162
+    function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
163 163
     {
164
-      phpCAS::traceBegin();
164
+        phpCAS::traceBegin();
165 165
 
166
-      // call the ancestor's constructor
167
-      $this->PGTStorage($cas_parent);
166
+        // call the ancestor's constructor
167
+        $this->PGTStorage($cas_parent);
168 168
 
169
-      if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
-      if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
-      if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
-      if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
-      if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
169
+        if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
+        if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
+        if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
+        if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
+        if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
174 174
 
175
-      // build and store the PEAR DB URL
176
-      $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
175
+        // build and store the PEAR DB URL
176
+        $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
177 177
 
178
-      // XXX should use setURL and setTable
179
-      phpCAS::traceEnd();
178
+        // XXX should use setURL and setTable
179
+        phpCAS::traceEnd();
180 180
     }
181 181
   
182
-  // ########################################################################
183
-  //  INITIALIZATION
184
-  // ########################################################################
182
+    // ########################################################################
183
+    //  INITIALIZATION
184
+    // ########################################################################
185 185
   
186
-  /**
187
-   * This method is used to initialize the storage. Halts on error.
188
-   *
189
-   * @public
190
-   */
191
-  function init()
186
+    /**
187
+     * This method is used to initialize the storage. Halts on error.
188
+     *
189
+     * @public
190
+     */
191
+    function init()
192 192
     {
193
-      phpCAS::traceBegin();
194
-      // if the storage has already been initialized, return immediatly
195
-      if ( $this->isInitialized() )
196
-		return;
197
-      // call the ancestor's method (mark as initialized)
198
-      parent::init();
193
+        phpCAS::traceBegin();
194
+        // if the storage has already been initialized, return immediatly
195
+        if ( $this->isInitialized() )
196
+        return;
197
+        // call the ancestor's method (mark as initialized)
198
+        parent::init();
199 199
       
200
-	  //include phpDB library (the test was introduced in release 0.4.8 for 
201
-	  //the integration into Tikiwiki).
202
-	  if (!class_exists('DB')) {
203
-		include_once('DB.php');
204
-	  }
205
-
206
-      // try to connect to the database
207
-      $this->_link = DB::connect($this->getURL());
208
-      if ( DB::isError($this->_link) ) {
209
-	    phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210
-      }
211
-      // Dump into trace
212
-      var_dump($this->_link);
213
-      phpCAS::traceBEnd();
200
+        //include phpDB library (the test was introduced in release 0.4.8 for 
201
+        //the integration into Tikiwiki).
202
+        if (!class_exists('DB')) {
203
+        include_once('DB.php');
204
+        }
205
+
206
+        // try to connect to the database
207
+        $this->_link = DB::connect($this->getURL());
208
+        if ( DB::isError($this->_link) ) {
209
+        phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210
+        }
211
+        // Dump into trace
212
+        var_dump($this->_link);
213
+        phpCAS::traceBEnd();
214 214
     }
215 215
 
216
-  /** @} */
216
+    /** @} */
217 217
 }
218 218
 
219 219
 ?>
220 220
\ No newline at end of file
Please login to merge, or discard this patch.