Completed
Push — 1.10.x ( f55f3b...22bf41 )
by Yannick
707:00 queued 656:35
created
main/coursecopy/classes/QuizQuestion.class.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@
 block discarded – undo
115 115
         $this->answers[] = $answer;
116 116
     }
117 117
 
118
+    /**
119
+     * @param QuizQuestionOption $option_obj
120
+     */
118 121
     public function add_option($option_obj)
119 122
     {
120 123
         $this->question_options[$option_obj->obj->id] = $option_obj;
Please login to merge, or discard this patch.
main/coursecopy/classes/Resource.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
128 128
 
129 129
     /**
130 130
      * Resturns the type of this resource
131
-     * @return constant The type.
131
+     * @return integer The type.
132 132
      */
133 133
     public function get_type()
134 134
     {
Please login to merge, or discard this patch.
main/coursecopy/copy_course_session_selected.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@
 block discarded – undo
65 65
 
66 66
 /* FUNCTIONS */
67 67
 
68
+/**
69
+ * @param string $name
70
+ */
68 71
 function make_select_session_list($name, $sessions, $attr = array())
69 72
 {
70 73
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 $nameTools = get_lang('CopyCourse');
49 49
 $returnLink = api_get_path(
50 50
         WEB_CODE_PATH
51
-    ) . 'course_info/maintenance_coach.php?' . api_get_cidreq();
51
+    ).'course_info/maintenance_coach.php?'.api_get_cidreq();
52 52
 $interbreadcrumb[] = array(
53 53
     'url' => $returnLink,
54 54
     'name' => get_lang('Maintenance')
@@ -71,29 +71,29 @@  discard block
 block discarded – undo
71 71
     $attrs = '';
72 72
     if (count($attr) > 0) {
73 73
         foreach ($attr as $key => $value) {
74
-            $attrs .= ' ' . $key . '="' . $value . '"';
74
+            $attrs .= ' '.$key.'="'.$value.'"';
75 75
         }
76 76
     }
77
-    $output = '<select name="' . $name . '" ' . $attrs . '>';
77
+    $output = '<select name="'.$name.'" '.$attrs.'>';
78 78
 
79 79
     if (count($sessions) == 0) {
80
-        $output .= '<option value = "0">' . get_lang(
80
+        $output .= '<option value = "0">'.get_lang(
81 81
                 'ThereIsNotStillASession'
82
-            ) . '</option>';
82
+            ).'</option>';
83 83
     } else {
84
-        $output .= '<option value = "0">' . get_lang(
84
+        $output .= '<option value = "0">'.get_lang(
85 85
                 'SelectASession'
86
-            ) . '</option>';
86
+            ).'</option>';
87 87
     }
88 88
 
89 89
     if (is_array($sessions)) {
90 90
         foreach ($sessions as $session) {
91 91
             $category_name = '';
92 92
             if (!empty($session['category_name'])) {
93
-                $category_name = ' (' . $session['category_name'] . ')';
93
+                $category_name = ' ('.$session['category_name'].')';
94 94
             }
95 95
 
96
-            $output .= '<option value="' . $session['id'] . '">' . $session['name'] . ' ' . $category_name . '</option>';
96
+            $output .= '<option value="'.$session['id'].'">'.$session['name'].' '.$category_name.'</option>';
97 97
         }
98 98
     }
99 99
     $output .= '</select>';
@@ -118,43 +118,43 @@  discard block
 block discarded – undo
118 118
     // Actions
119 119
     $html .= '<div class="actions">';
120 120
     // Link back to the documents overview
121
-    $html .= '<a href="' . $returnLink . '">' . Display::return_icon(
122
-            'back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM
123
-        ) . '</a>';
121
+    $html .= '<a href="'.$returnLink.'">'.Display::return_icon(
122
+            'back.png', get_lang('BackTo').' '.get_lang('Maintenance'), '', ICON_SIZE_MEDIUM
123
+        ).'</a>';
124 124
     $html .= '</div>';
125 125
 
126 126
     $html .= Display::return_message(
127 127
             get_lang('CopyCourseFromSessionToSessionExplanation')
128 128
     );
129 129
 
130
-    $html .= '<form name="formulaire" method="post" action="' . api_get_self(
131
-        ) . '?' . api_get_cidreq() . '" >';
130
+    $html .= '<form name="formulaire" method="post" action="'.api_get_self(
131
+        ).'?'.api_get_cidreq().'" >';
132 132
     $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
133 133
 
134 134
     // Source
135
-    $html .= '<tr><td width="15%"><b>' . get_lang(
135
+    $html .= '<tr><td width="15%"><b>'.get_lang(
136 136
             'OriginCoursesFromSession'
137
-        ) . ':</b></td>';
138
-    $html .= '<td width="10%" align="left">' . api_get_session_name(
137
+        ).':</b></td>';
138
+    $html .= '<td width="10%" align="left">'.api_get_session_name(
139 139
             $sessionId
140
-        ) . '</td>';
140
+        ).'</td>';
141 141
     $html .= '<td width="50%">';
142
-    $html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>';
142
+    $html .= "{$courseInfo['title']} ({$courseInfo['code']})".'</td></tr>';
143 143
 
144 144
     // Destination
145
-    $html .= '<tr><td width="15%"><b>' . get_lang(
145
+    $html .= '<tr><td width="15%"><b>'.get_lang(
146 146
             'DestinationCoursesFromSession'
147
-        ) . ':</b></td>';
147
+        ).':</b></td>';
148 148
     $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">';
149 149
     $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">';
150 150
     if (empty($sessions)) {
151
-        $html .= '<option value = "0">' . get_lang(
151
+        $html .= '<option value = "0">'.get_lang(
152 152
                 'ThereIsNotStillASession'
153
-            ) . '</option>';
153
+            ).'</option>';
154 154
     } else {
155
-        $html .= '<option value = "0">' . get_lang(
155
+        $html .= '<option value = "0">'.get_lang(
156 156
                 'SelectASession'
157
-            ) . '</option>';
157
+            ).'</option>';
158 158
         foreach ($sessions as $session) {
159 159
             if ($session['id'] == $sessionId) {
160 160
                 continue;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 continue;
165 165
             }
166 166
 
167
-            $html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>';
167
+            $html .= '<option value="'.$session['id'].'">'.$session['name'].'</option>';
168 168
         }
169 169
     }
170 170
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
     $html .= '</tr></table>';
177 177
 
178 178
     $html .= "<fieldset>";
179
-    $html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>';
179
+    $html .= '<legend>'.get_lang('TypeOfCopy').' <small>('.get_lang('CopyOnlySessionItems').')</small></legend>';
180 180
     $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
181
-    $html .= get_lang('FullCopy') . '</label>';
181
+    $html .= get_lang('FullCopy').'</label>';
182 182
     $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>';
183
-    $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>';
183
+    $html .= ' '.get_lang('LetMeSelectItems').'</label><br/>';
184 184
 
185 185
     $html .= "</fieldset>";
186 186
 
187
-    $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(
187
+    $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(
188 188
             api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)
189
-        ) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>';
189
+        )."'".')) return false;">'.get_lang('CopyCourse').'</button>';
190 190
     $html .= '</form>';
191 191
     echo $html;
192 192
 }
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 
213 213
             $courseTitle = str_replace("'", "\'", $course['title']);
214 214
 
215
-            $return .= '<option value="' . $course['code'] . '" title="' . @htmlspecialchars(
216
-                    $course['title'] . ' (' . $course['visual_code'] . ')', ENT_QUOTES, api_get_system_encoding()
217
-                ) . '">' .
218
-                $course['title'] . ' (' . $course['visual_code'] . ')</option>';
215
+            $return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars(
216
+                    $course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding()
217
+                ).'">'.
218
+                $course['title'].' ('.$course['visual_code'].')</option>';
219 219
         }
220 220
         $return .= '</select>';
221 221
         $_SESSION['course_list_destination'] = $course_list_destination;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 /* HTML head extra */
234 234
 
235 235
 $htmlHeadXtra[] = $xajax->getJavascript(
236
-    api_get_path(WEB_LIBRARY_PATH) . 'xajax/'
236
+    api_get_path(WEB_LIBRARY_PATH).'xajax/'
237 237
 );
238 238
 $htmlHeadXtra[] = '<script>
