@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | while (($file = readdir($handle)) !== false) { |
24 | 24 | if ($file != "." && $file != ".." && |
25 | 25 | strpos($file, 'CourseArchiver_') === 0 && |
26 | - is_dir($dir . '/' . $file) |
|
26 | + is_dir($dir.'/'.$file) |
|
27 | 27 | ) { |
28 | - rmdirr($dir . '/' . $file); |
|
28 | + rmdirr($dir.'/'.$file); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | closedir($handle); |
@@ -43,48 +43,48 @@ discard block |
||
43 | 43 | CourseArchiver::clean_backup_dir(); |
44 | 44 | |
45 | 45 | // Create a temp directory |
46 | - $tmp_dir_name = 'CourseArchiver_' . api_get_unique_id(); |
|
47 | - $backup_dir = api_get_path(SYS_ARCHIVE_PATH) . $tmp_dir_name . '/'; |
|
46 | + $tmp_dir_name = 'CourseArchiver_'.api_get_unique_id(); |
|
47 | + $backup_dir = api_get_path(SYS_ARCHIVE_PATH).$tmp_dir_name.'/'; |
|
48 | 48 | |
49 | 49 | // All course-information will be stored in course_info.dat |
50 | - $course_info_file = $backup_dir . 'course_info.dat'; |
|
50 | + $course_info_file = $backup_dir.'course_info.dat'; |
|
51 | 51 | $zip_dir = api_get_path(SYS_ARCHIVE_PATH); |
52 | 52 | $user = api_get_user_info(); |
53 | 53 | $date = new \DateTime(api_get_local_time()); |
54 | - $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip'; |
|
54 | + $zip_file = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip'; |
|
55 | 55 | $php_errormsg = ''; |
56 | 56 | $res = @mkdir($backup_dir, $perm_dirs); |
57 | 57 | if ($res === false) { |
58 | 58 | //TODO set and handle an error message telling the user to review the permissions on the archive directory |
59 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini') . ' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
59 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
60 | 60 | } |
61 | 61 | // Write the course-object to the file |
62 | 62 | $fp = @fopen($course_info_file, 'w'); |
63 | 63 | if ($fp === false) { |
64 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
64 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $res = @fwrite($fp, base64_encode(serialize($course))); |
68 | 68 | if ($res === false) { |
69 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
69 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $res = @fclose($fp); |
73 | 73 | if ($res === false) { |
74 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
74 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Copy all documents to the temp-dir |
78 | 78 | if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) { |
79 | 79 | foreach ($course->resources[RESOURCE_DOCUMENT] as $document) { |
80 | 80 | if ($document->file_type == DOCUMENT) { |
81 | - $doc_dir = $backup_dir . $document->path; |
|
81 | + $doc_dir = $backup_dir.$document->path; |
|
82 | 82 | @mkdir(dirname($doc_dir), $perm_dirs, true); |
83 | - if (file_exists($course->path . $document->path)) { |
|
84 | - copy($course->path . $document->path, $doc_dir); |
|
83 | + if (file_exists($course->path.$document->path)) { |
|
84 | + copy($course->path.$document->path, $doc_dir); |
|
85 | 85 | } |
86 | 86 | } else { |
87 | - @mkdir($backup_dir . $document->path, $perm_dirs, true); |
|
87 | + @mkdir($backup_dir.$document->path, $perm_dirs, true); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -92,49 +92,49 @@ discard block |
||
92 | 92 | // Copy all scorm documents to the temp-dir |
93 | 93 | if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) { |
94 | 94 | foreach ($course->resources[RESOURCE_SCORM] as $document) { |
95 | - $doc_dir = dirname($backup_dir . $document->path); |
|
95 | + $doc_dir = dirname($backup_dir.$document->path); |
|
96 | 96 | @mkdir($doc_dir, $perm_dirs, true); |
97 | - copyDirTo($course->path . $document->path, $doc_dir, false); |
|
97 | + copyDirTo($course->path.$document->path, $doc_dir, false); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Copy calendar attachments. |
102 | 102 | |
103 | 103 | if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) { |
104 | - $doc_dir = dirname($backup_dir . '/upload/calendar/'); |
|
104 | + $doc_dir = dirname($backup_dir.'/upload/calendar/'); |
|
105 | 105 | @mkdir($doc_dir, $perm_dirs, true); |
106 | - copyDirTo($course->path . 'upload/calendar/', $doc_dir, false); |
|
106 | + copyDirTo($course->path.'upload/calendar/', $doc_dir, false); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Copy Learning path author image. |
110 | 110 | if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) { |
111 | - $doc_dir = dirname($backup_dir . '/upload/learning_path/'); |
|
111 | + $doc_dir = dirname($backup_dir.'/upload/learning_path/'); |
|
112 | 112 | @mkdir($doc_dir, $perm_dirs, true); |
113 | - copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false); |
|
113 | + copyDirTo($course->path.'upload/learning_path/', $doc_dir, false); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Copy announcements attachments. |
117 | 117 | if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) { |
118 | - $doc_dir = dirname($backup_dir . '/upload/announcements/'); |
|
118 | + $doc_dir = dirname($backup_dir.'/upload/announcements/'); |
|
119 | 119 | @mkdir($doc_dir, $perm_dirs, true); |
120 | - copyDirTo($course->path . 'upload/announcements/', $doc_dir, false); |
|
120 | + copyDirTo($course->path.'upload/announcements/', $doc_dir, false); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Copy work folders (only folders) |
124 | 124 | if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) { |
125 | - $doc_dir = dirname($backup_dir . '/upload/work/'); |
|
125 | + $doc_dir = dirname($backup_dir.'/upload/work/'); |
|
126 | 126 | @mkdir($doc_dir, $perm_dirs, true); |
127 | 127 | // @todo: adjust to only create subdirs, but not copy files |
128 | - copyDirTo($course->path . 'upload/work/', $doc_dir, false); |
|
128 | + copyDirTo($course->path.'upload/work/', $doc_dir, false); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Zip the course-contents |
132 | - $zip = new \PclZip($zip_dir . $zip_file); |
|
133 | - $zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/'); |
|
132 | + $zip = new \PclZip($zip_dir.$zip_file); |
|
133 | + $zip->create($zip_dir.$tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir.$tmp_dir_name.'/'); |
|
134 | 134 | //$zip->deleteByIndex(0); |
135 | 135 | // Remove the temp-dir. |
136 | 136 | rmdirr($backup_dir); |
137 | - return '' . $zip_file; |
|
137 | + return ''.$zip_file; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public static function get_available_backups($user_id = null) |
145 | 145 | { |
146 | 146 | $backup_files = array(); |
147 | - $dirname = api_get_path(SYS_ARCHIVE_PATH) . ''; |
|
147 | + $dirname = api_get_path(SYS_ARCHIVE_PATH).''; |
|
148 | 148 | if ($dir = opendir($dirname)) { |
149 | 149 | while (($file = readdir($dir)) !== false) { |
150 | 150 | $file_parts = explode('_', $file); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $date = $file_parts[0]; |
156 | 156 | $ext = isset($file_parts[1]) ? $file_parts[1] : null; |
157 | 157 | if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) { |
158 | - $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2); |
|
158 | + $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6, 2).' '.substr($date, 9, 2).':'.substr($date, 11, 2).':'.substr($date, 13, 2); |
|
159 | 159 | $backup_files[] = array( |
160 | 160 | 'file' => $file, |
161 | 161 | 'date' => $date, |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function import_uploaded_file($file) |
178 | 178 | { |
179 | - $new_filename = uniqid('') . '.zip'; |
|
179 | + $new_filename = uniqid('').'.zip'; |
|
180 | 180 | $new_dir = api_get_path(SYS_ARCHIVE_PATH); |
181 | 181 | if (is_dir($new_dir) && is_writable($new_dir)) { |
182 | 182 | move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename); |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | { |
200 | 200 | CourseArchiver::clean_backup_dir(); |
201 | 201 | // Create a temp directory |
202 | - $tmp_dir_name = 'CourseArchiver_' . uniqid(''); |
|
203 | - $unzip_dir = api_get_path(SYS_ARCHIVE_PATH) . '' . $tmp_dir_name; |
|
202 | + $tmp_dir_name = 'CourseArchiver_'.uniqid(''); |
|
203 | + $unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name; |
|
204 | 204 | @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true); |
205 | - @copy(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename, $unzip_dir . '/backup.zip'); |
|
205 | + @copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename, $unzip_dir.'/backup.zip'); |
|
206 | 206 | // unzip the archive |
207 | - $zip = new \PclZip($unzip_dir . '/backup.zip'); |
|
207 | + $zip = new \PclZip($unzip_dir.'/backup.zip'); |
|
208 | 208 | @chdir($unzip_dir); |
209 | 209 | $zip->extract(PCLZIP_OPT_TEMP_FILE_ON); |
210 | 210 | // remove the archive-file |
211 | 211 | if ($delete) { |
212 | - @unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename); |
|
212 | + @unlink(api_get_path(SYS_ARCHIVE_PATH).''.$filename); |
|
213 | 213 | } |
214 | 214 | // read the course |
215 | 215 | if (!is_file('course_info.dat')) { |
@@ -22,9 +22,9 @@ |
||
22 | 22 | * @param string $description |
23 | 23 | * @param int $display_order |
24 | 24 | */ |
25 | - public function __construct($id,$name,$description,$display_order) |
|
25 | + public function __construct($id, $name, $description, $display_order) |
|
26 | 26 | { |
27 | - parent::__construct($id,RESOURCE_GLOSSARY); |
|
27 | + parent::__construct($id, RESOURCE_GLOSSARY); |
|
28 | 28 | $this->glossary_id = $id; |
29 | 29 | $this->name = $name; |
30 | 30 | $this->description = $description; |
@@ -25,6 +25,6 @@ |
||
25 | 25 | public function show() |
26 | 26 | { |
27 | 27 | parent::show(); |
28 | - echo $this->obj->title . ' (' . $this->obj->poster_name . ', ' . $this->obj->post_date . ')'; |
|
28 | + echo $this->obj->title.' ('.$this->obj->poster_name.', '.$this->obj->post_date.')'; |
|
29 | 29 | } |
30 | 30 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @param int $id |
19 | 19 | * @param string $title |
20 | 20 | */ |
21 | - public function __construct($id,$title) |
|
21 | + public function __construct($id, $title) |
|
22 | 22 | { |
23 | 23 | parent::__construct($id, RESOURCE_SESSION_COURSE); |
24 | 24 | $this->title = $title; |
@@ -153,18 +153,18 @@ |
||
153 | 153 | $this->js_lib = $js_lib; |
154 | 154 | $this->content_license = $content_license; |
155 | 155 | $this->debug = $debug; |
156 | - $this->visibility=$visibility; |
|
156 | + $this->visibility = $visibility; |
|
157 | 157 | |
158 | - $this->use_max_score=$use_max_score; |
|
159 | - $this->autolaunch=$autolaunch; |
|
160 | - $this->created_on=$created_on; |
|
161 | - $this->modified_on=$modified_on; |
|
162 | - $this->publicated_on=$publicated_on; |
|
163 | - $this->expired_on=$expired_on; |
|
164 | - $this->session_id=$session_id; |
|
158 | + $this->use_max_score = $use_max_score; |
|
159 | + $this->autolaunch = $autolaunch; |
|
160 | + $this->created_on = $created_on; |
|
161 | + $this->modified_on = $modified_on; |
|
162 | + $this->publicated_on = $publicated_on; |
|
163 | + $this->expired_on = $expired_on; |
|
164 | + $this->session_id = $session_id; |
|
165 | 165 | |
166 | - $this->author= $author; |
|
167 | - $this->preview_image= $preview_image; |
|
166 | + $this->author = $author; |
|
167 | + $this->preview_image = $preview_image; |
|
168 | 168 | |
169 | 169 | $this->items = $items; |
170 | 170 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $category_id, |
47 | 47 | $on_homepage |
48 | 48 | ) { |
49 | - parent::__construct($id,RESOURCE_LINK); |
|
49 | + parent::__construct($id, RESOURCE_LINK); |
|
50 | 50 | $this->title = $title; |
51 | 51 | $this->url = $url; |
52 | 52 | $this->description = $description; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function __construct($id, $path, $comment, $title, $file_type, $size) |
29 | 29 | { |
30 | 30 | parent::__construct($id, RESOURCE_DOCUMENT); |
31 | - $this->path = 'document' . $path; |
|
31 | + $this->path = 'document'.$path; |
|
32 | 32 | $this->comment = $comment; |
33 | 33 | $this->title = $title; |
34 | 34 | $this->file_type = $file_type; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | echo preg_replace('@^document@', '', $this->path); |
45 | 45 | if (!empty($this->title)) { |
46 | 46 | if (strpos($this->path, $this->title) === false) { |
47 | - echo " - " . $this->title; |
|
47 | + echo " - ".$this->title; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -59,13 +59,13 @@ |
||
59 | 59 | $size, |
60 | 60 | $comment |
61 | 61 | ) { |
62 | - parent::__construct($id,RESOURCE_ANNOUNCEMENT); |
|
62 | + parent::__construct($id, RESOURCE_ANNOUNCEMENT); |
|
63 | 63 | |
64 | - $this->content = $content; |
|
65 | - $this->title = $title; |
|
66 | - $this->date = $date; |
|
67 | - $this->display_order = $display_order; |
|
68 | - $this->email_sent = $email_sent; |
|
64 | + $this->content = $content; |
|
65 | + $this->title = $title; |
|
66 | + $this->date = $date; |
|
67 | + $this->display_order = $display_order; |
|
68 | + $this->email_sent = $email_sent; |
|
69 | 69 | |
70 | 70 | $this->attachment_path = $path; |
71 | 71 | $this->attachment_filename = $filename; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $progress, |
48 | 48 | $version |
49 | 49 | ) { |
50 | - parent::__construct($id,RESOURCE_WIKI); |
|
50 | + parent::__construct($id, RESOURCE_WIKI); |
|
51 | 51 | $this->id = $id; |
52 | 52 | $this->page_id = $page_id; |
53 | 53 | $this->reflink = $reflink; |
@@ -63,6 +63,6 @@ discard block |
||
63 | 63 | public function show() |
64 | 64 | { |
65 | 65 | parent::show(); |
66 | - echo $this->reflink.' ('. (empty($this->group_id) ? get_lang('Everyone') : get_lang('Group') . ' ' . $this->group_id) .') ' . '<i>(' . $this->dtime . ')</i>'; |
|
66 | + echo $this->reflink.' ('.(empty($this->group_id) ? get_lang('Everyone') : get_lang('Group').' '.$this->group_id).') '.'<i>('.$this->dtime.')</i>'; |
|
67 | 67 | } |
68 | 68 | } |