Completed
Push — 1.11.x ( d84d27...922b6f )
by José
30:17
created
main/badge/issued_all.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
14 14
 
15 15
 if (!$userId || !$skillId) {
16
-    header('Location: ' . api_get_path(WEB_PATH));
16
+    header('Location: '.api_get_path(WEB_PATH));
17 17
     exit;
18 18
 }
19 19
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         Display::return_message(get_lang('NoResults'), 'error')
32 32
     );
33 33
 
34
-    header('Location: ' . api_get_path(WEB_PATH));
34
+    header('Location: '.api_get_path(WEB_PATH));
35 35
     exit;
36 36
 }
37 37
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $entityManager->persist($skillIssue);
168 168
         $entityManager->flush();
169 169
 
170
-        header("Location: " . $skillIssue->getIssueUrlAll());
170
+        header("Location: ".$skillIssue->getIssueUrlAll());
171 171
         exit;
172 172
     }
173 173
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $entityManager->persist($skillUserComment);
199 199
         $entityManager->flush();
200 200
 
201
-        header("Location: " . $skillIssue->getIssueUrlAll());
201
+        header("Location: ".$skillIssue->getIssueUrlAll());
202 202
         exit;
203 203
     }
204 204
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
             $backpack = $configBackpack;
215 215
         }
216 216
 
217
-        $htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>';
217
+        $htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';
218 218
         $objSkill = new Skill();
219 219
         $assertionUrl = $skillIssueInfo['badge_assertion'];
220 220
         $skills = $objSkill->get($skillId);
221
-        $unbakedBadge = api_get_path(SYS_UPLOAD_PATH) . "badges/".$skills['icon'];
221
+        $unbakedBadge = api_get_path(SYS_UPLOAD_PATH)."badges/".$skills['icon'];
222 222
         if (!is_file($unbakedBadge)) {
223 223
             $unbakedBadge = api_get_path(WEB_CODE_PATH).'img/icons/128/badges-default.png';
224 224
         }
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
                 mkdir($bakedBadge, api_get_permissions_for_new_directories(), true);
237 237
             }
238 238
             $skillRelUserId = $skillIssueInfo['id'];
239
-            if (!file_exists($bakedBadge . "/badge_" . $skillRelUserId)) {
240
-                file_put_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png", $bakedInfo);
239
+            if (!file_exists($bakedBadge."/badge_".$skillRelUserId)) {
240
+                file_put_contents($bakedBadge."/badge_".$skillRelUserId.".png", $bakedInfo);
241 241
             }
242 242
 
243 243
             //Process to validate a baked badge
244
-            $badgeContent = file_get_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png");
244
+            $badgeContent = file_get_contents($bakedBadge."/badge_".$skillRelUserId.".png");
245 245
             $verifyBakedBadge = $png->extractBadgeInfo($badgeContent);
246 246
             if (!is_array($verifyBakedBadge)) {
247 247
                 $badgeInfoError = true;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
             if (!$badgeInfoError) {
251 251
                 $personalBadge = UserManager::getUserPathById($userId, "web");
252
-                $personalBadge = $personalBadge."badges/badge_" . $skillRelUserId . ".png";
252
+                $personalBadge = $personalBadge."badges/badge_".$skillRelUserId.".png";
253 253
             }
254 254
         }
255 255
     }
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/SkillRelUser.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function getIssueUrl()
457 457
     {
458
-        return api_get_path(WEB_PATH) . "badge/{$this->id}";
458
+        return api_get_path(WEB_PATH)."badge/{$this->id}";
459 459
     }
460 460
 
461 461
     /**
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function getIssueUrlAll()
466 466
     {
467
-        return api_get_path(WEB_PATH) . "skill/{$this->skill->getId()}/user/{$this->user->getId()}";
467
+        return api_get_path(WEB_PATH)."skill/{$this->skill->getId()}/user/{$this->user->getId()}";
468 468
     }
469 469
 
470 470
     /**
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      */
474 474
     public function getAssertionUrl()