239 239
 	function checkSelected(id_select,id_radio,id_title,id_destination) {
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 
379 379
         CourseSelectForm :: display_form($course, $hiddenFields, true);
380 380
 
381
-        echo '<div style="float:right"><a href="javascript:window.history.go(-1);">' .
381
+        echo '<div style="float:right"><a href="javascript:window.history.go(-1);">'.
382 382
             Display::return_icon(
383
-                'back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang(
383
+                'back.png', get_lang('Back').' '.get_lang('To').' '.get_lang(
384 384
                     'PlatformAdmin'
385 385
                 ), array('style' => 'vertical-align:middle')
386
-            ) .
387
-            get_lang('Back') . '</a></div>';
386
+            ).
387
+            get_lang('Back').'</a></div>';
388 388
     } else {
389 389
         Display::display_error_message(
390 390
             get_lang('You must select a course from original session and select a destination session')
Please login to merge, or discard this patch.
main/cron/create_course_sessions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -50,6 +50,7 @@  discard block
 block discarded – undo
50 50
 /**
51 51
  * Returns a quarter from a month
52 52
  * @param   string  The month (digit), with or without leading 0
53
+ * @param string $month
53 54
  * @return  int The yearly quarter (1, 2, 3 or 4) in which this month lies
54 55
  */
55 56
 function getQuarter($month)
@@ -96,6 +97,7 @@  discard block
 block discarded – undo
96 97
 /**
97 98
  * Returns the first month of the quarter
98 99
  * @param   int Quarter
100
+ * @param integer $quarter
99 101
  * @return  string Number of the month, with leading 0
100 102
  */
101 103
 function getQuarterFirstMonth($quarter)
@@ -116,6 +118,7 @@  discard block
 block discarded – undo
116 118
 /**
117 119
  * Get the quarter in Roman letters
118 120
  * @param   int Quarter
121
+ * @param integer $quarter
119 122
  * @return  string  Roman letters
120 123
  */
121 124
 function getQuarterRoman($quarter)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     exit; //do not run from browser
15 15
 }
16 16
 
17
-require_once __DIR__ . "/../inc/global.inc.php";
17
+require_once __DIR__."/../inc/global.inc.php";
18 18
 
19 19
 // First day of the current month to create sessions and add courses for the next month (e.g. "07")
20 20
 define("OFFSET", "15");
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 {
42 42
     $startDate = $initialDate ? $initialDate : date("Y-m-01");
43 43
     $month = getQuarterFirstMonth(getQuarter(date('m', $startDate)));
44
-    $startDate = substr($startDate, 0, 5) . $month . '-01';
44
+    $startDate = substr($startDate, 0, 5).$month.'-01';
45 45
     $nextQuarterStartDate = date('Y-m-d', api_strtotime($startDate.' + 3 month'));
46 46
     $endDate = date('Y-m-d', api_strtotime($nextQuarterStartDate.' - 1 minute'));
47 47
     return array('startDate' => $startDate, 'endDate' => $endDate);
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
 {
146 146
     echo "\n";
147 147
     echo $courses ?
148
-        "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate :
149
-        "Every course is already in session for the period between ".$startDate." and ".$endDate;
148
+        "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate : "Every course is already in session for the period between ".$startDate." and ".$endDate;
150 149
     echo "\n=====================================================================================\n\n";
151 150
     // Loop through courses creating one session per each and adding them
152 151
     foreach ($courses as $course) {
@@ -155,8 +154,8 @@  discard block
 block discarded – undo
155 154
         $year = date("Y", api_strtotime($startDate));
156 155
         $quarter = getQuarter($month);
157 156
         $quarter = getQuarterRoman($quarter);
158
-        $period = $year . '-' . $quarter;
159
-        $sessionName = '[' . $period . '] ' . $course['title'];
157
+        $period = $year.'-'.$quarter;
158
+        $sessionName = '['.$period.'] '.$course['title'];
160 159
         $sessionId = SessionManager::create_session(
161 160
             $sessionName,
162 161
             $startDate,
@@ -175,7 +174,7 @@  discard block
 block discarded – undo
175 174
 }
176 175
 
177 176
 // Starts the script
178
-echo "Starting process..." . PHP_EOL;
177
+echo "Starting process...".PHP_EOL;
179 178
 // Get first active administrator
180 179
 $administrators = array_reverse(UserManager::get_all_administrators());
181 180
 $lastingAdministrators = count($administrators);
@@ -196,7 +195,7 @@  discard block
 block discarded – undo
196 195
 
197 196
 // Creates course sessions for the following month
198 197
 $offsetDay = intval(substr($dates['endDate'], 8, 2)) - OFFSET;
199
-if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8) . $offsetDay)) {
198
+if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8).$offsetDay)) {
200 199
     $dates = getQuarterFirstAndLastDates(date("Y-m-d", api_strtotime(date("Y-m-01")." + 3 month")));
201 200
     // Get courses that don't have any session the next month
202 201
     $courses = CourseManager::getCoursesWithoutSession($dates['startDate'], $dates['endDate']);
Please login to merge, or discard this patch.
main/cron/import_csv.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public $conditions;
49 49
 
50 50
     /**
51
-     * @param Logger $logger
51
+     * @param Monolog\Logger $logger
52 52
      * @param array
53 53
      */
54 54
     public function __construct($logger, $conditions)
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     /**
69
-     * @return mixed
69
+     * @return boolean
70 70
      */
71 71
     public function getDumpValues()
72 72
     {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-if (PHP_SAPI !='cli') {
4
+if (PHP_SAPI != 'cli') {
5 5
     die('Run this script through the command line or comment this line in the code');
6 6
 }
7 7
 
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
                 $row = $this->cleanUserRow($row);
366 366
 
367 367
                 $user_id = UserManager::get_user_id_from_original_id(
368
-                    $row['extra_' . $this->extraFieldIdNameList['user']],
368
+                    $row['extra_'.$this->extraFieldIdNameList['user']],
369 369
                     $this->extraFieldIdNameList['user']
370 370
                 );
371
-                $userInfo  = array();
372
-                $userInfoByOfficialCode  = null;
371
+                $userInfo = array();
372
+                $userInfoByOfficialCode = null;
373 373
 
374 374
                 if (!empty($user_id)) {
375 375
                     $userInfo = api_get_user_info($user_id);
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                     $result = UserManager::update_user(
424 424
                         $userInfo['user_id'],
425 425
                         $row['firstname'], // <<-- changed
426
-                        $row['lastname'],  // <<-- changed
426
+                        $row['lastname'], // <<-- changed
427 427
                         $userInfo['username'],
428 428
                         null, //$password = null,
429 429
                         $row['auth_source'],
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
                     if ($row['action'] == 'delete') {
559 559
                         // Inactive one year later
560
-                        $userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365*24*60*60));
560
+                        $userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365 * 24 * 60 * 60));
561 561
                     }
562 562
 
563 563
                     $password = $row['password']; // change password
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
                     $result = UserManager::update_user(
607 607
                         $userInfo['user_id'],
608 608
                         $row['firstname'], // <<-- changed
609
-                        $row['lastname'],  // <<-- changed
610
-                        $row['username'],  // <<-- changed
609
+                        $row['lastname'], // <<-- changed
610
+                        $row['username'], // <<-- changed
611 611
                         $password, //$password = null,
612 612
                         $row['auth_source'],
613 613
                         $email,
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         $data = Import::csv_to_array($file);
675 675
 
676 676
         if (!empty($data)) {
677
-            $this->logger->addInfo(count($data) . " records found.");
677
+            $this->logger->addInfo(count($data)." records found.");
678 678
             $eventsToCreate = array();
679 679
             $errorFound = false;
680 680
             foreach ($data as $row) {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                     );
689 689
                 }
690 690
 
691
-                $courseCode  = null;
691
+                $courseCode = null;
692 692
                 if (isset($row['coursecode'])) {
693 693
                     $courseCode = $row['coursecode'];
694 694
                 }
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                 }
743 743
 
744 744
                 $date = $row['date'];
745
-                $startTime  = $row['time_start'];
745
+                $startTime = $row['time_start'];
746 746
                 $endTime = $row['time_end'];
747 747
                 $title = $row['title'];
748 748
                 $comment = $row['comment'];
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 $row = $this->cleanCourseRow($row);
967 967
 
968 968
                 $courseId = CourseManager::get_course_id_from_original_id(
969
-                    $row['extra_' . $this->extraFieldIdNameList['course']],
969
+                    $row['extra_'.$this->extraFieldIdNameList['course']],
970 970
                     $this->extraFieldIdNameList['course']
971 971
                 );
972 972
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
         $data = Import::csv_reader($file);
1085 1085
 
1086 1086
         if (!empty($data)) {
1087
-            $this->logger->addInfo(count($data) . " records found.");
1087
+            $this->logger->addInfo(count($data)." records found.");
1088 1088
             foreach ($data as $row) {
1089 1089
                 $chamiloUserName = $row['UserName'];
1090 1090
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                 );
1127 1127
 
1128 1128
                 $this->logger->addError(
1129
-                    "User '$chamiloUserName' was remove from Session: #$chamiloSessionId - Course: " . $courseInfo['code']
1129
+                    "User '$chamiloUserName' was remove from Session: #$chamiloSessionId - Course: ".$courseInfo['code']
1130 1130
                 );
1131 1131
 
1132 1132
             }
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
         $data = Import::csv_reader($file);
1144 1144
 
1145 1145
         if (!empty($data)) {
1146
-            $this->logger->addInfo(count($data) . " records found.");
1146
+            $this->logger->addInfo(count($data)." records found.");
1147 1147
             foreach ($data as $row) {
1148 1148
                 $chamiloUserName = $row['UserName'];
1149 1149
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
                 }
1199 1199
 
1200 1200
                 $this->logger->addError(
1201
-                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: " . $courseInfo['code']
1201
+                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: ".$courseInfo['code']
1202 1202
                 );
1203 1203
             }
1204 1204
         }
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
     private function importSessions($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array())
