@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | function unset_session_resources() { |
27 | - $_SESSION['addedresource']=''; |
|
28 | - $_SESSION['addedresourceid']=''; |
|
29 | - Session::erase('addedresource'); |
|
30 | - Session::erase('addedresourceid'); |
|
27 | + $_SESSION['addedresource']=''; |
|
28 | + $_SESSION['addedresourceid']=''; |
|
29 | + Session::erase('addedresource'); |
|
30 | + Session::erase('addedresourceid'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function show_folder_up() |
37 | 37 | { |
38 | - global $folder; |
|
39 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
40 | - |
|
41 | - $level = get_levels($folder); |
|
42 | - |
|
43 | - if ($level == 1) |
|
44 | - { |
|
45 | - echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
46 | - } |
|
47 | - if ($level and $level != 0 and $level != 1) |
|
48 | - { |
|
49 | - $folder_up=$folder; |
|
50 | - $folder_temp=explode('/',$folder); |
|
51 | - $last=count($folder_temp)-1; |
|
52 | - unset($folder_temp[$last]); |
|
53 | - $folder_up=implode('/',$folder_temp); |
|
54 | - echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
55 | - } |
|
38 | + global $folder; |
|
39 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
40 | + |
|
41 | + $level = get_levels($folder); |
|
42 | + |
|
43 | + if ($level == 1) |
|
44 | + { |
|
45 | + echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
46 | + } |
|
47 | + if ($level and $level != 0 and $level != 1) |
|
48 | + { |
|
49 | + $folder_up=$folder; |
|
50 | + $folder_temp=explode('/',$folder); |
|
51 | + $last=count($folder_temp)-1; |
|
52 | + unset($folder_temp[$last]); |
|
53 | + $folder_up=implode('/',$folder_temp); |
|
54 | + echo "<a href='".api_get_self()."?content=Document&source_forum=".$_GET['source_forum']."&folder=$folder_up&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>"; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function show_documents($folder) |
63 | 63 | { |
64 | - global $_course; |
|
65 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
66 | - |
|
67 | - // documents are a special case: the teacher can add an invisible document (it will be viewable by the user) |
|
68 | - // other tools do not have this feature. This only counts |
|
69 | - if (api_is_allowed_to_edit()) |
|
70 | - { |
|
71 | - $visibility="ip.visibility<>'2'"; |
|
72 | - } |
|
73 | - else |
|
74 | - { |
|
75 | - $visibility="ip.visibility='1'"; |
|
76 | - } |
|
77 | - |
|
78 | - $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
79 | - $document_table = Database::get_course_table(TABLE_DOCUMENT); |
|
80 | - $sql = "SELECT * from $document_table docs, $item_property_table ip |
|
64 | + global $_course; |
|
65 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
66 | + |
|
67 | + // documents are a special case: the teacher can add an invisible document (it will be viewable by the user) |
|
68 | + // other tools do not have this feature. This only counts |
|
69 | + if (api_is_allowed_to_edit()) |
|
70 | + { |
|
71 | + $visibility="ip.visibility<>'2'"; |
|
72 | + } |
|
73 | + else |
|
74 | + { |
|
75 | + $visibility="ip.visibility='1'"; |
|
76 | + } |
|
77 | + |
|
78 | + $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
79 | + $document_table = Database::get_course_table(TABLE_DOCUMENT); |
|
80 | + $sql = "SELECT * from $document_table docs, $item_property_table ip |
|
81 | 81 | WHERE |
82 | 82 | docs.id=ip.ref AND |
83 | 83 | ip.tool = '".TOOL_DOCUMENT."' AND |
@@ -85,104 +85,104 @@ discard block |
||
85 | 85 | (ip.to_group_id = 0 OR i.to_group_id IS NULL) AND |
86 | 86 | ip.to_user_id IS NULL |
87 | 87 | ORDER BY docs.path ASC"; |
88 | - $result=Database::query($sql); |
|
89 | - while ($row=Database::fetch_array($result)) |
|
90 | - { |
|
91 | - if (!$folder) |
|
92 | - { |
|
93 | - if (get_levels($row['path'])-1==1) |
|
94 | - { |
|
95 | - // showing the right icon |
|
96 | - if (file_or_folder($row['path'])) |
|
97 | - { |
|
98 | - echo '<img src="../img/file.gif" align="middle" />'; |
|
99 | - } |
|
100 | - else |
|
101 | - { |
|
102 | - $image = choose_image($row['path']); |
|
103 | - echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
104 | - } |
|
105 | - |
|
106 | - // folders should be clickable |
|
107 | - if (file_or_folder($row['path'])) |
|
108 | - { |
|
109 | - echo "<a href='".api_get_self()."?content=Document"; |
|
110 | - echo "&folder=".substr($row['path'],1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".substr($row['path'],1).'</a><br />'; |
|
111 | - } |
|
112 | - else |
|
113 | - { |
|
114 | - echo substr($row['path'],1).' '; |
|
115 | - echo showorhide_addresourcelink('Document',$row['id']); |
|
116 | - echo '<br />'; |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
120 | - else |
|
121 | - { |
|
122 | - // we calculate the level we are in by using the $folder in the url |
|
123 | - // we put +1 because it does not start with an / and in the database it does |
|
124 | - $level=get_levels($folder)+1; |
|
125 | - |
|
126 | - // we calculate each level of the database entry |
|
127 | - $file_level=get_levels($row['path'])-1; |
|
128 | - // if the level of the database entry is equal to the level we ar in, we put it into an array |
|
129 | - // as this is a potential good entry |
|
130 | - if ($file_level==$level) |
|
131 | - { |
|
132 | - $good_paths[]=$row['path']; |
|
133 | - $good_ids[]=$row['id']; |
|
134 | - } |
|
135 | - //$haystack=$row['path']; |
|
136 | - //$conform_folder=strstr($haystack, $folder); |
|
137 | - //if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
138 | - // { |
|
139 | - // $good_folders[]=$row['path']; |
|
140 | - //echo str_replace($folder.'/','',$conform_folder); |
|
141 | - // echo '<br />'; |
|
142 | - // }// if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
143 | - } // else (if (!$folder)) |
|
144 | - } //while ($row=Database::fetch_array($result)) |
|
145 | - |
|
146 | - // this is code for the case that we are in a subfolder |
|
147 | - if ($good_paths) |
|
148 | - { |
|
149 | - // we have all the potential good database entries, the good ones are those that start with $folder |
|
150 | - foreach ($good_paths as $path) |
|
151 | - { |
|
152 | - if (strstr($path,$folder)) |
|
153 | - { |
|
154 | - $good_key=key($good_paths); |
|
155 | - // showing the right icon |
|
156 | - if (file_or_folder($path)) |
|
157 | - { |
|
158 | - echo '<img src="../img/file.gif" align="middle" />'; |
|
159 | - } |
|
160 | - else |
|
161 | - { |
|
162 | - $image = choose_image($path); |
|
163 | - echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
164 | - } |
|
165 | - |
|
166 | - // folders should be clickable |
|
167 | - if (file_or_folder($path)) |
|
168 | - { |
|
169 | - $path=substr($path,1); // remove the first / in folder_up |
|
170 | - $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']); |
|
171 | - $newuri=str_replace('add=','addnot=',$uri); |
|
172 | - //using the correct name of the folder |
|
173 | - $folder_name=str_replace($folder.'/','',$path); |
|
174 | - echo "<a href='$newuri'>".$folder_name.'</a><br />'; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - echo str_replace("/$folder/", '',$path).' '; |
|
179 | - echo showorhide_addresourcelink('Document',$good_ids[$good_key]); |
|
180 | - echo '<br />'; |
|
181 | - } |
|
182 | - } |
|
183 | - next($good_paths); |
|
184 | - } |
|
185 | - } |
|
88 | + $result=Database::query($sql); |
|
89 | + while ($row=Database::fetch_array($result)) |
|
90 | + { |
|
91 | + if (!$folder) |
|
92 | + { |
|
93 | + if (get_levels($row['path'])-1==1) |
|
94 | + { |
|
95 | + // showing the right icon |
|
96 | + if (file_or_folder($row['path'])) |
|
97 | + { |
|
98 | + echo '<img src="../img/file.gif" align="middle" />'; |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
102 | + $image = choose_image($row['path']); |
|
103 | + echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
104 | + } |
|
105 | + |
|
106 | + // folders should be clickable |
|
107 | + if (file_or_folder($row['path'])) |
|
108 | + { |
|
109 | + echo "<a href='".api_get_self()."?content=Document"; |
|
110 | + echo "&folder=".substr($row['path'],1)."&source_id=$source_id&source_forum=".$_GET['source_forum']."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".substr($row['path'],1).'</a><br />'; |
|
111 | + } |
|
112 | + else |
|
113 | + { |
|
114 | + echo substr($row['path'],1).' '; |
|
115 | + echo showorhide_addresourcelink('Document',$row['id']); |
|
116 | + echo '<br />'; |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | + else |
|
121 | + { |
|
122 | + // we calculate the level we are in by using the $folder in the url |
|
123 | + // we put +1 because it does not start with an / and in the database it does |
|
124 | + $level=get_levels($folder)+1; |
|
125 | + |
|
126 | + // we calculate each level of the database entry |
|
127 | + $file_level=get_levels($row['path'])-1; |
|
128 | + // if the level of the database entry is equal to the level we ar in, we put it into an array |
|
129 | + // as this is a potential good entry |
|
130 | + if ($file_level==$level) |
|
131 | + { |
|
132 | + $good_paths[]=$row['path']; |
|
133 | + $good_ids[]=$row['id']; |
|
134 | + } |
|
135 | + //$haystack=$row['path']; |
|
136 | + //$conform_folder=strstr($haystack, $folder); |
|
137 | + //if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
138 | + // { |
|
139 | + // $good_folders[]=$row['path']; |
|
140 | + //echo str_replace($folder.'/','',$conform_folder); |
|
141 | + // echo '<br />'; |
|
142 | + // }// if (str_replace($folder.'/','',$conform_folder)!==$folder) |
|
143 | + } // else (if (!$folder)) |
|
144 | + } //while ($row=Database::fetch_array($result)) |
|
145 | + |
|
146 | + // this is code for the case that we are in a subfolder |
|
147 | + if ($good_paths) |
|
148 | + { |
|
149 | + // we have all the potential good database entries, the good ones are those that start with $folder |
|
150 | + foreach ($good_paths as $path) |
|
151 | + { |
|
152 | + if (strstr($path,$folder)) |
|
153 | + { |
|
154 | + $good_key=key($good_paths); |
|
155 | + // showing the right icon |
|
156 | + if (file_or_folder($path)) |
|
157 | + { |
|
158 | + echo '<img src="../img/file.gif" align="middle" />'; |
|
159 | + } |
|
160 | + else |
|
161 | + { |
|
162 | + $image = choose_image($path); |
|
163 | + echo "<img src=\"../img/$image\" align=\"middle\" />"; |
|
164 | + } |
|
165 | + |
|
166 | + // folders should be clickable |
|
167 | + if (file_or_folder($path)) |
|
168 | + { |
|
169 | + $path=substr($path,1); // remove the first / in folder_up |
|
170 | + $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']); |
|
171 | + $newuri=str_replace('add=','addnot=',$uri); |
|
172 | + //using the correct name of the folder |
|
173 | + $folder_name=str_replace($folder.'/','',$path); |
|
174 | + echo "<a href='$newuri'>".$folder_name.'</a><br />'; |
|
175 | + } |
|
176 | + else |
|
177 | + { |
|
178 | + echo str_replace("/$folder/", '',$path).' '; |
|
179 | + echo showorhide_addresourcelink('Document',$good_ids[$good_key]); |
|
180 | + echo '<br />'; |
|
181 | + } |
|
182 | + } |
|
183 | + next($good_paths); |
|
184 | + } |
|
185 | + } |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function file_or_folder($filefolder) |
195 | 195 | { |
196 | - global $_course; |
|
197 | - global $baseServDir; |
|
196 | + global $_course; |
|
197 | + global $baseServDir; |
|
198 | 198 | |
199 | - $courseDir = $_course['path'].'/document'; |
|
200 | - $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir; |
|
199 | + $courseDir = $_course['path'].'/document'; |
|
200 | + $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir; |
|
201 | 201 | |
202 | - return (is_dir($baseWorkDir.$filefolder) ? 1 : 0); |
|
202 | + return (is_dir($baseWorkDir.$filefolder) ? 1 : 0); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,23 +210,23 @@ discard block |
||
210 | 210 | */ |
211 | 211 | function store_resources($source_type, $source_id) |
212 | 212 | { |
213 | - global $_course; |
|
214 | - $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
215 | - |
|
216 | - $addedresource = $_SESSION['addedresource']; |
|
217 | - $addedresourceid = $_SESSION['addedresourceid']; |
|
218 | - if ($_SESSION['addedresource']) |
|
219 | - { |
|
220 | - foreach ($addedresource as $resource_type) |
|
221 | - { |
|
222 | - $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; |
|
223 | - Database::query($sql); |
|
224 | - $i=key($addedresource); |
|
225 | - next($addedresource); |
|
226 | - } |
|
227 | - $_SESSION['addedresource']=''; |
|
228 | - $_SESSION['addedresourceid']=''; |
|
229 | - } |
|
213 | + global $_course; |
|
214 | + $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
215 | + |
|
216 | + $addedresource = $_SESSION['addedresource']; |
|
217 | + $addedresourceid = $_SESSION['addedresourceid']; |
|
218 | + if ($_SESSION['addedresource']) |
|
219 | + { |
|
220 | + foreach ($addedresource as $resource_type) |
|
221 | + { |
|
222 | + $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')"; |
|
223 | + Database::query($sql); |
|
224 | + $i=key($addedresource); |
|
225 | + next($addedresource); |
|
226 | + } |
|
227 | + $_SESSION['addedresource']=''; |
|
228 | + $_SESSION['addedresourceid']=''; |
|
229 | + } |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -240,87 +240,87 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function display_addedresource_link($type, $id, $style='') |
242 | 242 | { |
243 | - global $_course; |
|
243 | + global $_course; |
|
244 | 244 | |
245 | - // styling the link of the added resource |
|
246 | - if ($style <> '') |
|
247 | - { |
|
248 | - $styling = ' class="'.$style.'"'; |
|
249 | - } |
|
245 | + // styling the link of the added resource |
|
246 | + if ($style <> '') |
|
247 | + { |
|
248 | + $styling = ' class="'.$style.'"'; |
|
249 | + } |
|
250 | 250 | |
251 | 251 | $course_id = api_get_course_int_id(); |
252 | 252 | |
253 | - switch ($type) |
|
254 | - { |
|
255 | - case 'Agenda': |
|
256 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
257 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id"); |
|
258 | - $myrow = Database::fetch_array($result); |
|
259 | - echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
260 | - break; |
|
261 | - case 'Ad_Valvas': |
|
262 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
263 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id"); |
|
264 | - $myrow = Database::fetch_array($result); |
|
265 | - echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
266 | - break; |
|
267 | - case 'Link':Database::get_course_table(TABLE_LINK); |
|
268 | - $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
|
269 | - $myrow = Database::fetch_array($result); |
|
270 | - echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n"; |
|
271 | - break; |
|
272 | - case 'Exercise': |
|
273 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
274 | - $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
|
275 | - $myrow = Database::fetch_array($result); |
|
276 | - echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercise/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
277 | - break; |
|
278 | - case 'Forum': |
|
279 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
280 | - $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id"); |
|
281 | - $myrow = Database::fetch_array($result); |
|
282 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n"; |
|
283 | - break; |
|
284 | - case 'Thread': //=topics |
|
253 | + switch ($type) |
|
254 | + { |
|
255 | + case 'Agenda': |
|
256 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
257 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id"); |
|
258 | + $myrow = Database::fetch_array($result); |
|
259 | + echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
260 | + break; |
|
261 | + case 'Ad_Valvas': |
|
262 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
263 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id"); |
|
264 | + $myrow = Database::fetch_array($result); |
|
265 | + echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
266 | + break; |
|
267 | + case 'Link':Database::get_course_table(TABLE_LINK); |
|
268 | + $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id"); |
|
269 | + $myrow = Database::fetch_array($result); |
|
270 | + echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n"; |
|
271 | + break; |
|
272 | + case 'Exercise': |
|
273 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
274 | + $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id"); |
|
275 | + $myrow = Database::fetch_array($result); |
|
276 | + echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercise/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n"; |
|
277 | + break; |
|
278 | + case 'Forum': |
|
279 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
280 | + $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id"); |
|
281 | + $myrow = Database::fetch_array($result); |
|
282 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewforum.php?forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n"; |
|
283 | + break; |
|
284 | + case 'Thread': //=topics |
|
285 | 285 | //deprecated |
286 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
287 | - $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
288 | - $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; |
|
289 | - $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); |
|
290 | - $myrow = Database::fetch_array($result); |
|
291 | - // grabbing the title of the post |
|
292 | - $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
293 | - $result_title = Database::query($sql_title); |
|
294 | - $myrow_title = Database::fetch_array($result_title); |
|
295 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewtopic.php?topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n"; |
|
296 | - break; |
|
297 | - case 'Post': |
|
286 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
287 | + $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
288 | + $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; |
|
289 | + $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); |
|
290 | + $myrow = Database::fetch_array($result); |
|
291 | + // grabbing the title of the post |
|
292 | + $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
293 | + $result_title = Database::query($sql_title); |
|
294 | + $myrow_title = Database::fetch_array($result_title); |
|
295 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../forum/viewtopic.php?topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n"; |
|
296 | + break; |
|
297 | + case 'Post': |
|
298 | 298 | //deprecated |
299 | - $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
300 | - $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE); |
|
301 | - $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id"; |
|
302 | - $result = Database::query($sql); |
|
303 | - $post = Database::fetch_object($result); |
|
304 | - echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n"; |
|
305 | - break; |
|
306 | - case 'Document': |
|
307 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
308 | - $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id"); |
|
309 | - $myrow = Database::fetch_array($result); |
|
310 | - $pathname = explode('/',$myrow['path']); // making a correct name for the link |
|
311 | - $last = count($pathname) - 1; // making a correct name for the link |
|
312 | - $filename = $pathname[$last]; // making a correct name for the link |
|
313 | - $image = choose_image($filename); |
|
314 | - $ext = explode('.',$filename); |
|
315 | - $ext = strtolower($ext[sizeof($ext)-1]); |
|
316 | - $myrow['path'] = rawurlencode($myrow['path']); |
|
317 | - $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png')); |
|
318 | - echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n"; |
|
319 | - break; |
|
320 | - case 'Externallink': |
|
321 | - echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n"; |
|
322 | - break; |
|
323 | - } |
|
299 | + $tbl_post = Database::get_course_table(TABLE_FORUM_POST); |
|
300 | + $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE); |
|
301 | + $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id"; |
|
302 | + $result = Database::query($sql); |
|
303 | + $post = Database::fetch_object($result); |
|
304 | + echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n"; |
|
305 | + break; |
|
306 | + case 'Document': |
|
307 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
308 | + $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id"); |
|
309 | + $myrow = Database::fetch_array($result); |
|
310 | + $pathname = explode('/',$myrow['path']); // making a correct name for the link |
|
311 | + $last = count($pathname) - 1; // making a correct name for the link |
|
312 | + $filename = $pathname[$last]; // making a correct name for the link |
|
313 | + $image = choose_image($filename); |
|
314 | + $ext = explode('.',$filename); |
|
315 | + $ext = strtolower($ext[sizeof($ext)-1]); |
|
316 | + $myrow['path'] = rawurlencode($myrow['path']); |
|
317 | + $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png')); |
|
318 | + echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n"; |
|
319 | + break; |
|
320 | + case 'Externallink': |
|
321 | + echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n"; |
|
322 | + break; |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -342,766 +342,766 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0) |
344 | 344 | { |
345 | - global $learnpath_id, $tbl_learnpath_item, $items; |
|
346 | - global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; |
|
347 | - |
|
348 | - $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"' |
|
349 | - |
|
350 | - $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32); |
|
351 | - |
|
352 | - if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
353 | - $linktype = $type; |
|
354 | - if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
|
355 | - |
|
356 | - switch ($type) |
|
357 | - { |
|
358 | - case "Agenda": |
|
359 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
360 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
361 | - $myrow=Database::fetch_array($result); |
|
362 | - |
|
363 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
364 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
365 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
366 | - $desc=$row['description']; |
|
367 | - $agenda_id=$row['item_id']; |
|
368 | - echo str_repeat(" >",$level); |
|
369 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
370 | - if ($icon != 'nolink') |
|
371 | - { |
|
372 | - if ($completed=='completed') { |
|
373 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
374 | - } else { |
|
375 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
376 | - //echo " "; |
|
377 | - } |
|
378 | - } |
|
379 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
380 | - |
|
381 | - if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
382 | - |
|
383 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
384 | - if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; } |
|
385 | - if ($builder != 'builder') |
|
386 | - { |
|
387 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
388 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
389 | - if ($desc != '') |
|
390 | - { |
|
391 | - if ($icon != 'wrap') |
|
392 | - { |
|
393 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
394 | - } |
|
395 | - else |
|
396 | - { |
|
397 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
398 | - } |
|
399 | - } |
|
400 | - } |
|
401 | - else |
|
402 | - { |
|
403 | - echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
404 | - } |
|
405 | - break; |
|
406 | - |
|
407 | - case "Ad_Valvas": |
|
408 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
409 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
410 | - $myrow=Database::fetch_array($result); |
|
411 | - |
|
412 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
413 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
414 | - if ($row['title'] != '') { $myrow["content"]=$row['title']; } |
|
415 | - $desc=$row['description']; |
|
416 | - $ann_id=$row['item_id']; |
|
417 | - echo str_repeat(" >",$level); |
|
418 | - |
|
419 | - // the title and the text are in the content field and we only want to display the title |
|
420 | - list($title, $text)=split('<br>',$myrow['content']); |
|
421 | - if ($title=='') { $title=$myrow['content']; } |
|
422 | - $title=$myrow['title']; |
|
423 | - $text=$myrow['content']; |
|
424 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
425 | - if ($icon != 'nolink') |
|
426 | - { |
|
427 | - if ($completed=='completed') { |
|
428 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
429 | - } else { |
|
430 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
431 | - //echo " "; |
|
432 | - } |
|
433 | - } |
|
434 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
435 | - |
|
436 | - if ($title=='') { |
|
437 | - $type="Announcement"; |
|
438 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
439 | - return(true); |
|
440 | - } |
|
441 | - |
|
442 | - if ($icon == 'nolink') { return(shorten($title,$length)); } |
|
443 | - if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; } |
|
444 | - if ($builder != 'builder') |
|
445 | - { |
|
446 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>"; |
|
447 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path"; |
|
448 | - if ($desc != '') |
|
449 | - { |
|
450 | - if ($icon != 'wrap') |
|
451 | - { |
|
452 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
453 | - } |
|
454 | - else |
|
455 | - { |
|
456 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
457 | - } |
|
458 | - } |
|
459 | - } |
|
460 | - else |
|
461 | - { |
|
462 | - echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>"; |
|
463 | - } |
|
464 | - break; |
|
465 | - |
|
466 | - case "Link" : |
|
467 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
468 | - $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
469 | - $myrow=Database::fetch_array($result); |
|
470 | - |
|
471 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
472 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
473 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
474 | - $desc=$row['description']; |
|
475 | - echo str_repeat(" >",$level); |
|
476 | - |
|
477 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
478 | - if ($icon != 'nolink') |
|
479 | - { |
|
480 | - if ($completed=='completed') { |
|
481 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
482 | - } else { |
|
483 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
484 | - //echo " "; |
|
485 | - } |
|
486 | - } |
|
487 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
488 | - |
|
489 | - if ($myrow["title"]=='') |
|
490 | - { |
|
491 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
492 | - return(true); |
|
493 | - } |
|
494 | - |
|
495 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
496 | - if ($icon == 'icon') |
|
497 | - { |
|
498 | - if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
|
499 | - else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
500 | - } |
|
501 | - $thelink=$myrow["url"]; |
|
502 | - if ($builder != 'builder') |
|
503 | - { |
|
504 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
505 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
506 | - if ($desc != '') |
|
507 | - { |
|
508 | - if ($icon != 'wrap') |
|
509 | - { |
|
510 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
511 | - } |
|
512 | - else |
|
513 | - { |
|
514 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
515 | - } |
|
516 | - } |
|
517 | - } |
|
518 | - else |
|
519 | - { |
|
520 | - echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
521 | - } |
|
522 | - break; |
|
523 | - |
|
524 | - case "Exercise": |
|
525 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
526 | - $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
527 | - $myrow=Database::fetch_array($result); |
|
528 | - |
|
529 | - if ($builder=='builder') { $origin='builder'; } |
|
530 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
531 | - |
|
532 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
533 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
534 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
535 | - $desc=$row['description']; |
|
536 | - echo str_repeat(" >",$level); |
|
537 | - |
|
538 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
539 | - if ($icon != 'nolink') |
|
540 | - { |
|
541 | - if ($completed=='completed') { |
|
542 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
543 | - } else { |
|
544 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
545 | - //echo " "; |
|
546 | - } |
|
547 | - } |
|
548 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
549 | - |
|
550 | - if ($myrow["title"]=='') { |
|
551 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
552 | - return(true); |
|
553 | - } |
|
554 | - |
|
555 | - if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
556 | - if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; } |
|
557 | - if ($builder != 'builder') |
|
558 | - { |
|
559 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
560 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
561 | - if ($desc != '') |
|
562 | - { |
|
563 | - if ($icon != 'wrap') |
|
564 | - { |
|
565 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
566 | - } |
|
567 | - else |
|
568 | - { |
|
569 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
570 | - } |
|
571 | - } |
|
572 | - } |
|
573 | - else |
|
574 | - { |
|
575 | - echo "<a href=\"../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
576 | - } |
|
577 | - break; |
|
578 | - |
|
579 | - case "HotPotatoes": |
|
580 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
581 | - $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
582 | - $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
583 | - $myrow= Database::fetch_array($result); |
|
584 | - $path=$myrow["path"]; |
|
585 | - $name=GetQuizName($path,$documentPath); |
|
586 | - |
|
587 | - if ($builder=='builder') { $origin='builder'; } |
|
588 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
589 | - |
|
590 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
591 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
592 | - if ($row['title'] != '') { $name=$row['title']; } |
|
593 | - $desc=$row['description']; |
|
594 | - echo str_repeat(" >",$level); |
|
595 | - |
|
596 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
597 | - if ($icon != 'nolink') |
|
598 | - { |
|
599 | - if ($completed=='completed') { |
|
600 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
601 | - } else { |
|
602 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
603 | - //echo " "; |
|
604 | - } |
|
605 | - } |
|
606 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
607 | - |
|
608 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
609 | - |
|
610 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
611 | - if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; } |
|
612 | - |
|
613 | - $cid = $_course['official_code']; |
|
614 | - |
|
615 | - if ($builder != 'builder') |
|
616 | - { |
|
617 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
618 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
619 | - if ($desc != '') |
|
620 | - { |
|
621 | - if ($icon != 'wrap') |
|
622 | - { |
|
623 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
624 | - } |
|
625 | - else |
|
626 | - { |
|
627 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
628 | - } |
|
629 | - } |
|
630 | - } |
|
631 | - else |
|
632 | - { |
|
633 | - echo " <a href=\"../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
634 | - } |
|
635 | - break; |
|
636 | - |
|
637 | - case "Forum": |
|
638 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
639 | - $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
640 | - $myrow=Database::fetch_array($result); |
|
641 | - |
|
642 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
643 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
644 | - if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
645 | - $desc=$row['description']; |
|
646 | - echo str_repeat(" >",$level); |
|
647 | - |
|
648 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
649 | - if ($icon != 'nolink') |
|
650 | - { |
|
651 | - if ($completed=='completed') { |
|
652 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
653 | - } else { |
|
654 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
655 | - //echo " "; |
|
656 | - } |
|
657 | - } |
|
658 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
659 | - |
|
660 | - if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
661 | - |
|
662 | - if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); } |
|
663 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
664 | - $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
665 | - if ($builder != 'builder') |
|
666 | - { |
|
667 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
668 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
669 | - if ($desc != '') |
|
670 | - { |
|
671 | - if ($icon != 'wrap') |
|
672 | - { |
|
673 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
674 | - } |
|
675 | - else |
|
676 | - { |
|
677 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
678 | - } |
|
679 | - } |
|
680 | - } |
|
681 | - else |
|
682 | - { |
|
683 | - echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
684 | - } |
|
685 | - break; |
|
686 | - |
|
687 | - case "Thread": //forum post |
|
345 | + global $learnpath_id, $tbl_learnpath_item, $items; |
|
346 | + global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid; |
|
347 | + |
|
348 | + $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"' |
|
349 | + |
|
350 | + $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32); |
|
351 | + |
|
352 | + if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view |
|
353 | + $linktype = $type; |
|
354 | + if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link'; |
|
355 | + |
|
356 | + switch ($type) |
|
357 | + { |
|
358 | + case "Agenda": |
|
359 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); |
|
360 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
361 | + $myrow=Database::fetch_array($result); |
|
362 | + |
|
363 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
364 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
365 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
366 | + $desc=$row['description']; |
|
367 | + $agenda_id=$row['item_id']; |
|
368 | + echo str_repeat(" >",$level); |
|
369 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
370 | + if ($icon != 'nolink') |
|
371 | + { |
|
372 | + if ($completed=='completed') { |
|
373 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
374 | + } else { |
|
375 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
376 | + //echo " "; |
|
377 | + } |
|
378 | + } |
|
379 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
380 | + |
|
381 | + if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
382 | + |
|
383 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
384 | + if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; } |
|
385 | + if ($builder != 'builder') |
|
386 | + { |
|
387 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
388 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
389 | + if ($desc != '') |
|
390 | + { |
|
391 | + if ($icon != 'wrap') |
|
392 | + { |
|
393 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
394 | + } |
|
395 | + else |
|
396 | + { |
|
397 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
398 | + } |
|
399 | + } |
|
400 | + } |
|
401 | + else |
|
402 | + { |
|
403 | + echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
404 | + } |
|
405 | + break; |
|
406 | + |
|
407 | + case "Ad_Valvas": |
|
408 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
409 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
410 | + $myrow=Database::fetch_array($result); |
|
411 | + |
|
412 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
413 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
414 | + if ($row['title'] != '') { $myrow["content"]=$row['title']; } |
|
415 | + $desc=$row['description']; |
|
416 | + $ann_id=$row['item_id']; |
|
417 | + echo str_repeat(" >",$level); |
|
418 | + |
|
419 | + // the title and the text are in the content field and we only want to display the title |
|
420 | + list($title, $text)=split('<br>',$myrow['content']); |
|
421 | + if ($title=='') { $title=$myrow['content']; } |
|
422 | + $title=$myrow['title']; |
|
423 | + $text=$myrow['content']; |
|
424 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
425 | + if ($icon != 'nolink') |
|
426 | + { |
|
427 | + if ($completed=='completed') { |
|
428 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
429 | + } else { |
|
430 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
431 | + //echo " "; |
|
432 | + } |
|
433 | + } |
|
434 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
435 | + |
|
436 | + if ($title=='') { |
|
437 | + $type="Announcement"; |
|
438 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
439 | + return(true); |
|
440 | + } |
|
441 | + |
|
442 | + if ($icon == 'nolink') { return(shorten($title,$length)); } |
|
443 | + if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; } |
|
444 | + if ($builder != 'builder') |
|
445 | + { |
|
446 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>"; |
|
447 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path"; |
|
448 | + if ($desc != '') |
|
449 | + { |
|
450 | + if ($icon != 'wrap') |
|
451 | + { |
|
452 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
453 | + } |
|
454 | + else |
|
455 | + { |
|
456 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
457 | + } |
|
458 | + } |
|
459 | + } |
|
460 | + else |
|
461 | + { |
|
462 | + echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>"; |
|
463 | + } |
|
464 | + break; |
|
465 | + |
|
466 | + case "Link" : |
|
467 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
468 | + $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
469 | + $myrow=Database::fetch_array($result); |
|
470 | + |
|
471 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
472 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
473 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
474 | + $desc=$row['description']; |
|
475 | + echo str_repeat(" >",$level); |
|
476 | + |
|
477 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
478 | + if ($icon != 'nolink') |
|
479 | + { |
|
480 | + if ($completed=='completed') { |
|
481 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
482 | + } else { |
|
483 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
484 | + //echo " "; |
|
485 | + } |
|
486 | + } |
|
487 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
488 | + |
|
489 | + if ($myrow["title"]=='') |
|
490 | + { |
|
491 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
492 | + return(true); |
|
493 | + } |
|
494 | + |
|
495 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
496 | + if ($icon == 'icon') |
|
497 | + { |
|
498 | + if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } |
|
499 | + else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; } |
|
500 | + } |
|
501 | + $thelink=$myrow["url"]; |
|
502 | + if ($builder != 'builder') |
|
503 | + { |
|
504 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
505 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
506 | + if ($desc != '') |
|
507 | + { |
|
508 | + if ($icon != 'wrap') |
|
509 | + { |
|
510 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
511 | + } |
|
512 | + else |
|
513 | + { |
|
514 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
515 | + } |
|
516 | + } |
|
517 | + } |
|
518 | + else |
|
519 | + { |
|
520 | + echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
521 | + } |
|
522 | + break; |
|
523 | + |
|
524 | + case "Exercise": |
|
525 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
526 | + $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
527 | + $myrow=Database::fetch_array($result); |
|
528 | + |
|
529 | + if ($builder=='builder') { $origin='builder'; } |
|
530 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
531 | + |
|
532 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
533 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
534 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
535 | + $desc=$row['description']; |
|
536 | + echo str_repeat(" >",$level); |
|
537 | + |
|
538 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
539 | + if ($icon != 'nolink') |
|
540 | + { |
|
541 | + if ($completed=='completed') { |
|
542 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
543 | + } else { |
|
544 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
545 | + //echo " "; |
|
546 | + } |
|
547 | + } |
|
548 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
549 | + |
|
550 | + if ($myrow["title"]=='') { |
|
551 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
552 | + return(true); |
|
553 | + } |
|
554 | + |
|
555 | + if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); } |
|
556 | + if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; } |
|
557 | + if ($builder != 'builder') |
|
558 | + { |
|
559 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
560 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
561 | + if ($desc != '') |
|
562 | + { |
|
563 | + if ($icon != 'wrap') |
|
564 | + { |
|
565 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
566 | + } |
|
567 | + else |
|
568 | + { |
|
569 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
570 | + } |
|
571 | + } |
|
572 | + } |
|
573 | + else |
|
574 | + { |
|
575 | + echo "<a href=\"../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>"; |
|
576 | + } |
|
577 | + break; |
|
578 | + |
|
579 | + case "HotPotatoes": |
|
580 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
581 | + $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
582 | + $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
583 | + $myrow= Database::fetch_array($result); |
|
584 | + $path=$myrow["path"]; |
|
585 | + $name=GetQuizName($path,$documentPath); |
|
586 | + |
|
587 | + if ($builder=='builder') { $origin='builder'; } |
|
588 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
589 | + |
|
590 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
591 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
592 | + if ($row['title'] != '') { $name=$row['title']; } |
|
593 | + $desc=$row['description']; |
|
594 | + echo str_repeat(" >",$level); |
|
595 | + |
|
596 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
597 | + if ($icon != 'nolink') |
|
598 | + { |
|
599 | + if ($completed=='completed') { |
|
600 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
601 | + } else { |
|
602 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
603 | + //echo " "; |
|
604 | + } |
|
605 | + } |
|
606 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
607 | + |
|
608 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
609 | + |
|
610 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
611 | + if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; } |
|
612 | + |
|
613 | + $cid = $_course['official_code']; |
|
614 | + |
|
615 | + if ($builder != 'builder') |
|
616 | + { |
|
617 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
618 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
619 | + if ($desc != '') |
|
620 | + { |
|
621 | + if ($icon != 'wrap') |
|
622 | + { |
|
623 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
624 | + } |
|
625 | + else |
|
626 | + { |
|
627 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
628 | + } |
|
629 | + } |
|
630 | + } |
|
631 | + else |
|
632 | + { |
|
633 | + echo " <a href=\"../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
634 | + } |
|
635 | + break; |
|
636 | + |
|
637 | + case "Forum": |
|
638 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
639 | + $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
640 | + $myrow=Database::fetch_array($result); |
|
641 | + |
|
642 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
643 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
644 | + if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
645 | + $desc=$row['description']; |
|
646 | + echo str_repeat(" >",$level); |
|
647 | + |
|
648 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
649 | + if ($icon != 'nolink') |
|
650 | + { |
|
651 | + if ($completed=='completed') { |
|
652 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
653 | + } else { |
|
654 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
655 | + //echo " "; |
|
656 | + } |
|
657 | + } |
|
658 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
659 | + |
|
660 | + if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
661 | + |
|
662 | + if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); } |
|
663 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
664 | + $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
665 | + if ($builder != 'builder') |
|
666 | + { |
|
667 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
668 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
669 | + if ($desc != '') |
|
670 | + { |
|
671 | + if ($icon != 'wrap') |
|
672 | + { |
|
673 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
674 | + } |
|
675 | + else |
|
676 | + { |
|
677 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
678 | + } |
|
679 | + } |
|
680 | + } |
|
681 | + else |
|
682 | + { |
|
683 | + echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>"; |
|
684 | + } |
|
685 | + break; |
|
686 | + |
|
687 | + case "Thread": //forum post |
|
688 | 688 | //deprecated |
689 | - $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
690 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
691 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
692 | - $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
693 | - $result= Database::query($sql); |
|
694 | - $myrow=Database::fetch_array($result); |
|
695 | - |
|
696 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
697 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
698 | - if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; } |
|
699 | - $desc=$row['description']; |
|
700 | - echo str_repeat(" >",$level); |
|
701 | - |
|
702 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
703 | - if ($icon != 'nolink') |
|
704 | - { |
|
705 | - if ($completed=='completed') { |
|
706 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
707 | - } else { |
|
708 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
709 | - //echo " "; |
|
710 | - } |
|
711 | - } |
|
712 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
713 | - |
|
714 | - if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
715 | - |
|
716 | - if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); } |
|
717 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
718 | - if ($builder != 'builder') |
|
719 | - { |
|
720 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
721 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
722 | - if ($desc != '') |
|
723 | - { |
|
724 | - if ($icon != 'wrap') |
|
725 | - { |
|
726 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
727 | - } |
|
728 | - else |
|
729 | - { |
|
730 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
734 | - else |
|
735 | - { |
|
736 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
737 | - } |
|
738 | - break; |
|
739 | - |
|
740 | - case "Post": |
|
689 | + $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
690 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
691 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
692 | + $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
693 | + $result= Database::query($sql); |
|
694 | + $myrow=Database::fetch_array($result); |
|
695 | + |
|
696 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
697 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
698 | + if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; } |
|
699 | + $desc=$row['description']; |
|
700 | + echo str_repeat(" >",$level); |
|
701 | + |
|
702 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
703 | + if ($icon != 'nolink') |
|
704 | + { |
|
705 | + if ($completed=='completed') { |
|
706 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
707 | + } else { |
|
708 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
709 | + //echo " "; |
|
710 | + } |
|
711 | + } |
|
712 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
713 | + |
|
714 | + if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
715 | + |
|
716 | + if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); } |
|
717 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
718 | + if ($builder != 'builder') |
|
719 | + { |
|
720 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
721 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
722 | + if ($desc != '') |
|
723 | + { |
|
724 | + if ($icon != 'wrap') |
|
725 | + { |
|
726 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
727 | + } |
|
728 | + else |
|
729 | + { |
|
730 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | + else |
|
735 | + { |
|
736 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>"; |
|
737 | + } |
|
738 | + break; |
|
739 | + |
|
740 | + case "Post": |
|
741 | 741 | //deprecated |
742 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
743 | - $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
744 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
745 | - $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id"); |
|
746 | - $myrow=Database::fetch_array($result); |
|
747 | - // grabbing the title of the post |
|
748 | - $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
749 | - $result_titel=Database::query($sql_titel); |
|
750 | - $myrow_titel=Database::fetch_array($result_titel); |
|
751 | - |
|
752 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
753 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
754 | - if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } |
|
755 | - $desc=$row['description']; |
|
756 | - echo str_repeat(" >",$level); |
|
757 | - |
|
758 | - $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; |
|
759 | - $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; |
|
760 | - $posttitle=$myrow_titel['post_title']; |
|
761 | - $posttext = str_replace('"',"'",$posttext); |
|
762 | - |
|
763 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
764 | - if ($icon != 'nolink') |
|
765 | - { |
|
766 | - if ($completed=='completed') { |
|
767 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
768 | - } else { |
|
769 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
770 | - //echo " "; |
|
771 | - } |
|
772 | - } |
|
773 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
774 | - |
|
775 | - if ($myrow_titel["post_title"]=='') |
|
776 | - { |
|
777 | - $type="Forum"; |
|
778 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
779 | - } |
|
780 | - |
|
781 | - if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); } |
|
782 | - if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
783 | - if ($builder != 'builder') |
|
784 | - { |
|
785 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
786 | - if ($desc != '') |
|
787 | - { |
|
788 | - if ($icon != 'wrap') |
|
789 | - { |
|
790 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
791 | - } |
|
792 | - else |
|
793 | - { |
|
794 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
795 | - } |
|
796 | - } |
|
797 | - } |
|
798 | - else |
|
799 | - { |
|
800 | - echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; |
|
801 | - } |
|
802 | - break; |
|
803 | - |
|
804 | - case "Document": |
|
805 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
806 | - $result=Database::query("SELECT * FROM $dbTable WHERE id=$id"); |
|
807 | - $myrow=Database::fetch_array($result); |
|
808 | - |
|
809 | - $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
810 | - $last=count($pathname)-1; // making a correct name for the link |
|
811 | - $filename=$pathname[$last]; // making a correct name for the link |
|
812 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
813 | - |
|
814 | - echo str_repeat(" >",$level); |
|
815 | - |
|
816 | - if ($icon != 'nolink') { |
|
817 | - if ($completed=='completed') { |
|
818 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
819 | - } else { |
|
820 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
821 | - //echo " "; |
|
822 | - } |
|
823 | - } |
|
824 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
825 | - $image=choose_image($filename); |
|
826 | - |
|
827 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
828 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
829 | - if ($row['title'] != '') { $filename=$row['title']; } |
|
830 | - $desc=$row['description']; |
|
831 | - |
|
832 | - if (($myrow["path"]=='') and ($filename=='')) { |
|
833 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
834 | - return(true); |
|
835 | - } |
|
836 | - |
|
837 | - if ($icon == 'nolink') { return(shorten($filename,$length)); } |
|
838 | - if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; } |
|
839 | - if ($builder != 'builder') |
|
840 | - { |
|
841 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>"; |
|
842 | - if ($desc != '') |
|
843 | - { |
|
844 | - if ($icon != 'wrap') |
|
845 | - { |
|
846 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
847 | - } |
|
848 | - else |
|
849 | - { |
|
850 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
851 | - } |
|
852 | - } $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
853 | - } |
|
854 | - else |
|
855 | - { |
|
856 | - $enableDocumentParsing='yes'; |
|
857 | - if (!$enableDocumentParsing) |
|
858 | - { //this is the solution for the non-parsing version in the builder |
|
859 | - $file=urlencode($myrow["path"]); |
|
860 | - echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
861 | - } |
|
862 | - else |
|
863 | - { |
|
864 | - echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
865 | - } |
|
866 | - } |
|
867 | - break; |
|
868 | - |
|
869 | - case "Assignments": |
|
870 | - $name=get_lang('Assignments'); |
|
871 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
872 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
873 | - if ($row['title'] != '') { $name=$row['title']; } |
|
874 | - $desc=$row['description']; |
|
875 | - echo str_repeat(" >",$level); |
|
876 | - |
|
877 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
878 | - if ($icon != 'nolink') |
|
879 | - { |
|
880 | - if ($completed=='completed') { |
|
881 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
882 | - } else { |
|
883 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
884 | - //echo " "; |
|
885 | - } |
|
886 | - } |
|
887 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
888 | - |
|
889 | - if ($name=='') |
|
890 | - { |
|
891 | - echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
892 | - } |
|
893 | - |
|
894 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
895 | - if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; } |
|
896 | - if ($builder != 'builder') |
|
897 | - { |
|
898 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
899 | - if ($desc != '') |
|
900 | - { |
|
901 | - if ($icon != 'wrap') |
|
902 | - { |
|
903 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
904 | - } |
|
905 | - else |
|
906 | - { |
|
907 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
908 | - } |
|
909 | - } |
|
910 | - } |
|
911 | - else |
|
912 | - { |
|
913 | - echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
914 | - } |
|
915 | - break; |
|
916 | - case "Dropbox": |
|
917 | - $name=get_lang('Dropbox'); |
|
918 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
919 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
920 | - if ($row['title'] != '') { $name=$row['title']; } |
|
921 | - $desc=$row['description']; |
|
922 | - echo str_repeat(" >",$level); |
|
923 | - |
|
924 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
925 | - if ($icon != 'nolink') { |
|
926 | - if ($completed=='completed') { |
|
927 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
928 | - } else { |
|
929 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
930 | - //echo " "; |
|
931 | - } |
|
932 | - } |
|
933 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
934 | - |
|
935 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
936 | - |
|
937 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
938 | - if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; } |
|
939 | - |
|
940 | - if ($builder != 'builder') |
|
941 | - { |
|
942 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
943 | - if ($desc != '') { |
|
944 | - if ($icon != 'wrap') { |
|
945 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
946 | - else { |
|
947 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
948 | - } |
|
949 | - } else { |
|
950 | - echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
951 | - } |
|
952 | - break; |
|
953 | - case "Introduction_text": |
|
954 | - $name=get_lang('IntroductionText'); |
|
955 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
956 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
957 | - if ($row['title'] != '') { $name=$row['title']; } |
|
958 | - $desc=$row['description']; |
|
959 | - echo str_repeat(" >",$level); |
|
960 | - |
|
961 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
962 | - if ($icon != 'nolink') { |
|
963 | - if ($completed=='completed') { |
|
964 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
965 | - } else { |
|
966 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
967 | - //echo " "; |
|
968 | - } |
|
969 | - } |
|
970 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
971 | - |
|
972 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
973 | - |
|
974 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
975 | - if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; } |
|
976 | - |
|
977 | - if ($builder != 'builder') |
|
978 | - { |
|
979 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
980 | - $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
981 | - if ($desc != '') { |
|
982 | - if ($icon != 'wrap') { |
|
983 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
984 | - else { |
|
985 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
986 | - } |
|
987 | - } else { |
|
988 | - $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
989 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
990 | - } |
|
991 | - break; |
|
992 | - case "Course_description": |
|
993 | - $name=get_lang('CourseDescription'); |
|
994 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
995 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
996 | - if ($row['title'] != '') { $name=$row['title']; } |
|
997 | - $desc=$row['description']; |
|
998 | - echo str_repeat(" >",$level); |
|
999 | - |
|
1000 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1001 | - if ($icon != 'nolink') { |
|
1002 | - if ($completed=='completed') { |
|
1003 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1004 | - } else { |
|
1005 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1006 | - //echo " "; |
|
1007 | - } |
|
1008 | - } |
|
1009 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1010 | - |
|
1011 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1012 | - |
|
1013 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1014 | - if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; } |
|
1015 | - |
|
1016 | - if ($builder != 'builder') |
|
1017 | - { |
|
1018 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1019 | - if ($desc != '') { |
|
1020 | - if ($icon != 'wrap') { |
|
1021 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1022 | - else { |
|
1023 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1027 | - echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1028 | - } |
|
1029 | - break; |
|
1030 | - case "Groups": |
|
1031 | - $name=get_lang('Groups'); |
|
1032 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1033 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1034 | - if ($row['title'] != '') { $name=$row['title']; } |
|
1035 | - $desc=$row['description']; |
|
1036 | - echo str_repeat(" >",$level); |
|
1037 | - |
|
1038 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1039 | - if ($icon != 'nolink') { |
|
1040 | - if ($completed=='completed') { |
|
1041 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1042 | - } else { |
|
1043 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1044 | - //echo " "; |
|
1045 | - } |
|
1046 | - } |
|
1047 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1048 | - |
|
1049 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1050 | - |
|
1051 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1052 | - if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; } |
|
1053 | - |
|
1054 | - if ($builder != 'builder') |
|
1055 | - { |
|
1056 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1057 | - if ($desc != '') { |
|
1058 | - if ($icon != 'wrap') { |
|
1059 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1060 | - else { |
|
1061 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1062 | - } |
|
1063 | - } else { |
|
1064 | - echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1065 | - } |
|
1066 | - break; |
|
1067 | - case "Users": |
|
1068 | - $name=get_lang('Users'); |
|
1069 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1070 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1071 | - if ($row['title'] != '') { $name=$row['title']; } |
|
1072 | - $desc=$row['description']; |
|
1073 | - echo str_repeat(" >",$level); |
|
1074 | - |
|
1075 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1076 | - if ($icon != 'nolink') { |
|
1077 | - if ($completed=='completed') { |
|
1078 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1079 | - } else { |
|
1080 | - echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1081 | - //echo " "; |
|
1082 | - } |
|
1083 | - } |
|
1084 | - if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1085 | - |
|
1086 | - if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1087 | - |
|
1088 | - if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1089 | - if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; } |
|
1090 | - |
|
1091 | - if ($builder != 'builder') |
|
1092 | - { |
|
1093 | - echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1094 | - if ($desc != '') { |
|
1095 | - if ($icon != 'wrap') { |
|
1096 | - echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1097 | - else { |
|
1098 | - echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1099 | - } |
|
1100 | - } else { |
|
1101 | - echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1102 | - } |
|
1103 | - break; |
|
1104 | - }//end huge switch-statement |
|
742 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
743 | + $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; |
|
744 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
745 | + $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id"); |
|
746 | + $myrow=Database::fetch_array($result); |
|
747 | + // grabbing the title of the post |
|
748 | + $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"]; |
|
749 | + $result_titel=Database::query($sql_titel); |
|
750 | + $myrow_titel=Database::fetch_array($result_titel); |
|
751 | + |
|
752 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
753 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
754 | + if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; } |
|
755 | + $desc=$row['description']; |
|
756 | + echo str_repeat(" >",$level); |
|
757 | + |
|
758 | + $posternom=$myrow['nom']; $posterprenom=$myrow['prenom']; |
|
759 | + $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text']; |
|
760 | + $posttitle=$myrow_titel['post_title']; |
|
761 | + $posttext = str_replace('"',"'",$posttext); |
|
762 | + |
|
763 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
764 | + if ($icon != 'nolink') |
|
765 | + { |
|
766 | + if ($completed=='completed') { |
|
767 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
768 | + } else { |
|
769 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
770 | + //echo " "; |
|
771 | + } |
|
772 | + } |
|
773 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
774 | + |
|
775 | + if ($myrow_titel["post_title"]=='') |
|
776 | + { |
|
777 | + $type="Forum"; |
|
778 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
779 | + } |
|
780 | + |
|
781 | + if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); } |
|
782 | + if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; } |
|
783 | + if ($builder != 'builder') |
|
784 | + { |
|
785 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path"; |
|
786 | + if ($desc != '') |
|
787 | + { |
|
788 | + if ($icon != 'wrap') |
|
789 | + { |
|
790 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
791 | + } |
|
792 | + else |
|
793 | + { |
|
794 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
795 | + } |
|
796 | + } |
|
797 | + } |
|
798 | + else |
|
799 | + { |
|
800 | + echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; |
|
801 | + } |
|
802 | + break; |
|
803 | + |
|
804 | + case "Document": |
|
805 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
806 | + $result=Database::query("SELECT * FROM $dbTable WHERE id=$id"); |
|
807 | + $myrow=Database::fetch_array($result); |
|
808 | + |
|
809 | + $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
810 | + $last=count($pathname)-1; // making a correct name for the link |
|
811 | + $filename=$pathname[$last]; // making a correct name for the link |
|
812 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
813 | + |
|
814 | + echo str_repeat(" >",$level); |
|
815 | + |
|
816 | + if ($icon != 'nolink') { |
|
817 | + if ($completed=='completed') { |
|
818 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
819 | + } else { |
|
820 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
821 | + //echo " "; |
|
822 | + } |
|
823 | + } |
|
824 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
825 | + $image=choose_image($filename); |
|
826 | + |
|
827 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
828 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
829 | + if ($row['title'] != '') { $filename=$row['title']; } |
|
830 | + $desc=$row['description']; |
|
831 | + |
|
832 | + if (($myrow["path"]=='') and ($filename=='')) { |
|
833 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; |
|
834 | + return(true); |
|
835 | + } |
|
836 | + |
|
837 | + if ($icon == 'nolink') { return(shorten($filename,$length)); } |
|
838 | + if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; } |
|
839 | + if ($builder != 'builder') |
|
840 | + { |
|
841 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>"; |
|
842 | + if ($desc != '') |
|
843 | + { |
|
844 | + if ($icon != 'wrap') |
|
845 | + { |
|
846 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
847 | + } |
|
848 | + else |
|
849 | + { |
|
850 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
851 | + } |
|
852 | + } $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
853 | + } |
|
854 | + else |
|
855 | + { |
|
856 | + $enableDocumentParsing='yes'; |
|
857 | + if (!$enableDocumentParsing) |
|
858 | + { //this is the solution for the non-parsing version in the builder |
|
859 | + $file=urlencode($myrow["path"]); |
|
860 | + echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
861 | + } |
|
862 | + else |
|
863 | + { |
|
864 | + echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>"; |
|
865 | + } |
|
866 | + } |
|
867 | + break; |
|
868 | + |
|
869 | + case "Assignments": |
|
870 | + $name=get_lang('Assignments'); |
|
871 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
872 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
873 | + if ($row['title'] != '') { $name=$row['title']; } |
|
874 | + $desc=$row['description']; |
|
875 | + echo str_repeat(" >",$level); |
|
876 | + |
|
877 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
878 | + if ($icon != 'nolink') |
|
879 | + { |
|
880 | + if ($completed=='completed') { |
|
881 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
882 | + } else { |
|
883 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
884 | + //echo " "; |
|
885 | + } |
|
886 | + } |
|
887 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
888 | + |
|
889 | + if ($name=='') |
|
890 | + { |
|
891 | + echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); |
|
892 | + } |
|
893 | + |
|
894 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
895 | + if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; } |
|
896 | + if ($builder != 'builder') |
|
897 | + { |
|
898 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
899 | + if ($desc != '') |
|
900 | + { |
|
901 | + if ($icon != 'wrap') |
|
902 | + { |
|
903 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; |
|
904 | + } |
|
905 | + else |
|
906 | + { |
|
907 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; |
|
908 | + } |
|
909 | + } |
|
910 | + } |
|
911 | + else |
|
912 | + { |
|
913 | + echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
914 | + } |
|
915 | + break; |
|
916 | + case "Dropbox": |
|
917 | + $name=get_lang('Dropbox'); |
|
918 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
919 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
920 | + if ($row['title'] != '') { $name=$row['title']; } |
|
921 | + $desc=$row['description']; |
|
922 | + echo str_repeat(" >",$level); |
|
923 | + |
|
924 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
925 | + if ($icon != 'nolink') { |
|
926 | + if ($completed=='completed') { |
|
927 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
928 | + } else { |
|
929 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
930 | + //echo " "; |
|
931 | + } |
|
932 | + } |
|
933 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
934 | + |
|
935 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
936 | + |
|
937 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
938 | + if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; } |
|
939 | + |
|
940 | + if ($builder != 'builder') |
|
941 | + { |
|
942 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
943 | + if ($desc != '') { |
|
944 | + if ($icon != 'wrap') { |
|
945 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
946 | + else { |
|
947 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
948 | + } |
|
949 | + } else { |
|
950 | + echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
951 | + } |
|
952 | + break; |
|
953 | + case "Introduction_text": |
|
954 | + $name=get_lang('IntroductionText'); |
|
955 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
956 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
957 | + if ($row['title'] != '') { $name=$row['title']; } |
|
958 | + $desc=$row['description']; |
|
959 | + echo str_repeat(" >",$level); |
|
960 | + |
|
961 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
962 | + if ($icon != 'nolink') { |
|
963 | + if ($completed=='completed') { |
|
964 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
965 | + } else { |
|
966 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
967 | + //echo " "; |
|
968 | + } |
|
969 | + } |
|
970 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
971 | + |
|
972 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
973 | + |
|
974 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
975 | + if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; } |
|
976 | + |
|
977 | + if ($builder != 'builder') |
|
978 | + { |
|
979 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; |
|
980 | + $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
981 | + if ($desc != '') { |
|
982 | + if ($icon != 'wrap') { |
|
983 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
984 | + else { |
|
985 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
986 | + } |
|
987 | + } else { |
|
988 | + $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
989 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
990 | + } |
|
991 | + break; |
|
992 | + case "Course_description": |
|
993 | + $name=get_lang('CourseDescription'); |
|
994 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
995 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
996 | + if ($row['title'] != '') { $name=$row['title']; } |
|
997 | + $desc=$row['description']; |
|
998 | + echo str_repeat(" >",$level); |
|
999 | + |
|
1000 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1001 | + if ($icon != 'nolink') { |
|
1002 | + if ($completed=='completed') { |
|
1003 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1004 | + } else { |
|
1005 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1006 | + //echo " "; |
|
1007 | + } |
|
1008 | + } |
|
1009 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1010 | + |
|
1011 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1012 | + |
|
1013 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1014 | + if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; } |
|
1015 | + |
|
1016 | + if ($builder != 'builder') |
|
1017 | + { |
|
1018 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1019 | + if ($desc != '') { |
|
1020 | + if ($icon != 'wrap') { |
|
1021 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1022 | + else { |
|
1023 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1027 | + echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1028 | + } |
|
1029 | + break; |
|
1030 | + case "Groups": |
|
1031 | + $name=get_lang('Groups'); |
|
1032 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1033 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1034 | + if ($row['title'] != '') { $name=$row['title']; } |
|
1035 | + $desc=$row['description']; |
|
1036 | + echo str_repeat(" >",$level); |
|
1037 | + |
|
1038 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1039 | + if ($icon != 'nolink') { |
|
1040 | + if ($completed=='completed') { |
|
1041 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1042 | + } else { |
|
1043 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1044 | + //echo " "; |
|
1045 | + } |
|
1046 | + } |
|
1047 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1048 | + |
|
1049 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1050 | + |
|
1051 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1052 | + if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; } |
|
1053 | + |
|
1054 | + if ($builder != 'builder') |
|
1055 | + { |
|
1056 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1057 | + if ($desc != '') { |
|
1058 | + if ($icon != 'wrap') { |
|
1059 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1060 | + else { |
|
1061 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1062 | + } |
|
1063 | + } else { |
|
1064 | + echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1065 | + } |
|
1066 | + break; |
|
1067 | + case "Users": |
|
1068 | + $name=get_lang('Users'); |
|
1069 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1070 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1071 | + if ($row['title'] != '') { $name=$row['title']; } |
|
1072 | + $desc=$row['description']; |
|
1073 | + echo str_repeat(" >",$level); |
|
1074 | + |
|
1075 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; } |
|
1076 | + if ($icon != 'nolink') { |
|
1077 | + if ($completed=='completed') { |
|
1078 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>"; |
|
1079 | + } else { |
|
1080 | + echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>"; |
|
1081 | + //echo " "; |
|
1082 | + } |
|
1083 | + } |
|
1084 | + if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; } |
|
1085 | + |
|
1086 | + if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); } |
|
1087 | + |
|
1088 | + if ($icon == 'nolink') { return(shorten($name,$length)); } |
|
1089 | + if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; } |
|
1090 | + |
|
1091 | + if ($builder != 'builder') |
|
1092 | + { |
|
1093 | + echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1094 | + if ($desc != '') { |
|
1095 | + if ($icon != 'wrap') { |
|
1096 | + echo "</tr><tr><td></td><td></td><td><div class='description'> ".shorten($desc,($length-3*$level))."</div></td></tr>"; } |
|
1097 | + else { |
|
1098 | + echo "<div class='description'> ".shorten($desc,($length-3*$level))."</div>"; } |
|
1099 | + } |
|
1100 | + } else { |
|
1101 | + echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>"; |
|
1102 | + } |
|
1103 | + break; |
|
1104 | + }//end huge switch-statement |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1116,253 +1116,253 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | function get_addedresource_link_in_learnpath($type, $id, $id_in_path) |
1118 | 1118 | { |
1119 | - global $_course, $learnpath_id, $tbl_learnpath_item, $items; |
|
1120 | - global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid; |
|
1121 | - |
|
1122 | - $hyperlink_target_parameter = ""; //or e.g. target='_blank' |
|
1123 | - $builder = 'player'; |
|
1124 | - $origin='learnpath'; |
|
1125 | - |
|
1126 | - $linktype=$type; |
|
1127 | - if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } |
|
1128 | - |
|
1129 | - $link = ''; |
|
1130 | - |
|
1131 | - switch ($type) |
|
1132 | - { |
|
1133 | - case "Agenda": |
|
1134 | - $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);; |
|
1135 | - $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
1136 | - $myrow=Database::fetch_array($result); |
|
1137 | - |
|
1138 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1139 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1140 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1141 | - $desc=$row['description']; |
|
1142 | - $agenda_id=$row['item_id']; |
|
1143 | - |
|
1144 | - if ($builder != 'builder') |
|
1145 | - { |
|
1146 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
1147 | - } |
|
1148 | - else |
|
1149 | - { |
|
1150 | - $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id"; |
|
1151 | - } |
|
1152 | - break; |
|
1153 | - |
|
1154 | - case "Ad_Valvas": |
|
1155 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
1156 | - $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
1157 | - $myrow=Database::fetch_array($result); |
|
1158 | - |
|
1159 | - if ($builder != 'builder') |
|
1160 | - { |
|
1161 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path"; |
|
1162 | - } |
|
1163 | - else |
|
1164 | - { |
|
1165 | - $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id"; |
|
1166 | - } |
|
1167 | - break; |
|
1168 | - |
|
1169 | - case "Link" : |
|
1170 | - $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1171 | - $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
1172 | - $myrow=Database::fetch_array($result); |
|
1173 | - |
|
1174 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1175 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1176 | - |
|
1177 | - $thelink=$myrow["url"]; |
|
1178 | - if ($builder != 'builder') |
|
1179 | - { |
|
1180 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
1181 | - } |
|
1182 | - else |
|
1183 | - { |
|
1184 | - $link .= $thelink; |
|
1185 | - } |
|
1186 | - break; |
|
1187 | - |
|
1188 | - case "Exercise": |
|
1189 | - $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1190 | - $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
1191 | - $myrow=Database::fetch_array($result); |
|
1192 | - |
|
1193 | - if ($builder=='builder') { $origin='builder'; } |
|
1194 | - //this is needed for the exercise_submit.php can delete the session info about tests |
|
1195 | - |
|
1196 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1197 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1198 | - if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1199 | - |
|
1200 | - if ($builder != 'builder') |
|
1201 | - { |
|
1202 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
1203 | - } |
|
1204 | - else |
|
1205 | - { |
|
1206 | - $link .= "../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]; |
|
1207 | - } |
|
1208 | - break; |
|
1209 | - |
|
1210 | - case "HotPotatoes": |
|
1211 | - $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1212 | - $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
1213 | - $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
1214 | - $myrow= Database::fetch_array($result); |
|
1215 | - $path=$myrow["path"]; |
|
1216 | - $name=GetQuizName($path,$documentPath); |
|
1217 | - |
|
1218 | - if ($builder=='builder') { $origin='builder'; } |
|
1219 | - |
|
1220 | - $cid = $_course['official_code']; |
|
1221 | - |
|
1222 | - if ($builder != 'builder') |
|
1223 | - { |
|
1224 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
1225 | - } |
|
1226 | - else |
|
1227 | - { |
|
1228 | - $link .= "../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'].""; |
|
1229 | - } |
|
1230 | - break; |
|
1231 | - |
|
1232 | - case "Forum": |
|
1119 | + global $_course, $learnpath_id, $tbl_learnpath_item, $items; |
|
1120 | + global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid; |
|
1121 | + |
|
1122 | + $hyperlink_target_parameter = ""; //or e.g. target='_blank' |
|
1123 | + $builder = 'player'; |
|
1124 | + $origin='learnpath'; |
|
1125 | + |
|
1126 | + $linktype=$type; |
|
1127 | + if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; } |
|
1128 | + |
|
1129 | + $link = ''; |
|
1130 | + |
|
1131 | + switch ($type) |
|
1132 | + { |
|
1133 | + case "Agenda": |
|
1134 | + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);; |
|
1135 | + $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id"); |
|
1136 | + $myrow=Database::fetch_array($result); |
|
1137 | + |
|
1138 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1139 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1140 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1141 | + $desc=$row['description']; |
|
1142 | + $agenda_id=$row['item_id']; |
|
1143 | + |
|
1144 | + if ($builder != 'builder') |
|
1145 | + { |
|
1146 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path"; |
|
1147 | + } |
|
1148 | + else |
|
1149 | + { |
|
1150 | + $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id"; |
|
1151 | + } |
|
1152 | + break; |
|
1153 | + |
|
1154 | + case "Ad_Valvas": |
|
1155 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
1156 | + $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id"); |
|
1157 | + $myrow=Database::fetch_array($result); |
|
1158 | + |
|
1159 | + if ($builder != 'builder') |
|
1160 | + { |
|
1161 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path"; |
|
1162 | + } |
|
1163 | + else |
|
1164 | + { |
|
1165 | + $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id"; |
|
1166 | + } |
|
1167 | + break; |
|
1168 | + |
|
1169 | + case "Link" : |
|
1170 | + $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); |
|
1171 | + $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id"); |
|
1172 | + $myrow=Database::fetch_array($result); |
|
1173 | + |
|
1174 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1175 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1176 | + |
|
1177 | + $thelink=$myrow["url"]; |
|
1178 | + if ($builder != 'builder') |
|
1179 | + { |
|
1180 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path"; |
|
1181 | + } |
|
1182 | + else |
|
1183 | + { |
|
1184 | + $link .= $thelink; |
|
1185 | + } |
|
1186 | + break; |
|
1187 | + |
|
1188 | + case "Exercise": |
|
1189 | + $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1190 | + $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id"); |
|
1191 | + $myrow=Database::fetch_array($result); |
|
1192 | + |
|
1193 | + if ($builder=='builder') { $origin='builder'; } |
|
1194 | + //this is needed for the exercise_submit.php can delete the session info about tests |
|
1195 | + |
|
1196 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1197 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1198 | + if ($row['title'] != '') { $myrow["title"]=$row['title']; } |
|
1199 | + |
|
1200 | + if ($builder != 'builder') |
|
1201 | + { |
|
1202 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path"; |
|
1203 | + } |
|
1204 | + else |
|
1205 | + { |
|
1206 | + $link .= "../exercise/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]; |
|
1207 | + } |
|
1208 | + break; |
|
1209 | + |
|
1210 | + case "HotPotatoes": |
|
1211 | + $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
|
1212 | + $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
1213 | + $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id"); |
|
1214 | + $myrow= Database::fetch_array($result); |
|
1215 | + $path=$myrow["path"]; |
|
1216 | + $name=GetQuizName($path,$documentPath); |
|
1217 | + |
|
1218 | + if ($builder=='builder') { $origin='builder'; } |
|
1219 | + |
|
1220 | + $cid = $_course['official_code']; |
|
1221 | + |
|
1222 | + if ($builder != 'builder') |
|
1223 | + { |
|
1224 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path"; |
|
1225 | + } |
|
1226 | + else |
|
1227 | + { |
|
1228 | + $link .= "../exercise/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id'].""; |
|
1229 | + } |
|
1230 | + break; |
|
1231 | + |
|
1232 | + case "Forum": |
|
1233 | 1233 | //deprecated |
1234 | - $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
1235 | - $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
1236 | - $myrow=Database::fetch_array($result); |
|
1237 | - |
|
1238 | - if ($builder=='builder') { $origin='builder'; } |
|
1239 | - |
|
1240 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1241 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1242 | - if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
1243 | - |
|
1244 | - if ($myrow["forum_name"]=='') { $type="Forum"; } |
|
1245 | - |
|
1246 | - $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1247 | - if ($builder != 'builder') |
|
1248 | - { |
|
1249 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
1250 | - } |
|
1251 | - else |
|
1252 | - { |
|
1253 | - $link .= "../phpbb/viewforum.php?$forumparameters"; |
|
1254 | - } |
|
1255 | - break; |
|
1256 | - |
|
1257 | - case "Thread": //forum post |
|
1234 | + $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); |
|
1235 | + $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id"); |
|
1236 | + $myrow=Database::fetch_array($result); |
|
1237 | + |
|
1238 | + if ($builder=='builder') { $origin='builder'; } |
|
1239 | + |
|
1240 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1241 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1242 | + if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; } |
|
1243 | + |
|
1244 | + if ($myrow["forum_name"]=='') { $type="Forum"; } |
|
1245 | + |
|
1246 | + $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1247 | + if ($builder != 'builder') |
|
1248 | + { |
|
1249 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path"; |
|
1250 | + } |
|
1251 | + else |
|
1252 | + { |
|
1253 | + $link .= "../phpbb/viewforum.php?$forumparameters"; |
|
1254 | + } |
|
1255 | + break; |
|
1256 | + |
|
1257 | + case "Thread": //forum post |
|
1258 | 1258 | //deprecated |
1259 | - $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
1260 | - $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
1261 | - $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
1262 | - $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
1263 | - $result= Database::query($sql); |
|
1264 | - $myrow=Database::fetch_array($result); |
|
1265 | - |
|
1266 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1267 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1268 | - |
|
1269 | - if ($builder != 'builder') |
|
1270 | - { |
|
1271 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
1272 | - } |
|
1273 | - else |
|
1274 | - { |
|
1275 | - $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1276 | - } |
|
1277 | - break; |
|
1278 | - case "Post": |
|
1279 | - break; |
|
1280 | - case "Document": |
|
1281 | - $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
1282 | - $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE); |
|
1283 | - $myrow=Database::fetch_array($result); |
|
1284 | - |
|
1285 | - $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
1286 | - $last=count($pathname)-1; // making a correct name for the link |
|
1287 | - $filename=$pathname[$last]; // making a correct name for the link |
|
1288 | - |
|
1289 | - $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1290 | - $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1291 | - |
|
1292 | - if ($builder != 'builder') |
|
1293 | - { |
|
1294 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
1295 | - |
|
1296 | - } |
|
1297 | - else |
|
1298 | - { |
|
1299 | - $enableDocumentParsing='yes'; |
|
1300 | - if (!$enableDocumentParsing) |
|
1301 | - { //this is the solution for the non-parsing version in the builder |
|
1302 | - $file=urlencode($myrow["path"]); |
|
1303 | - $link .= "../document/showinframes.php?file=$file"; |
|
1304 | - } |
|
1305 | - else |
|
1306 | - { |
|
1307 | - $link .= "../document/download.php?doc_url=".$myrow["path"]; |
|
1308 | - } |
|
1309 | - } |
|
1310 | - break; |
|
1311 | - |
|
1312 | - case "Assignments": |
|
1313 | - if ($builder != 'builder') |
|
1314 | - { |
|
1315 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
1316 | - } |
|
1317 | - else |
|
1318 | - { |
|
1319 | - $link .= "../work/work.php"; |
|
1320 | - } |
|
1321 | - break; |
|
1322 | - case "Dropbox": |
|
1323 | - if ($builder != 'builder') |
|
1324 | - { |
|
1325 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
1326 | - } else { |
|
1327 | - $link .= "../dropbox/index.php"; |
|
1328 | - } |
|
1329 | - break; |
|
1330 | - case "Introduction_text": |
|
1331 | - if ($builder != 'builder') |
|
1332 | - { |
|
1333 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
1334 | - } else { |
|
1335 | - $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
1336 | - $link .= $s; |
|
1337 | - } |
|
1338 | - break; |
|
1339 | - case "Course_description": |
|
1340 | - if ($builder != 'builder') |
|
1341 | - { |
|
1342 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1343 | - } else { |
|
1344 | - $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1345 | - $link .= $s; |
|
1346 | - } |
|
1347 | - break; |
|
1348 | - case "Groups": |
|
1349 | - |
|
1350 | - if ($builder != 'builder') |
|
1351 | - { |
|
1352 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1353 | - } else { |
|
1354 | - $link .= "../group/group.php?origin=$origin"; |
|
1355 | - } |
|
1356 | - break; |
|
1357 | - case "Users": |
|
1358 | - if ($builder != 'builder') |
|
1359 | - { |
|
1360 | - $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1361 | - } else { |
|
1362 | - $link .= "../user/user.php?origin=$origin"; |
|
1363 | - } |
|
1364 | - break; |
|
1365 | - }//end huge switch-statement |
|
1259 | + $tbl_topics = $_course['dbNameGlu'].'bb_topics'; |
|
1260 | + $tbl_posts = $_course['dbNameGlu'].'bb_posts'; |
|
1261 | + $TBL_FORUMS = $_course['dbNameGlu']."bb_forums"; |
|
1262 | + $sql="SELECT * FROM $tbl_topics where topic_id=$id"; |
|
1263 | + $result= Database::query($sql); |
|
1264 | + $myrow=Database::fetch_array($result); |
|
1265 | + |
|
1266 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1267 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1268 | + |
|
1269 | + if ($builder != 'builder') |
|
1270 | + { |
|
1271 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path"; |
|
1272 | + } |
|
1273 | + else |
|
1274 | + { |
|
1275 | + $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; |
|
1276 | + } |
|
1277 | + break; |
|
1278 | + case "Post": |
|
1279 | + break; |
|
1280 | + case "Document": |
|
1281 | + $dbTable = Database::get_course_table(TABLE_DOCUMENT); |
|
1282 | + $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE); |
|
1283 | + $myrow=Database::fetch_array($result); |
|
1284 | + |
|
1285 | + $pathname=explode("/",$myrow["path"]); // making a correct name for the link |
|
1286 | + $last=count($pathname)-1; // making a correct name for the link |
|
1287 | + $filename=$pathname[$last]; // making a correct name for the link |
|
1288 | + |
|
1289 | + $sql="select * from $tbl_learnpath_item where id=$id_in_path"; |
|
1290 | + $result=Database::query($sql); $row=Database::fetch_array($result); |
|
1291 | + |
|
1292 | + if ($builder != 'builder') |
|
1293 | + { |
|
1294 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path"; |
|
1295 | + |
|
1296 | + } |
|
1297 | + else |
|
1298 | + { |
|
1299 | + $enableDocumentParsing='yes'; |
|
1300 | + if (!$enableDocumentParsing) |
|
1301 | + { //this is the solution for the non-parsing version in the builder |
|
1302 | + $file=urlencode($myrow["path"]); |
|
1303 | + $link .= "../document/showinframes.php?file=$file"; |
|
1304 | + } |
|
1305 | + else |
|
1306 | + { |
|
1307 | + $link .= "../document/download.php?doc_url=".$myrow["path"]; |
|
1308 | + } |
|
1309 | + } |
|
1310 | + break; |
|
1311 | + |
|
1312 | + case "Assignments": |
|
1313 | + if ($builder != 'builder') |
|
1314 | + { |
|
1315 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path"; |
|
1316 | + } |
|
1317 | + else |
|
1318 | + { |
|
1319 | + $link .= "../work/work.php"; |
|
1320 | + } |
|
1321 | + break; |
|
1322 | + case "Dropbox": |
|
1323 | + if ($builder != 'builder') |
|
1324 | + { |
|
1325 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path"; |
|
1326 | + } else { |
|
1327 | + $link .= "../dropbox/index.php"; |
|
1328 | + } |
|
1329 | + break; |
|
1330 | + case "Introduction_text": |
|
1331 | + if ($builder != 'builder') |
|
1332 | + { |
|
1333 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path"; |
|
1334 | + } else { |
|
1335 | + $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1"; |
|
1336 | + $link .= $s; |
|
1337 | + } |
|
1338 | + break; |
|
1339 | + case "Course_description": |
|
1340 | + if ($builder != 'builder') |
|
1341 | + { |
|
1342 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path"; |
|
1343 | + } else { |
|
1344 | + $s=api_get_path(WEB_CODE_PATH)."course_description"; |
|
1345 | + $link .= $s; |
|
1346 | + } |
|
1347 | + break; |
|
1348 | + case "Groups": |
|
1349 | + |
|
1350 | + if ($builder != 'builder') |
|
1351 | + { |
|
1352 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path"; |
|
1353 | + } else { |
|
1354 | + $link .= "../group/group.php?origin=$origin"; |
|
1355 | + } |
|
1356 | + break; |
|
1357 | + case "Users": |
|
1358 | + if ($builder != 'builder') |
|
1359 | + { |
|
1360 | + $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path"; |
|
1361 | + } else { |
|
1362 | + $link .= "../user/user.php?origin=$origin"; |
|
1363 | + } |
|
1364 | + break; |
|
1365 | + }//end huge switch-statement |
|
1366 | 1366 | return $link; |
1367 | 1367 | } |
1368 | 1368 | |
@@ -1371,12 +1371,12 @@ discard block |
||
1371 | 1371 | */ |
1372 | 1372 | function remove_resource($resource_key) |
1373 | 1373 | { |
1374 | - $addedresource = $_SESSION['addedresource']; |
|
1375 | - $addedresourceid = $_SESSION['addedresourceid']; |
|
1376 | - unset($addedresource[$resource_key]); |
|
1377 | - unset($addedresourceid[$resource_key]); |
|
1378 | - $_SESSION['addedresource']=$addedresource; |
|
1379 | - $_SESSION['addedresourceid']=$addedresourceid ; |
|
1374 | + $addedresource = $_SESSION['addedresource']; |
|
1375 | + $addedresourceid = $_SESSION['addedresourceid']; |
|
1376 | + unset($addedresource[$resource_key]); |
|
1377 | + unset($addedresourceid[$resource_key]); |
|
1378 | + $_SESSION['addedresource']=$addedresource; |
|
1379 | + $_SESSION['addedresourceid']=$addedresourceid ; |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | /** |
@@ -1385,8 +1385,8 @@ discard block |
||
1385 | 1385 | */ |
1386 | 1386 | function show_addresource_button($additionalparameters = '') |
1387 | 1387 | { |
1388 | - global $charset; |
|
1389 | - echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />'; |
|
1388 | + global $charset; |
|
1389 | + echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />'; |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | /** |
@@ -1408,11 +1408,11 @@ discard block |
||
1408 | 1408 | */ |
1409 | 1409 | function delete_added_resource($type, $id) |
1410 | 1410 | { |
1411 | - global $_course; |
|
1412 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1411 | + global $_course; |
|
1412 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1413 | 1413 | |
1414 | - $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1415 | - Database::query($sql); |
|
1414 | + $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1415 | + Database::query($sql); |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | /** |
@@ -1421,12 +1421,12 @@ discard block |
||
1421 | 1421 | */ |
1422 | 1422 | function delete_all_resources_type($type) |
1423 | 1423 | { |
1424 | - global $_course; |
|
1425 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1424 | + global $_course; |
|
1425 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1426 | 1426 | |
1427 | - $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'"; |
|
1427 | + $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'"; |
|
1428 | 1428 | |
1429 | - Database::query($sql); |
|
1429 | + Database::query($sql); |
|
1430 | 1430 | } |
1431 | 1431 | |
1432 | 1432 | /** |
@@ -1434,15 +1434,15 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | function check_added_resources($type, $id) |
1436 | 1436 | { |
1437 | - global $_course, $origin; |
|
1438 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1439 | - $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1440 | - $result=Database::query($sql); |
|
1441 | - $number_added=Database::num_rows($result); |
|
1442 | - if ($number_added<>0) |
|
1443 | - return true; |
|
1444 | - else |
|
1445 | - return false; |
|
1437 | + global $_course, $origin; |
|
1438 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1439 | + $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1440 | + $result=Database::query($sql); |
|
1441 | + $number_added=Database::num_rows($result); |
|
1442 | + if ($number_added<>0) |
|
1443 | + return true; |
|
1444 | + else |
|
1445 | + return false; |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | |
@@ -1452,18 +1452,18 @@ discard block |
||
1452 | 1452 | */ |
1453 | 1453 | function edit_added_resources($type, $id) |
1454 | 1454 | { |
1455 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1455 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1456 | 1456 | $course_id = api_get_course_int_id(); |
1457 | 1457 | $id = intval($id); |
1458 | 1458 | $type = Database::escape_string($type); |
1459 | - $sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id"; |
|
1460 | - $result=Database::query($sql); |
|
1461 | - while ($row=Database::fetch_array($result)) { |
|
1462 | - $addedresource[]=$row["resource_type"]; |
|
1463 | - $addedresourceid[]=$row["resource_id"]; |
|
1464 | - } |
|
1465 | - $_SESSION['addedresource']=$addedresource; |
|
1466 | - $_SESSION['addedresourceid']=$addedresourceid; |
|
1459 | + $sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id"; |
|
1460 | + $result=Database::query($sql); |
|
1461 | + while ($row=Database::fetch_array($result)) { |
|
1462 | + $addedresource[]=$row["resource_type"]; |
|
1463 | + $addedresourceid[]=$row["resource_id"]; |
|
1464 | + } |
|
1465 | + $_SESSION['addedresource']=$addedresource; |
|
1466 | + $_SESSION['addedresourceid']=$addedresourceid; |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | /** |
@@ -1473,20 +1473,20 @@ discard block |
||
1473 | 1473 | */ |
1474 | 1474 | function update_added_resources($type, $id) |
1475 | 1475 | { |
1476 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1476 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1477 | 1477 | $course_id = api_get_course_int_id(); |
1478 | 1478 | $id = intval($id); |
1479 | 1479 | $type = Database::escape_string($type); |
1480 | - // delete all the added resources for this item in the database; |
|
1481 | - $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'"; |
|
1482 | - //echo $sql; |
|
1483 | - Database::query($sql); |
|
1480 | + // delete all the added resources for this item in the database; |
|
1481 | + $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'"; |
|
1482 | + //echo $sql; |
|
1483 | + Database::query($sql); |
|
1484 | 1484 | |
1485 | - // store the resources from the session into the database |
|
1486 | - store_resources($type, $id); |
|
1485 | + // store the resources from the session into the database |
|
1486 | + store_resources($type, $id); |
|
1487 | 1487 | |
1488 | - //delete_added_resource_($type, $id); |
|
1489 | - unset_session_resources(); |
|
1488 | + //delete_added_resource_($type, $id); |
|
1489 | + unset_session_resources(); |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | /** |
@@ -1494,25 +1494,25 @@ discard block |
||
1494 | 1494 | */ |
1495 | 1495 | function display_added_resources($type, $id, $style='') |
1496 | 1496 | { |
1497 | - // the array containing the icons |
|
1498 | - $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' ); |
|
1499 | - |
|
1500 | - global $_course, $origin; |
|
1501 | - $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1502 | - |
|
1503 | - $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1504 | - $result=Database::query($sql); |
|
1505 | - while ($row=Database::fetch_array($result)) |
|
1506 | - { |
|
1507 | - if ($origin != 'learnpath') |
|
1508 | - { |
|
1509 | - display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ; |
|
1510 | - } |
|
1511 | - else |
|
1512 | - { |
|
1513 | - display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>"; |
|
1514 | - } |
|
1515 | - } |
|
1497 | + // the array containing the icons |
|
1498 | + $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' ); |
|
1499 | + |
|
1500 | + global $_course, $origin; |
|
1501 | + $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); |
|
1502 | + |
|
1503 | + $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'"; |
|
1504 | + $result=Database::query($sql); |
|
1505 | + while ($row=Database::fetch_array($result)) |
|
1506 | + { |
|
1507 | + if ($origin != 'learnpath') |
|
1508 | + { |
|
1509 | + display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ; |
|
1510 | + } |
|
1511 | + else |
|
1512 | + { |
|
1513 | + display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>"; |
|
1514 | + } |
|
1515 | + } |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | |
@@ -1523,15 +1523,15 @@ discard block |
||
1523 | 1523 | */ |
1524 | 1524 | function display_resources($showdeleteimg) |
1525 | 1525 | { |
1526 | - global $action; |
|
1527 | - global $resourceaction; |
|
1528 | - global $id; |
|
1529 | - global $locationkey; |
|
1530 | - global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
1531 | - |
|
1532 | - if ($resourceaction=="removeresource") |
|
1533 | - { |
|
1534 | - /* unneccessary because when editing we delete all the added resources from the |
|
1526 | + global $action; |
|
1527 | + global $resourceaction; |
|
1528 | + global $id; |
|
1529 | + global $locationkey; |
|
1530 | + global $source_id, $action, $learnpath_id, $chapter_id, $originalresource; |
|
1531 | + |
|
1532 | + if ($resourceaction=="removeresource") |
|
1533 | + { |
|
1534 | + /* unneccessary because when editing we delete all the added resources from the |
|
1535 | 1535 | database and add all these from the session |
1536 | 1536 | if ($action=="edit") // we have an edit and thus we delete from the database and from the session |
1537 | 1537 | { |
@@ -1547,41 +1547,41 @@ discard block |
||
1547 | 1547 | } |
1548 | 1548 | else // we remove from the session |
1549 | 1549 | {*/ |
1550 | - //echo "remove from session"; |
|
1551 | - remove_resource($locationkey); |
|
1552 | - } |
|
1553 | - $addedresource=$_SESSION['addedresource']; |
|
1554 | - $addedresourceid=$_SESSION['addedresourceid']; |
|
1555 | - if (is_array($addedresource)) |
|
1556 | - { |
|
1557 | - echo '<table>'; |
|
1558 | - foreach ($addedresource as $resource) |
|
1559 | - { |
|
1560 | - //echo $resource.":".$addedresourceid[key($addedresource)]; |
|
1561 | - echo '<tr><td>'; |
|
1562 | - display_addedresource_link($resource,$addedresourceid[key($addedresource)]); |
|
1563 | - echo '</td><td width="30">'; |
|
1564 | - |
|
1565 | - // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource |
|
1566 | - // should also contain this id. |
|
1567 | - $test=parse_url($_SERVER['REQUEST_URI']); |
|
1568 | - $output = array(); |
|
1569 | - parse_str($test['query'],$output); |
|
1570 | - |
|
1571 | - if ($showdeleteimg==1) |
|
1572 | - { |
|
1573 | - echo "<a href=".api_get_self()."?showresources=true&source_forum=".$_GET['source_forum']."&resourceaction=removeresource&locationkey=".key($addedresource)."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />"; |
|
1574 | - } |
|
1575 | - echo '</td></tr>'; |
|
1576 | - next($addedresource); |
|
1577 | - //$_SESSION['edit']==''; |
|
1578 | - } |
|
1579 | - echo '</table>'; |
|
1580 | - } |
|
1581 | - else // it is a string |
|
1582 | - { |
|
1583 | - echo ''; |
|
1584 | - } |
|
1550 | + //echo "remove from session"; |
|
1551 | + remove_resource($locationkey); |
|
1552 | + } |
|
1553 | + $addedresource=$_SESSION['addedresource']; |
|
1554 | + $addedresourceid=$_SESSION['addedresourceid']; |
|
1555 | + if (is_array($addedresource)) |
|
1556 | + { |
|
1557 | + echo '<table>'; |
|
1558 | + foreach ($addedresource as $resource) |
|
1559 | + { |
|
1560 | + //echo $resource.":".$addedresourceid[key($addedresource)]; |
|
1561 | + echo '<tr><td>'; |
|
1562 | + display_addedresource_link($resource,$addedresourceid[key($addedresource)]); |
|
1563 | + echo '</td><td width="30">'; |
|
1564 | + |
|
1565 | + // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource |
|
1566 | + // should also contain this id. |
|
1567 | + $test=parse_url($_SERVER['REQUEST_URI']); |
|
1568 | + $output = array(); |
|
1569 | + parse_str($test['query'],$output); |
|
1570 | + |
|
1571 | + if ($showdeleteimg==1) |
|
1572 | + { |
|
1573 | + echo "<a href=".api_get_self()."?showresources=true&source_forum=".$_GET['source_forum']."&resourceaction=removeresource&locationkey=".key($addedresource)."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />"; |
|
1574 | + } |
|
1575 | + echo '</td></tr>'; |
|
1576 | + next($addedresource); |
|
1577 | + //$_SESSION['edit']==''; |
|
1578 | + } |
|
1579 | + echo '</table>'; |
|
1580 | + } |
|
1581 | + else // it is a string |
|
1582 | + { |
|
1583 | + echo ''; |
|
1584 | + } |
|
1585 | 1585 | } // end of the display_resources function |
1586 | 1586 | |
1587 | 1587 | |
@@ -1593,49 +1593,49 @@ discard block |
||
1593 | 1593 | */ |
1594 | 1594 | function showorhide_addresourcelink($type, $id) |
1595 | 1595 | { |
1596 | - global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target; |
|
1597 | - //global $_SESSION['addresource']; |
|
1598 | - //global $_SESSION['addresourceid']; |
|
1599 | - $addedresource=$_SESSION['addedresource']; |
|
1600 | - $addedresourceid=$_SESSION['addedresourceid']; |
|
1601 | - |
|
1602 | - if (is_array($_SESSION['addedresource'])) |
|
1603 | - { |
|
1604 | - foreach ($addedresource as $toolcompare) |
|
1605 | - { |
|
1606 | - //echo $toolcompare; |
|
1607 | - //echo "/".$type."/".$id."****"; |
|
1608 | - //$key=key($addedresource); |
|
1609 | - //echo $addedresourceid[$key]; |
|
1610 | - //print_r($addedresourceid); |
|
1611 | - //echo "<br>"; |
|
1612 | - |
|
1613 | - if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id) |
|
1614 | - { |
|
1615 | - $show=0; |
|
1616 | - } |
|
1617 | - next($addedresource); |
|
1618 | - } |
|
1619 | - if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1620 | - if ($show!==0) |
|
1621 | - { |
|
1622 | - if ($type=="Document") |
|
1623 | - { |
|
1624 | - echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>"; |
|
1625 | - } |
|
1626 | - else |
|
1627 | - { |
|
1628 | - echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1629 | - } |
|
1630 | - } |
|
1631 | - } |
|
1632 | - else // if it is not an array, it is a string |
|
1633 | - { |
|
1634 | - if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id) |
|
1635 | - { |
|
1636 | - if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1637 | - echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1638 | - } |
|
1639 | - } |
|
1596 | + global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target; |
|
1597 | + //global $_SESSION['addresource']; |
|
1598 | + //global $_SESSION['addresourceid']; |
|
1599 | + $addedresource=$_SESSION['addedresource']; |
|
1600 | + $addedresourceid=$_SESSION['addedresourceid']; |
|
1601 | + |
|
1602 | + if (is_array($_SESSION['addedresource'])) |
|
1603 | + { |
|
1604 | + foreach ($addedresource as $toolcompare) |
|
1605 | + { |
|
1606 | + //echo $toolcompare; |
|
1607 | + //echo "/".$type."/".$id."****"; |
|
1608 | + //$key=key($addedresource); |
|
1609 | + //echo $addedresourceid[$key]; |
|
1610 | + //print_r($addedresourceid); |
|
1611 | + //echo "<br>"; |
|
1612 | + |
|
1613 | + if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id) |
|
1614 | + { |
|
1615 | + $show=0; |
|
1616 | + } |
|
1617 | + next($addedresource); |
|
1618 | + } |
|
1619 | + if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1620 | + if ($show!==0) |
|
1621 | + { |
|
1622 | + if ($type=="Document") |
|
1623 | + { |
|
1624 | + echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>"; |
|
1625 | + } |
|
1626 | + else |
|
1627 | + { |
|
1628 | + echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1629 | + } |
|
1630 | + } |
|
1631 | + } |
|
1632 | + else // if it is not an array, it is a string |
|
1633 | + { |
|
1634 | + if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id) |
|
1635 | + { |
|
1636 | + if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); } |
|
1637 | + echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>"; |
|
1638 | + } |
|
1639 | + } |
|
1640 | 1640 | } |
1641 | 1641 | ?> |
@@ -6,47 +6,47 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class AddCourseToSession |
8 | 8 | { |
9 | - /** |
|
10 | - * Searches a course, given a search string and a type of search box |
|
11 | - * @param string $needle Search string |
|
12 | - * @param string $type Type of search box ('single' or anything else) |
|
13 | - * @return xajaxResponse XajaxResponse |
|
14 | - * @assert ('abc', 'single') !== null |
|
15 | - * @assert ('abc', 'multiple') !== null |
|
16 | - */ |
|
17 | - public static function search_courses($needle, $type) |
|
18 | - { |
|
19 | - global $tbl_session_rel_course, $id_session; |
|
9 | + /** |
|
10 | + * Searches a course, given a search string and a type of search box |
|
11 | + * @param string $needle Search string |
|
12 | + * @param string $type Type of search box ('single' or anything else) |
|
13 | + * @return xajaxResponse XajaxResponse |
|
14 | + * @assert ('abc', 'single') !== null |
|
15 | + * @assert ('abc', 'multiple') !== null |
|
16 | + */ |
|
17 | + public static function search_courses($needle, $type) |
|
18 | + { |
|
19 | + global $tbl_session_rel_course, $id_session; |
|
20 | 20 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
21 | - $course_title = null; |
|
22 | - $xajax_response = new xajaxResponse(); |
|
23 | - $return = ''; |
|
24 | - if(!empty($needle) && !empty($type)) { |
|
25 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | - $charset = api_get_system_encoding(); |
|
27 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
21 | + $course_title = null; |
|
22 | + $xajax_response = new xajaxResponse(); |
|
23 | + $return = ''; |
|
24 | + if(!empty($needle) && !empty($type)) { |
|
25 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | + $charset = api_get_system_encoding(); |
|
27 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
28 | 28 | |
29 | - $cond_course_code = ''; |
|
30 | - if (!empty($id_session)) { |
|
31 | - $id_session = intval($id_session); |
|
32 | - // check course_code from session_rel_course table |
|
33 | - $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
29 | + $cond_course_code = ''; |
|
30 | + if (!empty($id_session)) { |
|
31 | + $id_session = intval($id_session); |
|
32 | + // check course_code from session_rel_course table |
|
33 | + $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
34 | 34 | WHERE session_id = '.$id_session; |
35 | - $res = Database::query($sql); |
|
36 | - $course_codes = ''; |
|
37 | - if (Database::num_rows($res) > 0) { |
|
38 | - while ($row = Database::fetch_row($res)) { |
|
39 | - $course_codes .= '\''.$row[0].'\','; |
|
40 | - } |
|
41 | - $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
35 | + $res = Database::query($sql); |
|
36 | + $course_codes = ''; |
|
37 | + if (Database::num_rows($res) > 0) { |
|
38 | + while ($row = Database::fetch_row($res)) { |
|
39 | + $course_codes .= '\''.$row[0].'\','; |
|
40 | + } |
|
41 | + $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
42 | 42 | |
43 | - $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | - } |
|
45 | - } |
|
43 | + $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | if ($type == 'single') { |
48 | - // search users where username or firstname or lastname begins likes $needle |
|
49 | - $sql = 'SELECT |
|
48 | + // search users where username or firstname or lastname begins likes $needle |
|
49 | + $sql = 'SELECT |
|
50 | 50 | course.id, |
51 | 51 | course.visual_code, |
52 | 52 | course.title, |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | WHERE |
59 | 59 | course.visual_code LIKE "'.$needle.'%" OR |
60 | 60 | course.title LIKE "'.$needle.'%"'; |
61 | - } else { |
|
61 | + } else { |
|
62 | 62 | $sql = 'SELECT course.id, course.visual_code, course.title |
63 | 63 | FROM '.$tbl_course.' course |
64 | 64 | WHERE |
65 | 65 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
66 | 66 | ORDER BY course.code '; |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - if (api_is_multiple_url_enabled()) { |
|
70 | - $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | - $access_url_id = api_get_current_access_url_id(); |
|
72 | - if ($access_url_id != -1){ |
|
69 | + if (api_is_multiple_url_enabled()) { |
|
70 | + $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | + $access_url_id = api_get_current_access_url_id(); |
|
72 | + if ($access_url_id != -1){ |
|
73 | 73 | |
74 | - if ($type=='single') { |
|
75 | - $sql = 'SELECT |
|
74 | + if ($type=='single') { |
|
75 | + $sql = 'SELECT |
|
76 | 76 | course.id, |
77 | 77 | course.visual_code, |
78 | 78 | course.title, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | access_url_id = '.$access_url_id.' AND |
88 | 88 | (course.visual_code LIKE "'.$needle.'%" OR |
89 | 89 | course.title LIKE "'.$needle.'%" )'; |
90 | - } else { |
|
90 | + } else { |
|
91 | 91 | $sql = 'SELECT course.id, course.visual_code, course.title |
92 | 92 | FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course |
93 | 93 | WHERE |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | access_url_id = '.$access_url_id.' AND |
96 | 96 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
97 | 97 | ORDER BY course.code '; |
98 | - } |
|
99 | - } |
|
100 | - } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - $rs = Database::query($sql); |
|
103 | - $course_list = array(); |
|
102 | + $rs = Database::query($sql); |
|
103 | + $course_list = array(); |
|
104 | 104 | if ($type == 'single') { |
105 | - while ($course = Database :: fetch_array($rs)) { |
|
106 | - $course_list[] = $course['code']; |
|
107 | - $course_title=str_replace("'","\'",$course_title); |
|
105 | + while ($course = Database :: fetch_array($rs)) { |
|
106 | + $course_list[] = $course['code']; |
|
107 | + $course_title=str_replace("'","\'",$course_title); |
|
108 | 108 | $return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['id'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />'; |
109 | - } |
|
110 | - $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
111 | - } else { |
|
112 | - $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
113 | - while($course = Database :: fetch_array($rs)) { |
|
114 | - $course_list[] = $course['code']; |
|
115 | - $course_title=str_replace("'","\'",$course_title); |
|
109 | + } |
|
110 | + $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
111 | + } else { |
|
112 | + $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
113 | + while($course = Database :: fetch_array($rs)) { |
|
114 | + $course_list[] = $course['code']; |
|
115 | + $course_title=str_replace("'","\'",$course_title); |
|
116 | 116 | $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>'; |
117 | - } |
|
118 | - $return .= '</select>'; |
|
119 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
120 | - } |
|
121 | - } |
|
122 | - $_SESSION['course_list'] = $course_list; |
|
117 | + } |
|
118 | + $return .= '</select>'; |
|
119 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
120 | + } |
|
121 | + } |
|
122 | + $_SESSION['course_list'] = $course_list; |
|
123 | 123 | |
124 | - return $xajax_response; |
|
125 | - } |
|
124 | + return $xajax_response; |
|
125 | + } |
|
126 | 126 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | if (!$is_allowedToEdit) { |
47 | - // api_not_allowed(); |
|
47 | + // api_not_allowed(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if (!empty($_REQUEST['path'])) { |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | get_lang('Actions') |
190 | 190 | ); |
191 | 191 | |
192 | - // Column config |
|
193 | - // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
192 | + // Column config |
|
193 | + // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
194 | 194 | $column_model = array( |
195 | 195 | array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'), |
196 | 196 | array( |
@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | $sublanguage_folder_error = false; |
67 | 67 | |
68 | 68 | if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
69 | - $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | - $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | - $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | - $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | - $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
69 | + $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | + $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | + $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | + $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | + $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
74 | 74 | |
75 | - if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | - $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | - } |
|
78 | - if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | - $language_id_exist = true; |
|
80 | - } else { |
|
81 | - $language_id_exist = false; |
|
82 | - } |
|
75 | + if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | + $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | + } |
|
78 | + if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | + $language_id_exist = true; |
|
80 | + } else { |
|
81 | + $language_id_exist = false; |
|
82 | + } |
|
83 | 83 | } else { |
84 | - $language_name=''; |
|
85 | - $language_id_exist=false; |
|
84 | + $language_name=''; |
|
85 | + $language_id_exist=false; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $intro = sprintf(get_lang('RegisterTermsOfSubLanguageForX'), strtolower($sub_language_name)); |
89 | 89 | $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder']; |
90 | 90 | |
91 | 91 | if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { |
92 | - api_not_allowed(true); |
|
92 | + api_not_allowed(true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | Display :: display_header($language_name); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | echo $html; |
115 | 115 | echo '<br /><br /><br />'; |
116 | 116 | if (!empty($sublanguage_folder_error)) { |
117 | - Display::display_warning_message($sublanguage_folder_error); |
|
117 | + Display::display_warning_message($sublanguage_folder_error); |
|
118 | 118 | } |
119 | 119 | echo '<div id="div_message_information_id"> </div>'; |
120 | 120 | |
@@ -128,186 +128,186 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | function search_language_term( |
131 | - $term, |
|
132 | - $search_in_variable = true, |
|
133 | - $search_in_english = true, |
|
134 | - $search_in_parent = true, |
|
135 | - $search_in_sub_language = true |
|
131 | + $term, |
|
132 | + $search_in_variable = true, |
|
133 | + $search_in_english = true, |
|
134 | + $search_in_parent = true, |
|
135 | + $search_in_sub_language = true |
|
136 | 136 | ) { |
137 | - //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
138 | - /* |
|
137 | + //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
138 | + /* |
|
139 | 139 | These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php |
140 | 140 | $english_language_array |
141 | 141 | $parent_language_array |
142 | 142 | $sub_language_array |
143 | 143 | $language_files_to_load |
144 | 144 | */ |
145 | - global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
146 | - $language_files_to_load_keys = array_flip($language_files_to_load); |
|
147 | - $array_to_search = $parent_language_array; |
|
148 | - $list_info = array(); |
|
149 | - $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
150 | - //@todo optimize this foreach |
|
151 | - foreach ($language_files_to_load as $lang_file) { |
|
152 | - //searching in parent language of the sub language |
|
153 | - if ($search_in_parent) { |
|
154 | - $variables = $parent_language_array[$lang_file]; |
|
155 | - foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
156 | - //arrays are avoided |
|
157 | - if (is_array($parent_variable_value)) { |
|
158 | - continue; |
|
159 | - } |
|
160 | - $founded = false; |
|
161 | - // searching the item in the parent tool |
|
162 | - if (preg_match($term,$parent_variable_value)!==0) { |
|
163 | - $founded = true; |
|
164 | - } |
|
165 | - if ($founded) { |
|
166 | - //loading variable from the english array |
|
167 | - $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
168 | - //loading variable from the english array |
|
169 | - $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
145 | + global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
146 | + $language_files_to_load_keys = array_flip($language_files_to_load); |
|
147 | + $array_to_search = $parent_language_array; |
|
148 | + $list_info = array(); |
|
149 | + $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
150 | + //@todo optimize this foreach |
|
151 | + foreach ($language_files_to_load as $lang_file) { |
|
152 | + //searching in parent language of the sub language |
|
153 | + if ($search_in_parent) { |
|
154 | + $variables = $parent_language_array[$lang_file]; |
|
155 | + foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
156 | + //arrays are avoided |
|
157 | + if (is_array($parent_variable_value)) { |
|
158 | + continue; |
|
159 | + } |
|
160 | + $founded = false; |
|
161 | + // searching the item in the parent tool |
|
162 | + if (preg_match($term,$parent_variable_value)!==0) { |
|
163 | + $founded = true; |
|
164 | + } |
|
165 | + if ($founded) { |
|
166 | + //loading variable from the english array |
|
167 | + $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
168 | + //loading variable from the english array |
|
169 | + $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
170 | 170 | |
171 | - //config buttons |
|
172 | - /*if (strlen($english_name_variable)>1500) { |
|
171 | + //config buttons |
|
172 | + /*if (strlen($english_name_variable)>1500) { |
|
173 | 173 | $size =20; |
174 | 174 | } else { |
175 | 175 | $size =4; |
176 | 176 | }*/ |
177 | 177 | |
178 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
179 | - $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
178 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
179 | + $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
180 | 180 | |
181 | - $list_info[] = array( |
|
182 | - $lang_file . '.inc.php', |
|
183 | - $parent_name_variable, |
|
184 | - $english_name_variable, |
|
185 | - $parent_variable_value, |
|
186 | - $obj_text, |
|
187 | - $obj_button |
|
188 | - ); |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
181 | + $list_info[] = array( |
|
182 | + $lang_file . '.inc.php', |
|
183 | + $parent_name_variable, |
|
184 | + $english_name_variable, |
|
185 | + $parent_variable_value, |
|
186 | + $obj_text, |
|
187 | + $obj_button |
|
188 | + ); |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | 192 | |
193 | - //search in english |
|
194 | - if ($search_in_english || $search_in_variable) { |
|
195 | - $variables = $english_language_array[$lang_file]; |
|
196 | - foreach ($variables as $name_variable =>$variable_value) { |
|
197 | - if (is_array($variable_value)) { |
|
198 | - continue; |
|
199 | - } |
|
193 | + //search in english |
|
194 | + if ($search_in_english || $search_in_variable) { |
|
195 | + $variables = $english_language_array[$lang_file]; |
|
196 | + foreach ($variables as $name_variable =>$variable_value) { |
|
197 | + if (is_array($variable_value)) { |
|
198 | + continue; |
|
199 | + } |
|
200 | 200 | |
201 | - if (is_array($variable_value)) |
|
202 | - echo $lang_file; |
|
203 | - $founded = false; |
|
204 | - if ($search_in_english && $search_in_variable) { |
|
205 | - // searching the item in the parent tool |
|
206 | - if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
207 | - $founded = true; |
|
208 | - } |
|
209 | - } else { |
|
210 | - if ($search_in_english) { |
|
211 | - if (preg_match($term,$variable_value)!==0) { |
|
212 | - $founded = true; |
|
213 | - } |
|
214 | - } else { |
|
215 | - if (preg_match($term,$name_variable)!==0) { |
|
216 | - $founded = true; |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
201 | + if (is_array($variable_value)) |
|
202 | + echo $lang_file; |
|
203 | + $founded = false; |
|
204 | + if ($search_in_english && $search_in_variable) { |
|
205 | + // searching the item in the parent tool |
|
206 | + if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
207 | + $founded = true; |
|
208 | + } |
|
209 | + } else { |
|
210 | + if ($search_in_english) { |
|
211 | + if (preg_match($term,$variable_value)!==0) { |
|
212 | + $founded = true; |
|
213 | + } |
|
214 | + } else { |
|
215 | + if (preg_match($term,$name_variable)!==0) { |
|
216 | + $founded = true; |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ($founded) { |
|
222 | - //loading variable from the english array |
|
223 | - $sub_language_name_variable = null; |
|
224 | - if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
225 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
226 | - } |
|
227 | - $parent_variable_value = null; |
|
228 | - if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
229 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
230 | - } |
|
231 | - //config buttons |
|
232 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
233 | - $sub_language_name_variable.' |
|
221 | + if ($founded) { |
|
222 | + //loading variable from the english array |
|
223 | + $sub_language_name_variable = null; |
|
224 | + if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
225 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
226 | + } |
|
227 | + $parent_variable_value = null; |
|
228 | + if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
229 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
230 | + } |
|
231 | + //config buttons |
|
232 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
233 | + $sub_language_name_variable.' |
|
234 | 234 | </textarea>'; |
235 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
235 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
236 | 236 | |
237 | - //loading variable from the english array |
|
238 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
237 | + //loading variable from the english array |
|
238 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
239 | 239 | |
240 | - $list_info[] = array( |
|
241 | - $lang_file . '.inc.php', |
|
242 | - $name_variable, |
|
243 | - $english_name_variable, |
|
244 | - $parent_variable_value, |
|
245 | - $obj_text, |
|
246 | - $obj_button |
|
247 | - ); |
|
248 | - } |
|
249 | - } |
|
250 | - } |
|
240 | + $list_info[] = array( |
|
241 | + $lang_file . '.inc.php', |
|
242 | + $name_variable, |
|
243 | + $english_name_variable, |
|
244 | + $parent_variable_value, |
|
245 | + $obj_text, |
|
246 | + $obj_button |
|
247 | + ); |
|
248 | + } |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - // Search in sub language |
|
253 | - if ($search_in_sub_language) { |
|
254 | - $variables = $sub_language_array[$lang_file]; |
|
255 | - foreach ($variables as $name_variable =>$variable_value) { |
|
256 | - if (is_array($parent_variable_value)) { |
|
257 | - continue; |
|
258 | - } |
|
252 | + // Search in sub language |
|
253 | + if ($search_in_sub_language) { |
|
254 | + $variables = $sub_language_array[$lang_file]; |
|
255 | + foreach ($variables as $name_variable =>$variable_value) { |
|
256 | + if (is_array($parent_variable_value)) { |
|
257 | + continue; |
|
258 | + } |
|
259 | 259 | |
260 | - if (is_array($variable_value)) { |
|
261 | - continue; |
|
262 | - } |
|
260 | + if (is_array($variable_value)) { |
|
261 | + continue; |
|
262 | + } |
|
263 | 263 | |
264 | - $founded = false; |
|
265 | - // searching the item in the parent tool |
|
266 | - if (preg_match($term,$variable_value)!==0) { |
|
267 | - $founded = true; |
|
268 | - } |
|
269 | - if ($founded) { |
|
270 | - //loading variable from the english array |
|
271 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
272 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
273 | - //config buttons |
|
274 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
275 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
264 | + $founded = false; |
|
265 | + // searching the item in the parent tool |
|
266 | + if (preg_match($term,$variable_value)!==0) { |
|
267 | + $founded = true; |
|
268 | + } |
|
269 | + if ($founded) { |
|
270 | + //loading variable from the english array |
|
271 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
272 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
273 | + //config buttons |
|
274 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
275 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
276 | 276 | |
277 | - //loading variable from the english array |
|
278 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
279 | - $list_info[]=array($lang_file.'.inc.php', |
|
280 | - $name_variable, |
|
281 | - $english_name_variable, |
|
282 | - $parent_variable_value,$obj_text,$obj_button); |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
277 | + //loading variable from the english array |
|
278 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
279 | + $list_info[]=array($lang_file.'.inc.php', |
|
280 | + $name_variable, |
|
281 | + $english_name_variable, |
|
282 | + $parent_variable_value,$obj_text,$obj_button); |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | 287 | |
288 | - $list_info = array_unique_dimensional($list_info); |
|
289 | - return $list_info; |
|
288 | + $list_info = array_unique_dimensional($list_info); |
|
289 | + return $list_info; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Allow see data in sort table |
293 | 293 | $list_info = array(); |
294 | 294 | if (isset($_REQUEST['txt_search_word'])) { |
295 | - //@todo fix to accept a char with 1 char |
|
296 | - if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
297 | - $list_info = search_language_term( |
|
298 | - $_REQUEST['txt_search_word'], |
|
299 | - true, |
|
300 | - true, |
|
301 | - true, |
|
302 | - true |
|
303 | - ); |
|
304 | - } |
|
295 | + //@todo fix to accept a char with 1 char |
|
296 | + if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
297 | + $list_info = search_language_term( |
|
298 | + $_REQUEST['txt_search_word'], |
|
299 | + true, |
|
300 | + true, |
|
301 | + true, |
|
302 | + true |
|
303 | + ); |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $parameters = array( |
308 | - 'id' => intval($_GET['id']), |
|
309 | - 'sub_language_id' => intval($_GET['sub_language_id']), |
|
310 | - 'txt_search_word' => $txt_search_word |
|
308 | + 'id' => intval($_GET['id']), |
|
309 | + 'sub_language_id' => intval($_GET['sub_language_id']), |
|
310 | + 'txt_search_word' => $txt_search_word |
|
311 | 311 | ); |
312 | 312 | $table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); |
313 | 313 | $table->set_additional_parameters($parameters); |
@@ -99,27 +99,27 @@ discard block |
||
99 | 99 | $form = new FormValidator('user_add'); |
100 | 100 | $form->addElement('header', '', $tool_name); |
101 | 101 | if (api_is_western_name_order()) { |
102 | - // Firstname |
|
103 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
104 | - $form->applyFilter('firstname', 'html_filter'); |
|
105 | - $form->applyFilter('firstname', 'trim'); |
|
106 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
107 | - // Lastname |
|
108 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
109 | - $form->applyFilter('lastname', 'html_filter'); |
|
110 | - $form->applyFilter('lastname', 'trim'); |
|
111 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
102 | + // Firstname |
|
103 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
104 | + $form->applyFilter('firstname', 'html_filter'); |
|
105 | + $form->applyFilter('firstname', 'trim'); |
|
106 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
107 | + // Lastname |
|
108 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
109 | + $form->applyFilter('lastname', 'html_filter'); |
|
110 | + $form->applyFilter('lastname', 'trim'); |
|
111 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
112 | 112 | } else { |
113 | - // Lastname |
|
114 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
115 | - $form->applyFilter('lastname', 'html_filter'); |
|
116 | - $form->applyFilter('lastname', 'trim'); |
|
117 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
118 | - // Firstname |
|
119 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
120 | - $form->applyFilter('firstname', 'html_filter'); |
|
121 | - $form->applyFilter('firstname', 'trim'); |
|
122 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
113 | + // Lastname |
|
114 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
115 | + $form->applyFilter('lastname', 'html_filter'); |
|
116 | + $form->applyFilter('lastname', 'trim'); |
|
117 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
118 | + // Firstname |
|
119 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
120 | + $form->applyFilter('firstname', 'html_filter'); |
|
121 | + $form->applyFilter('firstname', 'trim'); |
|
122 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
123 | 123 | } |
124 | 124 | // Official code |
125 | 125 | $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => '40')); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $auth_sources = 0; //make available wider as we need it in case of form reset (see below) |
164 | 164 | $nb_ext_auth_source_added = 0; |
165 | 165 | if (isset($extAuthSource) && count($extAuthSource) > 0) { |
166 | - $auth_sources = array(); |
|
166 | + $auth_sources = array(); |
|
167 | 167 | foreach ($extAuthSource as $key => $info) { |
168 | 168 | // @todo : make uniform external authentification configuration (ex : cas and external_login ldap) |
169 | 169 | // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | $nb_ext_auth_source_added++; |
175 | 175 | } |
176 | 176 | } |
177 | - if ($nb_ext_auth_source_added > 0) { |
|
178 | - $group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); |
|
179 | - $group[] = $form->createElement('select', 'auth_source', null, $auth_sources); |
|
180 | - $group[] = $form->createElement('static', '', '', '<br />'); |
|
177 | + if ($nb_ext_auth_source_added > 0) { |
|
178 | + $group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); |
|
179 | + $group[] = $form->createElement('select', 'auth_source', null, $auth_sources); |
|
180 | + $group[] = $form->createElement('static', '', '', '<br />'); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | $form->addElement('html', '<div id="drh_list" style="display:'.$display.';">'); |
247 | 247 | |
248 | 248 | if (isset($drh_list) && is_array($drh_list)) { |
249 | - foreach ($drh_list as $drh) { |
|
249 | + foreach ($drh_list as $drh) { |
|
250 | 250 | $drh_select->addOption( |
251 | 251 | api_get_person_name($drh['firstname'], $drh['lastname']), |
252 | 252 | $drh['user_id'] |
253 | 253 | ); |
254 | - } |
|
254 | + } |
|
255 | 255 | } |
256 | 256 | $form->addElement('html', '</div>'); |
257 | 257 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | // Validate form |
327 | 327 | if ($form->validate()) { |
328 | - $check = Security::check_token('post'); |
|
328 | + $check = Security::check_token('post'); |
|
329 | 329 | if ($check) { |
330 | 330 | $user = $form->exportValues(); |
331 | 331 | $lastname = $user['lastname']; |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | $send_mail = intval($user['mail']['send_mail']); |
342 | 342 | $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : 0; |
343 | 343 | |
344 | - if (isset($extAuthSource) && count($extAuthSource) > 0 && |
|
344 | + if (isset($extAuthSource) && count($extAuthSource) > 0 && |
|
345 | 345 | $user['password']['password_auto'] == '2' |
346 | 346 | ) { |
347 | - $auth_source = $user['password']['auth_source']; |
|
348 | - $password = 'PLACEHOLDER'; |
|
349 | - } else { |
|
350 | - $auth_source = PLATFORM_AUTH_SOURCE; |
|
351 | - $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
352 | - } |
|
347 | + $auth_source = $user['password']['auth_source']; |
|
348 | + $password = 'PLACEHOLDER'; |
|
349 | + } else { |
|
350 | + $auth_source = PLATFORM_AUTH_SOURCE; |
|
351 | + $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
352 | + } |
|
353 | 353 | |
354 | 354 | if ($user['radio_expiration_date'] == '1') { |
355 | 355 | $expiration_date = $user['expiration_date']; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $expiration_date = null; |
358 | 358 | } |
359 | 359 | |
360 | - $active = intval($user['active']); |
|
360 | + $active = intval($user['active']); |
|
361 | 361 | |
362 | 362 | if (api_get_setting('login_is_email') == 'true') { |
363 | 363 | $username = $email; |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | $extra, |
389 | 389 | null, |
390 | 390 | $send_mail, |
391 | - $platform_admin |
|
391 | + $platform_admin |
|
392 | 392 | ); |
393 | 393 | |
394 | - Security::clear_token(); |
|
395 | - $tok = Security::get_token(); |
|
396 | - if (!empty($user_id)) { |
|
394 | + Security::clear_token(); |
|
395 | + $tok = Security::get_token(); |
|
396 | + if (!empty($user_id)) { |
|
397 | 397 | if (!empty($picture['name'])) { |
398 | 398 | $picture_uri = UserManager::update_user_picture( |
399 | 399 | $user_id, |
@@ -420,37 +420,37 @@ discard block |
||
420 | 420 | null, |
421 | 421 | $language |
422 | 422 | ); |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | 425 | $extraFieldValues = new ExtraFieldValue('user'); |
426 | 426 | $user['item_id'] = $user_id; |
427 | 427 | $extraFieldValues->saveFieldValues($user); |
428 | - $message = get_lang('UserAdded'); |
|
429 | - } |
|
428 | + $message = get_lang('UserAdded'); |
|
429 | + } |
|
430 | 430 | |
431 | - if (isset($user['submit_plus'])) { |
|
432 | - //we want to add more. Prepare report message and redirect to the same page (to clean the form) |
|
431 | + if (isset($user['submit_plus'])) { |
|
432 | + //we want to add more. Prepare report message and redirect to the same page (to clean the form) |
|
433 | 433 | Display::addFlash(Display::return_message($message)); |
434 | - header('Location: user_add.php?sec_token='.$tok); |
|
435 | - exit; |
|
436 | - } else { |
|
437 | - $tok = Security::get_token(); |
|
434 | + header('Location: user_add.php?sec_token='.$tok); |
|
435 | + exit; |
|
436 | + } else { |
|
437 | + $tok = Security::get_token(); |
|
438 | 438 | Display::addFlash(Display::return_message($message)); |
439 | - header('Location: user_list.php?sec_token='.$tok); |
|
440 | - exit; |
|
441 | - } |
|
442 | - } |
|
439 | + header('Location: user_list.php?sec_token='.$tok); |
|
440 | + exit; |
|
441 | + } |
|
442 | + } |
|
443 | 443 | } else { |
444 | - if (isset($_POST['submit'])) { |
|
445 | - Security::clear_token(); |
|
446 | - } |
|
447 | - $token = Security::get_token(); |
|
448 | - $form->addElement('hidden', 'sec_token'); |
|
449 | - $form->setConstants(array('sec_token' => $token)); |
|
444 | + if (isset($_POST['submit'])) { |
|
445 | + Security::clear_token(); |
|
446 | + } |
|
447 | + $token = Security::get_token(); |
|
448 | + $form->addElement('hidden', 'sec_token'); |
|
449 | + $form->setConstants(array('sec_token' => $token)); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | if (!empty($message)){ |
453 | - $message = Display::return_message(stripslashes($message)); |
|
453 | + $message = Display::return_message(stripslashes($message)); |
|
454 | 454 | } |
455 | 455 | $content = $form->returnForm(); |
456 | 456 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | unset($user_data['password']); |
103 | 103 | |
104 | 104 | if ($userGeolocalization) { |
105 | - $htmlHeadXtra[] = '<script> |
|
105 | + $htmlHeadXtra[] = '<script> |
|
106 | 106 | $(document).ready(function() { |
107 | 107 | |
108 | 108 | var address = "' . $user_data['address'] . '"; |
@@ -212,27 +212,27 @@ discard block |
||
212 | 212 | $form->addElement('hidden', 'user_id', $user_id); |
213 | 213 | |
214 | 214 | if (api_is_western_name_order()) { |
215 | - // Firstname |
|
216 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
217 | - $form->applyFilter('firstname', 'html_filter'); |
|
218 | - $form->applyFilter('firstname', 'trim'); |
|
219 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
220 | - // Lastname |
|
221 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
222 | - $form->applyFilter('lastname', 'html_filter'); |
|
223 | - $form->applyFilter('lastname', 'trim'); |
|
224 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
215 | + // Firstname |
|
216 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
217 | + $form->applyFilter('firstname', 'html_filter'); |
|
218 | + $form->applyFilter('firstname', 'trim'); |
|
219 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
220 | + // Lastname |
|
221 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
222 | + $form->applyFilter('lastname', 'html_filter'); |
|
223 | + $form->applyFilter('lastname', 'trim'); |
|
224 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
225 | 225 | } else { |
226 | - // Lastname |
|
227 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
228 | - $form->applyFilter('lastname', 'html_filter'); |
|
229 | - $form->applyFilter('lastname', 'trim'); |
|
230 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
231 | - // Firstname |
|
232 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
233 | - $form->applyFilter('firstname', 'html_filter'); |
|
234 | - $form->applyFilter('firstname', 'trim'); |
|
235 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
226 | + // Lastname |
|
227 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
228 | + $form->applyFilter('lastname', 'html_filter'); |
|
229 | + $form->applyFilter('lastname', 'trim'); |
|
230 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
231 | + // Firstname |
|
232 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
233 | + $form->applyFilter('firstname', 'html_filter'); |
|
234 | + $form->applyFilter('firstname', 'trim'); |
|
235 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // Official code |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | |
255 | 255 | // OpenID |
256 | 256 | if (api_get_setting('openid_authentication') == 'true') { |
257 | - $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
257 | + $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Phone |
261 | 261 | $form->addElement('text', 'phone', get_lang('PhoneNumber')); |
262 | 262 | |
263 | 263 | if ($userGeolocalization) { |
264 | - // Geolocation |
|
265 | - $form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']); |
|
266 | - $form->addHtml(' |
|
264 | + // Geolocation |
|
265 | + $form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']); |
|
266 | + $form->addHtml(' |
|
267 | 267 | <div class="form-group"> |
268 | 268 | <label for="geolocalization" class="col-sm-2 control-label"></label> |
269 | 269 | <div class="col-sm-8"> |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | </div> |
274 | 274 | '); |
275 | 275 | |
276 | - $form->addHtml(' |
|
276 | + $form->addHtml(' |
|
277 | 277 | <div class="form-group"> |
278 | 278 | <label for="map" class="col-sm-2 control-label"> |
279 | 279 | '.get_lang('Map').' |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | $allowed_picture_types = api_get_supported_image_extensions(false); |
296 | 296 | |
297 | 297 | $form->addRule( |
298 | - 'picture', |
|
299 | - get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
300 | - 'filetype', |
|
301 | - $allowed_picture_types |
|
298 | + 'picture', |
|
299 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
300 | + 'filetype', |
|
301 | + $allowed_picture_types |
|
302 | 302 | ); |
303 | 303 | if (strlen($user_data['picture_uri']) > 0) { |
304 | - $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
304 | + $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | // Username |
308 | 308 | if (api_get_setting('login_is_email') != 'true') { |
309 | - $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
309 | + $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
310 | 310 | $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); |
311 | 311 | $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
312 | 312 | $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username'); |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | |
379 | 379 | // Platform admin |
380 | 380 | if (api_is_platform_admin()) { |
381 | - $group = array(); |
|
382 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
383 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
381 | + $group = array(); |
|
382 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
383 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
384 | 384 | |
385 | - $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
385 | + $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
386 | 386 | |
387 | - $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
388 | - $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
389 | - $form->addElement('html', '</div>'); |
|
387 | + $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
388 | + $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
389 | + $form->addElement('html', '</div>'); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | //Language |
@@ -404,16 +404,16 @@ discard block |
||
404 | 404 | $form->addElement('label', get_lang('RegistrationDate'), $date); |
405 | 405 | |
406 | 406 | if (!$user_data['platform_admin']) { |
407 | - // Expiration Date |
|
408 | - $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
409 | - $group = array (); |
|
410 | - $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
411 | - $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
412 | - $form->addGroup($group, 'max_member_group', null, null, false); |
|
413 | - |
|
414 | - // Active account or inactive account |
|
415 | - $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
416 | - $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
407 | + // Expiration Date |
|
408 | + $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
409 | + $group = array (); |
|
410 | + $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
411 | + $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
412 | + $form->addGroup($group, 'max_member_group', null, null, false); |
|
413 | + |
|
414 | + // Active account or inactive account |
|
415 | + $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
416 | + $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
417 | 417 | } |
418 | 418 | $studentBossList = UserManager::getStudentBossList($user_data['user_id']); |
419 | 419 | |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | $expiration_date = $user_data['expiration_date']; |
456 | 456 | |
457 | 457 | if (empty($expiration_date)) { |
458 | - $user_data['radio_expiration_date'] = 0; |
|
459 | - $user_data['expiration_date'] = api_get_local_time(); |
|
458 | + $user_data['radio_expiration_date'] = 0; |
|
459 | + $user_data['expiration_date'] = api_get_local_time(); |
|
460 | 460 | } else { |
461 | - $user_data['radio_expiration_date'] = 1; |
|
462 | - $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
461 | + $user_data['radio_expiration_date'] = 1; |
|
462 | + $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
463 | 463 | } |
464 | 464 | $form->setDefaults($user_data); |
465 | 465 | |
466 | 466 | $error_drh = false; |
467 | 467 | // Validate form |
468 | 468 | if ($form->validate()) { |
469 | - $user = $form->getSubmitValues(1); |
|
469 | + $user = $form->getSubmitValues(1); |
|
470 | 470 | $reset_password = intval($user['reset_password']); |
471 | 471 | if ($reset_password == 2 && empty($user['password'])) { |
472 | 472 | Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort'))); |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | exit(); |
475 | 475 | } |
476 | 476 | |
477 | - $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
477 | + $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
478 | 478 | |
479 | - if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
480 | - $error_drh = true; |
|
481 | - } else { |
|
482 | - $picture_element = $form->getElement('picture'); |
|
483 | - $picture = $picture_element->getValue(); |
|
479 | + if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
480 | + $error_drh = true; |
|
481 | + } else { |
|
482 | + $picture_element = $form->getElement('picture'); |
|
483 | + $picture = $picture_element->getValue(); |
|
484 | 484 | |
485 | - $picture_uri = $user_data['picture_uri']; |
|
486 | - if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
487 | - $picture_uri = UserManager::delete_user_picture($user_id); |
|
488 | - } elseif (!empty($picture['name'])) { |
|
485 | + $picture_uri = $user_data['picture_uri']; |
|
486 | + if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
487 | + $picture_uri = UserManager::delete_user_picture($user_id); |
|
488 | + } elseif (!empty($picture['name'])) { |
|
489 | 489 | $picture_uri = UserManager::update_user_picture( |
490 | 490 | $user_id, |
491 | 491 | $_FILES['picture']['name'], |
@@ -493,30 +493,30 @@ discard block |
||
493 | 493 | $user['picture_crop_result'] |
494 | 494 | |
495 | 495 | ); |
496 | - } |
|
496 | + } |
|
497 | 497 | |
498 | - $lastname = $user['lastname']; |
|
499 | - $firstname = $user['firstname']; |
|
498 | + $lastname = $user['lastname']; |
|
499 | + $firstname = $user['firstname']; |
|
500 | 500 | $password = $user['password']; |
501 | 501 | $auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
502 | - $official_code = $user['official_code']; |
|
503 | - $email = $user['email']; |
|
504 | - $phone = $user['phone']; |
|
505 | - $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
506 | - $status = intval($user['status']); |
|
507 | - $platform_admin = intval($user['platform_admin']); |
|
508 | - $send_mail = intval($user['send_mail']); |
|
509 | - $reset_password = intval($user['reset_password']); |
|
510 | - $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
511 | - $language = $user['language']; |
|
512 | - |
|
513 | - if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
502 | + $official_code = $user['official_code']; |
|
503 | + $email = $user['email']; |
|
504 | + $phone = $user['phone']; |
|
505 | + $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
506 | + $status = intval($user['status']); |
|
507 | + $platform_admin = intval($user['platform_admin']); |
|
508 | + $send_mail = intval($user['send_mail']); |
|
509 | + $reset_password = intval($user['reset_password']); |
|
510 | + $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
511 | + $language = $user['language']; |
|
512 | + |
|
513 | + if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
514 | 514 | $expiration_date = $user['expiration_date']; |
515 | - } else { |
|
516 | - $expiration_date = null; |
|
517 | - } |
|
515 | + } else { |
|
516 | + $expiration_date = null; |
|
517 | + } |
|
518 | 518 | |
519 | - $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
519 | + $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
520 | 520 | |
521 | 521 | //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
522 | 522 | if ($platform_admin == 1) { |
@@ -548,40 +548,40 @@ discard block |
||
548 | 548 | null, |
549 | 549 | $send_mail, |
550 | 550 | $reset_password, |
551 | - $user['address'] |
|
551 | + $user['address'] |
|
552 | 552 | ); |
553 | 553 | |
554 | 554 | if (isset($user['student_boss'])) { |
555 | 555 | UserManager::subscribeUserToBossList($user_id, $user['student_boss']); |
556 | 556 | } |
557 | 557 | |
558 | - if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
559 | - $up = UserManager::update_openid($user_id, $user['openid']); |
|
560 | - } |
|
558 | + if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
559 | + $up = UserManager::update_openid($user_id, $user['openid']); |
|
560 | + } |
|
561 | 561 | $currentUserId = api_get_user_id(); |
562 | 562 | |
563 | 563 | $userObj = api_get_user_entity($user_id); |
564 | 564 | |
565 | 565 | UserManager::add_user_as_admin($userObj); |
566 | 566 | |
567 | - if ($user_id != $currentUserId) { |
|
568 | - if ($platform_admin == 1) { |
|
569 | - $userObj = api_get_user_entity($user_id); |
|
567 | + if ($user_id != $currentUserId) { |
|
568 | + if ($platform_admin == 1) { |
|
569 | + $userObj = api_get_user_entity($user_id); |
|
570 | 570 | UserManager::add_user_as_admin($userObj); |
571 | - } else { |
|
571 | + } else { |
|
572 | 572 | UserManager::remove_user_admin($user_id); |
573 | - } |
|
574 | - } |
|
573 | + } |
|
574 | + } |
|
575 | 575 | |
576 | 576 | $extraFieldValue = new ExtraFieldValue('user'); |
577 | 577 | $extraFieldValue->saveFieldValues($user); |
578 | 578 | |
579 | - $tok = Security::get_token(); |
|
579 | + $tok = Security::get_token(); |
|
580 | 580 | |
581 | 581 | Display::addFlash(Display::return_message(get_lang('UserUpdated'))); |
582 | - header('Location: user_list.php?sec_token='.$tok); |
|
583 | - exit(); |
|
584 | - } |
|
582 | + header('Location: user_list.php?sec_token='.$tok); |
|
583 | + exit(); |
|
584 | + } |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | if ($error_drh) { |
@@ -11,232 +11,232 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class WSUser extends WS { |
13 | 13 | |
14 | - /** |
|
15 | - * Enables or disables a user |
|
16 | - * |
|
17 | - * @param string User id field name |
|
18 | - * @param string User id value |
|
19 | - * @param int Set to 1 to enable and to 0 to disable |
|
20 | - */ |
|
21 | - protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
22 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | - if($user_id instanceof WSError) { |
|
24 | - return $user_id; |
|
25 | - } else { |
|
26 | - if($state == 0) { |
|
27 | - UserManager::disable($user_id); |
|
28 | - } else if($state == 1) { |
|
29 | - UserManager::enable($user_id); |
|
30 | - } |
|
31 | - } |
|
32 | - } |
|
14 | + /** |
|
15 | + * Enables or disables a user |
|
16 | + * |
|
17 | + * @param string User id field name |
|
18 | + * @param string User id value |
|
19 | + * @param int Set to 1 to enable and to 0 to disable |
|
20 | + */ |
|
21 | + protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
22 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | + if($user_id instanceof WSError) { |
|
24 | + return $user_id; |
|
25 | + } else { |
|
26 | + if($state == 0) { |
|
27 | + UserManager::disable($user_id); |
|
28 | + } else if($state == 1) { |
|
29 | + UserManager::enable($user_id); |
|
30 | + } |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Enables or disables multiple users |
|
36 | - * |
|
37 | - * @param array Users |
|
38 | - * @param int Set to 1 to enable and to 0 to disable |
|
39 | - * @return array Array of results |
|
40 | - */ |
|
41 | - protected function changeUsersActiveState($users, $state) { |
|
42 | - $results = array(); |
|
43 | - foreach($users as $user) { |
|
44 | - $result_tmp = array(); |
|
45 | - $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
46 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
47 | - if($result_op instanceof WSError) { |
|
48 | - // Return the error in the results |
|
49 | - $result_tmp['result'] = $result_op->toArray(); |
|
50 | - } else { |
|
51 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
52 | - } |
|
53 | - $results[] = $result_tmp; |
|
54 | - } |
|
55 | - return $results; |
|
56 | - } |
|
34 | + /** |
|
35 | + * Enables or disables multiple users |
|
36 | + * |
|
37 | + * @param array Users |
|
38 | + * @param int Set to 1 to enable and to 0 to disable |
|
39 | + * @return array Array of results |
|
40 | + */ |
|
41 | + protected function changeUsersActiveState($users, $state) { |
|
42 | + $results = array(); |
|
43 | + foreach($users as $user) { |
|
44 | + $result_tmp = array(); |
|
45 | + $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
46 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
47 | + if($result_op instanceof WSError) { |
|
48 | + // Return the error in the results |
|
49 | + $result_tmp['result'] = $result_op->toArray(); |
|
50 | + } else { |
|
51 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
52 | + } |
|
53 | + $results[] = $result_tmp; |
|
54 | + } |
|
55 | + return $results; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Disables a user |
|
60 | - * |
|
61 | - * @param string API secret key |
|
62 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
63 | - * @param string User id value |
|
64 | - */ |
|
65 | - public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
66 | - $verifKey = $this->verifyKey($secret_key); |
|
67 | - if($verifKey instanceof WSError) { |
|
68 | - // Let the implementation handle it |
|
69 | - $this->handleError($verifKey); |
|
70 | - } else { |
|
71 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
72 | - if($result instanceof WSError) { |
|
73 | - $this->handleError($result); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
58 | + /** |
|
59 | + * Disables a user |
|
60 | + * |
|
61 | + * @param string API secret key |
|
62 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
63 | + * @param string User id value |
|
64 | + */ |
|
65 | + public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
66 | + $verifKey = $this->verifyKey($secret_key); |
|
67 | + if($verifKey instanceof WSError) { |
|
68 | + // Let the implementation handle it |
|
69 | + $this->handleError($verifKey); |
|
70 | + } else { |
|
71 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
72 | + if($result instanceof WSError) { |
|
73 | + $this->handleError($result); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Disables multiple users |
|
80 | - * |
|
81 | - * @param string API secret key |
|
82 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
83 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
84 | - * than 0, an error occured |
|
85 | - */ |
|
86 | - public function DisableUsers($secret_key, $users) { |
|
87 | - $verifKey = $this->verifyKey($secret_key); |
|
88 | - if($verifKey instanceof WSError) { |
|
89 | - // Let the implementation handle it |
|
90 | - $this->handleError($verifKey); |
|
91 | - } else { |
|
92 | - return $this->changeUsersActiveState($users, 0); |
|
93 | - } |
|
94 | - } |
|
78 | + /** |
|
79 | + * Disables multiple users |
|
80 | + * |
|
81 | + * @param string API secret key |
|
82 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
83 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
84 | + * than 0, an error occured |
|
85 | + */ |
|
86 | + public function DisableUsers($secret_key, $users) { |
|
87 | + $verifKey = $this->verifyKey($secret_key); |
|
88 | + if($verifKey instanceof WSError) { |
|
89 | + // Let the implementation handle it |
|
90 | + $this->handleError($verifKey); |
|
91 | + } else { |
|
92 | + return $this->changeUsersActiveState($users, 0); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Enables a user |
|
98 | - * |
|
99 | - * @param string API secret key |
|
100 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
101 | - * @param string User id value |
|
102 | - */ |
|
103 | - public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
104 | - $verifKey = $this->verifyKey($secret_key); |
|
105 | - if($verifKey instanceof WSError) { |
|
106 | - $this->handleError($verifKey); |
|
107 | - } else { |
|
108 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
109 | - if($result instanceof WSError) { |
|
110 | - $this->handleError($result); |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
96 | + /** |
|
97 | + * Enables a user |
|
98 | + * |
|
99 | + * @param string API secret key |
|
100 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
101 | + * @param string User id value |
|
102 | + */ |
|
103 | + public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
104 | + $verifKey = $this->verifyKey($secret_key); |
|
105 | + if($verifKey instanceof WSError) { |
|
106 | + $this->handleError($verifKey); |
|
107 | + } else { |
|
108 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
109 | + if($result instanceof WSError) { |
|
110 | + $this->handleError($result); |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Enables multiple users |
|
117 | - * |
|
118 | - * @param string API secret key |
|
119 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
120 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
121 | - * than 0, an error occured |
|
122 | - */ |
|
123 | - public function EnableUsers($secret_key, $users) { |
|
124 | - $verifKey = $this->verifyKey($secret_key); |
|
125 | - if($verifKey instanceof WSError) { |
|
126 | - // Let the implementation handle it |
|
127 | - $this->handleError($verifKey); |
|
128 | - } else { |
|
129 | - return $this->changeUsersActiveState($users, 1); |
|
130 | - } |
|
131 | - } |
|
115 | + /** |
|
116 | + * Enables multiple users |
|
117 | + * |
|
118 | + * @param string API secret key |
|
119 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
120 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
121 | + * than 0, an error occured |
|
122 | + */ |
|
123 | + public function EnableUsers($secret_key, $users) { |
|
124 | + $verifKey = $this->verifyKey($secret_key); |
|
125 | + if($verifKey instanceof WSError) { |
|
126 | + // Let the implementation handle it |
|
127 | + $this->handleError($verifKey); |
|
128 | + } else { |
|
129 | + return $this->changeUsersActiveState($users, 1); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Deletes a user (helper method) |
|
135 | - * |
|
136 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
137 | - * @param string User id value |
|
138 | - * @return mixed True if user was successfully deleted, WSError otherwise |
|
139 | - */ |
|
140 | - protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
141 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
142 | - if($user_id instanceof WSError) { |
|
143 | - return $user_id; |
|
144 | - } else { |
|
145 | - if(!UserManager::delete_user($user_id)) { |
|
146 | - return new WSError(101, "There was a problem while deleting this user"); |
|
147 | - } else { |
|
148 | - return true; |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
133 | + /** |
|
134 | + * Deletes a user (helper method) |
|
135 | + * |
|
136 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
137 | + * @param string User id value |
|
138 | + * @return mixed True if user was successfully deleted, WSError otherwise |
|
139 | + */ |
|
140 | + protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
141 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
142 | + if($user_id instanceof WSError) { |
|
143 | + return $user_id; |
|
144 | + } else { |
|
145 | + if(!UserManager::delete_user($user_id)) { |
|
146 | + return new WSError(101, "There was a problem while deleting this user"); |
|
147 | + } else { |
|
148 | + return true; |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Deletes a user |
|
155 | - * |
|
156 | - * @param string API secret key |
|
157 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
158 | - * @param string User id value |
|
159 | - */ |
|
160 | - public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
161 | - $verifKey = $this->verifyKey($secret_key); |
|
162 | - if($verifKey instanceof WSError) { |
|
163 | - $this->handleError($verifKey); |
|
164 | - } else { |
|
165 | - $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
166 | - if($result instanceof WSError) { |
|
167 | - $this->handleError($result); |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
153 | + /** |
|
154 | + * Deletes a user |
|
155 | + * |
|
156 | + * @param string API secret key |
|
157 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
158 | + * @param string User id value |
|
159 | + */ |
|
160 | + public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
161 | + $verifKey = $this->verifyKey($secret_key); |
|
162 | + if($verifKey instanceof WSError) { |
|
163 | + $this->handleError($verifKey); |
|
164 | + } else { |
|
165 | + $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
166 | + if($result instanceof WSError) { |
|
167 | + $this->handleError($result); |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Deletes multiple users |
|
174 | - * |
|
175 | - * @param string API secret key |
|
176 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
177 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
178 | - * than 0, an error occured |
|
179 | - */ |
|
180 | - public function DeleteUsers($secret_key, $users) { |
|
181 | - $verifKey = $this->verifyKey($secret_key); |
|
182 | - if($verifKey instanceof WSError) { |
|
183 | - $this->handleError($verifKey); |
|
184 | - } else { |
|
185 | - $results = array(); |
|
186 | - foreach($users as $user) { |
|
187 | - $result_tmp = array(); |
|
188 | - $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
189 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
190 | - if($result_op instanceof WSError) { |
|
191 | - // Return the error in the results |
|
192 | - $result_tmp['result'] = $result_op->toArray(); |
|
193 | - } else { |
|
194 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
195 | - } |
|
196 | - $results[] = $result_tmp; |
|
197 | - } |
|
198 | - return $results; |
|
199 | - } |
|
200 | - } |
|
172 | + /** |
|
173 | + * Deletes multiple users |
|
174 | + * |
|
175 | + * @param string API secret key |
|
176 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
177 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
178 | + * than 0, an error occured |
|
179 | + */ |
|
180 | + public function DeleteUsers($secret_key, $users) { |
|
181 | + $verifKey = $this->verifyKey($secret_key); |
|
182 | + if($verifKey instanceof WSError) { |
|
183 | + $this->handleError($verifKey); |
|
184 | + } else { |
|
185 | + $results = array(); |
|
186 | + foreach($users as $user) { |
|
187 | + $result_tmp = array(); |
|
188 | + $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
189 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
190 | + if($result_op instanceof WSError) { |
|
191 | + // Return the error in the results |
|
192 | + $result_tmp['result'] = $result_op->toArray(); |
|
193 | + } else { |
|
194 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
195 | + } |
|
196 | + $results[] = $result_tmp; |
|
197 | + } |
|
198 | + return $results; |
|
199 | + } |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Creates a user (helper method) |
|
204 | - * |
|
205 | - * @param string User first name |
|
206 | - * @param string User last name |
|
207 | - * @param int User status |
|
208 | - * @param string Login name |
|
209 | - * @param string Password (encrypted or not) |
|
210 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
211 | - * to include the salt in the extra fields if you are encrypting the password |
|
212 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
213 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
214 | - * @param int Visibility. |
|
215 | - * @param string User email. |
|
216 | - * @param string Language. |
|
217 | - * @param string Phone. |
|
218 | - * @param string Expiration date |
|
219 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
220 | - * @return mixed New user id generated by the system, WSError otherwise |
|
221 | - */ |
|
222 | - protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
202 | + /** |
|
203 | + * Creates a user (helper method) |
|
204 | + * |
|
205 | + * @param string User first name |
|
206 | + * @param string User last name |
|
207 | + * @param int User status |
|
208 | + * @param string Login name |
|
209 | + * @param string Password (encrypted or not) |
|
210 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
211 | + * to include the salt in the extra fields if you are encrypting the password |
|
212 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
213 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
214 | + * @param int Visibility. |
|
215 | + * @param string User email. |
|
216 | + * @param string Language. |
|
217 | + * @param string Phone. |
|
218 | + * @param string Expiration date |
|
219 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
220 | + * @return mixed New user id generated by the system, WSError otherwise |
|
221 | + */ |
|
222 | + protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
223 | 223 | |
224 | - // Add the original user id field name and value to the extra fields if needed |
|
225 | - $extras_associative = array(); |
|
226 | - if($user_id_field_name != "chamilo_user_id") { |
|
227 | - $extras_associative[$user_id_field_name] = $user_id_value; |
|
228 | - } |
|
224 | + // Add the original user id field name and value to the extra fields if needed |
|
225 | + $extras_associative = array(); |
|
226 | + if($user_id_field_name != "chamilo_user_id") { |
|
227 | + $extras_associative[$user_id_field_name] = $user_id_value; |
|
228 | + } |
|
229 | 229 | if (!empty($extras)) { |
230 | 230 | foreach($extras as $extra) { |
231 | 231 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
232 | 232 | } |
233 | 233 | } |
234 | - $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
235 | - if (!$result) { |
|
234 | + $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
235 | + if (!$result) { |
|
236 | 236 | |
237 | - return new WSError(104, 'There was an error creating the user'); |
|
237 | + return new WSError(104, 'There was an error creating the user'); |
|
238 | 238 | |
239 | - /*$failure = $api_failureList[0]; |
|
239 | + /*$failure = $api_failureList[0]; |
|
240 | 240 | if($failure == 'login-pass already taken') { |
241 | 241 | return new WSError(102, 'This username is already taken'); |
242 | 242 | } else if($failure == 'encrypt_method invalid') { |
@@ -244,227 +244,227 @@ discard block |
||
244 | 244 | } else { |
245 | 245 | return new WSError(104, 'There was an error creating the user'); |
246 | 246 | }*/ |
247 | - } else { |
|
248 | - return $result; |
|
249 | - } |
|
250 | - } |
|
247 | + } else { |
|
248 | + return $result; |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * Creates a user |
|
254 | - * |
|
255 | - * @param string API secret key |
|
256 | - * @param string User first name |
|
257 | - * @param string User last name |
|
258 | - * @param int User status |
|
259 | - * @param string Login name |
|
260 | - * @param string Password (encrypted or not) |
|
261 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
262 | - * to include the salt in the extra fields if you are encrypting the password |
|
263 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
264 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
265 | - * @param int Visibility. Set by default to 1 |
|
266 | - * @param string User email. Set by default to an empty string |
|
267 | - * @param string Language. Set by default to english |
|
268 | - * @param string Phone. Set by default to an empty string |
|
269 | - * @param string Expiration date. Set to null by default |
|
270 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
271 | - * @return int New user id generated by the system |
|
272 | - */ |
|
273 | - public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
274 | - // First, verify the secret key |
|
275 | - $verifKey = $this->verifyKey($secret_key); |
|
276 | - if($verifKey instanceof WSError) { |
|
277 | - $this->handleError($verifKey); |
|
278 | - } else { |
|
279 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
280 | - if($result instanceof WSError) { |
|
281 | - $this->handleError($result); |
|
282 | - } else { |
|
283 | - return $result; |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
252 | + /** |
|
253 | + * Creates a user |
|
254 | + * |
|
255 | + * @param string API secret key |
|
256 | + * @param string User first name |
|
257 | + * @param string User last name |
|
258 | + * @param int User status |
|
259 | + * @param string Login name |
|
260 | + * @param string Password (encrypted or not) |
|
261 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
262 | + * to include the salt in the extra fields if you are encrypting the password |
|
263 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
264 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
265 | + * @param int Visibility. Set by default to 1 |
|
266 | + * @param string User email. Set by default to an empty string |
|
267 | + * @param string Language. Set by default to english |
|
268 | + * @param string Phone. Set by default to an empty string |
|
269 | + * @param string Expiration date. Set to null by default |
|
270 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
271 | + * @return int New user id generated by the system |
|
272 | + */ |
|
273 | + public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
274 | + // First, verify the secret key |
|
275 | + $verifKey = $this->verifyKey($secret_key); |
|
276 | + if($verifKey instanceof WSError) { |
|
277 | + $this->handleError($verifKey); |
|
278 | + } else { |
|
279 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
280 | + if($result instanceof WSError) { |
|
281 | + $this->handleError($result); |
|
282 | + } else { |
|
283 | + return $result; |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
289 | - * Creates multiple users |
|
290 | - * |
|
291 | - * @param string API secret key |
|
292 | - * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
293 | - * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
294 | - */ |
|
295 | - public function CreateUsers($secret_key, $users) { |
|
296 | - $verifKey = $this->verifyKey($secret_key); |
|
297 | - if($verifKey instanceof WSError) { |
|
298 | - $this->handleError($verifKey); |
|
299 | - } else { |
|
300 | - $results = array(); |
|
301 | - foreach($users as $user) { |
|
302 | - $result_tmp = array(); |
|
288 | + /** |
|
289 | + * Creates multiple users |
|
290 | + * |
|
291 | + * @param string API secret key |
|
292 | + * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
293 | + * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
294 | + */ |
|
295 | + public function CreateUsers($secret_key, $users) { |
|
296 | + $verifKey = $this->verifyKey($secret_key); |
|
297 | + if($verifKey instanceof WSError) { |
|
298 | + $this->handleError($verifKey); |
|
299 | + } else { |
|
300 | + $results = array(); |
|
301 | + foreach($users as $user) { |
|
302 | + $result_tmp = array(); |
|
303 | 303 | // re-initialize variables just in case |
304 | 304 | $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null; |
305 | - extract($user); |
|
306 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
307 | - if($result instanceof WSError) { |
|
308 | - $result_tmp['result'] = $result->toArray(); |
|
309 | - $result_tmp['user_id_value'] = $user_id_value; |
|
310 | - $result_tmp['user_id_generated'] = 0; |
|
311 | - } else { |
|
312 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
313 | - $result_tmp['user_id_value'] = $user_id_value; |
|
314 | - $result_tmp['user_id_generated'] = $result; |
|
315 | - } |
|
316 | - $results[] = $result_tmp; |
|
317 | - } |
|
318 | - return $results; |
|
319 | - } |
|
320 | - } |
|
305 | + extract($user); |
|
306 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
307 | + if($result instanceof WSError) { |
|
308 | + $result_tmp['result'] = $result->toArray(); |
|
309 | + $result_tmp['user_id_value'] = $user_id_value; |
|
310 | + $result_tmp['user_id_generated'] = 0; |
|
311 | + } else { |
|
312 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
313 | + $result_tmp['user_id_value'] = $user_id_value; |
|
314 | + $result_tmp['user_id_generated'] = $result; |
|
315 | + } |
|
316 | + $results[] = $result_tmp; |
|
317 | + } |
|
318 | + return $results; |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | - /** |
|
323 | - * Edits user info (helper method) |
|
324 | - * |
|
325 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
326 | - * @param string User id value |
|
327 | - * @param string First name |
|
328 | - * @param string Last name |
|
329 | - * @param int User status |
|
330 | - * @param string Login name |
|
331 | - * @param string Password. Leave blank if you don't want to update it |
|
332 | - * @param string Encrypt method |
|
333 | - * @param string User email |
|
334 | - * @param string Language. Set by default to english |
|
335 | - * @param string Phone. Set by default to an empty string |
|
336 | - * @param string Expiration date. Set to null by default |
|
337 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
338 | - * @return mixed True if user was successfully updated, WSError otherwise |
|
339 | - */ |
|
340 | - protected function editUserHelper( |
|
341 | - $user_id_field_name, |
|
342 | - $user_id_value, |
|
343 | - $firstname, |
|
344 | - $lastname, |
|
345 | - $status, |
|
346 | - $loginname, |
|
347 | - $password, |
|
348 | - $encrypt_method, |
|
349 | - $email, |
|
350 | - $language, |
|
351 | - $phone, |
|
352 | - $expiration_date, |
|
353 | - $extras |
|
354 | - ) { |
|
355 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
356 | - if($user_id instanceof WSError) { |
|
357 | - return $user_id; |
|
358 | - } else { |
|
359 | - if($password == '') { |
|
360 | - $password = null; |
|
361 | - } |
|
362 | - $user_info = api_get_user_info($user_id); |
|
363 | - if (count($extras) == 0) { |
|
364 | - $extras = null; |
|
365 | - } |
|
322 | + /** |
|
323 | + * Edits user info (helper method) |
|
324 | + * |
|
325 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
326 | + * @param string User id value |
|
327 | + * @param string First name |
|
328 | + * @param string Last name |
|
329 | + * @param int User status |
|
330 | + * @param string Login name |
|
331 | + * @param string Password. Leave blank if you don't want to update it |
|
332 | + * @param string Encrypt method |
|
333 | + * @param string User email |
|
334 | + * @param string Language. Set by default to english |
|
335 | + * @param string Phone. Set by default to an empty string |
|
336 | + * @param string Expiration date. Set to null by default |
|
337 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
338 | + * @return mixed True if user was successfully updated, WSError otherwise |
|
339 | + */ |
|
340 | + protected function editUserHelper( |
|
341 | + $user_id_field_name, |
|
342 | + $user_id_value, |
|
343 | + $firstname, |
|
344 | + $lastname, |
|
345 | + $status, |
|
346 | + $loginname, |
|
347 | + $password, |
|
348 | + $encrypt_method, |
|
349 | + $email, |
|
350 | + $language, |
|
351 | + $phone, |
|
352 | + $expiration_date, |
|
353 | + $extras |
|
354 | + ) { |
|
355 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
356 | + if($user_id instanceof WSError) { |
|
357 | + return $user_id; |
|
358 | + } else { |
|
359 | + if($password == '') { |
|
360 | + $password = null; |
|
361 | + } |
|
362 | + $user_info = api_get_user_info($user_id); |
|
363 | + if (count($extras) == 0) { |
|
364 | + $extras = null; |
|
365 | + } |
|
366 | 366 | |
367 | - $result = UserManager::update_user( |
|
368 | - $user_id, |
|
369 | - $firstname, |
|
370 | - $lastname, |
|
371 | - $loginname, |
|
372 | - $password, |
|
373 | - PLATFORM_AUTH_SOURCE, |
|
374 | - $email, |
|
375 | - $status, |
|
376 | - '', |
|
377 | - $phone, |
|
378 | - $user_info['picture_uri'], |
|
379 | - $expiration_date, |
|
380 | - $user_info['active'], |
|
381 | - null, |
|
382 | - $user_info['hr_dept_id'], |
|
383 | - $extras, |
|
384 | - $encrypt_method |
|
385 | - ); |
|
386 | - if (!$result) { |
|
387 | - /*if($failure == 'encrypt_method invalid') { |
|
367 | + $result = UserManager::update_user( |
|
368 | + $user_id, |
|
369 | + $firstname, |
|
370 | + $lastname, |
|
371 | + $loginname, |
|
372 | + $password, |
|
373 | + PLATFORM_AUTH_SOURCE, |
|
374 | + $email, |
|
375 | + $status, |
|
376 | + '', |
|
377 | + $phone, |
|
378 | + $user_info['picture_uri'], |
|
379 | + $expiration_date, |
|
380 | + $user_info['active'], |
|
381 | + null, |
|
382 | + $user_info['hr_dept_id'], |
|
383 | + $extras, |
|
384 | + $encrypt_method |
|
385 | + ); |
|
386 | + if (!$result) { |
|
387 | + /*if($failure == 'encrypt_method invalid') { |
|
388 | 388 | return new WSError(103, 'The encryption of the password is invalid'); |
389 | 389 | } else { |
390 | 390 | return new WSError(105, 'There was an error updating the user'); |
391 | 391 | }*/ |
392 | - return new WSError(105, 'There was an error updating the user'); |
|
393 | - } else { |
|
394 | - return $result; |
|
395 | - } |
|
396 | - } |
|
397 | - } |
|
392 | + return new WSError(105, 'There was an error updating the user'); |
|
393 | + } else { |
|
394 | + return $result; |
|
395 | + } |
|
396 | + } |
|
397 | + } |
|
398 | 398 | |
399 | - /** |
|
400 | - * Edits user info |
|
401 | - * |
|
402 | - * @param string API secret key |
|
403 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
404 | - * @param string User id value |
|
405 | - * @param string First name |
|
406 | - * @param string Last name |
|
407 | - * @param int User status |
|
408 | - * @param string Login name |
|
409 | - * @param string Password. Leave blank if you don't want to update it |
|
410 | - * @param string Encrypt method |
|
411 | - * @param string User email |
|
412 | - * @param string Language. Set by default to english |
|
413 | - * @param string Phone. Set by default to an empty string |
|
414 | - * @param string Expiration date. Set to null by default |
|
415 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
416 | - */ |
|
417 | - public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
418 | - // First, verify the secret key |
|
419 | - $verifKey = $this->verifyKey($secret_key); |
|
420 | - if($verifKey instanceof WSError) { |
|
421 | - $this->handleError($verifKey); |
|
422 | - } else { |
|
399 | + /** |
|
400 | + * Edits user info |
|
401 | + * |
|
402 | + * @param string API secret key |
|
403 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
404 | + * @param string User id value |
|
405 | + * @param string First name |
|
406 | + * @param string Last name |
|
407 | + * @param int User status |
|
408 | + * @param string Login name |
|
409 | + * @param string Password. Leave blank if you don't want to update it |
|
410 | + * @param string Encrypt method |
|
411 | + * @param string User email |
|
412 | + * @param string Language. Set by default to english |
|
413 | + * @param string Phone. Set by default to an empty string |
|
414 | + * @param string Expiration date. Set to null by default |
|
415 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
416 | + */ |
|
417 | + public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
418 | + // First, verify the secret key |
|
419 | + $verifKey = $this->verifyKey($secret_key); |
|
420 | + if($verifKey instanceof WSError) { |
|
421 | + $this->handleError($verifKey); |
|
422 | + } else { |
|
423 | 423 | |
424 | - $extras_associative = array(); |
|
425 | - if (!empty($extras)) { |
|
426 | - foreach($extras as $extra) { |
|
427 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
428 | - } |
|
429 | - } |
|
424 | + $extras_associative = array(); |
|
425 | + if (!empty($extras)) { |
|
426 | + foreach($extras as $extra) { |
|
427 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
428 | + } |
|
429 | + } |
|
430 | 430 | |
431 | - $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
432 | - if($result instanceof WSError) { |
|
433 | - $this->handleError($result); |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
431 | + $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
432 | + if($result instanceof WSError) { |
|
433 | + $this->handleError($result); |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | 437 | |
438 | - /** |
|
439 | - * Edits multiple users |
|
440 | - * |
|
441 | - * @param string API secret key |
|
442 | - * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
443 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
444 | - * than 0, an error occured |
|
445 | - */ |
|
446 | - public function EditUsers($secret_key, $users) { |
|
447 | - $verifKey = $this->verifyKey($secret_key); |
|
448 | - if($verifKey instanceof WSError) { |
|
449 | - $this->handleError($verifKey); |
|
450 | - } else { |
|
451 | - $results = array(); |
|
452 | - foreach($users as $user) { |
|
453 | - $result_tmp = array(); |
|
438 | + /** |
|
439 | + * Edits multiple users |
|
440 | + * |
|
441 | + * @param string API secret key |
|
442 | + * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
443 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
444 | + * than 0, an error occured |
|
445 | + */ |
|
446 | + public function EditUsers($secret_key, $users) { |
|
447 | + $verifKey = $this->verifyKey($secret_key); |
|
448 | + if($verifKey instanceof WSError) { |
|
449 | + $this->handleError($verifKey); |
|
450 | + } else { |
|
451 | + $results = array(); |
|
452 | + foreach($users as $user) { |
|
453 | + $result_tmp = array(); |
|
454 | 454 | // re-initialize variables just in case |
455 | 455 | $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null; |
456 | - extract($user); |
|
457 | - $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
458 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
459 | - if($result_op instanceof WSError) { |
|
460 | - // Return the error in the results |
|
461 | - $result_tmp['result'] = $result_op->toArray(); |
|
462 | - } else { |
|
463 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
464 | - } |
|
465 | - $results[] = $result_tmp; |
|
466 | - } |
|
467 | - return $results; |
|
468 | - } |
|
469 | - } |
|
456 | + extract($user); |
|
457 | + $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
458 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
459 | + if($result_op instanceof WSError) { |
|
460 | + // Return the error in the results |
|
461 | + $result_tmp['result'] = $result_op->toArray(); |
|
462 | + } else { |
|
463 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
464 | + } |
|
465 | + $results[] = $result_tmp; |
|
466 | + } |
|
467 | + return $results; |
|
468 | + } |
|
469 | + } |
|
470 | 470 | } |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | $is_certificate_mode = false; |
62 | 62 | |
63 | 63 | if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { |
64 | - $is_certificate_mode = true; |
|
64 | + $is_certificate_mode = true; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($is_certificate_mode) { |
68 | - $nameTools = get_lang('CreateCertificate'); |
|
68 | + $nameTools = get_lang('CreateCertificate'); |
|
69 | 69 | } else { |
70 | - $nameTools = get_lang('CreateDocument'); |
|
70 | + $nameTools = get_lang('CreateDocument'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /* Constants and variables */ |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | |
120 | 120 | // Please, do not modify this dirname formatting |
121 | 121 | if (strstr($dir, '..')) { |
122 | - $dir = '/'; |
|
122 | + $dir = '/'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($dir[0] == '.') { |
126 | - $dir = substr($dir, 1); |
|
126 | + $dir = substr($dir, 1); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | if ($dir[0] != '/') { |
130 | - $dir = '/'.$dir; |
|
130 | + $dir = '/'.$dir; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | if ($dir[strlen($dir) - 1] != '/') { |
134 | - $dir .= '/'; |
|
134 | + $dir .= '/'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | if ($is_certificate_mode) { |
138 | - $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
139 | - $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
140 | - $folder_id = $document_data['id']; |
|
141 | - $dir = '/certificates/'; |
|
138 | + $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
139 | + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
140 | + $folder_id = $document_data['id']; |
|
141 | + $dir = '/certificates/'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $doc_tree = explode('/', $dir); |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | |
150 | 150 | // Level correction for group documents. |
151 | 151 | if (!empty($group_properties['directory'])) { |
152 | - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
152 | + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | $relative_url = ''; |
156 | 156 | for ($i = 0; $i < ($count_dir); $i++) { |
157 | - $relative_url .= '../'; |
|
157 | + $relative_url .= '../'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | if ($relative_url== '') { |
161 | - $relative_url = '/'; |
|
161 | + $relative_url = '/'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | 'cols-size' => [2, 10, 0], |
171 | 171 | 'FullPage' => true, |
172 | 172 | 'InDocument' => true, |
173 | - 'CreateDocumentDir' => $relative_url, |
|
174 | - 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
175 | - ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
176 | - : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
177 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
173 | + 'CreateDocumentDir' => $relative_url, |
|
174 | + 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
175 | + ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
176 | + : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
177 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
178 | 178 | ); |
179 | 179 | |
180 | 180 | if ($is_certificate_mode) { |
@@ -186,42 +186,42 @@ discard block |
||
186 | 186 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
187 | 187 | |
188 | 188 | if (!is_dir($filepath)) { |
189 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
190 | - $dir = '/'; |
|
189 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
190 | + $dir = '/'; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $to_group_id = 0; |
194 | 194 | |
195 | 195 | if (!$is_certificate_mode) { |
196 | - if (api_is_in_group()) { |
|
196 | + if (api_is_in_group()) { |
|
197 | 197 | $interbreadcrumb[] = array( |
198 | 198 | "url" => "../group/group_space.php?".api_get_cidreq(), |
199 | 199 | "name" => get_lang('GroupSpace'), |
200 | 200 | ); |
201 | - $noPHP_SELF = true; |
|
202 | - $to_group_id = api_get_group_id(); |
|
203 | - $path = explode('/', $dir); |
|
204 | - if ('/'.$path[1] != $group_properties['directory']) { |
|
205 | - api_not_allowed(true); |
|
206 | - } |
|
207 | - } |
|
201 | + $noPHP_SELF = true; |
|
202 | + $to_group_id = api_get_group_id(); |
|
203 | + $path = explode('/', $dir); |
|
204 | + if ('/'.$path[1] != $group_properties['directory']) { |
|
205 | + api_not_allowed(true); |
|
206 | + } |
|
207 | + } |
|
208 | 208 | $interbreadcrumb[] = array( |
209 | 209 | "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), |
210 | 210 | "name" => get_lang('Documents'), |
211 | 211 | ); |
212 | 212 | } else { |
213 | - $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
213 | + $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | if (!$is_allowed_in_course) { |
217 | - api_not_allowed(true); |
|
217 | + api_not_allowed(true); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | if (!($is_allowed_to_edit || |
221 | 221 | $groupRights || |
222 | 222 | DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id())) |
223 | 223 | ) { |
224 | - api_not_allowed(true); |
|
224 | + api_not_allowed(true); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /* Header */ |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | |
230 | 230 | $display_dir = $dir; |
231 | 231 | if (isset($group_properties)) { |
232 | - $display_dir = explode('/', $dir); |
|
233 | - unset($display_dir[0]); |
|
234 | - unset($display_dir[1]); |
|
235 | - $display_dir = implode('/', $display_dir); |
|
232 | + $display_dir = explode('/', $dir); |
|
233 | + unset($display_dir[0]); |
|
234 | + unset($display_dir[1]); |
|
235 | + $display_dir = implode('/', $display_dir); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null; |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | $form->addElement('header', $nameTools); |
250 | 250 | |
251 | 251 | if ($is_certificate_mode) {//added condition for certicate in gradebook |
252 | - $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
253 | - if (isset($_GET['selectcat'])) { |
|
254 | - $form->addElement('hidden','selectcat', $select_cat); |
|
252 | + $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
253 | + if (isset($_GET['selectcat'])) { |
|
254 | + $form->addElement('hidden','selectcat', $select_cat); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | // new document created |
307 | 307 | |
308 | 308 | if (!$is_certificate_mode && |
309 | - !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
309 | + !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
310 | 310 | ) { |
311 | - $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); |
|
311 | + $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); |
|
312 | 312 | |
313 | - //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); |
|
313 | + //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); |
|
314 | 314 | $parent_select = $form->addSelect('curdirpath', get_lang('DestinationDirectory'),null, array('cols-size' => [2, 10, 0]) ); |
315 | - // Following two conditions copied from document.inc.php::build_directory_selector() |
|
316 | - $folder_titles = array(); |
|
315 | + // Following two conditions copied from document.inc.php::build_directory_selector() |
|
316 | + $folder_titles = array(); |
|
317 | 317 | |
318 | 318 | if (is_array($folders)) { |
319 | 319 | $escaped_folders = array(); |
@@ -351,22 +351,22 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - if (empty($group_dir)) { |
|
355 | - $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
356 | - if (is_array($folders)) { |
|
357 | - foreach ($folders as & $folder) { |
|
358 | - //Hide some folders |
|
359 | - if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
354 | + if (empty($group_dir)) { |
|
355 | + $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
356 | + if (is_array($folders)) { |
|
357 | + foreach ($folders as & $folder) { |
|
358 | + //Hide some folders |
|
359 | + if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
360 | 360 | continue; |
361 | - } |
|
362 | - //Admin setting for Hide/Show the folders of all users |
|
363 | - if (api_get_setting('show_users_folders') == 'false' && |
|
361 | + } |
|
362 | + //Admin setting for Hide/Show the folders of all users |
|
363 | + if (api_get_setting('show_users_folders') == 'false' && |
|
364 | 364 | (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_')) |
365 | 365 | ){ |
366 | - continue; |
|
367 | - } |
|
368 | - //Admin setting for Hide/Show Default folders to all users |
|
369 | - if (api_get_setting('show_default_folders') == 'false' && |
|
366 | + continue; |
|
367 | + } |
|
368 | + //Admin setting for Hide/Show Default folders to all users |
|
369 | + if (api_get_setting('show_default_folders') == 'false' && |
|
370 | 370 | ( |
371 | 371 | $folder == '/images' || |
372 | 372 | $folder == '/flash' || |
@@ -376,82 +376,82 @@ discard block |
||
376 | 376 | $folder == '/video/flv' |
377 | 377 | ) |
378 | 378 | ){ |
379 | - continue; |
|
380 | - } |
|
381 | - //Admin setting for Hide/Show chat history folder |
|
382 | - if (api_get_setting('show_chat_folder') == 'false' && |
|
379 | + continue; |
|
380 | + } |
|
381 | + //Admin setting for Hide/Show chat history folder |
|
382 | + if (api_get_setting('show_chat_folder') == 'false' && |
|
383 | 383 | $folder=='/chat_files' |
384 | 384 | ){ |
385 | - continue; |
|
386 | - } |
|
385 | + continue; |
|
386 | + } |
|
387 | 387 | |
388 | - $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
389 | - $path_parts = explode('/', $folder); |
|
390 | - $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
388 | + $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
389 | + $path_parts = explode('/', $folder); |
|
390 | + $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
391 | 391 | $space_counter =count($path_parts) - 2; |
392 | 392 | if ($space_counter > 0) { |
393 | 393 | $label = str_repeat(' ', $space_counter).' — '.$folder_titles[$folder]; |
394 | 394 | } else { |
395 | 395 | $label = ' — '.$folder_titles[$folder]; |
396 | 396 | } |
397 | - $parent_select -> addOption($label, $folder); |
|
398 | - if ($selected != '') { |
|
399 | - $parent_select->setSelected($folder); |
|
400 | - } |
|
401 | - } |
|
402 | - } |
|
403 | - } else { |
|
404 | - if (is_array($folders) && !empty($folders)) { |
|
405 | - foreach ($folders as & $folder) { |
|
406 | - $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
407 | - $label = $folder_titles[$folder]; |
|
408 | - if ($folder == $group_dir) { |
|
409 | - $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
410 | - } else { |
|
411 | - $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
412 | - $label = cut($label, 80); |
|
413 | - $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
414 | - } |
|
415 | - $parent_select->addOption($label, $folder); |
|
416 | - if ($selected != '') { |
|
417 | - $parent_select->setSelected($folder); |
|
418 | - } |
|
419 | - } |
|
420 | - } |
|
421 | - } |
|
397 | + $parent_select -> addOption($label, $folder); |
|
398 | + if ($selected != '') { |
|
399 | + $parent_select->setSelected($folder); |
|
400 | + } |
|
401 | + } |
|
402 | + } |
|
403 | + } else { |
|
404 | + if (is_array($folders) && !empty($folders)) { |
|
405 | + foreach ($folders as & $folder) { |
|
406 | + $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
407 | + $label = $folder_titles[$folder]; |
|
408 | + if ($folder == $group_dir) { |
|
409 | + $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
410 | + } else { |
|
411 | + $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
412 | + $label = cut($label, 80); |
|
413 | + $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
414 | + } |
|
415 | + $parent_select->addOption($label, $folder); |
|
416 | + if ($selected != '') { |
|
417 | + $parent_select->setSelected($folder); |
|
418 | + } |
|
419 | + } |
|
420 | + } |
|
421 | + } |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $form->addHidden('dirValue', ''); |
425 | 425 | |
426 | 426 | if ($is_certificate_mode) { |
427 | - $form->addButtonCreate(get_lang('CreateCertificate')); |
|
427 | + $form->addButtonCreate(get_lang('CreateCertificate')); |
|
428 | 428 | } else { |
429 | - $form->addButtonCreate(get_lang('CreateDoc')); |
|
429 | + $form->addButtonCreate(get_lang('CreateDoc')); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $form->setDefaults($defaults); |
433 | 433 | |
434 | 434 | // If form validates -> save the new document |
435 | 435 | if ($form->validate()) { |
436 | - $values = $form->exportValues(); |
|
437 | - $readonly = isset($values['readonly']) ? 1 : 0; |
|
438 | - $values['title'] = trim($values['title']); |
|
436 | + $values = $form->exportValues(); |
|
437 | + $readonly = isset($values['readonly']) ? 1 : 0; |
|
438 | + $values['title'] = trim($values['title']); |
|
439 | 439 | |
440 | 440 | if (!empty($values['dirValue'])) { |
441 | 441 | $dir = $values['dirValue']; |
442 | 442 | } |
443 | 443 | |
444 | 444 | if ($dir[strlen($dir) - 1] != '/') { |
445 | - $dir .= '/'; |
|
446 | - } |
|
445 | + $dir .= '/'; |
|
446 | + } |
|
447 | 447 | $filepath = $filepath.$dir; |
448 | 448 | |
449 | 449 | // Setting the filename |
450 | - $filename = $values['title']; |
|
451 | - $filename = addslashes(trim($filename)); |
|
452 | - $filename = Security::remove_XSS($filename); |
|
453 | - $filename = api_replace_dangerous_char($filename); |
|
454 | - $filename = disable_dangerous_file($filename); |
|
450 | + $filename = $values['title']; |
|
451 | + $filename = addslashes(trim($filename)); |
|
452 | + $filename = Security::remove_XSS($filename); |
|
453 | + $filename = api_replace_dangerous_char($filename); |
|
454 | + $filename = disable_dangerous_file($filename); |
|
455 | 455 | $filename .= DocumentManager::getDocumentSuffix( |
456 | 456 | $_course, |
457 | 457 | api_get_session_id(), |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | ); |
460 | 460 | |
461 | 461 | // Setting the title |
462 | - $title = $values['title']; |
|
462 | + $title = $values['title']; |
|
463 | 463 | |
464 | 464 | // Setting the extension |
465 | - $extension = 'html'; |
|
465 | + $extension = 'html'; |
|
466 | 466 | |
467 | - $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
467 | + $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
468 | 468 | |
469 | - /*if (strpos($content, '/css/frames.css') == false) { |
|
469 | + /*if (strpos($content, '/css/frames.css') == false) { |
|
470 | 470 | $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content); |
471 | 471 | }*/ |
472 | 472 | |
@@ -479,13 +479,13 @@ discard block |
||
479 | 479 | exit; |
480 | 480 | } |
481 | 481 | |
482 | - if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
483 | - //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); |
|
484 | - $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content); |
|
482 | + if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
483 | + //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); |
|
484 | + $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content); |
|
485 | 485 | |
486 | - fputs($fp, $content); |
|
487 | - fclose($fp); |
|
488 | - chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
486 | + fputs($fp, $content); |
|
487 | + fclose($fp); |
|
488 | + chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
489 | 489 | |
490 | 490 | /* |
491 | 491 | if (!is_dir($filepath.'css')) { |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, null, null, null, null, $current_session_id); |
504 | 504 | }*/ |
505 | 505 | |
506 | - $file_size = filesize($filepath.$filename.'.'.$extension); |
|
507 | - $save_file_path = $dir.$filename.'.'.$extension; |
|
506 | + $file_size = filesize($filepath.$filename.'.'.$extension); |
|
507 | + $save_file_path = $dir.$filename.'.'.$extension; |
|
508 | 508 | |
509 | 509 | $document_id = add_document( |
510 | 510 | $_course, |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | $readonly |
517 | 517 | ); |
518 | 518 | |
519 | - if ($document_id) { |
|
520 | - api_item_property_update( |
|
519 | + if ($document_id) { |
|
520 | + api_item_property_update( |
|
521 | 521 | $_course, |
522 | 522 | TOOL_DOCUMENT, |
523 | 523 | $document_id, |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | null, |
530 | 530 | $current_session_id |
531 | 531 | ); |
532 | - // Update parent folders |
|
533 | - item_property_update_on_folder($_course, $dir, $userId); |
|
534 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
535 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
532 | + // Update parent folders |
|
533 | + item_property_update_on_folder($_course, $dir, $userId); |
|
534 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
535 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
536 | 536 | $new_title = htmlspecialchars($new_title); |
537 | - if ($new_comment || $new_title) { |
|
538 | - $ct = ''; |
|
537 | + if ($new_comment || $new_title) { |
|
538 | + $ct = ''; |
|
539 | 539 | $params = []; |
540 | 540 | if ($new_comment) { |
541 | 541 | $params['comment'] = $new_comment; |
@@ -550,39 +550,39 @@ discard block |
||
550 | 550 | ['c_id = ? AND id = ?' => [$course_id, $document_id]] |
551 | 551 | ); |
552 | 552 | } |
553 | - } |
|
554 | - $dir= substr($dir,0,-1); |
|
555 | - $selectcat = ''; |
|
553 | + } |
|
554 | + $dir= substr($dir,0,-1); |
|
555 | + $selectcat = ''; |
|
556 | 556 | if (isset($_REQUEST['selectcat'])) { |
557 | 557 | $selectcat = "&selectcat=".intval($_REQUEST['selectcat']); |
558 | 558 | } |
559 | - $certificate_condition = ''; |
|
560 | - if ($is_certificate_mode) { |
|
561 | - $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
559 | + $certificate_condition = ''; |
|
560 | + if ($is_certificate_mode) { |
|
561 | + $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
562 | 562 | if (!isset($df)) { |
563 | 563 | DocumentManager::attach_gradebook_certificate($_course['code'],$document_id); |
564 | - } |
|
565 | - $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
566 | - } |
|
564 | + } |
|
565 | + $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
566 | + } |
|
567 | 567 | Display::addFlash(Display::return_message(get_lang('ItemAdded'))); |
568 | - header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
569 | - exit(); |
|
570 | - } else { |
|
571 | - Display :: display_header($nameTools, 'Doc'); |
|
572 | - Display :: display_error_message(get_lang('Impossible')); |
|
573 | - Display :: display_footer(); |
|
574 | - } |
|
575 | - } else { |
|
576 | - Display :: display_header($nameTools, 'Doc'); |
|
577 | - Display :: display_error_message(get_lang('Impossible')); |
|
578 | - Display :: display_footer(); |
|
579 | - } |
|
568 | + header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
569 | + exit(); |
|
570 | + } else { |
|
571 | + Display :: display_header($nameTools, 'Doc'); |
|
572 | + Display :: display_error_message(get_lang('Impossible')); |
|
573 | + Display :: display_footer(); |
|
574 | + } |
|
575 | + } else { |
|
576 | + Display :: display_header($nameTools, 'Doc'); |
|
577 | + Display :: display_error_message(get_lang('Impossible')); |
|
578 | + Display :: display_footer(); |
|
579 | + } |
|
580 | 580 | } else { |
581 | - // Copied from document.php |
|
582 | - $dir_array = explode('/', $dir); |
|
583 | - $array_len = count($dir_array); |
|
581 | + // Copied from document.php |
|
582 | + $dir_array = explode('/', $dir); |
|
583 | + $array_len = count($dir_array); |
|
584 | 584 | |
585 | - // Breadcrumb for the current directory root path |
|
585 | + // Breadcrumb for the current directory root path |
|
586 | 586 | if (!empty($document_data)) { |
587 | 587 | if (empty($document_data['parents'])) { |
588 | 588 | $interbreadcrumb[] = array( |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | - Display :: display_header($nameTools, "Doc"); |
|
603 | - // actions |
|
602 | + Display :: display_header($nameTools, "Doc"); |
|
603 | + // actions |
|
604 | 604 | |
605 | - // link back to the documents overview |
|
606 | - if ($is_certificate_mode) { |
|
605 | + // link back to the documents overview |
|
606 | + if ($is_certificate_mode) { |
|
607 | 607 | $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'. |
608 | 608 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
609 | 609 | $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'. |
@@ -618,19 +618,19 @@ discard block |
||
618 | 618 | |
619 | 619 | echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft)); |
620 | 620 | |
621 | - if ($is_certificate_mode) { |
|
621 | + if ($is_certificate_mode) { |
|
622 | 622 | $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate( |
623 | 623 | api_get_user_id(), |
624 | 624 | api_get_course_id() |
625 | 625 | ); |
626 | 626 | |
627 | - $str_info = ''; |
|
628 | - foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
629 | - $str_info.=$info_value.'<br/>'; |
|
630 | - } |
|
631 | - $create_certificate = get_lang('CreateCertificateWithTags'); |
|
632 | - Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
633 | - } |
|
627 | + $str_info = ''; |
|
628 | + foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
629 | + $str_info.=$info_value.'<br/>'; |
|
630 | + } |
|
631 | + $create_certificate = get_lang('CreateCertificateWithTags'); |
|
632 | + Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
633 | + } |
|
634 | 634 | |
635 | 635 | // HTML-editor |
636 | 636 | echo '<div class="page-create"> |
@@ -646,5 +646,5 @@ discard block |
||
646 | 646 | '.$form->returnForm().' |
647 | 647 | </div> |
648 | 648 | </div></div>'; |
649 | - Display :: display_footer(); |
|
649 | + Display :: display_footer(); |
|
650 | 650 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if ($add_type == 'multiple') { |
123 | - $link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'. |
|
123 | + $link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'. |
|
124 | 124 | get_lang('SessionAddTypeUnique').'</a>'; |
125 | - $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
|
125 | + $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
|
126 | 126 | } else { |
127 | - $link_add_type_unique = get_lang('SessionAddTypeUnique'); |
|
128 | - $link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'. |
|
127 | + $link_add_type_unique = get_lang('SessionAddTypeUnique'); |
|
128 | + $link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'. |
|
129 | 129 | get_lang('SessionAddTypeMultiple').'</a>'; |
130 | 130 | } |
131 | 131 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | <td colspan="3" align="center"> |
224 | 224 | <br /> |
225 | 225 | <?php |
226 | - if(isset($_GET['add'])) |
|
227 | - echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>'; |
|
228 | - else |
|
229 | - echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>'; |
|
230 | - ?> |
|
226 | + if(isset($_GET['add'])) |
|
227 | + echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>'; |
|
228 | + else |
|
229 | + echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>'; |
|
230 | + ?> |
|
231 | 231 | </td> |
232 | 232 | </tr> |
233 | 233 | </table> |