475 475
     {
476
-        $url = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?";
476
+        $url = api_get_path(WEB_CODE_PATH)."badge/assertion.php?";
477 477
 
478 478
         $url .= http_build_query(array(
479 479
             'user' => $this->user->getId(),
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
     /**
199 199
      * Get user
200
-     * @return \User
200
+     * @return User
201 201
      */
202 202
     public function getUser()
203 203
     {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
     /**
514 514
      * Calculate the average value from the feedback comments
515
-     * @return int
515
+     * @return string
516 516
      */
517 517
     public function getAverage()
518 518
     {
Please login to merge, or discard this patch.
main/document/edit_draw.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 $dir = str_replace('\\', '/', $dir);
38 38
 
39 39
 /* Constants & Variables */
40
-$current_session_id=api_get_session_id();
40
+$current_session_id = api_get_session_id();
41 41
 $group_id = api_get_group_id();
42 42
 
43 43
 //path for svg-edit save
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 $file = basename($get_file);
51 51
 $temp_file = explode(".", $file);
52 52
 $filename = $temp_file[0];
53
-$nameTools = get_lang('EditDocument') . ': ' . $filename;
54
-$courseDir = $_course['path'] . '/document';
53
+$nameTools = get_lang('EditDocument').': '.$filename;
54
+$courseDir = $_course['path'].'/document';
55 55
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
56 56
 
57 57
 /*	Other initialization code */
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 Display :: display_header($nameTools, 'Doc');
126 126
 echo '<div class="actions">';
127 127
 echo '<a href="document.php?id='.$parent_id.'">'.
128
-    Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
128
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
129 129
 echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.
130
-    Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
130
+    Display::return_icon('edit.png', get_lang('Rename').'/'.get_lang('Comments'), '', ICON_SIZE_MEDIUM).'</a>';
131 131
 echo '</div>';
132 132
 
133 133
 if (api_browser_support('svg')) {
134 134
 	//automatic loading the course language
135 135
 	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
136
-	$langsvgedit  = api_get_language_isocode();
136
+	$langsvgedit = api_get_language_isocode();
137 137
 	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
138 138
 	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
139 139
 	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 //path for svg-edit save
47 47
 $_SESSION['draw_dir'] = Security::remove_XSS($dir);
48 48
 if ($_SESSION['draw_dir'] == '/') {
49
-	$_SESSION['draw_dir'] = '';
49
+    $_SESSION['draw_dir'] = '';
50 50
 }
51 51
 $_SESSION['draw_file'] = basename(Security::remove_XSS($file_path));
52 52
 $get_file = Security::remove_XSS($file_path);
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 /* Please, do not modify this dirname formatting */
63 63
 
64 64
 if (strstr($dir, '..')) {
65
-	$dir = '/';
65
+    $dir = '/';
66 66
 }
67 67
 
68 68
 if ($dir[0] == '.') {
69
-	$dir = substr($dir, 1);
69
+    $dir = substr($dir, 1);
70 70
 }
71 71
 
72 72
 if ($dir[0] != '/') {
73
-	$dir = '/'.$dir;
73
+    $dir = '/'.$dir;
74 74
 }
75 75
 
76 76
 if ($dir[strlen($dir) - 1] != '/') {
77
-	$dir .= '/';
77
+    $dir .= '/';
78 78
 }
79 79
 
80 80
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
81 81
 
82 82
 if (!is_dir($filepath)) {
83
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
84
-	$dir = '/';
83
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
84
+    $dir = '/';
85 85
 }
86 86
 
87 87
 //groups //TODO:clean
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
         'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
91 91
         'name' => get_lang('GroupSpace'),
92 92
     );
93
-	$group_document = true;
94
-	$noPHP_SELF = true;
93
+    $group_document = true;
94
+    $noPHP_SELF = true;
95 95
 }
96 96
 
97 97
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 }
118 118
 
119 119
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights ||
120
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
120
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
121 121
 
122 122
 if (!$is_allowedToEdit) {
123
-	api_not_allowed(true);
123
+    api_not_allowed(true);
124 124
 }
125 125
 
126 126
 Event::event_access_tool(TOOL_DOCUMENT);
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 echo '</div>';
135 135
 
136 136
 if (api_browser_support('svg')) {
137
-	//automatic loading the course language
138
-	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
139
-	$langsvgedit  = api_get_language_isocode();
140
-	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
141
-	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
142
-	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
143
-	?>
137
+    //automatic loading the course language
138
+    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
139
+    $langsvgedit  = api_get_language_isocode();
140
+    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
141
+    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
142
+    $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
143
+    ?>
144 144
 	<script>
145 145
 	document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo  $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
146 146
 	function resizeIframe() {
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 
159 159
     <?php
160 160
     echo '<noscript>';
161
-	echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
162
-	echo '</noscript>';
161
+    echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
162
+    echo '</noscript>';
163 163
 } else {
164
-	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
164
+    Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
165 165
 }
166 166
 Display::display_footer();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,13 +96,14 @@
 block discarded – undo
96 96
 
97 97
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
98 98
 
99
-if (!$is_certificate_mode)
99
+if (!$is_certificate_mode) {
100 100
     $interbreadcrumb[] = array(
101 101
         "url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
102 102
         "name" => get_lang('Documents'),
103 103
     );
104
-else
104
+} else {
105 105
     $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
106
+}
106 107
 
107 108
 // Interbreadcrumb for the current directory root path
108 109
 if (empty($document_data['parents'])) {
Please login to merge, or discard this patch.
main/inc/lib/api.lib.php 4 patches
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1701,7 +1701,9 @@  discard block
 block discarded – undo
1701 1701
     }
1702 1702
 
1703 1703
     global $_course;
1704
-    if ($_course == '-1') $_course = array();
1704
+    if ($_course == '-1') {
1705
+        $_course = array();
1706
+    }
1705 1707
     return $_course;
1706 1708
 }
1707 1709
 
@@ -4154,18 +4156,21 @@  discard block
 block discarded – undo
4154 4156
     switch ($lang_type) {
4155 4157
         case 'platform_lang':
4156 4158
             $temp_lang = api_get_setting('platformLanguage');
4157
-            if (!empty($temp_lang))
4158
-                $return = $temp_lang;
4159
+            if (!empty($temp_lang)) {
4160
+                            $return = $temp_lang;
4161
+            }
4159 4162
             break;
4160 4163
         case 'user_profil_lang':
4161 4164
             $_user = api_get_user_info();
4162 4165
 
4163
-            if (isset($_user['language']) && !empty($_user['language']))
4164
-                $return = $_user['language'];
4166
+            if (isset($_user['language']) && !empty($_user['language'])) {
4167
+                            $return = $_user['language'];
4168
+            }
4165 4169
             break;
4166 4170
         case 'user_selected_lang':
4167
-            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
4168
-                $return = $_SESSION['user_language_choice'];
4171
+            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
4172
+                            $return = $_SESSION['user_language_choice'];
4173
+            }
4169 4174
             break;
4170 4175
         case 'course_lang':
4171 4176
             global $_course;
@@ -5434,8 +5439,7 @@  discard block
 block discarded – undo
5434 5439
             $is_courseAdmin = false;
5435 5440
             $is_courseCoach = true;
5436 5441
             $is_sessionAdmin = false;
5437
-        }
5438
-        elseif ($row[0]['session_admin_id'] == $userid) {
5442
+        } elseif ($row[0]['session_admin_id'] == $userid) {
5439 5443
             $is_courseMember = false;
5440 5444
             $is_courseTutor = false;
5441 5445
             $is_courseAdmin = false;
@@ -5778,8 +5782,7 @@  discard block
 block discarded – undo
5778 5782
     elseif (isset($_ENV['OS'])) {
5779 5783
         // Sometimes $_ENV['OS'] may not be present (bugs?)
5780 5784
         $os = $_ENV['OS'];
5781
-    }
5782
-    elseif (defined('PHP_OS')) {
5785
+    } elseif (defined('PHP_OS')) {
5783 5786
         // PHP_OS means on which OS PHP was compiled, this is why
5784 5787
         // using PHP_OS is the last choice for detection.
5785 5788
         $os = PHP_OS;
@@ -5843,12 +5846,10 @@  discard block
 block discarded – undo
5843 5846
     if ($delta_width > $delta_height) {
5844 5847
         $result['width'] = ceil($image_width * $resize_factor_height);
5845 5848
         $result['height'] = ceil($image_height * $resize_factor_height);
5846
-    }
5847
-    elseif ($delta_width < $delta_height) {
5849
+    } elseif ($delta_width < $delta_height) {
5848 5850
         $result['width'] = ceil($image_width * $resize_factor_width);
5849 5851
         $result['height'] = ceil($image_height * $resize_factor_width);
5850
-    }
5851
-    else {
5852
+    } else {
5852 5853
         $result['width'] = ceil($target_width);
5853 5854
         $result['height'] = ceil($target_height);
5854 5855
     }
@@ -6629,7 +6630,9 @@  discard block
 block discarded – undo
6629 6630
         }
6630 6631
         $ip = trim($ip1);
6631 6632
     }
6632
-    if (!empty($debug)) error_log('Real IP: '.$ip);
6633
+    if (!empty($debug)) {
6634
+        error_log('Real IP: '.$ip);
6635
+    }
6633 6636
     return $ip;
6634 6637
 }
6635 6638
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -626,7 +626,6 @@  discard block
 block discarded – undo
626 626
  * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
627 627
  *
628 628
  * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
629
-
630 629
  * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
631 630
  * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
632 631
  * @return string                   The requested path or the converted path.
@@ -1733,7 +1732,6 @@  discard block
 block discarded – undo
1733 1732
 
1734 1733
 /**
1735 1734
  * Returns the current course info array.
1736
-
1737 1735
  * Now if the course_code is given, the returned array gives info about that
1738 1736
  * particular course, not specially the current one.
1739 1737
  * @param int $id Numeric ID of the course
@@ -6210,7 +6208,7 @@  discard block
 block discarded – undo
6210 6208
 function api_get_jquery_ui_js($include_jqgrid = false) {
6211 6209
     $libraries = array();
6212 6210
     if ($include_jqgrid) {
6213
-       $libraries[]='jqgrid';
6211
+        $libraries[]='jqgrid';
6214 6212
     }
6215 6213
     return api_get_jquery_libraries_js($libraries);
6216 6214
 }
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1271,6 +1271,7 @@  discard block
 block discarded – undo
1271 1271
  * Gets the list of courses a specific user is subscribed to
1272 1272
  * @param int       User ID
1273 1273
  * @param boolean   $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED
1274
+ * @param integer $userid
1274 1275
  * @return array    Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d)
1275 1276
  */
1276 1277
 function api_get_user_courses($userid, $fetch_session = true)
@@ -3016,7 +3017,7 @@  discard block
 block discarded – undo
3016 3017
 * on the session visibility
3017 3018
 * @param bool $tutor  Whether to check if the user has the tutor role
3018 3019
 * @param bool  $coach Whether to check if the user has the coach role
3019
-* @return boolean true: the user has the rights to edit, false: he does not
3020
+* @return boolean|null true: the user has the rights to edit, false: he does not
3020 3021
 */
3021 3022
 function api_is_allowed_to_session_edit($tutor = false, $coach = false)
3022 3023
 {
@@ -5197,6 +5198,7 @@  discard block
 block discarded – undo
5197 5198
  * @param string    Whether we want a simple list (display a category) or
5198 5199
  * a grouped list (group by variable as in settings.php default). Values: 'list' or 'group'
5199 5200
  * @param int       Access URL's ID. Optional. Uses 1 by default, which is the unique URL
5201
+ * @param string $cat
5200 5202
  * @return array    Array of database results for the current settings of the current access URL
5201 5203
  */
5202 5204
 function &api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0)
@@ -6590,7 +6592,7 @@  discard block
 block discarded – undo
6590 6592
 /**
6591 6593
  * Returns an array of global configuration settings which should be ignored
6592 6594
  * when printing the configuration settings screens
6593
- * @return array Array of strings, each identifying one of the excluded settings
6595
+ * @return string[] Array of strings, each identifying one of the excluded settings
6594 6596
  */
6595 6597
 function api_get_locked_settings() {
6596 6598
     return array(
@@ -6631,6 +6633,7 @@  discard block
 block discarded – undo
6631 6633
  * false if he isn't. If the user ID is given and is an integer, then the same
6632 6634
  * ID is simply returned
6633 6635
  * @param  integer User ID
6636
+ * @param integer $user_id
6634 6637
  * @return boolean Integer User ID is logged in, or false otherwise
6635 6638
  */
6636 6639
 function api_user_is_login($user_id = null) {
@@ -7051,6 +7054,7 @@  discard block
 block discarded – undo
7051 7054
 /**
7052 7055
  * Gets memory limit in bytes
7053 7056
  * @param string The memory size (128M, 1G, 1000K, etc)
7057
+ * @param string $mem
7054 7058
  * @return int
7055 7059
  * @assert (null) === false
7056 7060
  * @assert ('1t')  === 1099511627776
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -41,19 +41,19 @@  discard block
 block discarded – undo
41 41
 define('PLATFORM_ADMIN', 11);
42 42
 define('SESSION_COURSE_COACH', 12);
43 43
 define('SESSION_GENERAL_COACH', 13);
44
-define('COURSE_STUDENT', 14);   //student subscribed in a course
45
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
44
+define('COURSE_STUDENT', 14); //student subscribed in a course
45
+define('SESSION_STUDENT', 15); //student subscribed in a session course
46 46
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
47 47
 define('STUDENT_BOSS', 17); // student is boss
48 48
 define('INVITEE', 20);
49 49
 
50 50
 // Table of status
51
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
52
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
53
-$_status_list[DRH] = 'drh';            // 4
54
-$_status_list[STUDENT] = 'user';           // 5
55
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
56
-$_status_list[INVITEE] = 'invited';        // 20
51
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
52
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
53
+$_status_list[DRH] = 'drh'; // 4
54
+$_status_list[STUDENT] = 'user'; // 5
55
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
56
+$_status_list[INVITEE] = 'invited'; // 20
57 57
 
58 58
 // COURSE VISIBILITY CONSTANTS
59 59
 /** only visible for course admin */
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 define('IS_WINDOWS_OS', api_is_windows_os());
268 268
 
269 269
 // Checks for installed optional php-extensions.
270
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
271
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
272
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
270
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
271
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
272
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
273 273
 
274 274
 // Patterns for processing paths.                                   // Examples:
275
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
276
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
277
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
275
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
276
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
277
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
278 278
 
279 279
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
280 280
 // basic (leaf elements)
@@ -363,19 +363,19 @@  discard block
 block discarded – undo
363 363
 define('LINK_HOTPOTATOES', 9);
364 364
 
365 365
 // Score display types constants
366
-define('SCORE_DIV', 1);    // X / Y
367
-define('SCORE_PERCENT', 2);    // XX %
368
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
369
-define('SCORE_AVERAGE', 4);    // XX %
370
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
371
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
372
-define('SCORE_SIMPLE', 7);    // X
373
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
374
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
375
-define('SCORE_CUSTOM', 10);    // Good!
376
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
377
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
378
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
366
+define('SCORE_DIV', 1); // X / Y
367
+define('SCORE_PERCENT', 2); // XX %
368
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
369
+define('SCORE_AVERAGE', 4); // XX %
370
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
371
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
372
+define('SCORE_SIMPLE', 7); // X
373
+define('SCORE_IGNORE_SPLIT', 8); //  ??
374
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
375
+define('SCORE_CUSTOM', 10); // Good!
376
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
377
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
378
+define('SCORE_ONLY_SCORE', 13); // X - Good!
379 379
 
380 380
 define('SCORE_BOTH', 1);
381 381
 define('SCORE_ONLY_DEFAULT', 2);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 define('TIMELINE_STATUS_INACTIVE', '2');
559 559
 
560 560
 // Event email template class
561
-define('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
561
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
562 562
 define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
563 563
 
564 564
 // Course home
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 define('FILE_OVERWRITE', 3);
575 575
 define('UTF8_CONVERT', false); //false by default
576 576
 
577
-define('DOCUMENT','file');
578
-define('FOLDER','folder');
577
+define('DOCUMENT', 'file');
578
+define('FOLDER', 'folder');
579 579
 
580 580
 define('RESOURCE_ASSET', 'asset');
581 581
 define('RESOURCE_DOCUMENT', 'document');
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
     $emptyConfigurationParam = false;
672 672
     if (empty($configuration)) {
673
-        $configuration = (array)$_configuration;
673
+        $configuration = (array) $_configuration;
674 674
         $emptyConfigurationParam = true;
675 675
     }
676 676
 
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
                         && (($server_protocol == 'http'
703 703
                                 && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))
704 704
                     ) {
705
-                        $server_name .= ":" . $_SERVER['SERVER_PORT'];
705
+                        $server_name .= ":".$_SERVER['SERVER_PORT'];
706 706
                     }
707
-                    $root_web = $server_protocol . '://' . $server_name . $root_rel;
708
-                    $root_sys = str_replace('\\', '/', realpath(__DIR__ . '/../../../')) . '/';
707
+                    $root_web = $server_protocol.'://'.$server_name.$root_rel;
708
+                    $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
709 709
                 }
710 710
                 // Here we give up, so we don't touch anything.
711 711
             }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
                 $sys_course_code =
893 893
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
894 894
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
895
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
895
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
896 896
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
897 897
             }
898 898
         }