1443 1443
     {
1444
-        $avoid =  null;
1444
+        $avoid = null;
1445 1445
         if (isset($this->conditions['importSessions']) &&
1446 1446
             isset($this->conditions['importSessions']['update'])
1447 1447
         ) {
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
         $data = Import::csv_reader($file);
1487 1487
 
1488 1488
         if (!empty($data)) {
1489
-            $this->logger->addInfo(count($data) . " records found.");
1489
+            $this->logger->addInfo(count($data)." records found.");
1490 1490
             foreach ($data as $row) {
1491 1491
                 $chamiloUserName = $row['UserName'];
1492 1492
                 $chamiloCourseCode = $row['CourseCode'];
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
                 }
1534 1534
 
1535 1535
                 $this->logger->addError(
1536
-                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: " . $courseInfo['code']
1536
+                    "User '$chamiloUserName' with status $type was added to session: #$chamiloSessionId - Course: ".$courseInfo['code']
1537 1537
                 );
1538 1538
             }
1539 1539
         }
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param string $author
267 267
 	 * @param string $filename
268 268
 	 * @param int $filesize
269
-	 * @param array $recipient_ids
269
+	 * @param unknown_type|null $recipient_ids
270 270
 	 */
271 271
 	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
272 272
     {
@@ -584,6 +584,7 @@  discard block
 block discarded – undo
584 584
 
585 585
 	/**
586 586
 	 * Deletes all the received categories and work of this person
587
+	 * @param integer $id
587 588
 	 */
588 589
 	function deleteReceivedWorkFolder($id)
589 590
     {
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $action = isset($_GET['action']) ? $_GET['action'] : null;
185 185
 
186 186
         // Do some sanity checks
187
-        $id	= intval($id);
187
+        $id = intval($id);
188 188
 
189 189
         // Get the data from DB
190 190
         $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
                 $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
227 227
                 $feedback2[] = $row_feedback;
228 228
             }
229
-            $this->feedback2= $feedback2;
229
+            $this->feedback2 = $feedback2;
230 230
         }
231 231
 	}
232 232
 }
233 233
 
234 234
 class Dropbox_SentWork extends Dropbox_Work
235 235
 {
236
-	public $recipients;	//array of ['id']['name'] arrays
236
+	public $recipients; //array of ['id']['name'] arrays
237 237
 
238 238
 	/**
239 239
 	 * Constructor calls private functions to create a new work or retreive an existing work from DB
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
291 291
 
292 292
 		$justSubmit = false;
293
-		if ( is_int($recipient_ids)) {
293
+		if (is_int($recipient_ids)) {
294 294
 			$justSubmit = true;
295 295
 			$recipient_ids = array($recipient_ids + $this->id);
296
-		} elseif ( count($recipient_ids) == 0) {
296
+		} elseif (count($recipient_ids) == 0) {
297 297
 			$justSubmit = true;
298 298
 			$recipient_ids = array($uploader_id);
299 299
 		}
300 300
 
301
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
301
+		if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
302 302
 			die(get_lang('GeneralError').' (code 209)');
303 303
 		}
304 304
 
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
         $table_person = $dropbox_cnf['tbl_person'];
314 314
         $session_id = api_get_session_id();
315 315
         $uploader_id = $this->uploader_id;
316
-        $user  = api_get_user_id();
316
+        $user = api_get_user_id();
317 317
 		// Insert data in dropbox_post and dropbox_person table for each recipient
318 318
 		foreach ($this->recipients as $rec) {
319
-            $file_id = (int)$this->id;
320
-            $user_id = (int)$rec['id'];
319
+            $file_id = (int) $this->id;
320
+            $user_id = (int) $rec['id'];
321 321
 			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id)
322 322
                     VALUES ($course_id, $file_id, $user_id, $session_id)";
323 323
 	        Database::query($sql);
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                 // Do not add recipient in person table if mailing zip or just upload.
335 335
                 if (!$justSubmit) {
336
-                    Database::query($sql);	// If work already exists no error is generated
336
+                    Database::query($sql); // If work already exists no error is generated
337 337
                 }
338 338
             }
339 339
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			    $ownerid = getUserOwningThisMailing($ownerid);
343 343
 			}
344 344
 			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
345
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
345
+			    $recipid = $ownerid; // mailing file recipient = mailing id, not a person
346 346
 			}
347 347
             api_item_property_update(
348 348
                 $_course,
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 class Dropbox_Person
402 402
 {
403 403
 	// The receivedWork and the sentWork arrays are sorted.
404
-	public $receivedWork;	// an array of Dropbox_Work objects
405
-	public $sentWork;		// an array of Dropbox_SentWork objects
404
+	public $receivedWork; // an array of Dropbox_Work objects
405
+	public $sentWork; // an array of Dropbox_SentWork objects
406 406
 
407 407
 	public $userId = 0;
408 408
 	public $isCourseAdmin = false;
409 409
 	public $isCourseTutor = false;
410
-	public $_orderBy = '';	// private property that determines by which field
410
+	public $_orderBy = ''; // private property that determines by which field
411 411
 
412 412
 	/**
413 413
 	 * Constructor for recreating the Dropbox_Person object
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 */
507 507
 	function orderSentWork($sort)
508 508
     {
509
-		switch($sort) {
509
+		switch ($sort) {
510 510
 			case 'lastDate':
511 511
 				$this->_orderBy = 'last_upload_date';
512 512
 				break;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 */
540 540
 	function orderReceivedWork($sort)
541 541
     {
542
-		switch($sort) {
542
+		switch ($sort) {
543 543
 			case 'lastDate':
544 544
 				$this->_orderBy = 'last_upload_date';
545 545
 				break;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
633 633
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
634 634
 		Database::query($sql);
635
-		removeUnusedFiles();	// Check for unused files
635
+		removeUnusedFiles(); // Check for unused files
636 636
 	}
637 637
 
638 638
 	/**
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 			Database::query($sql);
650 650
 			removeMoreIfMailing($w->id);
651 651
 		}
652
-		removeUnusedFiles();	// Check for unused files
652
+		removeUnusedFiles(); // Check for unused files
653 653
 	}
654 654
 
655 655
 	/**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
684 684
 		Database::query($sql);
685 685
 		removeMoreIfMailing($id);
686
-		removeUnusedFiles();	// Check for unused files
686
+		removeUnusedFiles(); // Check for unused files
687 687
 	}
688 688
 
689 689
 	/**
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 		$wi = -1;
706 706
 		foreach ($this->receivedWork as $w) {
707 707
 			$wi++;
708
-			if ($w->id == $id){
708
+			if ($w->id == $id) {
709 709
 			   $found = true;
710 710
 			   break;
711 711
 			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -303,7 +303,9 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		foreach ($recipient_ids as $rec) {
306
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
306
+			if (empty($rec)) {
307
+			    die(get_lang('GeneralError').' (code 210)');
308
+			}
307 309
 			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
308 310
 				//this check is done when validating submitted data
309 311
 			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
@@ -593,13 +595,19 @@  discard block
 block discarded – undo
593 595
 		$id = intval($id);
594 596
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
595 597
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
596
-		if (!Database::query($sql)) return false;
598
+		if (!Database::query($sql)) {
599
+		    return false;
600
+		}
597 601
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
598 602
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
599
-		if (!Database::query($sql)) return false;
603
+		if (!Database::query($sql)) {
604
+		    return false;
605
+		}
600 606
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
601 607
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
602
-		if (!Database::query($sql)) return false;
608
+		if (!Database::query($sql)) {
609
+		    return false;
610
+		}
603 611
 		return true;
604 612
 	}
605 613
 
Please login to merge, or discard this patch.
Indentation   +421 added lines, -421 removed lines patch added patch discarded remove patch
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
         }
78 78
     }
79 79
 
80
-	/**
81
-	 * private function creating a new work object
82
-	 *
83
-	 * @param int $uploader_id
84
-	 * @param string $title
85
-	 * @param string $description
86
-	 * @param string $author
87
-	 * @param string $filename
88
-	 * @param int $filesize
89
-	 *
90
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
91
-	 * 			As a consequence this parameter can be removed
92
-	 */
93
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
80
+    /**
81
+     * private function creating a new work object
82
+     *
83
+     * @param int $uploader_id
84
+     * @param string $title
85
+     * @param string $description
86
+     * @param string $author
87
+     * @param string $filename
88
+     * @param int $filesize
89
+     *
90
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
91
+     * 			As a consequence this parameter can be removed
92
+     */
93
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
94 94
     {
95 95
         $dropbox_cnf = getDropboxConf();
96 96
 
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
         // Check if object exists already. If it does, the old object is used
109 109
         // with updated information (authors, description, upload_date)
110 110
         $this->isOldWork = false;
111
-		$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
111
+        $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
112 112
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
113 113
         $result = Database::query($sql);
114
-		$res = Database::fetch_array($result);
115
-		if ($res) {
116
-			$this->isOldWork = true;
117
-		}
118
-		// Insert or update the dropbox_file table and set the id property
119
-		if ($this->isOldWork) {
120
-			$this->id = $res['id'];
121
-			$this->upload_date = $res['upload_date'];
114
+        $res = Database::fetch_array($result);
115
+        if ($res) {
116
+            $this->isOldWork = true;
117
+        }
118
+        // Insert or update the dropbox_file table and set the id property
119
+        if ($this->isOldWork) {
120
+            $this->id = $res['id'];
121
+            $this->upload_date = $res['upload_date'];
122 122
 
123 123
             $params = [
124 124
                 'filesize' => $this->filesize,
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
136 136
             );
137 137
 
138
-		} else {
139
-			$this->upload_date = $this->last_upload_date;
140
-			$params = [
138
+        } else {
139
+            $this->upload_date = $this->last_upload_date;
140
+            $params = [
141 141
                 'c_id' => $course_id,
142 142
                 'uploader_id' => $this->uploader_id,
143 143
                 'filename' => $this->filename,
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
                 'last_upload_date' => $this->last_upload_date,
150 150
                 'session_id' => api_get_session_id(),
151 151
                 'cat_id' => 0
152
-			];
152
+            ];
153 153
 
154
-			$this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
155
-			if ($this->id) {
156
-				$sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
157
-				Database::query($sql);
158
-			}
159
-		}
154
+            $this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
155
+            if ($this->id) {
156
+                $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
157
+                Database::query($sql);
158
+            }
159
+        }
160 160
 
161 161
         $sql = "SELECT count(file_id) as count
162 162
         		FROM ".$dropbox_cnf['tbl_person']."
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
171 171
             Database::query($sql);
172 172
         }
173
-	}
174
-
175
-	/**
176
-	 * private function creating existing object by retreiving info from db
177
-	 *
178
-	 * @param int $id
179
-	 */
180
-	public function _createExistingWork($id)
173
+    }
174
+
175
+    /**
176
+     * private function creating existing object by retreiving info from db
177
+     *
178
+     * @param int $id
179
+     */
180
+    public function _createExistingWork($id)
181 181
     {
182
-	    $course_id = api_get_course_int_id();
182
+        $course_id = api_get_course_int_id();
183 183
         $dropbox_cnf = getDropboxConf();
184 184
 
185 185
         $action = isset($_GET['action']) ? $_GET['action'] : null;
@@ -229,52 +229,52 @@  discard block
 block discarded – undo
229 229
             }
230 230
             $this->feedback2= $feedback2;
231 231
         }
232
-	}
232
+    }
233 233
 }
234 234
 
235 235
 class Dropbox_SentWork extends Dropbox_Work
236 236
 {
237
-	public $recipients;	//array of ['id']['name'] arrays
238
-
239
-	/**
240
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
241
-	 * depending on the number of parameters
242
-	 *
243
-	 * @param unknown_type $arg1
244
-	 * @param unknown_type $arg2
245
-	 * @param unknown_type $arg3
246
-	 * @param unknown_type $arg4
247
-	 * @param unknown_type $arg5
248
-	 * @param unknown_type $arg6
249
-	 * @param unknown_type $arg7
250
-	 * @return Dropbox_SentWork
251
-	 */
252
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
237
+    public $recipients;	//array of ['id']['name'] arrays
238
+
239
+    /**
240
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
241
+     * depending on the number of parameters
242
+     *
243
+     * @param unknown_type $arg1
244
+     * @param unknown_type $arg2
245
+     * @param unknown_type $arg3
246
+     * @param unknown_type $arg4
247
+     * @param unknown_type $arg5
248
+     * @param unknown_type $arg6
249
+     * @param unknown_type $arg7
250
+     * @return Dropbox_SentWork
251
+     */
252
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
253 253
     {
254
-		if (func_num_args() > 1) {
255
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
256
-		} else {
257
-			$this->_createExistingSentWork($arg1);
258
-		}
259
-	}
260
-
261
-	/**
262
-	 * private function creating a new SentWork object
263
-	 *
264
-	 * @param int $uploader_id
265
-	 * @param string $title
266
-	 * @param string $description
267
-	 * @param string $author
268
-	 * @param string $filename
269
-	 * @param int $filesize
270
-	 * @param array $recipient_ids
271
-	 */
272
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
254
+        if (func_num_args() > 1) {
255
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
256
+        } else {
257
+            $this->_createExistingSentWork($arg1);
258
+        }
259
+    }
260
+
261
+    /**
262
+     * private function creating a new SentWork object
263
+     *
264
+     * @param int $uploader_id
265
+     * @param string $title
266
+     * @param string $description
267
+     * @param string $author
268
+     * @param string $filename
269
+     * @param int $filesize
270
+     * @param array $recipient_ids
271
+     */
272
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
274 274
         $dropbox_cnf = getDropboxConf();
275 275
         $_course = api_get_course_info();
276 276
 
277
-		// Call constructor of Dropbox_Work object
277
+        // Call constructor of Dropbox_Work object
278 278
         parent::__construct(
279 279
             $uploader_id,
280 280
             $title,
@@ -284,31 +284,31 @@  discard block
 block discarded – undo
284 284
             $filesize
285 285
         );
286 286
 
287
-		$course_id = api_get_course_int_id();
288
-
289
-		// Do sanity checks on recipient_ids array & property fillin
290
-		// The sanity check for ex-coursemembers is already done in base constructor
291
-		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
287
+        $course_id = api_get_course_int_id();
292 288
 
293
-		$justSubmit = false;
294
-		if ( is_int($recipient_ids)) {
295
-			$justSubmit = true;
296
-			$recipient_ids = array($recipient_ids + $this->id);
297
-		} elseif ( count($recipient_ids) == 0) {
298
-			$justSubmit = true;
299
-			$recipient_ids = array($uploader_id);
300
-		}
289
+        // Do sanity checks on recipient_ids array & property fillin
290
+        // The sanity check for ex-coursemembers is already done in base constructor
291
+        settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
292
+
293
+        $justSubmit = false;
294
+        if ( is_int($recipient_ids)) {
295
+            $justSubmit = true;
296
+            $recipient_ids = array($recipient_ids + $this->id);
297
+        } elseif ( count($recipient_ids) == 0) {
298
+            $justSubmit = true;
299
+            $recipient_ids = array($uploader_id);
300
+        }
301 301
 
302
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
303
-			die(get_lang('GeneralError').' (code 209)');
304
-		}
302
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
303
+            die(get_lang('GeneralError').' (code 209)');
304
+        }
305 305
 
306
-		foreach ($recipient_ids as $rec) {
307
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
308
-			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
309
-				//this check is done when validating submitted data
310
-			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
311
-		}
306
+        foreach ($recipient_ids as $rec) {
307
+            if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
308
+            //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
309
+                //this check is done when validating submitted data
310
+            $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
311
+        }
312 312
 
313 313
         $table_post = $dropbox_cnf['tbl_post'];
314 314
         $table_person = $dropbox_cnf['tbl_person'];
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
         $user  = api_get_user_id();
318 318
         $now = api_get_utc_datetime();
319 319
 
320
-		// Insert data in dropbox_post and dropbox_person table for each recipient
321
-		foreach ($this->recipients as $rec) {
320
+        // Insert data in dropbox_post and dropbox_person table for each recipient
321
+        foreach ($this->recipients as $rec) {
322 322
             $file_id = (int)$this->id;
323 323
             $user_id = (int)$rec['id'];
324
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
324
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
325 325
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
326
-	        Database::query($sql);
326
+            Database::query($sql);
327 327
             // If work already exists no error is generated
328 328
 
329 329
             /**
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
                 }
341 341
             }
342 342
 
343
-			// Update item_property table for each recipient
344
-			if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
345
-			    $ownerid = getUserOwningThisMailing($ownerid);
346
-			}
347
-			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
348
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
349
-			}
343
+            // Update item_property table for each recipient
344
+            if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
345
+                $ownerid = getUserOwningThisMailing($ownerid);
346
+            }
347
+            if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
348
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
349
+            }
350 350
             api_item_property_update(
351 351
                 $_course,
352 352
                 TOOL_DROPBOX,
@@ -356,92 +356,92 @@  discard block
 block discarded – undo
356 356
                 null,
357 357
                 $recipid
358 358
             );
359
-		}
360
-	}
361
-
362
-	/**
363
-	 * private function creating existing object by retreiving info from db
364
-	 *
365
-	 * @param unknown_type $id
366
-	 */
367
-	public function _createExistingSentWork($id)
359
+        }
360
+    }
361
+
362
+    /**
363
+     * private function creating existing object by retreiving info from db
364
+     *
365
+     * @param unknown_type $id
366
+     */
367
+    public function _createExistingSentWork($id)
368 368
     {
369 369
         $dropbox_cnf = getDropboxConf();
370 370
         $id = intval($id);
371 371
 
372
-		$course_id = api_get_course_int_id();
372
+        $course_id = api_get_course_int_id();
373 373
 
374
-		// Call constructor of Dropbox_Work object
375
-		parent::__construct($id);
374
+        // Call constructor of Dropbox_Work object
375
+        parent::__construct($id);
376 376
 
377
-		// Fill in recipients array
378
-		$this->recipients = array();
379
-		$sql = "SELECT dest_user_id, feedback_date, feedback
377
+        // Fill in recipients array
378
+        $this->recipients = array();
379
+        $sql = "SELECT dest_user_id, feedback_date, feedback
380 380
 				FROM ".$dropbox_cnf['tbl_post']."
381 381
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
382 382
         $result = Database::query($sql);
383
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
384
-
385
-			// Check for deleted users
386
-			$dest_user_id = $res['dest_user_id'];
387
-			$user_info = api_get_user_info($dest_user_id);
388
-			//$this->category = $res['cat_id'];
389
-			if (!$user_info) {
390
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
391
-			} else {
392
-				$this->recipients[] = array(
383
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
384
+
385
+            // Check for deleted users
386
+            $dest_user_id = $res['dest_user_id'];
387
+            $user_info = api_get_user_info($dest_user_id);
388
+            //$this->category = $res['cat_id'];
389
+            if (!$user_info) {
390
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
391
+            } else {
392
+                $this->recipients[] = array(
393 393
                     'id' => $dest_user_id,
394 394
                     'name' => $user_info['complete_name'],
395 395
                     'user_id' => $dest_user_id,
396
-				    'feedback_date' => $res['feedback_date'],
396
+                    'feedback_date' => $res['feedback_date'],
397 397
                     'feedback' => $res['feedback']
398 398
                 );
399
-			}
400
-		}
401
-	}
399
+            }
400
+        }
401
+    }
402 402
 }