@@ -917,15 +917,15 @@  discard block
 block discarded – undo
917 917
 {
918 918
     global $_configuration;
919 919
     $web_root = api_get_path(WEB_PATH);
920
-    $ext = substr($web_path,strrpos($web_path,'.'));
920
+    $ext = substr($web_path, strrpos($web_path, '.'));
921 921
     if (isset($ext[2])) { // faster version of strlen to check if len>2
922 922
         // Check for CDN definitions
923 923
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
924 924
             foreach ($_configuration['cdn'] as $host => $exts) {
925
-                if (in_array($ext,$exts)) {
925
+                if (in_array($ext, $exts)) {
926 926
                     //Use host as defined in $_configuration['cdn'], without
927 927
                     // trailing slash
928
-                    return str_replace($web_root,$host.'/',$web_path);
928
+                    return str_replace($web_root, $host.'/', $web_path);
929 929
                 }
930 930
             }
931 931
         }
@@ -1372,10 +1372,10 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
     if (isset($user['email'])) {
1374 1374
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1375
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1375
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1376 1376
     } else {
1377 1377
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1378
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1378
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1379 1379
     }
1380 1380
     $user_id = intval($user['user_id']);
1381 1381
     // Maintain the user_id index for backwards compatibility
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
         foreach ($param_list1 as $key => $enreg) {
1928 1928
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1929 1929
         }
1930
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1930
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1931 1931
         foreach ($param_list2 as $enreg) {
1932 1932
             $enreg = explode('=', $enreg);
1933 1933
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1960,12 +1960,12 @@  discard block
 block discarded – undo
1960 1960
         $length = 2;
1961 1961
     }
1962 1962
     $password = '';
1963
-    for ($i = 0; $i < $length; $i ++) {
1963
+    for ($i = 0; $i < $length; $i++) {
1964 1964
         $password .= $characters[rand() % strlen($characters)];
1965 1965
     }
1966 1966
 
1967 1967
     // At least 2 digits
1968
-    for ($i = 0; $i < 2; $i ++) {
1968
+    for ($i = 0; $i < 2; $i++) {
1969 1969
         $password .= $numbers[rand() % strlen($numbers)];
1970 1970
     }
1971 1971
 
@@ -1993,10 +1993,10 @@  discard block
 block discarded – undo
1993 1993
     $digits = 0;
1994 1994
     $consequent_characters = 0;
1995 1995
     $previous_character_code = 0;
1996
-    for ($i = 0; $i < $password_length; $i ++) {
1996
+    for ($i = 0; $i < $password_length; $i++) {
1997 1997
         $current_character_code = api_ord(api_substr($password, $i, 1));
1998 1998
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
1999
-            $consequent_characters ++;
1999
+            $consequent_characters++;
2000 2000
             if ($consequent_characters == 3) {
2001 2001
                 return false;
2002 2002
             }
@@ -2004,9 +2004,9 @@  discard block
 block discarded – undo
2004 2004
             $consequent_characters = 1;
2005 2005
         }
2006 2006
         if ($current_character_code >= 97 && $current_character_code <= 122) {
2007
-            $letters ++;
2007
+            $letters++;
2008 2008
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
2009
-            $digits ++;
2009
+            $digits++;
2010 2010
         } else {
2011 2011
             return false;
2012 2012
         }
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
         if (empty($session_id)) { return null; }
2112 2112
     }
2113 2113
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2114
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2114
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2115 2115
     $r = Database::query($s);
2116 2116
     $c = Database::num_rows($r);
2117 2117
     if ($c > 0) {
@@ -2281,9 +2281,9 @@  discard block
 block discarded – undo
2281 2281
  */
2282 2282
 function api_get_session_image($session_id, $status_id)
2283 2283
 {
2284
-    $session_id = (int)$session_id;
2284
+    $session_id = (int) $session_id;
2285 2285
     $session_img = '';
2286
-    if ((int)$status_id != 5) { //check whether is not a student
2286
+    if ((int) $status_id != 5) { //check whether is not a student
2287 2287
         if ($session_id > 0) {
2288 2288
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2289 2289
                 'star.png',
@@ -2560,7 +2560,7 @@  discard block
 block discarded – undo
2560 2560
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2561 2561
 {
2562 2562
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2563
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2563
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2564 2564
 
2565 2565
     $user_id = intval($user_id);
2566 2566
     $session_id = intval($session_id);
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
                 ORDER BY access_start_date, access_end_date, name";
2635 2635
         $result = Database::query($sql);
2636 2636
         if (!empty($sessionIsCoach)) {
2637
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2637
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2638 2638
         } else {
2639 2639
             $sessionIsCoach = Database::store_result($result);
2640 2640
         }
@@ -2808,7 +2808,7 @@  discard block
 block discarded – undo
2808 2808
             return '';
2809 2809
         }
2810 2810
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
2811
-        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
2811
+        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
2812 2812
         //showinframes doesn't handle student view anyway...
2813 2813
         //return '';
2814 2814
         $is_framed = true;
@@ -3292,7 +3292,7 @@  discard block
 block discarded – undo
3292 3292
         }
3293 3293
         $content .= '<div class="well">';
3294 3294
         $content .= $form->returnForm();
3295
-        $content .='</div>';
3295
+        $content .= '</div>';
3296 3296
         if (api_is_cas_activated()) {
3297 3297
             $content .= "</div>";
3298 3298
         }
@@ -3344,7 +3344,7 @@  discard block
 block discarded – undo
3344 3344
         }
3345 3345
         $msg .= '<div class="well">';
3346 3346
         $msg .= $form->returnForm();
3347
-        $msg .='</div>';
3347
+        $msg .= '</div>';
3348 3348
         if ($casEnabled) {
3349 3349
             $msg .= "</div>";
3350 3350
         }
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3375 3375
     list ($year, $month, $day) = explode('-', $last_post_date);
3376 3376
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3377
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3377
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3378 3378
 }
3379 3379
 
3380 3380
 /**
@@ -3846,7 +3846,7 @@  discard block
 block discarded – undo
3846 3846
                 c_id = $course_id AND
3847 3847
                 tool = '$tool'
3848 3848
                 $session_condition ";
3849
-    $rs  = Database::query($sql);
3849
+    $rs = Database::query($sql);
3850 3850
     $list = array();
3851 3851
     if (Database::num_rows($rs) > 0) {
3852 3852
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -3927,7 +3927,7 @@  discard block
 block discarded – undo
3927 3927
                 tool = '$tool' AND
3928 3928
                 ref = $ref
3929 3929
                 $sessionCondition";
3930
-    $rs  = Database::query($sql);
3930
+    $rs = Database::query($sql);
3931 3931
     $item_property_id = '';
3932 3932
     if (Database::num_rows($rs) > 0) {
3933 3933
         $row = Database::fetch_array($rs);
@@ -3988,7 +3988,7 @@  discard block
 block discarded – undo
3988 3988
     if ($result == false) {
3989 3989
         $result = array();
3990 3990
     } else {
3991
-        $result = Database::store_result($result,'ASSOC');
3991
+        $result = Database::store_result($result, 'ASSOC');
3992 3992
     }
3993 3993
 
3994 3994
     return $result;
@@ -4040,7 +4040,7 @@  discard block
 block discarded – undo
4040 4040
     $rs  = Database::query($sql);
4041 4041
     $row = array();
4042 4042
     if (Database::num_rows($rs) > 0) {
4043
-        $row = Database::fetch_array($rs,'ASSOC');
4043
+        $row = Database::fetch_array($rs, 'ASSOC');
4044 4044
     }
4045 4045
 
4046 4046
     return $row;
@@ -4075,7 +4075,7 @@  discard block
 block discarded – undo
4075 4075
     $languages  = $language_list['name'];
4076 4076
     $folder     = $language_list['folder'];
4077 4077
 
4078
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
4078
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
4079 4079
     foreach ($languages as $key => $value) {
4080 4080
         if ($folder[$key] == $default) {
4081 4081
             $selected = ' selected="selected"';
@@ -4125,8 +4125,8 @@  discard block
 block discarded – undo
4125 4125
     }
4126 4126
     </script>';
4127 4127
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4128
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4129
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4128
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4129
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4130 4130
 
4131 4131
     foreach ($original_languages as $key => $value) {
4132 4132
         if ($folder[$key] == $user_selected_language) {
@@ -4134,13 +4134,13 @@  discard block
 block discarded – undo
4134 4134
         } else {
4135 4135
             $option_end = '>';
4136 4136
         }
4137
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4137
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4138 4138
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4139
-        $html .=  $value.'</option>';
4139
+        $html .= $value.'</option>';
4140 4140
     }
4141
-    $html .=  '</select>';
4142
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4143
-    $html .=  '</form>';
4141
+    $html .= '</select>';
4142
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4143
+    $html .= '</form>';
4144 4144
     return $html;
4145 4145
 }
4146 4146
 
@@ -4358,7 +4358,7 @@  discard block
 block discarded – undo
4358 4358
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4359 4359
  */
4360 4360
 function api_get_themes() {
4361
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4361
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4362 4362
     $list_dir = array();
4363 4363
     $list_name = array();
4364 4364
 
@@ -4519,7 +4519,7 @@  discard block
 block discarded – undo
4519 4519
     if (is_file($dirname) || is_link($dirname)) {
4520 4520
         $res = unlink($dirname);
4521 4521
         if ($res === false) {
4522
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4522
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4523 4523
         }
4524 4524
         return $res;
4525 4525
     }
@@ -4556,7 +4556,7 @@  discard block
 block discarded – undo
4556 4556
     if ($delete_only_content_in_folder == false) {
4557 4557
         $res = rmdir($dirname);
4558 4558
         if ($res === false) {
4559
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4559
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4560 4560
         }
4561 4561
     }
4562 4562
     return $res;
@@ -4641,7 +4641,7 @@  discard block
 block discarded – undo
4641 4641
 
4642 4642
     $course_id = $course_info['real_id'];
4643 4643
 
4644
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4644
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4645 4645
 
4646 4646
     $new_pathname = $base_path_document;
4647 4647
     $path = '';
@@ -4659,7 +4659,7 @@  discard block
 block discarded – undo
4659 4659
                         path = '$path' AND
4660 4660
                         filetype = 'folder' AND
4661 4661
                         session_id = '$session_id'";
4662
-            $rs1  = Database::query($sql);
4662
+            $rs1 = Database::query($sql);
4663 4663
             $num_rows = Database::num_rows($rs1);
4664 4664
 
4665 4665
             if ($num_rows == 0) {
@@ -4819,7 +4819,7 @@  discard block
 block discarded – undo
4819 4819
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4820 4820
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4821 4821
             }
4822
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4822
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4823 4823
 
4824 4824
             // Parse array syntax.
4825 4825
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4985,7 +4985,7 @@  discard block
 block discarded – undo
4985 4985
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
4986 4986
     $var = Database::escape_string($var);
4987 4987
     $value = Database::escape_string($value);
4988
-    $access_url = (int)$access_url;
4988
+    $access_url = (int) $access_url;
4989 4989
     if (empty($access_url)) { $access_url = 1; }
4990 4990
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
4991 4991
     if (!empty($subvar)) {
@@ -5026,11 +5026,11 @@  discard block
 block discarded – undo
5026 5026
                 $row = Database::fetch_array($res);
5027 5027
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5028 5028
                         VALUES
5029
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5030
-                        "'".$row['type']."','".$row['category']."'," .
5031
-                        "'$value','".$row['title']."'," .
5032
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5033
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5029
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5030
+                        "'".$row['type']."','".$row['category']."',".
5031
+                        "'$value','".$row['title']."',".
5032
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5033
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5034 5034
                 Database::query($insert);
5035 5035
             } else {
5036 5036
                 // Such a setting does not exist.
@@ -5052,11 +5052,11 @@  discard block
 block discarded – undo
5052 5052
                 if ($row['access_url_changeable'] == 1) {
5053 5053
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5054 5054
                             ('".$row['variable']."',".
5055
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5056
-                            "'".$row['type']."','".$row['category']."'," .
5057
-                            "'$value','".$row['title']."'," .
5055
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5056
+                            "'".$row['type']."','".$row['category']."',".
5057
+                            "'$value','".$row['title']."',".
5058 5058
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5059
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5059
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5060 5060
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5061 5061
                     Database::query($insert);
5062 5062
                 }
@@ -5089,10 +5089,10 @@  discard block
 block discarded – undo
5089 5089
         $value = Database::escape_string($value);
5090 5090
         $sql = "UPDATE $t_s SET selected_value = '$value'
5091 5091
                 WHERE category = '$category' AND access_url = $access_url";
5092
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5092
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5093 5093
             $sql .= " AND ( ";
5094 5094
             $i = 0;
5095
-            foreach ($fieldtype as $type){
5095
+            foreach ($fieldtype as $type) {
5096 5096
                 if ($i > 0) {
5097 5097
                     $sql .= ' OR ';
5098 5098
                 }
@@ -5107,10 +5107,10 @@  discard block
 block discarded – undo
5107 5107
     } else {
5108 5108
         $sql = "UPDATE $t_s SET selected_value = NULL
5109 5109
                 WHERE category = '$category' AND access_url = $access_url";
5110
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5110
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5111 5111
             $sql .= " AND ( ";
5112 5112
             $i = 0;
5113
-            foreach ($fieldtype as $type){
5113
+            foreach ($fieldtype as $type) {
5114 5114
                 if ($i > 0) {
5115 5115
                     $sql .= ' OR ';
5116 5116
                 }
@@ -5223,7 +5223,7 @@  discard block
 block discarded – undo
5223 5223
         $sql .= " ORDER BY 1,2 ASC";
5224 5224
     }
5225 5225
     $result = Database::query($sql);
5226
-    $result = Database::store_result($result,'ASSOC');
5226
+    $result = Database::store_result($result, 'ASSOC');
5227 5227
 
5228 5228
     return $result;
5229 5229
 }
@@ -5290,12 +5290,12 @@  discard block
 block discarded – undo
5290 5290
 
5291 5291
     // Item not found for this access_url, we have to check if the whole thing is missing
5292 5292
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5293
-    $insert = "INSERT INTO $t_settings " .
5294
-                "(variable,selected_value," .
5295
-                "type,category," .
5296
-                "subkey,title," .
5297
-                "comment,scope," .
5298
-                "subkeytext,access_url,access_url_changeable)" .
5293
+    $insert = "INSERT INTO $t_settings ".
5294
+                "(variable,selected_value,".
5295
+                "type,category,".
5296
+                "subkey,title,".
5297
+                "comment,scope,".
5298
+                "subkeytext,access_url,access_url_changeable)".
5299 5299
                 " VALUES ('$var','$val',";
5300 5300
     if (isset($type)) {
5301 5301
         $type = Database::escape_string($type);
@@ -5461,7 +5461,7 @@  discard block
 block discarded – undo
5461 5461
             $result = Database::query($sql);
5462 5462
 
5463 5463
             //if ($row = Database::fetch_array($result)) {
5464
-            if (Database::num_rows($result) > 0 ) {
5464
+            if (Database::num_rows($result) > 0) {
5465 5465
                 $is_courseMember = true;
5466 5466
                 $is_courseTutor = true;
5467 5467
                 $is_courseCoach = true;
@@ -5751,7 +5751,7 @@  discard block
 block discarded – undo
5751 5751
     } else {
5752 5752
         return false;
5753 5753
     }
5754
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5754
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5755 5755
 }
5756 5756
 
5757 5757
 /**
@@ -6342,7 +6342,7 @@  discard block
 block discarded – undo
6342 6342
 function api_get_jquery_ui_js($include_jqgrid = false) {
6343 6343
     $libraries = array();
6344 6344
     if ($include_jqgrid) {
6345
-       $libraries[]='jqgrid';
6345
+       $libraries[] = 'jqgrid';
6346 6346
     }
6347 6347
     return api_get_jquery_libraries_js($libraries);
6348 6348
 }
@@ -6365,12 +6365,12 @@  discard block
 block discarded – undo
6365 6365
 
6366 6366
     //jqgrid js and css
6367 6367
     if (in_array('jqgrid', $libraries)) {
6368
-        $languaje   = 'en';
6368
+        $languaje = 'en';
6369 6369
         $platform_isocode = strtolower(api_get_language_isocode());
6370 6370
 
6371 6371
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6372 6372
         $jqgrid_langs = array(
6373
-            'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua'
6373
+            'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua'
6374 6374
         );
6375 6375
 
6376 6376
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6401,7 +6401,7 @@  discard block
 block discarded – undo
6401 6401
 
6402 6402
     // jquery datepicker
6403 6403
     if (in_array('datepicker', $libraries)) {
6404
-        $languaje   = 'en-GB';
6404
+        $languaje = 'en-GB';
6405 6405
         $platform_isocode = strtolower(api_get_language_isocode());
6406 6406
 
6407 6407
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6567,7 +6567,7 @@  discard block
 block discarded – undo
6567 6567
  * @return void
6568 6568
  */
6569 6569
 function api_check_php_version($my_inc_path = null) {
6570
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6570
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6571 6571
         $global_error_code = 1;
6572 6572
         // Incorrect PHP version
6573 6573
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6583,7 +6583,7 @@  discard block
 block discarded – undo
6583 6583
  */
6584 6584
 function api_check_archive_dir() {
6585 6585
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6586
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6586
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6587 6587
         api_not_allowed(true, $message);
6588 6588
     }
6589 6589
 }
@@ -6646,7 +6646,7 @@  discard block
 block discarded – undo
6646 6646
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6647 6647
  * @version CEV CHANGE 24APR2012
6648 6648
  */
6649
-function api_get_real_ip(){
6649
+function api_get_real_ip() {
6650 6650
     // Guess the IP if behind a reverse proxy
6651 6651
     global $debug;
6652 6652
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6672,23 +6672,23 @@  discard block
 block discarded – undo
6672 6672
  * @author Yannick Warnier for improvements and managment of multiple ranges
6673 6673
  * @todo check for IPv6 support
6674 6674
  */
6675
-function api_check_ip_in_range($ip,$range)
6675
+function api_check_ip_in_range($ip, $range)
6676 6676
 {
6677 6677
     if (empty($ip) or empty($range)) {
6678 6678
         return false;
6679 6679
     }
6680
-    $ip_ip = ip2long ($ip);
6680
+    $ip_ip = ip2long($ip);
6681 6681
     // divide range param into array of elements
6682
-    if (strpos($range,',')!==false) {
6683
-        $ranges = explode(',',$range);
6682
+    if (strpos($range, ',') !== false) {
6683
+        $ranges = explode(',', $range);
6684 6684
     } else {
6685 6685
         $ranges = array($range);
6686 6686
     }
6687 6687
     foreach ($ranges as $range) {
6688 6688
         $range = trim($range);
6689 6689
         if (empty($range)) { continue; }
6690
-        if (strpos($range,'/')===false) {
6691
-            if (strcmp($ip,$range)===0) {
6690
+        if (strpos($range, '/') === false) {
6691
+            if (strcmp($ip, $range) === 0) {
6692 6692
                 return true; // there is a direct IP match, return OK
6693 6693
             }
6694 6694
             continue; //otherwise, get to the next range
@@ -6696,7 +6696,7 @@  discard block
 block discarded – undo
6696 6696
         // the range contains a "/", so analyse completely
6697 6697
         list ($net, $mask) = explode("/", $range);
6698 6698
 
6699
-        $ip_net = ip2long ($net);
6699
+        $ip_net = ip2long($net);
6700 6700
         // mask binary magic
6701 6701
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6702 6702
 
@@ -7034,14 +7034,14 @@  discard block
 block discarded – undo
7034 7034
  * @assert (0) === true
7035 7035
  * @assert ('1G') === true
7036 7036
  */
7037
-function api_set_memory_limit($mem){
7037
+function api_set_memory_limit($mem) {
7038 7038
     //if ini_set() not available, this function is useless
7039 7039
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7040 7040
         return false;
7041 7041
     }
7042 7042
 
7043 7043
     $memory_limit = ini_get('memory_limit');
7044
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7044
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7045 7045
         ini_set('memory_limit', $mem);
7046 7046
         return true;
7047 7047
     }
@@ -7058,21 +7058,21 @@  discard block
 block discarded – undo
7058 7058
  * @assert ('1m')  === 1048576
7059 7059
  * @assert ('100k') === 102400
7060 7060
  */
7061
-function api_get_bytes_memory_limit($mem){
7062
-    $size = strtolower(substr($mem,-1));
7061
+function api_get_bytes_memory_limit($mem) {
7062
+    $size = strtolower(substr($mem, -1));
7063 7063
 
7064 7064
     switch ($size) {
7065 7065
         case 't':
7066
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7066
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7067 7067
             break;
7068 7068
         case 'g':
7069
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7069
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7070 7070
             break;
7071 7071
         case 'm':
7072
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7072
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7073 7073
             break;
7074 7074
         case 'k':
7075
-            $mem = intval(substr($mem,0,-1))*1024;
7075
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7076 7076
             break;
7077 7077
         default:
7078 7078
             // we assume it's integer only
@@ -7135,7 +7135,7 @@  discard block
 block discarded – undo
7135 7135
     ];
7136 7136
 
7137 7137
     $js = api_get_asset('pwstrength-bootstrap/dist/pwstrength-bootstrap.min.js');
7138
-    $js .=  "<script>    
7138
+    $js .= "<script>    
7139 7139
     var errorMessages = {
7140 7140
         password_to_short : \"" . get_lang('PasswordIsTooShort')."\",
7141 7141
         same_as_username : \"".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."\"
@@ -7182,7 +7182,7 @@  discard block
 block discarded – undo
7182 7182
         return false;
7183 7183
     }
7184 7184
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7185
-    $time = time() + $minutesToBlock*60;
7185
+    $time = time() + $minutesToBlock * 60;
7186 7186
     UserManager::update_extra_field_value(
7187 7187
         $userInfo['user_id'],
7188 7188
         'captcha_blocked_until_date',
@@ -7256,7 +7256,7 @@  discard block
 block discarded – undo
7256 7256
         $out_res = str_replace('"', "''", $out_res);
7257 7257
     }
7258 7258
     // avoid text stuck together when tags are removed, adding a space after >
7259
-    $out_res = str_replace (">", "> ", $out_res);
7259
+    $out_res = str_replace(">", "> ", $out_res);
7260 7260
     $out_res = strip_tags($out_res);
7261 7261
 
7262 7262
     return $out_res;
@@ -7465,7 +7465,7 @@  discard block
 block discarded – undo
7465 7465
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7466 7466
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7467 7467
         if (isset($hostingParams[$limitName])) {
7468
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7468
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7469 7469
         }
7470 7470
         api_mail_html(null, $email, $subject, $body);
7471 7471
     }
@@ -7597,7 +7597,7 @@  discard block
 block discarded – undo
7597 7597
  */
7598 7598
 function api_set_site_use_cookie_warning_cookie()
7599 7599
 {
7600
-    setcookie('ChamiloUsesCookies', 'ok', time()+31556926);
7600
+    setcookie('ChamiloUsesCookies', 'ok', time() + 31556926);
7601 7601
 }
7602 7602
 
7603 7603
 /**
@@ -7651,10 +7651,10 @@  discard block
 block discarded – undo
7651 7651
         return false;
7652 7652
     }
7653 7653
 
7654
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7654
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7655 7655
 
7656 7656
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7657
-        $fp = fopen($fullPath . '/index.html', 'w');
7657
+        $fp = fopen($fullPath.'/index.html', 'w');
7658 7658
 
7659 7659
         if ($fp) {
7660 7660
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7719,7 +7719,7 @@  discard block
 block discarded – undo
7719 7719
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7720 7720
         }
7721 7721
     }
7722
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7722
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7723 7723
 
7724 7724
     // 5 = low, 1 = high
7725 7725
     $mail->Priority = 3;
@@ -7869,11 +7869,11 @@  discard block
 block discarded – undo
7869 7869
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
7870 7870
         if ($mail->SMTPDebug) {
7871 7871
             error_log(
7872
-                "Connection details :: " .
7873
-                "Protocol: " . $mail->Mailer . ' :: ' .
7874
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
7875
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
7876
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
7872
+                "Connection details :: ".
7873
+                "Protocol: ".$mail->Mailer.' :: '.
7874
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
7875
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
7876
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
7877 7877
             );
7878 7878
         }
7879 7879
         return 0;
@@ -7949,13 +7949,13 @@  discard block
 block discarded – undo
7949 7949
  * @return array
7950 7950
  *
7951 7951
  */
7952
-function api_unique_multidim_array($array, $key){
7952
+function api_unique_multidim_array($array, $key) {
7953 7953
     $temp_array = [];
7954 7954
     $i = 0;
7955 7955
     $key_array = [];
7956 7956
 
7957
-    foreach($array as $val){
7958
-        if(!in_array($val[$key],$key_array)){
7957
+    foreach ($array as $val) {
7958
+        if (!in_array($val[$key], $key_array)) {
7959 7959
             $key_array[$i] = $val[$key];
7960 7960
             $temp_array[$i] = $val;
7961 7961
         }
@@ -7999,7 +7999,7 @@  discard block
 block discarded – undo
7999 7999
         // No "dangerous" files
8000 8000
         $name = disable_dangerous_file($name);
8001 8001
 
8002
-        $pathId = '/'.substr((string)$itemId, 0, 1).'/'.$itemId.'/';
8002
+        $pathId = '/'.substr((string) $itemId, 0, 1).'/'.$itemId.'/';
8003 8003
         $path = api_get_path(SYS_UPLOAD_PATH).$type.$pathId;
8004 8004
 
8005 8005
         if (!is_dir($path)) {
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
 	 * @param string $author
268 268
 	 * @param string $filename
269 269
 	 * @param int $filesize
270
-	 * @param array $recipient_ids
270
+	 * @param unknown_type|null $recipient_ids
271 271
 	 */
272 272
 	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
Please login to merge, or discard this patch.
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
         }
77 77
     }
78 78
 
79
-	/**
80
-	 * private function creating a new work object
81
-	 *
82
-	 * @param int $uploader_id
83
-	 * @param string $title
84
-	 * @param string $description
85
-	 * @param string $author
86
-	 * @param string $filename
87
-	 * @param int $filesize
88
-	 *
89
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
-	 * 			As a consequence this parameter can be removed
91
-	 */
92
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
79
+    /**
80
+     * private function creating a new work object
81
+     *
82
+     * @param int $uploader_id
83
+     * @param string $title
84
+     * @param string $description
85
+     * @param string $author
86
+     * @param string $filename
87
+     * @param int $filesize
88
+     *
89
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
+     * 			As a consequence this parameter can be removed
91
+     */
92
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
93 93
     {
94 94
         // Fill in the properties
95 95
         $this->uploader_id = intval($uploader_id);
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
         // Check if object exists already. If it does, the old object is used
105 105
         // with updated information (authors, description, upload_date)
106 106
         $this->isOldWork = false;
107
-		$sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
107
+        $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
108 108
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
109 109
         $result = Database::query($sql);
110
-		$res = Database::fetch_array($result);
111
-		if ($res) {
112
-			$this->isOldWork = true;
113
-		}
114
-		// Insert or update the dropbox_file table and set the id property
115
-		if ($this->isOldWork) {
116
-			$this->id = $res['id'];
117
-			$this->upload_date = $res['upload_date'];
110
+        $res = Database::fetch_array($result);
111
+        if ($res) {
112
+            $this->isOldWork = true;
113
+        }
114
+        // Insert or update the dropbox_file table and set the id property
115
+        if ($this->isOldWork) {
116
+            $this->id = $res['id'];
117
+            $this->upload_date = $res['upload_date'];
118 118
 
119 119
             $params = [
120 120
                 'filesize' => $this->filesize,
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                 $params,
131 131
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
132 132
             );
133
-		} else {
134
-			$this->upload_date = $this->last_upload_date;
135
-			$params = [
133
+        } else {
134
+            $this->upload_date = $this->last_upload_date;
135
+            $params = [
136 136
                 'c_id' => $course_id,
137 137
                 'uploader_id' => $this->uploader_id,
138 138
                 'filename' => $this->filename,
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
                 'last_upload_date' => $this->last_upload_date,
145 145
                 'session_id' => api_get_session_id(),
146 146
                 'cat_id' => 0
147
-			];
147
+            ];
148 148
 
149
-			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
-			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
-				Database::query($sql);
153
-			}
154
-		}
149
+            $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
+            if ($this->id) {
151
+                $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
+                Database::query($sql);
153
+            }
154
+        }
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157 157
         		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
168
-	}
169
-
170
-	/**
171
-	 * private function creating existing object by retreiving info from db
172
-	 *
173
-	 * @param int $id
174
-	 */
175
-	public function _createExistingWork($id)
168
+    }
169
+
170
+    /**
171
+     * private function creating existing object by retreiving info from db
172
+     *
173
+     * @param int $id
174
+     */
175
+    public function _createExistingWork($id)
176 176
     {
177
-	    $course_id = api_get_course_int_id();
177
+        $course_id = api_get_course_int_id();
178 178
 
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
@@ -222,52 +222,52 @@  discard block
 block discarded – undo
222 222
             }
223 223
             $this->feedback2= $feedback2;
224 224
         }
225
-	}
225
+    }
226 226
 }
227 227
 
228 228
 class Dropbox_SentWork extends Dropbox_Work
229 229
 {
230
-	public $recipients;	//array of ['id']['name'] arrays
231
-
232
-	/**
233
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
234
-	 * depending on the number of parameters
235
-	 *
236
-	 * @param unknown_type $arg1
237
-	 * @param unknown_type $arg2
238
-	 * @param unknown_type $arg3
239
-	 * @param unknown_type $arg4
240
-	 * @param unknown_type $arg5
241
-	 * @param unknown_type $arg6
242
-	 * @param unknown_type $arg7
243
-	 * @return Dropbox_SentWork
244
-	 */
245
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
230
+    public $recipients;	//array of ['id']['name'] arrays
231
+
232
+    /**
233
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
234
+     * depending on the number of parameters
235
+     *
236
+     * @param unknown_type $arg1
237
+     * @param unknown_type $arg2
238
+     * @param unknown_type $arg3
239
+     * @param unknown_type $arg4
240
+     * @param unknown_type $arg5
241
+     * @param unknown_type $arg6
242
+     * @param unknown_type $arg7
243
+     * @return Dropbox_SentWork
244
+     */
245
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
246 246
     {
247
-		if (func_num_args() > 1) {
248
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
-		} else {
250
-			$this->_createExistingSentWork($arg1);
251
-		}
252
-	}
253
-
254
-	/**
255
-	 * private function creating a new SentWork object
256
-	 *
257
-	 * @param int $uploader_id
258
-	 * @param string $title
259
-	 * @param string $description
260
-	 * @param string $author
261
-	 * @param string $filename
262
-	 * @param int $filesize
263
-	 * @param array $recipient_ids
264
-	 */
265
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
247
+        if (func_num_args() > 1) {
248
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
+        } else {
250
+            $this->_createExistingSentWork($arg1);
251
+        }
252
+    }
253
+
254
+    /**
255
+     * private function creating a new SentWork object
256
+     *
257
+     * @param int $uploader_id
258
+     * @param string $title
259
+     * @param string $description
260
+     * @param string $author
261
+     * @param string $filename
262
+     * @param int $filesize
263
+     * @param array $recipient_ids
264
+     */
265
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
266 266
     {
267 267
         $dropbox_cnf = getDropboxConf();
268 268
         $_course = api_get_course_info();
269 269
 
270
-		// Call constructor of Dropbox_Work object
270
+        // Call constructor of Dropbox_Work object
271 271
         parent::__construct(
272 272
             $uploader_id,
273 273
             $title,
@@ -277,33 +277,33 @@  discard block
 block discarded – undo
277 277
             $filesize
278 278
         );
279 279
 
280
-		$course_id = api_get_course_int_id();
281
-
282
-		// Do sanity checks on recipient_ids array & property fillin
283
-		// The sanity check for ex-coursemembers is already done in base constructor
284
-		$uploader_id = (int) $uploader_id;
280
+        $course_id = api_get_course_int_id();
285 281
 
286
-		$justSubmit = false;
287
-		if (is_int($recipient_ids)) {
288
-			$justSubmit = true;
289
-			$recipient_ids = array($recipient_ids + $this->id);
290
-		} elseif (count($recipient_ids) == 0) {
291
-			$justSubmit = true;
292
-			$recipient_ids = array($uploader_id);
293
-		}
282
+        // Do sanity checks on recipient_ids array & property fillin
283
+        // The sanity check for ex-coursemembers is already done in base constructor
284
+        $uploader_id = (int) $uploader_id;
285
+
286
+        $justSubmit = false;
287
+        if (is_int($recipient_ids)) {
288
+            $justSubmit = true;
289
+            $recipient_ids = array($recipient_ids + $this->id);
290
+        } elseif (count($recipient_ids) == 0) {
291
+            $justSubmit = true;
292
+            $recipient_ids = array($uploader_id);
293
+        }
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
-			die(get_lang('GeneralError').' (code 209)');
297
-		}
295
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
+            die(get_lang('GeneralError').' (code 209)');
297
+        }
298 298
 
299
-		foreach ($recipient_ids as $rec) {
300
-			if (empty($rec)) {
301
-			    continue;
299
+        foreach ($recipient_ids as $rec) {
300
+            if (empty($rec)) {
301
+                continue;
302 302
             }
303 303
 
304 304
             //this check is done when validating submitted data
305
-			$this->recipients[] = array('id' => $rec);
306
-		}
305
+            $this->recipients[] = array('id' => $rec);
306
+        }
307 307
 
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         $mailId = get_mail_id_base();
314 314
 
315 315
         // Insert data in dropbox_post and dropbox_person table for each recipient
316
-		foreach ($this->recipients as $rec) {
316
+        foreach ($this->recipients as $rec) {
317 317
             $file_id = (int)$this->id;
318 318
             $user_id = (int)$rec['id'];
319
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
319
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
320 320
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
321
-	        Database::query($sql);
321
+            Database::query($sql);
322 322
             // If work already exists no error is generated
323 323
 
324 324
             /**
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
                 }
336 336
             }
337 337
 
338
-			// Update item_property table for each recipient
339
-			if (($ownerid = $this->uploader_id) > $mailId) {
340
-			    $ownerid = getUserOwningThisMailing($ownerid);
341
-			}
342
-			if (($recipid = $rec["id"]) > $mailId) {
343
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
-			}
338
+            // Update item_property table for each recipient
339
+            if (($ownerid = $this->uploader_id) > $mailId) {
340
+                $ownerid = getUserOwningThisMailing($ownerid);
341
+            }
342
+            if (($recipid = $rec["id"]) > $mailId) {
343
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
+            }
345 345
             api_item_property_update(
346 346
                 $_course,
347 347
                 TOOL_DROPBOX,
@@ -351,90 +351,90 @@  discard block
 block discarded – undo
351 351
                 null,
352 352
                 $recipid
353 353
             );
354
-		}
355
-	}
356
-
357
-	/**
358
-	 * private function creating existing object by retreiving info from db
359
-	 *
360
-	 * @param unknown_type $id
361
-	 */
362
-	public function _createExistingSentWork($id)
354
+        }
355
+    }
356
+
357
+    /**
358
+     * private function creating existing object by retreiving info from db
359
+     *
360
+     * @param unknown_type $id
361
+     */
362
+    public function _createExistingSentWork($id)
363 363
     {
364 364
         $id = intval($id);
365 365
 
366
-		$course_id = api_get_course_int_id();
366
+        $course_id = api_get_course_int_id();
367 367
 
368
-		// Call constructor of Dropbox_Work object
369
-		parent::__construct($id);
368
+        // Call constructor of Dropbox_Work object
369
+        parent::__construct($id);
370 370
 
371
-		// Fill in recipients array
372
-		$this->recipients = array();
373
-		$sql = "SELECT dest_user_id, feedback_date, feedback
371
+        // Fill in recipients array
372
+        $this->recipients = array();
373
+        $sql = "SELECT dest_user_id, feedback_date, feedback
374 374
 				FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
375 375
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
376 376
         $result = Database::query($sql);
377
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
378
-			// Check for deleted users
379
-			$dest_user_id = $res['dest_user_id'];
380
-			$user_info = api_get_user_info($dest_user_id);
381
-			//$this->category = $res['cat_id'];
382
-			if (!$user_info) {
383
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
-			} else {
385
-				$this->recipients[] = array(
377
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
378
+            // Check for deleted users
379
+            $dest_user_id = $res['dest_user_id'];
380
+            $user_info = api_get_user_info($dest_user_id);
381
+            //$this->category = $res['cat_id'];
382
+            if (!$user_info) {
383
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
+            } else {
385
+                $this->recipients[] = array(
386 386
                     'id' => $dest_user_id,
387 387
                     'name' => $user_info['complete_name'],
388 388
                     'user_id' => $dest_user_id,
389
-				    'feedback_date' => $res['feedback_date'],
389
+                    'feedback_date' => $res['feedback_date'],
390 390
                     'feedback' => $res['feedback']
391 391
                 );
392
-			}
393
-		}
394
-	}
392
+            }
393
+        }
394
+    }
395 395
 }
396 396
 
397 397
 class Dropbox_Person
398 398
 {
399
-	// The receivedWork and the sentWork arrays are sorted.
400
-	public $receivedWork;	// an array of Dropbox_Work objects
401
-	public $sentWork;		// an array of Dropbox_SentWork objects
402
-
403
-	public $userId = 0;
404
-	public $isCourseAdmin = false;
405
-	public $isCourseTutor = false;
406
-	public $_orderBy = '';	// private property that determines by which field
407
-
408
-	/**
409
-	 * Constructor for recreating the Dropbox_Person object
410
-	 *
411
-	 * @param int $userId
412
-	 * @param bool $isCourseAdmin
413
-	 * @param bool $isCourseTutor
414
-	 * @return Dropbox_Person
415
-	 */
416
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
399
+    // The receivedWork and the sentWork arrays are sorted.
400
+    public $receivedWork;	// an array of Dropbox_Work objects
401
+    public $sentWork;		// an array of Dropbox_SentWork objects
402
+
403
+    public $userId = 0;
404
+    public $isCourseAdmin = false;
405
+    public $isCourseTutor = false;
406
+    public $_orderBy = '';	// private property that determines by which field
407
+
408
+    /**
409
+     * Constructor for recreating the Dropbox_Person object
410
+     *
411
+     * @param int $userId
412
+     * @param bool $isCourseAdmin
413
+     * @param bool $isCourseTutor
414
+     * @return Dropbox_Person
415
+     */
416
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
417 417
     {
418
-	    $course_id = api_get_course_int_id();
418
+        $course_id = api_get_course_int_id();
419 419
 
420
-		// Fill in properties
420
+        // Fill in properties
421 421
         $this->userId = $userId;
422 422
         $this->isCourseAdmin = $isCourseAdmin;
423 423
         $this->isCourseTutor = $isCourseTutor;
424 424
         $this->receivedWork = array();
425 425
         $this->sentWork = array();
426 426
 
427
-		// Note: perhaps include an ex coursemember check to delete old files
427
+        // Note: perhaps include an ex coursemember check to delete old files
428 428
 
429
-		$session_id = api_get_session_id();
430
-		$condition_session = api_get_session_condition($session_id);
429
+        $session_id = api_get_session_id();
430
+        $condition_session = api_get_session_condition($session_id);
431 431
 
432
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
432
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
435 435
 
436 436
         // Find all entries where this person is the recipient
437
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
437
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
438 438
                 FROM $post_tbl r
439 439
                 INNER JOIN $person_tbl p
440 440
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
444 444
 
445 445
         $result = Database::query($sql);
446
-		while ($res = Database::fetch_array($result)) {
447
-			$temp = new Dropbox_Work($res['file_id']);
448
-			$temp->category = $res['cat_id'];
449
-			$this->receivedWork[] = $temp;
450
-		}
451
-		// Find all entries where this person is the sender/uploader
446
+        while ($res = Database::fetch_array($result)) {
447
+            $temp = new Dropbox_Work($res['file_id']);
448
+            $temp->category = $res['cat_id'];
449
+            $this->receivedWork[] = $temp;
450
+        }
451
+        // Find all entries where this person is the sender/uploader
452 452
         $sql = "SELECT DISTINCT f.id
453 453
 				FROM $file_tbl f
454 454
 				INNER JOIN $person_tbl p
@@ -459,160 +459,160 @@  discard block
 block discarded – undo
459 459
                     $condition_session
460 460
                 ";
461 461
         $result = Database::query($sql);
462
-		while ($res = Database::fetch_array($result)) {
463
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
464
-		}
465
-	}
466
-
467
-	/**
468
-	 * Deletes all the received work of this person
469
-	 */
470
-	public function deleteAllReceivedWork()
462
+        while ($res = Database::fetch_array($result)) {
463
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
464
+        }
465
+    }
466
+
467
+    /**
468
+     * Deletes all the received work of this person
469
+     */
470
+    public function deleteAllReceivedWork()
471 471
     {
472
-	    $course_id = api_get_course_int_id();
473
-		// Delete entries in person table concerning received works
474
-		foreach ($this->receivedWork as $w) {
472
+        $course_id = api_get_course_int_id();
473
+        // Delete entries in person table concerning received works
474
+        foreach ($this->receivedWork as $w) {
475 475
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
476 476
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
477
-			Database::query($sql);
478
-		}
477
+            Database::query($sql);
478
+        }
479 479
         // Check for unused files
480
-		removeUnusedFiles();
481
-	}
482
-
483
-	/**
484
-	 * Deletes all the received categories and work of this person
485
-	 * @param integer $id
486
-	 */
487
-	public function deleteReceivedWorkFolder($id)
480
+        removeUnusedFiles();
481
+    }
482
+
483
+    /**
484
+     * Deletes all the received categories and work of this person
485
+     * @param integer $id
486
+     */
487
+    public function deleteReceivedWorkFolder($id)
488 488
     {
489 489
         $course_id = api_get_course_int_id();
490 490
 
491
-		$id = intval($id);
492
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
491
+        $id = intval($id);
492
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494
-		if (!Database::query($sql)) return false;
495
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
494
+        if (!Database::query($sql)) return false;
495
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
496 496
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497
-		if (!Database::query($sql)) return false;
498
-		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
497
+        if (!Database::query($sql)) return false;
498
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
499 499
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
500
-		if (!Database::query($sql)) return false;
501
-		return true;
502
-	}
503
-
504
-	/**
505
-	 * Deletes a received dropbox file of this person with id=$id
506
-	 *
507
-	 * @param integer $id
508
-	 */
509
-	public function deleteReceivedWork($id)
500
+        if (!Database::query($sql)) return false;
501
+        return true;
502
+    }
503
+
504
+    /**
505
+     * Deletes a received dropbox file of this person with id=$id
506
+     *
507
+     * @param integer $id
508
+     */
509
+    public function deleteReceivedWork($id)
510 510
     {
511
-	    $course_id = api_get_course_int_id();
512
-		$id = intval($id);
513
-
514
-		// index check
515
-		$found = false;
516
-		foreach ($this->receivedWork as $w) {
517
-			if ($w->id == $id) {
518
-			   $found = true;
519
-			   break;
520
-			}
521
-		}
522
-
523
-		if (!$found) {
524
-			if (!$this->deleteReceivedWorkFolder($id)) {
525
-				die(get_lang('GeneralError').' (code 216)');
526
-			}
527
-		}
528
-		// Delete entries in person table concerning received works
511
+        $course_id = api_get_course_int_id();
512
+        $id = intval($id);
513
+
514
+        // index check
515
+        $found = false;
516
+        foreach ($this->receivedWork as $w) {
517
+            if ($w->id == $id) {
518
+                $found = true;
519
+                break;
520
+            }
521
+        }
522
+
523
+        if (!$found) {
524
+            if (!$this->deleteReceivedWorkFolder($id)) {
525
+                die(get_lang('GeneralError').' (code 216)');
526
+            }
527
+        }
528
+        // Delete entries in person table concerning received works
529 529
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
530 530
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
531
-		Database::query($sql);
532
-		removeUnusedFiles();	// Check for unused files
533
-	}
534
-
535
-	/**
536
-	 * Deletes all the sent dropbox files of this person
537
-	 */
538
-	public function deleteAllSentWork()
531
+        Database::query($sql);
532
+        removeUnusedFiles();	// Check for unused files
533
+    }
534
+
535
+    /**
536
+     * Deletes all the sent dropbox files of this person
537
+     */
538
+    public function deleteAllSentWork()
539 539
     {
540
-	    $course_id = api_get_course_int_id();
541
-		//delete entries in person table concerning sent works
542
-		foreach ($this->sentWork as $w) {
540
+        $course_id = api_get_course_int_id();
541
+        //delete entries in person table concerning sent works
542
+        foreach ($this->sentWork as $w) {
543 543
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
544 544
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
545
-			Database::query($sql);
546
-			removeMoreIfMailing($w->id);
547
-		}
548
-		removeUnusedFiles();	// Check for unused files
549
-	}
550
-
551
-	/**
552
-	 * Deletes a sent dropbox file of this person with id=$id
553
-	 *
554
-	 * @param unknown_type $id
555
-	 */
556
-	public function deleteSentWork($id)
545
+            Database::query($sql);
546
+            removeMoreIfMailing($w->id);
547
+        }
548
+        removeUnusedFiles();	// Check for unused files
549
+    }
550
+
551
+    /**
552
+     * Deletes a sent dropbox file of this person with id=$id
553
+     *
554
+     * @param unknown_type $id
555
+     */
556
+    public function deleteSentWork($id)
557 557
     {
558
-	    $course_id = api_get_course_int_id();
559
-
560
-		$id = intval($id);
561
-
562
-		// index check
563
-		$found = false;
564
-		foreach ($this->sentWork as $w) {
565
-			if ($w->id == $id) {
566
-			   $found = true;
567
-			   break;
568
-			}
569
-		}
570
-		if (!$found) {
571
-			if (!$this->deleteReceivedWorkFolder($id)) {
572
-				die(get_lang('GeneralError').' (code 219)');
573
-			}
574
-		}
575
-		//$file_id = $this->sentWork[$index]->id;
576
-		// Delete entries in person table concerning sent works
558
+        $course_id = api_get_course_int_id();
559
+
560
+        $id = intval($id);
561
+
562
+        // index check
563
+        $found = false;
564
+        foreach ($this->sentWork as $w) {
565
+            if ($w->id == $id) {
566
+                $found = true;
567
+                break;
568
+            }
569
+        }
570
+        if (!$found) {
571
+            if (!$this->deleteReceivedWorkFolder($id)) {
572
+                die(get_lang('GeneralError').' (code 219)');
573
+            }
574
+        }
575
+        //$file_id = $this->sentWork[$index]->id;
576
+        // Delete entries in person table concerning sent works
577 577
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
578 578
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
579
-		Database::query($sql);
580
-		removeMoreIfMailing($id);
581
-		removeUnusedFiles();	// Check for unused files
582
-	}
583
-
584
-	/**
585
-	 * Updates feedback for received work of this person with id=$id
586
-	 *
587
-	 * @param string $id
588
-	 * @param string $text
589
-	 */
590
-	public function updateFeedback($id, $text)
579
+        Database::query($sql);
580
+        removeMoreIfMailing($id);
581
+        removeUnusedFiles();	// Check for unused files
582
+    }
583
+
584
+    /**
585
+     * Updates feedback for received work of this person with id=$id
586
+     *
587
+     * @param string $id
588
+     * @param string $text
589
+     */
590
+    public function updateFeedback($id, $text)
591 591
     {
592
-	    $course_id = api_get_course_int_id();
592
+        $course_id = api_get_course_int_id();
593 593
         $_course = api_get_course_info();
594 594
         $dropbox_cnf = getDropboxConf();
595 595
 
596
-		$id = intval($id);
596
+        $id = intval($id);
597 597
 
598
-		// index check
599
-		$found = false;
600
-		$wi = -1;
601
-		foreach ($this->receivedWork as $w) {
602
-			$wi++;
603
-			if ($w->id == $id){
604
-			   $found = true;
605
-			   break;
606
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
-		}
598
+        // index check
599
+        $found = false;
600
+        $wi = -1;
601
+        foreach ($this->receivedWork as $w) {
602
+            $wi++;
603
+            if ($w->id == $id){
604
+                $found = true;
605
+                break;
606
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
+        }
608 608
 
609
-		if (!$found) {
610
-			return false;
611
-		}
609
+        if (!$found) {
610
+            return false;
611
+        }
612 612
 
613
-		$feedback_date = api_get_utc_datetime();
614
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
615
-		$this->receivedWork[$wi]->feedback = $text;
613
+        $feedback_date = api_get_utc_datetime();
614
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
615
+        $this->receivedWork[$wi]->feedback = $text;
616 616
 
617 617
         $params = [
618 618
             'feedback_date' => $feedback_date,
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
             ]
631 631
         );
632 632
 
633
-		// Update item_property table
633
+        // Update item_property table
634 634
         $mailId = get_mail_id_base();
635
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
-		    $ownerid = getUserOwningThisMailing($ownerid);
637
-		}
635
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
+            $ownerid = getUserOwningThisMailing($ownerid);
637
+        }
638 638
 
639 639
         api_item_property_update(
640 640
             $_course,
@@ -646,33 +646,33 @@  discard block
 block discarded – undo
646 646
             $ownerid
647 647
         );
648 648
 
649
-	}
649
+    }
650 650
 
651
-	/**
652
-	 * Filter the received work
653
-	 * @param string $type
654
-	 * @param string $value
655
-	 */
656
-	public function filter_received_work($type, $value)
651
+    /**
652
+     * Filter the received work
653
+     * @param string $type
654
+     * @param string $value
655
+     */
656
+    public function filter_received_work($type, $value)
657 657
     {
658 658
         $dropbox_cnf = getDropboxConf();
659
-    	$new_received_work = array();
659
+        $new_received_work = array();
660 660
         $mailId = get_mail_id_base();
661 661
         foreach ($this->receivedWork as $work) {
662
-			switch ($type) {
663
-				case 'uploader_id':
664
-					if ($work->uploader_id == $value ||
665
-						($work->uploader_id > $mailId &&
662
+            switch ($type) {
663
+                case 'uploader_id':
664
+                    if ($work->uploader_id == $value ||
665
+                        ($work->uploader_id > $mailId &&
666 666
                         getUserOwningThisMailing($work->uploader_id) == $value)
667 667
                     ) {
668
-						$new_received_work[] = $work;
669
-					}
670
-					break;
671
-				default:
672
-					$new_received_work[] = $work;
668
+                        $new_received_work[] = $work;
669
+                    }
670
+                    break;
671
+                default:
672
+                    $new_received_work[] = $work;
673 673
                     break;
674
-			}
675
-		}
676
-		$this->receivedWork = $new_received_work;
677
-	}
674
+            }
675
+        }
676
+        $this->receivedWork = $new_received_work;
677
+    }
678 678
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         // Check if object exists already. If it does, the old object is used
105 105
         // with updated information (authors, description, upload_date)
106 106
         $this->isOldWork = false;
107
-		$sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
107
+		$sql = "SELECT id, upload_date FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
108 108
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
109 109
         $result = Database::query($sql);
110 110
 		$res = Database::fetch_array($result);
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 
149 149
 			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150 150
 			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
151
+				$sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)." SET id = iid WHERE iid = {$this->id}";
152 152
 				Database::query($sql);
153 153
 			}
154 154
 		}
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157
-        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
157
+        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON)."
158 158
 				WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id;
159 159
         $result = Database::query($sql);
160 160
         $row = Database::fetch_array($result);
161 161
         if ($row['count'] == 0) {
162 162
 
163 163
             // Insert entries into person table
164
-            $sql = "INSERT INTO ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." (c_id, file_id, user_id)
164
+            $sql = "INSERT INTO ".Database::get_course_table(TABLE_DROPBOX_PERSON)." (c_id, file_id, user_id)
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
181 181
         // Do some sanity checks
182
-        $id	= intval($id);
182
+        $id = intval($id);
183 183
 
184 184
         // Get the data from DB
185 185
         $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
186
-                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
186
+                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)."
187 187
                 WHERE c_id = $course_id AND id = ".$id."";
188 188
         $result = Database::query($sql);
189 189
         $res = Database::fetch_array($result, 'ASSOC');
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         // Getting the feedback on the work.
213 213
         if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
214 214
             $feedback2 = array();
215
-            $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ."
215
+            $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)."
216 216
                     WHERE c_id = $course_id AND file_id='".$id."' 
217 217
                     ORDER BY feedback_id ASC";
218 218
             $result = Database::query($sql);
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
                 $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
221 221
                 $feedback2[] = $row_feedback;
222 222
             }
223
-            $this->feedback2= $feedback2;
223
+            $this->feedback2 = $feedback2;
224 224
         }
225 225
 	}