403 403
 
404 404
 class Dropbox_Person
405 405
 {
406
-	// The receivedWork and the sentWork arrays are sorted.
407
-	public $receivedWork;	// an array of Dropbox_Work objects
408
-	public $sentWork;		// an array of Dropbox_SentWork objects
409
-
410
-	public $userId = 0;
411
-	public $isCourseAdmin = false;
412
-	public $isCourseTutor = false;
413
-	public $_orderBy = '';	// private property that determines by which field
414
-
415
-	/**
416
-	 * Constructor for recreating the Dropbox_Person object
417
-	 *
418
-	 * @param int $userId
419
-	 * @param bool $isCourseAdmin
420
-	 * @param bool $isCourseTutor
421
-	 * @return Dropbox_Person
422
-	 */
423
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
406
+    // The receivedWork and the sentWork arrays are sorted.
407
+    public $receivedWork;	// an array of Dropbox_Work objects
408
+    public $sentWork;		// an array of Dropbox_SentWork objects
409
+
410
+    public $userId = 0;
411
+    public $isCourseAdmin = false;
412
+    public $isCourseTutor = false;
413
+    public $_orderBy = '';	// private property that determines by which field
414
+
415
+    /**
416
+     * Constructor for recreating the Dropbox_Person object
417
+     *
418
+     * @param int $userId
419
+     * @param bool $isCourseAdmin
420
+     * @param bool $isCourseTutor
421
+     * @return Dropbox_Person
422
+     */
423
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
424 424
     {
425
-	    $course_id = api_get_course_int_id();
425
+        $course_id = api_get_course_int_id();
426 426
 
427
-		// Fill in properties
427
+        // Fill in properties
428 428
         $this->userId = $userId;
429 429
         $this->isCourseAdmin = $isCourseAdmin;
430 430
         $this->isCourseTutor = $isCourseTutor;
431 431
         $this->receivedWork = array();
432 432
         $this->sentWork = array();
433 433
 
434
-		// Note: perhaps include an ex coursemember check to delete old files
434
+        // Note: perhaps include an ex coursemember check to delete old files
435 435
 
436
-		$session_id = api_get_session_id();
437
-		$condition_session = api_get_session_condition($session_id);
436
+        $session_id = api_get_session_id();
437
+        $condition_session = api_get_session_condition($session_id);
438 438
 
439
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
440
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
441
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
439
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
440
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
441
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
442 442
 
443 443
         // Find all entries where this person is the recipient
444
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
444
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
445 445
                 FROM $post_tbl r
446 446
                 INNER JOIN $person_tbl p
447 447
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
451 451
 
452 452
         $result = Database::query($sql);
453
-		while ($res = Database::fetch_array($result)) {
454
-			$temp = new Dropbox_Work($res['file_id']);
455
-			$temp->category = $res['cat_id'];
456
-			$this->receivedWork[] = $temp;
457
-		}
458
-		// Find all entries where this person is the sender/uploader
453
+        while ($res = Database::fetch_array($result)) {
454
+            $temp = new Dropbox_Work($res['file_id']);
455
+            $temp->category = $res['cat_id'];
456
+            $this->receivedWork[] = $temp;
457
+        }
458
+        // Find all entries where this person is the sender/uploader
459 459
         $sql = "SELECT DISTINCT f.id
460 460
 				FROM $file_tbl f
461 461
 				INNER JOIN $person_tbl p
@@ -466,260 +466,260 @@  discard block
 block discarded – undo
466 466
                     $condition_session
467 467
                 ";
468 468
         $result = Database::query($sql);
469
-		while ($res = Database::fetch_array($result)) {
470
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
471
-		}
472
-	}
473
-
474
-	/**
475
-	 * This private method is used by the usort function in  the
476
-	 * orderSentWork and orderReceivedWork methods.
477
-	 * It compares 2 work-objects by 1 of the properties of that object, dictated by the
478
-	 * private property _orderBy
479
-	 *
480
-	 * @param unknown_type $a
481
-	 * @param unknown_type $b
482
-	 * @return -1, 0 or 1 dependent of the result of the comparison.
483
-	 */
484
-	function _cmpWork($a, $b)
469
+        while ($res = Database::fetch_array($result)) {
470
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
471
+        }
472
+    }
473
+
474
+    /**
475
+     * This private method is used by the usort function in  the
476
+     * orderSentWork and orderReceivedWork methods.
477
+     * It compares 2 work-objects by 1 of the properties of that object, dictated by the
478
+     * private property _orderBy
479
+     *
480
+     * @param unknown_type $a
481
+     * @param unknown_type $b
482
+     * @return -1, 0 or 1 dependent of the result of the comparison.
483
+     */
484
+    function _cmpWork($a, $b)
485 485
     {
486
-		$sort = $this->_orderBy;
487
-		$aval = $a->$sort;
488
-		$bval = $b->$sort;
489
-		if ($sort == 'recipients') {
490
-		    // The recipients property is an array so we do the comparison based
491
-		    // on the first item of the recipients array
492
-		    $aval = $aval[0]['name'];
493
-			$bval = $bval[0]['name'];
494
-		}
495
-		if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
496
-			return $aval < $bval ? -1 : 1;
497
-		} elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
498
-			return api_strnatcmp($aval, $bval);
499
-		} else {
500
-		    return api_strcasecmp($aval, $bval);
501
-		}
502
-	}
503
-
504
-	/**
505
-	 * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
506
-	 * $sort can be lastDate, firstDate, title, size, ...
507
-	 *
508
-	 * @param unknown_type $sort
509
-	 */
510
-	function orderSentWork($sort)
486
+        $sort = $this->_orderBy;
487
+        $aval = $a->$sort;
488
+        $bval = $b->$sort;
489
+        if ($sort == 'recipients') {
490
+            // The recipients property is an array so we do the comparison based
491
+            // on the first item of the recipients array
492
+            $aval = $aval[0]['name'];
493
+            $bval = $bval[0]['name'];
494
+        }
495
+        if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
496
+            return $aval < $bval ? -1 : 1;
497
+        } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
498
+            return api_strnatcmp($aval, $bval);
499
+        } else {
500
+            return api_strcasecmp($aval, $bval);
501
+        }
502
+    }
503
+
504
+    /**
505
+     * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
506
+     * $sort can be lastDate, firstDate, title, size, ...
507
+     *
508
+     * @param unknown_type $sort
509
+     */
510
+    function orderSentWork($sort)
511 511
     {
512
-		switch($sort) {
513
-			case 'lastDate':
514
-				$this->_orderBy = 'last_upload_date';
515
-				break;
516
-			case 'firstDate':
517
-				$this->_orderBy = 'upload_date';
518
-				break;
519
-			case 'title':
520
-				$this->_orderBy = 'title';
521
-				break;
522
-			case 'size':
523
-				$this->_orderBy = 'filesize';
524
-				break;
525
-			case 'author':
526
-				$this->_orderBy = 'author';
527
-				break;
528
-			case 'recipient':
529
-				$this->_orderBy = 'recipients';
530
-				break;
531
-			default:
532
-				$this->_orderBy = 'last_upload_date';
533
-		}
534
-
535
-		usort($this->sentWork, array($this, '_cmpWork'));
536
-	}
537
-
538
-	/**
539
-	 * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
540
-	 * $sort can be lastDate, firstDate, title, size, ...
541
-	 * @param unknown_type $sort
542
-	 */
543
-	function orderReceivedWork($sort)
512
+        switch($sort) {
513
+            case 'lastDate':
514
+                $this->_orderBy = 'last_upload_date';
515
+                break;
516
+            case 'firstDate':
517
+                $this->_orderBy = 'upload_date';
518
+                break;
519
+            case 'title':
520
+                $this->_orderBy = 'title';
521
+                break;
522
+            case 'size':
523
+                $this->_orderBy = 'filesize';
524
+                break;
525
+            case 'author':
526
+                $this->_orderBy = 'author';
527
+                break;
528
+            case 'recipient':
529
+                $this->_orderBy = 'recipients';
530
+                break;
531
+            default:
532
+                $this->_orderBy = 'last_upload_date';
533
+        }
534
+
535
+        usort($this->sentWork, array($this, '_cmpWork'));
536
+    }
537
+
538
+    /**
539
+     * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
540
+     * $sort can be lastDate, firstDate, title, size, ...
541
+     * @param unknown_type $sort
542
+     */
543
+    function orderReceivedWork($sort)
544 544
     {
545
-		switch($sort) {
546
-			case 'lastDate':
547
-				$this->_orderBy = 'last_upload_date';
548
-				break;
549
-			case 'firstDate':
550
-				$this->_orderBy = 'upload_date';
551
-				break;
552
-			case 'title':
553
-				$this->_orderBy = 'title';
554
-				break;
555
-			case 'size':
556
-				$this->_orderBy = 'filesize';
557
-				break;
558
-			case 'author':
559
-				$this->_orderBy = 'author';
560
-				break;
561
-			case 'sender':
562
-				$this->_orderBy = 'uploaderName';
563
-				break;
564
-			default:
565
-				$this->_orderBy = 'last_upload_date';
566
-		}
567
-
568
-		usort($this->receivedWork, array($this, '_cmpWork'));
569
-	}
570
-
571
-	/**
572
-	 * Deletes all the received work of this person
573
-	 */
574
-	function deleteAllReceivedWork()
545
+        switch($sort) {
546
+            case 'lastDate':
547
+                $this->_orderBy = 'last_upload_date';
548
+                break;
549
+            case 'firstDate':
550
+                $this->_orderBy = 'upload_date';
551
+                break;
552
+            case 'title':
553
+                $this->_orderBy = 'title';
554
+                break;
555
+            case 'size':
556
+                $this->_orderBy = 'filesize';
557
+                break;
558
+            case 'author':
559
+                $this->_orderBy = 'author';
560
+                break;
561
+            case 'sender':
562
+                $this->_orderBy = 'uploaderName';
563
+                break;
564
+            default:
565
+                $this->_orderBy = 'last_upload_date';
566
+        }
567
+
568
+        usort($this->receivedWork, array($this, '_cmpWork'));
569
+    }
570
+
571
+    /**
572
+     * Deletes all the received work of this person
573
+     */
574
+    function deleteAllReceivedWork()
575 575
     {
576
-	    $course_id = api_get_course_int_id();
576
+        $course_id = api_get_course_int_id();
577 577
         $dropbox_cnf = getDropboxConf();
578
-		// Delete entries in person table concerning received works
579
-		foreach ($this->receivedWork as $w) {
578
+        // Delete entries in person table concerning received works
579
+        foreach ($this->receivedWork as $w) {
580 580
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
581 581
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
582
-			Database::query($sql);
583
-		}
582
+            Database::query($sql);
583
+        }
584 584
         // Check for unused files
585
-		removeUnusedFiles();
586
-	}
585
+        removeUnusedFiles();
586
+    }
587 587
 
588
-	/**
589
-	 * Deletes all the received categories and work of this person
590
-	 */
591
-	function deleteReceivedWorkFolder($id)
588
+    /**
589
+     * Deletes all the received categories and work of this person
590
+     */
591
+    function deleteReceivedWorkFolder($id)
592 592
     {
593 593
         $dropbox_cnf = getDropboxConf();
594 594
         $course_id = api_get_course_int_id();
595 595
 
596
-		$id = intval($id);
597
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
596
+        $id = intval($id);
597
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
598 598
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
599
-		if (!Database::query($sql)) return false;
600
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
599
+        if (!Database::query($sql)) return false;
600
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
601 601
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
602
-		if (!Database::query($sql)) return false;
603
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
602
+        if (!Database::query($sql)) return false;
603
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
604 604
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
605
-		if (!Database::query($sql)) return false;
606
-		return true;
607
-	}
608
-
609
-	/**
610
-	 * Deletes a received dropbox file of this person with id=$id
611
-	 *
612
-	 * @param integer $id
613
-	 */
614
-	function deleteReceivedWork($id)
605
+        if (!Database::query($sql)) return false;
606
+        return true;
607
+    }
608
+
609
+    /**
610
+     * Deletes a received dropbox file of this person with id=$id
611
+     *
612
+     * @param integer $id
613
+     */
614
+    function deleteReceivedWork($id)
615 615
     {
616
-	    $course_id = api_get_course_int_id();
616
+        $course_id = api_get_course_int_id();
617 617
         $dropbox_cnf = getDropboxConf();
618
-		$id = intval($id);
619
-
620
-		// index check
621
-		$found = false;
622
-		foreach ($this->receivedWork as $w) {
623
-			if ($w->id == $id) {
624
-			   $found = true;
625
-			   break;
626
-			}
627
-		}
628
-
629
-		if (!$found) {
630
-			if (!$this->deleteReceivedWorkFolder($id)) {
631
-				die(get_lang('GeneralError').' (code 216)');
632
-			}
633
-		}
634
-		// Delete entries in person table concerning received works
618
+        $id = intval($id);
619
+
620
+        // index check
621
+        $found = false;
622
+        foreach ($this->receivedWork as $w) {
623
+            if ($w->id == $id) {
624
+                $found = true;
625
+                break;
626
+            }
627
+        }
628
+
629
+        if (!$found) {
630
+            if (!$this->deleteReceivedWorkFolder($id)) {
631
+                die(get_lang('GeneralError').' (code 216)');
632
+            }
633
+        }
634
+        // Delete entries in person table concerning received works
635 635
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
636 636
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
637
-		Database::query($sql);
638
-		removeUnusedFiles();	// Check for unused files
639
-	}
640
-
641
-	/**
642
-	 * Deletes all the sent dropbox files of this person
643
-	 */
644
-	function deleteAllSentWork()
637
+        Database::query($sql);
638
+        removeUnusedFiles();	// Check for unused files
639
+    }
640
+
641
+    /**
642
+     * Deletes all the sent dropbox files of this person
643
+     */
644
+    function deleteAllSentWork()
645 645
     {
646
-	    $course_id = api_get_course_int_id();
646
+        $course_id = api_get_course_int_id();
647 647
         $dropbox_cnf = getDropboxConf();
648
-		//delete entries in person table concerning sent works
649
-		foreach ($this->sentWork as $w) {
648
+        //delete entries in person table concerning sent works
649
+        foreach ($this->sentWork as $w) {
650 650
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
651 651
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
652
-			Database::query($sql);
653
-			removeMoreIfMailing($w->id);
654
-		}
655
-		removeUnusedFiles();	// Check for unused files
656
-	}
657
-
658
-	/**
659
-	 * Deletes a sent dropbox file of this person with id=$id
660
-	 *
661
-	 * @param unknown_type $id
662
-	 */
663
-	function deleteSentWork($id)
652
+            Database::query($sql);
653
+            removeMoreIfMailing($w->id);
654
+        }
655
+        removeUnusedFiles();	// Check for unused files
656
+    }
657
+
658
+    /**
659
+     * Deletes a sent dropbox file of this person with id=$id
660
+     *
661
+     * @param unknown_type $id
662
+     */
663
+    function deleteSentWork($id)
664 664
     {
665
-	    $course_id = api_get_course_int_id();
665
+        $course_id = api_get_course_int_id();
666 666
         $dropbox_cnf = getDropboxConf();
667 667
 
668
-		$id = intval($id);
669
-
670
-		// index check
671
-		$found = false;
672
-		foreach ($this->sentWork as $w) {
673
-			if ($w->id == $id) {
674
-			   $found = true;
675
-			   break;
676
-			}
677
-		}
678
-		if (!$found) {
679
-			if (!$this->deleteReceivedWorkFolder($id)) {
680
-				die(get_lang('GeneralError').' (code 219)');
681
-			}
682
-		}
683
-		//$file_id = $this->sentWork[$index]->id;
684
-		// Delete entries in person table concerning sent works
668
+        $id = intval($id);
669
+
670
+        // index check
671
+        $found = false;
672
+        foreach ($this->sentWork as $w) {
673
+            if ($w->id == $id) {
674
+                $found = true;
675
+                break;
676
+            }
677
+        }
678
+        if (!$found) {
679
+            if (!$this->deleteReceivedWorkFolder($id)) {
680
+                die(get_lang('GeneralError').' (code 219)');
681
+            }
682
+        }
683
+        //$file_id = $this->sentWork[$index]->id;
684
+        // Delete entries in person table concerning sent works
685 685
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
686 686
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
687
-		Database::query($sql);
688
-		removeMoreIfMailing($id);
689
-		removeUnusedFiles();	// Check for unused files
690
-	}
691
-
692
-	/**
693
-	 * Updates feedback for received work of this person with id=$id
694
-	 *
695
-	 * @param string $id
696
-	 * @param string $text
697
-	 */
698
-	function updateFeedback($id, $text)
687
+        Database::query($sql);
688
+        removeMoreIfMailing($id);
689
+        removeUnusedFiles();	// Check for unused files
690
+    }
691
+
692
+    /**
693
+     * Updates feedback for received work of this person with id=$id
694
+     *
695
+     * @param string $id
696
+     * @param string $text
697
+     */
698
+    function updateFeedback($id, $text)
699 699
     {
700
-	    $course_id = api_get_course_int_id();
700
+        $course_id = api_get_course_int_id();
701 701
         $_course = api_get_course_info();
702 702
         $dropbox_cnf = getDropboxConf();
703 703
 
704
-		$id = intval($id);
705
-
706
-		// index check
707
-		$found = false;
708
-		$wi = -1;
709
-		foreach ($this->receivedWork as $w) {
710
-			$wi++;
711
-			if ($w->id == $id){
712
-			   $found = true;
713
-			   break;
714
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
715
-		}
716
-		if (!$found) {
717
-			die(get_lang('GeneralError').' (code 221)');
718
-		}
719
-
720
-		$feedback_date = api_get_utc_datetime();
721
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
722
-		$this->receivedWork[$wi]->feedback = $text;
704
+        $id = intval($id);
705
+
706
+        // index check
707
+        $found = false;
708
+        $wi = -1;
709
+        foreach ($this->receivedWork as $w) {
710
+            $wi++;
711
+            if ($w->id == $id){
712
+                $found = true;
713
+                break;
714
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
715
+        }
716
+        if (!$found) {
717
+            die(get_lang('GeneralError').' (code 221)');
718
+        }
719
+
720
+        $feedback_date = api_get_utc_datetime();
721
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
722
+        $this->receivedWork[$wi]->feedback = $text;
723 723
 
724 724
         $params = [
725 725
             'feedback_date' => $feedback_date,
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
             ]
738 738
         );
739 739
 
740
-		// Update item_property table
740
+        // Update item_property table
741 741
 
742
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
743
-		    $ownerid = getUserOwningThisMailing($ownerid);
744
-		}
742
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
743
+            $ownerid = getUserOwningThisMailing($ownerid);
744
+        }
745 745
         api_item_property_update(
746 746
             $_course,
747 747
             TOOL_DROPBOX,
@@ -752,31 +752,31 @@  discard block
 block discarded – undo
752 752
             $ownerid
753 753
         );