226 226
 }
227 227
 
228 228
 class Dropbox_SentWork extends Dropbox_Work
229 229
 {
230
-	public $recipients;	//array of ['id']['name'] arrays
230
+	public $recipients; //array of ['id']['name'] arrays
231 231
 
232 232
 	/**
233 233
 	 * Constructor calls private functions to create a new work or retreive an existing work from DB
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$recipient_ids = array($uploader_id);
293 293
 		}
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
295
+		if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
296 296
 			die(get_lang('GeneralError').' (code 209)');
297 297
 		}
298 298
 
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
310 310
         $session_id = api_get_session_id();
311
-        $user  = api_get_user_id();
311
+        $user = api_get_user_id();
312 312
         $now = api_get_utc_datetime();
313 313
         $mailId = get_mail_id_base();
314 314
 
315 315
         // Insert data in dropbox_post and dropbox_person table for each recipient
316 316
 		foreach ($this->recipients as $rec) {
317
-            $file_id = (int)$this->id;
318
-            $user_id = (int)$rec['id'];
317
+            $file_id = (int) $this->id;
318
+            $user_id = (int) $rec['id'];
319 319
 			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
320 320
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
321 321
 	        Database::query($sql);
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
                 // Do not add recipient in person table if mailing zip or just upload.
333 333
                 if (!$justSubmit) {
334
-                    Database::query($sql);	// If work already exists no error is generated
334
+                    Database::query($sql); // If work already exists no error is generated
335 335
                 }
336 336
             }
337 337
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			    $ownerid = getUserOwningThisMailing($ownerid);
341 341
 			}
342 342
 			if (($recipid = $rec["id"]) > $mailId) {
343
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
343
+			    $recipid = $ownerid; // mailing file recipient = mailing id, not a person
344 344
 			}
345 345
             api_item_property_update(
346 346
                 $_course,
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 class Dropbox_Person
398 398
 {
399 399
 	// The receivedWork and the sentWork arrays are sorted.
400
-	public $receivedWork;	// an array of Dropbox_Work objects
401
-	public $sentWork;		// an array of Dropbox_SentWork objects
400
+	public $receivedWork; // an array of Dropbox_Work objects
401
+	public $sentWork; // an array of Dropbox_SentWork objects
402 402
 
403 403
 	public $userId = 0;
404 404
 	public $isCourseAdmin = false;
405 405
 	public $isCourseTutor = false;
406
-	public $_orderBy = '';	// private property that determines by which field
406
+	public $_orderBy = ''; // private property that determines by which field
407 407
 
408 408
 	/**
409 409
 	 * Constructor for recreating the Dropbox_Person object
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	    $course_id = api_get_course_int_id();
473 473
 		// Delete entries in person table concerning received works
474 474
 		foreach ($this->receivedWork as $w) {
475
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
475
+            $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
476 476
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
477 477
 			Database::query($sql);
478 478
 		}
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
         $course_id = api_get_course_int_id();
490 490
 
491 491
 		$id = intval($id);
492
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
492
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494 494
 		if (!Database::query($sql)) return false;
495
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
495
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
496 496
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497 497
 		if (!Database::query($sql)) return false;
498 498
 		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 			}
527 527
 		}
528 528
 		// Delete entries in person table concerning received works
529
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
529
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
530 530
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
531 531
 		Database::query($sql);
532
-		removeUnusedFiles();	// Check for unused files
532
+		removeUnusedFiles(); // Check for unused files
533 533
 	}
534 534
 
535 535
 	/**
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 	    $course_id = api_get_course_int_id();
541 541
 		//delete entries in person table concerning sent works
542 542
 		foreach ($this->sentWork as $w) {
543
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
543
+            $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
544 544
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
545 545
 			Database::query($sql);
546 546
 			removeMoreIfMailing($w->id);
547 547
 		}
548
-		removeUnusedFiles();	// Check for unused files
548
+		removeUnusedFiles(); // Check for unused files
549 549
 	}
550 550
 
551 551
 	/**
@@ -574,11 +574,11 @@  discard block
 block discarded – undo
574 574
 		}
575 575
 		//$file_id = $this->sentWork[$index]->id;
576 576
 		// Delete entries in person table concerning sent works
577
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
577
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
578 578
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
579 579
 		Database::query($sql);
580 580
 		removeMoreIfMailing($id);
581
-		removeUnusedFiles();	// Check for unused files
581
+		removeUnusedFiles(); // Check for unused files
582 582
 	}
583 583
 
584 584
 	/**
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		$wi = -1;
601 601
 		foreach ($this->receivedWork as $w) {
602 602
 			$wi++;
603
-			if ($w->id == $id){
603
+			if ($w->id == $id) {
604 604
 			   $found = true;
605 605
 			   break;
606 606
 			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -491,13 +491,19 @@
 block discarded – undo
491 491
 		$id = intval($id);
492 492
 		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494
-		if (!Database::query($sql)) return false;
494
+		if (!Database::query($sql)) {
495
+		    return false;
496
+		}
495 497
 		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
496 498
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497
-		if (!Database::query($sql)) return false;
499
+		if (!Database::query($sql)) {
500
+		    return false;
501
+		}
498 502
 		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
499 503
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
500
-		if (!Database::query($sql)) return false;
504
+		if (!Database::query($sql)) {
505
+		    return false;
506
+		}
501 507
 		return true;
502 508
 	}
503 509
 
Please login to merge, or discard this patch.
plugin/courseblock/install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For license terms, see /license.txt */
3 3
 
4
-require_once dirname(__FILE__) . '/config.php';
4
+require_once dirname(__FILE__).'/config.php';
5 5
 
6 6
 if (!api_is_platform_admin()) {
7 7
     die ('You must have admin permissions to install plugins');
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/Message.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@
 block discarded – undo
314 314
      * Set votes
315 315
      *
316 316
      * @param integer $votes
317
-     * @return integer
317
+     * @return Message
318 318
      */
319 319
     public function setVotes($votes)
320 320
     {
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/SkillRelUserComment.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
 
115 115
     /**
116 116
      * Get feedbackDateTime
117
-     * @return type
117
+     * @return \DateTime
118 118
      */
119 119
     public function getFeedbackDateTime()
120 120
     {
Please login to merge, or discard this patch.
main/inc/lib/surveymanager.lib.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
         $res = Database::query($sql);
48 48
         $refs = array();
49 49
         $list = array();
50
-        $plain_array=array();
50
+        $plain_array = array();
51 51
 
52 52
         while ($survey = Database::fetch_array($res, 'ASSOC')) {
53
-            $plain_array[$survey['survey_id']]=$survey;
54
-            $surveys_parents[]=$survey['survey_version'];
55
-            $thisref = &$refs[ $survey['survey_id'] ];
53
+            $plain_array[$survey['survey_id']] = $survey;
54
+            $surveys_parents[] = $survey['survey_version'];
55
+            $thisref = &$refs[$survey['survey_id']];
56 56
             $thisref['parent_id'] = $survey['parent_id'];
57 57
             $thisref['name'] = $survey['name'];
58 58
             $thisref['id'] = $survey['survey_id'];
59 59
             $thisref['survey_version'] = $survey['survey_version'];
60 60
             if ($survey['parent_id'] == 0) {
61
-                $list[ $survey['survey_id'] ] = &$thisref;
61
+                $list[$survey['survey_id']] = &$thisref;
62 62
             } else {
63
-                $refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
63
+                $refs[$survey['parent_id']]['children'][$survey['survey_id']] = &$thisref;
64 64
             }
65 65
         }
66 66
         $this->surveylist = $list;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     public function getParentId($id)
80 80
     {
81 81
         $node = $this->plainsurveylist[$id];
82
-        if (is_array($node)&& !empty($node['parent_id'])) {
82
+        if (is_array($node) && !empty($node['parent_id'])) {
83 83
             return $node['parent_id'];
84 84
         } else {
85 85
             return -1;
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         if (is_array($list)) {
100 100
             foreach ($list as $key => $node) {
101 101
                 if (isset($node['children']) && is_array($node['children'])) {
102
-                    $result[$key]= $node['name'];
102
+                    $result[$key] = $node['name'];
103 103
                     $re = self::createList($node['children']);
104 104
                     if (!empty($re)) {
105 105
                         if (is_array($re)) {
106 106
                             foreach ($re as $key => $r) {
107
-                                $result[$key] = '' . $r;
107
+                                $result[$key] = ''.$r;
108 108
                             }
109 109
                         } else {
110 110
                             $result[] = $re;
Please login to merge, or discard this patch.