754 754
 
755
-	}
755
+    }
756 756
 
757
-	/**
758
-	 * Filter the received work
759
-	 * @param string $type
760
-	 * @param string $value
761
-	 */
762
-	function filter_received_work($type, $value)
757
+    /**
758
+     * Filter the received work
759
+     * @param string $type
760
+     * @param string $value
761
+     */
762
+    function filter_received_work($type, $value)
763 763
     {
764 764
         $dropbox_cnf = getDropboxConf();
765
-    	$new_received_work = array();
766
-		foreach ($this->receivedWork as $work) {
767
-			switch ($type) {
768
-				case 'uploader_id':
769
-					if ($work->uploader_id == $value ||
770
-						($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
765
+        $new_received_work = array();
766
+        foreach ($this->receivedWork as $work) {
767
+            switch ($type) {
768
+                case 'uploader_id':
769
+                    if ($work->uploader_id == $value ||
770
+                        ($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
771 771
                         getUserOwningThisMailing($work->uploader_id) == $value)
772 772
                     ) {
773
-						$new_received_work[] = $work;
774
-					}
775
-					break;
776
-				default:
777
-					$new_received_work[] = $work;
778
-			}
779
-		}
780
-		$this->receivedWork = $new_received_work;
781
-	}
773
+                        $new_received_work[] = $work;
774
+                    }
775
+                    break;
776
+                default:
777
+                    $new_received_work[] = $work;
778
+            }
779
+        }
780
+        $this->receivedWork = $new_received_work;
781
+    }
782 782
 }
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_classes.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -10,6 +10,10 @@
 block discarded – undo
10 10
 if ( count( get_included_files() ) == 1 ) die( '---' );
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13
+
14
+	/**
15
+	 * @param string $filename
16
+	 */
13 17
 	function mime_content_type($filename) {
14 18
 		return DocumentManager::file_get_mime_type((string)$filename);
15 19
 	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if (count(get_included_files()) == 1) die('---');
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 	function mime_content_type($filename) {
14
-		return DocumentManager::file_get_mime_type((string)$filename);
14
+		return DocumentManager::file_get_mime_type((string) $filename);
15 15
 	}
16 16
 }
17 17
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     function setAnswer()
27 27
     {
28
-        switch($this->type)
28
+        switch ($this->type)
29 29
         {
30 30
             case MCUA :
31 31
                 $answer = new AikenAnswerMultipleChoice($this->id);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if ( count( get_included_files() ) == 1 ) {
11
+    die( '---' );
12
+}
11 13
 
12 14
 if (!function_exists('mime_content_type')) {
13 15
 	function mime_content_type($filename) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 if ( count( get_included_files() ) == 1 ) die( '---' );
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13
-	function mime_content_type($filename) {
14
-		return DocumentManager::file_get_mime_type((string)$filename);
15
-	}
13
+    function mime_content_type($filename) {
14
+        return DocumentManager::file_get_mime_type((string)$filename);
15
+    }
16 16
 }
17 17
 
18 18
 /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         {
30 30
             case MCUA :
31 31
                 $answer = new AikenAnswerMultipleChoice($this->id);
32
-            	return $answer;
32
+                return $answer;
33 33
             default :
34 34
                 $answer = null;
35 35
                 break;
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
     }
39 39
     function createAnswersForm($form)
40 40
     {
41
-    	return true;
41
+        return true;
42 42
     }
43 43
     function processAnswersCreation($form)
44 44
     {
45
-    	return true;
45
+        return true;
46 46
     }
47 47
 }
48 48
 
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_import.inc.php 4 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,6 +55,8 @@  discard block
 block discarded – undo
55 55
  * Gets the uploaded file (from $_FILES) and unzip it to the given directory
56 56
  * @param string The directory where to do the work
57 57
  * @param string The path of the temporary directory where the exercise was uploaded and unzipped
58
+ * @param string $baseWorkDir
59
+ * @param string $uploadPath
58 60
  * @return bool True on success, false on failure
59 61
  */
60 62
 function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) {
@@ -229,7 +231,10 @@  discard block
 block discarded – undo
229 231
  * @param string Path to the directory with the file to be parsed (without final /)
230 232
  * @param string Name of the last directory part for the file (without /)
231 233
  * @param string Name of the file to be parsed (including extension)
232
- * @return mixed True on success, error message on error
234
+ * @param string $exercisePath
235
+ * @param string $file
236
+ * @param string $questionFile
237
+ * @return string|boolean True on success, error message on error
233 238
  * @assert ('','','') === false
234 239
  */
235 240
 function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $dir .= '/';
26 26
 
27 27
     do {
28
-        $path = $dir . $prefix . mt_rand(0, 9999999);
28
+        $path = $dir.$prefix.mt_rand(0, 9999999);
29 29
     } while (!mkdir($path, $mode));
30 30
 
31 31
     return $path;
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 function aiken_display_form($msg = '') {
39 39
     $name_tools = get_lang('ImportAikenQuiz');
40 40
     $form  = '<div class="actions">';
41
-    $form .= '<a href="exercise.php?show=test">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
41
+    $form .= '<a href="exercise.php?show=test">'.Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
42 42
     $form .= '</div>';
43 43
     $form .= $msg;
44
-    $form_validator  = new FormValidator('aiken_upload', 'post',api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data') );
44
+    $form_validator = new FormValidator('aiken_upload', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
45 45
     $form_validator->addElement('header', $name_tools);
46 46
     $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight'));
47 47
     $form_validator->addElement('file', 'userFile', get_lang('DownloadFile'));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     global $record_item_body;
90 90
     // used to specify the question directory where files could be found in relation in any question
91 91
     global $questionTempDir;
92
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'aiken';
92
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'aiken';
93 93
     $baseWorkDir = $archive_path;
94 94
 
95 95
     if (!is_dir($baseWorkDir)) {
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 
131 131
     // Parse every subdirectory to search txt question files
132 132
     while (false !== ($file = readdir($exerciseHandle))) {
133
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
133
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
134 134
             //find each manifest for each question repository found
135
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
135
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
136 136
             while (false !== ($questionFile = readdir($questionHandle))) {
137 137
                 if (preg_match('/.txt$/i', $questionFile)) {
138 138
                     $result = aiken_parse_file(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $result = 'NoTxtFileFoundInTheZip';
155 155
     }
156 156
 
157
-    if ($result !== true ) {
157
+    if ($result !== true) {
158 158
         return $result;
159 159
     }
160 160
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         }
216 216
 
217 217
         // Delete the temp dir where the exercise was unzipped
218
-        my_delete($baseWorkDir . $uploadPath);
218
+        my_delete($baseWorkDir.$uploadPath);
219 219
         $operation = $last_exercise_id;
220 220
     }
221 221
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) {
236 236
     global $questionTempDir;
237 237
 
238
-    $questionTempDir = $exercisePath . '/' . $file . '/';
239
-    $questionFilePath = $questionTempDir . $questionFile;
238
+    $questionTempDir = $exercisePath.'/'.$file.'/';
239
+    $questionFilePath = $questionTempDir.$questionFile;
240 240
 
241 241
     if (!is_file($questionFilePath)) {
242 242
         return 'FileNotFound';
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
     $answers_array = array();
249 249
     $new_question = true;
250 250
     foreach ($data as $line => $info) {
251
-        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/',$info)) {
251
+        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) {
252 252
             // double empty line
253 253
             continue;
254 254
         }
255 255
         $new_question = false;
256 256
         //make sure it is transformed from iso-8859-1 to utf-8 if in that form
257
-        if (!mb_check_encoding($info,'utf-8') && mb_check_encoding($info,'iso-8859-1')) {
257
+        if (!mb_check_encoding($info, 'utf-8') && mb_check_encoding($info, 'iso-8859-1')) {
258 258
             $info = utf8_encode($info);
259 259
         }
260 260
         $exercise_info['question'][$question_index]['type'] = 'MCUA';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
287 287
             //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
288 288
             $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
289
-        } elseif (preg_match('/^(\r)?\n/',$info)) {
289
+        } elseif (preg_match('/^(\r)?\n/', $info)) {
290 290
             //moving to next question (tolerate \r\n or just \n)
291 291
             if (empty($exercise_info['question'][$question_index]['correct_answers'])) {
292 292
                 error_log('Aiken: Error in question index '.$question_index.': no correct answer defined');
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                     $exercise_info['question'][$question_index]['title'] = $info;
307 307
                 } else {
308 308
                     //Question itself (use a 100-chars long title and a larger description)
309
-                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...';
309
+                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
310 310
                     $exercise_info['question'][$question_index]['description'] = $info;
311 311
                 }
312 312
             } else {
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     }
317 317
     $total_questions = count($exercise_info['question']);
318 318
     $total_weight = (!empty($_POST['total_weight'])) ? intval($_POST['total_weight']) : 20;
319
-    foreach  ($exercise_info['question'] as $key => $question) {
319
+    foreach ($exercise_info['question'] as $key => $question) {
320 320
         $exercise_info['question'][$key]['weighting'][current(array_keys($exercise_info['question'][$key]['weighting']))] = $total_weight / $total_questions;
321 321
     }
322 322
     return true;
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * Security check
12 12
  */
13
-if (count(get_included_files()) == 1)
13
+if (count(get_included_files()) == 1) {
14 14
     die('---');
15
+}
15 16
 
16 17
 /**
17 18
  * Creates a temporary directory
@@ -21,8 +22,9 @@  discard block
 block discarded – undo
21 22
  * @return string
22 23
  */
23 24
 function tempdir($dir, $prefix = 'tmp', $mode = 0777) {
24
-    if (substr($dir, -1) != '/')
25
-        $dir .= '/';
25
+    if (substr($dir, -1) != '/') {
26
+            $dir .= '/';
27
+    }
26 28
 
27 29
     do {
28 30
         $path = $dir . $prefix . mt_rand(0, 9999999);
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@
 block discarded – undo
281 281
             $correct_answer_index = array_search($matches[1], $answers_array);
282 282
             $exercise_info['question'][$question_index]['title'] = $matches[1];
283 283
         } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) {
284
-             //TAGS for chamilo >= 1.10
284
+                //TAGS for chamilo >= 1.10
285 285
             $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
286 286
         } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
287 287
             //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
Please login to merge, or discard this patch.
main/exercice/export/exercise_import.inc.php 2 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,6 +30,8 @@  discard block
 block discarded – undo
30 30
  * Unzip the exercise in the temp folder
31 31
  * @param string The path of the temporary directory where the exercise was uploaded and unzipped
32 32
  * @param string
33
+ * @param string $baseWorkDir
34
+ * @param string $uploadPath
33 35
  * @return bool
34 36
  */
35 37
 function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath)
@@ -217,9 +219,9 @@  discard block
 block discarded – undo
217 219
 
218 220
 /**
219 221
  * Parses a given XML file and fills global arrays with the elements
220
- * @param $exercisePath
221
- * @param $file
222
- * @param $questionFile
222
+ * @param string $exercisePath
223
+ * @param string $file
224
+ * @param string $questionFile
223 225
  * @return bool
224 226
  */
225 227
 function parse_file($exercisePath, $file, $questionFile)
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     }
21 21
 
22 22
     do {
23
-        $path = $dir . $prefix . mt_rand(0, 9999999);
23
+        $path = $dir.$prefix.mt_rand(0, 9999999);
24 24
     } while (!mkdir($path, $mode));
25 25
 
26 26
     return $path;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     // used to specify the question directory where files could be found in relation in any question
75 75
     global $questionTempDir;
76 76
 
77
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2';
77
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2';
78 78
     $baseWorkDir = $archive_path;
79 79
 
80 80
     if (!is_dir($baseWorkDir)) {
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
     // parse every subdirectory to search xml question files
119 119
     while (false !== ($file = readdir($exerciseHandle))) {
120 120
 
121
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
121
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
122 122
 
123 123
             // Find each manifest for each question repository found
124
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
124
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
125 125
             while (false !== ($questionFile = readdir($questionHandle))) {
126 126
                 if (preg_match('/.xml$/i', $questionFile)) {
127 127
                     $result = parse_file($baseWorkDir, $file, $questionFile);
128
-                    $filePath = $baseWorkDir . $file;
128
+                    $filePath = $baseWorkDir.$file;
129 129
                     $file_found = true;
130 130
                 }
131 131
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
             // Else ignore file
135 135
             $result = parse_file($baseWorkDir, '', $file);
136
-            $filePath = $baseWorkDir . '/' . $file;
136
+            $filePath = $baseWorkDir.'/'.$file;
137 137
             $file_found = true;
138 138
         }
139 139
     }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         }
201 201
 
202 202
         // delete the temp dir where the exercise was unzipped
203
-        my_delete($baseWorkDir . $uploadPath);
203
+        my_delete($baseWorkDir.$uploadPath);
204 204
         return $last_exercise_id;
205 205
     }
206 206
 
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
     global $record_item_body;
229 229
     global $questionTempDir;
230 230
 
231
-    $questionTempDir = $exercisePath . '/' . $file . '/';
232
-    $questionFilePath = $questionTempDir . $questionFile;
231
+    $questionTempDir = $exercisePath.'/'.$file.'/';
232
+    $questionFilePath = $questionTempDir.$questionFile;
233 233
 
234 234
     if (!($fp = fopen($questionFilePath, 'r'))) {
235 235
         Display:: display_error_message(get_lang('Error opening question\'s XML file'));
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
     if ($record_item_body) {
327 327
 
328 328
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
329
-            $current_question_item_body .= "<" . $name;
329
+            $current_question_item_body .= "<".$name;
330 330
 
331 331
             foreach ($attributes as $attribute_name => $attribute_value) {
332
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
332
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
333 333
             }
334 334
             $current_question_item_body .= ">";
335 335
         } else {
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 
339 339
             if ($current_element == 'INLINECHOICEINTERACTION') {
340 340
 
341
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
341
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
342 342
             }
343 343
             if ($current_element == 'TEXTENTRYINTERACTION') {
344 344
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
345
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
345
+                $current_question_item_body .= "[".$correct_answer_value."]";
346 346
 
347 347
             }
348 348
             if ($current_element == 'BR') {
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
     //treat the record of the full content of itembody tag :
458 458
 
459 459
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
460
-        $current_question_item_body .= "</" . $name . ">";
460
+        $current_question_item_body .= "</".$name.">";
461 461
     }
462 462
 
463 463
     switch ($name) {
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) {
516 516
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data);
517 517
             } else {
518
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data);
518
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data);
519 519
             }
520 520
             break;
521 521
         case 'FEEDBACKINLINE':
522 522
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) {
523 523
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data);
524 524
             } else {
525
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data);
525
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data);
526 526
             }
527 527
             break;
528 528
         case 'SIMPLEASSOCIABLECHOICE':
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
             $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
547 547
             if ($current_inlinechoice_id == $answer_identifier) {
548 548
                 $current_question_item_body = str_replace(
549
-                    "**claroline_start**" . $current_answer_id . "**claroline_end**",
550
-                    "[" . $data . "]",
549
+                    "**claroline_start**".$current_answer_id."**claroline_end**",
550
+                    "[".$data."]",
551 551
                     $current_question_item_body
552 552
                 );
553 553
             } else {
Please login to merge, or discard this patch.