@@ -17,7 +17,7 @@ |
||
17 | 17 | * Search for a session based on a given search string |
18 | 18 | * @param string A search string |
19 | 19 | * @param string A search box type (single or anything else) |
20 | - * @return string XajaxResponse |
|
20 | + * @return xajaxResponse XajaxResponse |
|
21 | 21 | * @assert () !== '' |
22 | 22 | * @assert ('abc','single') !== '' |
23 | 23 | */ |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @assert () !== '' |
22 | 22 | * @assert ('abc','single') !== '' |
23 | 23 | */ |
24 | - function search_courses($needle,$type) |
|
24 | + function search_courses($needle, $type) |
|
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | 27 | $xajax_response = new xajaxResponse(); |
28 | 28 | $return = ''; |
29 | - if(!empty($needle) && !empty($type)) { |
|
29 | + if (!empty($needle) && !empty($type)) { |
|
30 | 30 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
31 | 31 | $charset = api_get_system_encoding(); |
32 | 32 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $course_list = array(); |
39 | 39 | |
40 | 40 | $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
41 | - while($course = Database :: fetch_array($rs)) { |
|
41 | + while ($course = Database :: fetch_array($rs)) { |
|
42 | 42 | $course_list[] = $course['id']; |
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | 44 | } |
45 | 45 | $return .= '</select>'; |
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return)); |
|
47 | 47 | } |
48 | 48 | $_SESSION['course_list'] = $course_list; |
49 | 49 | return $xajax_response; |
@@ -24,30 +24,30 @@ |
||
24 | 24 | function search_courses($needle,$type) |
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | - $xajax_response = new xajaxResponse(); |
|
28 | - $return = ''; |
|
29 | - if(!empty($needle) && !empty($type)) { |
|
30 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
31 | - $charset = api_get_system_encoding(); |
|
32 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
33 | - $needle = Database::escape_string($needle); |
|
27 | + $xajax_response = new xajaxResponse(); |
|
28 | + $return = ''; |
|
29 | + if(!empty($needle) && !empty($type)) { |
|
30 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
31 | + $charset = api_get_system_encoding(); |
|
32 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
33 | + $needle = Database::escape_string($needle); |
|
34 | 34 | |
35 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
35 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | 36 | |
37 | - $rs = Database::query($sql); |
|
38 | - $course_list = array(); |
|
37 | + $rs = Database::query($sql); |
|
38 | + $course_list = array(); |
|
39 | 39 | |
40 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
41 | - while($course = Database :: fetch_array($rs)) { |
|
42 | - $course_list[] = $course['id']; |
|
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | - } |
|
45 | - $return .= '</select>'; |
|
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
47 | - } |
|
40 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
41 | + while($course = Database :: fetch_array($rs)) { |
|
42 | + $course_list[] = $course['id']; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | + } |
|
45 | + $return .= '</select>'; |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
47 | + } |
|
48 | 48 | |
49 | - Session::write('course_list', $course_list); |
|
49 | + Session::write('course_list', $course_list); |
|
50 | 50 | |
51 | - return $xajax_response; |
|
52 | - } |
|
51 | + return $xajax_response; |
|
52 | + } |
|
53 | 53 | } |
@@ -554,13 +554,12 @@ discard block |
||
554 | 554 | * @param string $title |
555 | 555 | * @param string $content |
556 | 556 | * @param array $usersToSend |
557 | - * @param int $editRepeatType |
|
558 | 557 | * @param array $attachmentArray |
559 | 558 | * @param string $attachmentComment |
560 | 559 | * @param string $comment |
561 | 560 | * @param string $color |
562 | 561 | * |
563 | - * @return bool |
|
562 | + * @return null|false |
|
564 | 563 | */ |
565 | 564 | public function editEvent( |
566 | 565 | $id, |
@@ -1292,6 +1291,7 @@ discard block |
||
1292 | 1291 | * |
1293 | 1292 | * @param int $eventId |
1294 | 1293 | * @param int $courseId |
1294 | + * @param integer $sessionId |
|
1295 | 1295 | * @paraù int $sessionId |
1296 | 1296 | * |
1297 | 1297 | * @return array |
@@ -2284,6 +2284,7 @@ discard block |
||
2284 | 2284 | * @param array $fileUserUpload ($_FILES['user_upload']) |
2285 | 2285 | * @param string comment about file |
2286 | 2286 | * @param array $courseInfo |
2287 | + * @param string $comment |
|
2287 | 2288 | * @return string |
2288 | 2289 | */ |
2289 | 2290 | public function addAttachment($eventId, $fileUserUpload, $comment, $courseInfo) |
@@ -2403,6 +2404,7 @@ discard block |
||
2403 | 2404 | * Adds x weeks to a UNIX timestamp |
2404 | 2405 | * @param int The timestamp |
2405 | 2406 | * @param int The number of weeks to add |
2407 | + * @param integer $timestamp |
|
2406 | 2408 | * @return int The new timestamp |
2407 | 2409 | */ |
2408 | 2410 | function addWeek($timestamp, $num = 1) |
@@ -2414,6 +2416,7 @@ discard block |
||
2414 | 2416 | * Adds x months to a UNIX timestamp |
2415 | 2417 | * @param int The timestamp |
2416 | 2418 | * @param int The number of years to add |
2419 | + * @param integer $timestamp |
|
2417 | 2420 | * @return int The new timestamp |
2418 | 2421 | */ |
2419 | 2422 | function addMonth($timestamp, $num = 1) |
@@ -2432,6 +2435,7 @@ discard block |
||
2432 | 2435 | * Adds x years to a UNIX timestamp |
2433 | 2436 | * @param int The timestamp |
2434 | 2437 | * @param int The number of years to add |
2438 | + * @param integer $timestamp |
|
2435 | 2439 | * @return int The new timestamp |
2436 | 2440 | */ |
2437 | 2441 | function addYear($timestamp, $num = 1) |
@@ -2631,7 +2635,7 @@ discard block |
||
2631 | 2635 | /** |
2632 | 2636 | * @param array $courseInfo |
2633 | 2637 | * @param $file |
2634 | - * @return array|bool|string |
|
2638 | + * @return false|string |
|
2635 | 2639 | */ |
2636 | 2640 | public function importEventFile($courseInfo, $file) |
2637 | 2641 | { |
@@ -2744,7 +2748,7 @@ discard block |
||
2744 | 2748 | |
2745 | 2749 | /** |
2746 | 2750 | * Parse filter turns USER:12 to ['users' => [12])] or G:1 ['groups' => [1]] |
2747 | - * @param $filter |
|
2751 | + * @param integer $filter |
|
2748 | 2752 | * @return array |
2749 | 2753 | */ |
2750 | 2754 | public function parseAgendaFilter($filter) |
@@ -3259,6 +3263,7 @@ discard block |
||
3259 | 3263 | * @param int user ID of the user |
3260 | 3264 | * @param string Optional start date in datetime format (if no start date is given, uses today) |
3261 | 3265 | * @param string Optional end date in datetime format (if no date is given, uses one year from now) |
3266 | + * @param integer $user_id |
|
3262 | 3267 | * @return array Array of events ordered by start date, in |
3263 | 3268 | * [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format, |
3264 | 3269 | * where datestart and dateend are in yyyyMMddhhmmss format. |
@@ -3122,8 +3122,9 @@ |
||
3122 | 3122 | global $DaysShort, $course_path; |
3123 | 3123 | //Handle leap year |
3124 | 3124 | $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
3125 | - if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
3126 | - $numberofdays[2] = 29; |
|
3125 | + if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) { |
|
3126 | + $numberofdays[2] = 29; |
|
3127 | + } |
|
3127 | 3128 | //Get the first day of the month |
3128 | 3129 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
3129 | 3130 | //Start the week on monday |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | |
1098 | 1098 | if ($personalAgenda) { |
1099 | 1099 | $newEndDate = $personalAgenda->getEnddate(); |
1100 | - $newEndDate->add(new DateInterval("PT" . $delta . "M")); |
|
1100 | + $newEndDate->add(new DateInterval("PT".$delta."M")); |
|
1101 | 1101 | |
1102 | 1102 | $personalAgenda |
1103 | 1103 | ->setAllDay(0) |
@@ -1152,9 +1152,9 @@ discard block |
||
1152 | 1152 | |
1153 | 1153 | if ($personalAgenda) { |
1154 | 1154 | $newDate = $personalAgenda->getDate(); |
1155 | - $newDate->add(new DateInterval("PT" . $delta . "M")); |
|
1155 | + $newDate->add(new DateInterval("PT".$delta."M")); |
|
1156 | 1156 | $newEndDate = $personalAgenda->getEnddate(); |
1157 | - $newEndDate->add(new DateInterval("PT" . $delta . "M")); |
|
1157 | + $newEndDate->add(new DateInterval("PT".$delta."M")); |
|
1158 | 1158 | |
1159 | 1159 | $personalAgenda |
1160 | 1160 | ->setAllDay($allDay) |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | if (count($result)) { |
1314 | 1314 | foreach ($result as $row) { |
1315 | 1315 | $event = array(); |
1316 | - $event['id'] = 'personal_' . $row->getId(); |
|
1316 | + $event['id'] = 'personal_'.$row->getId(); |
|
1317 | 1317 | $event['title'] = $row->getTitle(); |
1318 | 1318 | $event['className'] = 'personal'; |
1319 | 1319 | $event['borderColor'] = $event['backgroundColor'] = $this->event_personal_color; |
@@ -1539,12 +1539,12 @@ discard block |
||
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | if (empty($session_id)) { |
1542 | - $sessionCondition = " |
|
1542 | + $sessionCondition = " |
|
1543 | 1543 | ( |
1544 | 1544 | agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0) |
1545 | 1545 | ) "; |
1546 | 1546 | } else { |
1547 | - $sessionCondition = " |
|
1547 | + $sessionCondition = " |
|
1548 | 1548 | ( |
1549 | 1549 | agenda.session_id = $session_id AND |
1550 | 1550 | ip.session_id = $session_id |
@@ -1583,13 +1583,13 @@ discard block |
||
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | if (empty($session_id)) { |
1586 | - $sessionCondition = " |
|
1586 | + $sessionCondition = " |
|
1587 | 1587 | ( |
1588 | 1588 | agenda.session_id = 0 AND |
1589 | 1589 | (ip.session_id IS NULL OR ip.session_id = 0) |
1590 | 1590 | ) "; |
1591 | 1591 | } else { |
1592 | - $sessionCondition = " |
|
1592 | + $sessionCondition = " |
|
1593 | 1593 | ( |
1594 | 1594 | agenda.session_id = $session_id AND |
1595 | 1595 | ip.session_id = $session_id |
@@ -1641,7 +1641,7 @@ discard block |
||
1641 | 1641 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1642 | 1642 | $event = array(); |
1643 | 1643 | $event['id'] = 'course_'.$row['id']; |
1644 | - $event['unique_id'] = $row['iid']; |
|
1644 | + $event['unique_id'] = $row['iid']; |
|
1645 | 1645 | // To avoid doubles |
1646 | 1646 | if (in_array($event['unique_id'], $eventsAdded)) { |
1647 | 1647 | continue; |
@@ -2713,8 +2713,8 @@ discard block |
||
2713 | 2713 | |
2714 | 2714 | $startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e')); |
2715 | 2715 | $endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e')); |
2716 | - $title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8'); |
|
2717 | - $description = api_convert_encoding((string)$event->description, $charset, 'UTF-8'); |
|
2716 | + $title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8'); |
|
2717 | + $description = api_convert_encoding((string) $event->description, $charset, 'UTF-8'); |
|
2718 | 2718 | |
2719 | 2719 | $id = $this->addEvent( |
2720 | 2720 | $startDateTime, |
@@ -2856,7 +2856,7 @@ discard block |
||
2856 | 2856 | ORDER BY start_date "; |
2857 | 2857 | } else { |
2858 | 2858 | // if the user is not an administrator of that course |
2859 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
2859 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
2860 | 2860 | $sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref |
2861 | 2861 | FROM ".$TABLEAGENDA." agenda, |
2862 | 2862 | ".$TABLE_ITEMPROPERTY." ip |
@@ -2886,14 +2886,14 @@ discard block |
||
2886 | 2886 | $agendaday = -1; |
2887 | 2887 | if ($item['start_date'] != '0000-00-00 00:00:00') { |
2888 | 2888 | $item['start_date'] = api_get_local_time($item['start_date']); |
2889 | - $item['start_date_tms'] = api_strtotime($item['start_date']); |
|
2889 | + $item['start_date_tms'] = api_strtotime($item['start_date']); |
|
2890 | 2890 | $agendaday = date("j", $item['start_date_tms']); |
2891 | 2891 | } |
2892 | 2892 | if ($item['end_date'] != '0000-00-00 00:00:00') { |
2893 | 2893 | $item['end_date'] = api_get_local_time($item['end_date']); |
2894 | 2894 | } |
2895 | 2895 | |
2896 | - $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
|
2896 | + $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
|
2897 | 2897 | |
2898 | 2898 | $item['url'] = $url; |
2899 | 2899 | $item['course_name'] = $array_course_info['title']; |
@@ -2905,9 +2905,9 @@ discard block |
||
2905 | 2905 | } |
2906 | 2906 | |
2907 | 2907 | // sorting by hour for every day |
2908 | - $agendaitems = array (); |
|
2908 | + $agendaitems = array(); |
|
2909 | 2909 | while (list ($agendaday, $tmpitems) = each($items)) { |
2910 | - if(!isset($agendaitems[$agendaday])) { |
|
2910 | + if (!isset($agendaitems[$agendaday])) { |
|
2911 | 2911 | $agendaitems[$agendaday] = ''; |
2912 | 2912 | } |
2913 | 2913 | sort($tmpitems); |
@@ -3081,9 +3081,9 @@ discard block |
||
3081 | 3081 | $end_year = $start_end_day_of_week['end']['year']; |
3082 | 3082 | // in sql statements you have to use year-month-day for date calculations |
3083 | 3083 | $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00"; |
3084 | - $start_filter = api_get_utc_datetime($start_filter); |
|
3084 | + $start_filter = api_get_utc_datetime($start_filter); |
|
3085 | 3085 | $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59"; |
3086 | - $end_filter = api_get_utc_datetime($end_filter); |
|
3086 | + $end_filter = api_get_utc_datetime($end_filter); |
|
3087 | 3087 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; |
3088 | 3088 | } |
3089 | 3089 | // 3. creating the SQL statement for getting the personal agenda items in DAY view |
@@ -3091,18 +3091,18 @@ discard block |
||
3091 | 3091 | // we are in day view |
3092 | 3092 | // we could use mysql date() function but this is only available from 4.1 and higher |
3093 | 3093 | $start_filter = $year."-".$month."-".$day." 00:00:00"; |
3094 | - $start_filter = api_get_utc_datetime($start_filter); |
|
3094 | + $start_filter = api_get_utc_datetime($start_filter); |
|
3095 | 3095 | $end_filter = $year."-".$month."-".$day." 23:59:59"; |
3096 | - $end_filter = api_get_utc_datetime($end_filter); |
|
3096 | + $end_filter = api_get_utc_datetime($end_filter); |
|
3097 | 3097 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; |
3098 | 3098 | } |
3099 | 3099 | |
3100 | 3100 | $result = Database::query($sql); |
3101 | 3101 | while ($item = Database::fetch_array($result, 'ASSOC')) { |
3102 | 3102 | |
3103 | - $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT); |
|
3104 | - $item['date'] = api_get_local_time($item['date']); |
|
3105 | - $item['start_date_tms'] = api_strtotime($item['date']); |
|
3103 | + $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT); |
|
3104 | + $item['date'] = api_get_local_time($item['date']); |
|
3105 | + $item['start_date_tms'] = api_strtotime($item['date']); |
|
3106 | 3106 | $item['content'] = $item['text']; |
3107 | 3107 | |
3108 | 3108 | // we break the date field in the database into a date and a time part |
@@ -3122,7 +3122,7 @@ discard block |
||
3122 | 3122 | $second = $agendatime[2]; |
3123 | 3123 | |
3124 | 3124 | if ($type == 'month_view') { |
3125 | - $item['calendar_type'] = 'personal'; |
|
3125 | + $item['calendar_type'] = 'personal'; |
|
3126 | 3126 | $item['start_date'] = $item['date']; |
3127 | 3127 | $agendaitems[$day][] = $item; |
3128 | 3128 | continue; |
@@ -3147,7 +3147,7 @@ discard block |
||
3147 | 3147 | // this is the array construction for the DAY view |
3148 | 3148 | $halfhour = 2 * $agendatime['0']; |
3149 | 3149 | if ($agendatime['1'] >= '30') { |
3150 | - $halfhour = $halfhour +1; |
|
3150 | + $halfhour = $halfhour + 1; |
|
3151 | 3151 | } |
3152 | 3152 | |
3153 | 3153 | //Display events by list |
@@ -3171,25 +3171,25 @@ discard block |
||
3171 | 3171 | { |
3172 | 3172 | global $DaysShort, $course_path; |
3173 | 3173 | //Handle leap year |
3174 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
3174 | + $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
3175 | 3175 | if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
3176 | 3176 | $numberofdays[2] = 29; |
3177 | 3177 | //Get the first day of the month |
3178 | 3178 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
3179 | 3179 | //Start the week on monday |
3180 | 3180 | $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
3181 | - $g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:''); |
|
3181 | + $g_cc = (isset($_GET['courseCode']) ? $_GET['courseCode'] : ''); |
|
3182 | 3182 | |
3183 | - $prev_icon = Display::return_icon('action_prev.png',get_lang('Previous')); |
|
3184 | - $next_icon = Display::return_icon('action_next.png',get_lang('Next')); |
|
3183 | + $prev_icon = Display::return_icon('action_prev.png', get_lang('Previous')); |
|
3184 | + $next_icon = Display::return_icon('action_next.png', get_lang('Next')); |
|
3185 | 3185 | |
3186 | - $next_month = ($month == 1 ? 12 : $month -1); |
|
3187 | - $prev_month = ($month == 12 ? 1 : $month +1); |
|
3186 | + $next_month = ($month == 1 ? 12 : $month - 1); |
|
3187 | + $prev_month = ($month == 12 ? 1 : $month + 1); |
|
3188 | 3188 | |
3189 | - $next_year = ($month == 1 ? $year -1 : $year); |
|
3190 | - $prev_year = ($month == 12 ? $year +1 : $year); |
|
3189 | + $next_year = ($month == 1 ? $year - 1 : $year); |
|
3190 | + $prev_year = ($month == 12 ? $year + 1 : $year); |
|
3191 | 3191 | |
3192 | - if ($show_content) { |
|
3192 | + if ($show_content) { |
|
3193 | 3193 | $back_url = Display::url($prev_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year); |
3194 | 3194 | $next_url = Display::url($next_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year); |
3195 | 3195 | } else { |
@@ -3205,7 +3205,7 @@ discard block |
||
3205 | 3205 | echo '</tr>'; |
3206 | 3206 | |
3207 | 3207 | echo '<tr>'; |
3208 | - for ($ii = 1; $ii < 8; $ii ++) { |
|
3208 | + for ($ii = 1; $ii < 8; $ii++) { |
|
3209 | 3209 | echo '<td class="weekdays">'.$DaysShort[$ii % 7].'</td>'; |
3210 | 3210 | } |
3211 | 3211 | echo '</tr>'; |
@@ -3214,7 +3214,7 @@ discard block |
||
3214 | 3214 | $today = getdate(); |
3215 | 3215 | while ($curday <= $numberofdays[$month]) { |
3216 | 3216 | echo "<tr>"; |
3217 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
3217 | + for ($ii = 0; $ii < 7; $ii++) { |
|
3218 | 3218 | if (($curday == -1) && ($ii == $startdayofweek)) { |
3219 | 3219 | $curday = 1; |
3220 | 3220 | } |
@@ -3231,18 +3231,18 @@ discard block |
||
3231 | 3231 | $items = $agendaitems[$curday]; |
3232 | 3232 | $items = ArrayClass::msort($items, 'start_date_tms'); |
3233 | 3233 | |
3234 | - foreach($items as $value) { |
|
3234 | + foreach ($items as $value) { |
|
3235 | 3235 | $value['title'] = Security::remove_XSS($value['title']); |
3236 | 3236 | $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT); |
3237 | 3237 | $end_time = ''; |
3238 | 3238 | |
3239 | 3239 | if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') { |
3240 | - $end_time = '- <i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>'; |
|
3240 | + $end_time = '- <i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>'; |
|
3241 | 3241 | } |
3242 | 3242 | $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i> '.$end_time; |
3243 | 3243 | $time = '<i>'.$start_time.'</i>'; |
3244 | 3244 | |
3245 | - switch($value['calendar_type']) { |
|
3245 | + switch ($value['calendar_type']) { |
|
3246 | 3246 | case 'personal': |
3247 | 3247 | $bg_color = '#D0E7F4'; |
3248 | 3248 | $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL); |
@@ -3294,7 +3294,7 @@ discard block |
||
3294 | 3294 | } |
3295 | 3295 | } |
3296 | 3296 | echo "</td>"; |
3297 | - $curday ++; |
|
3297 | + $curday++; |
|
3298 | 3298 | } else { |
3299 | 3299 | echo "<td></td>"; |
3300 | 3300 | } |
@@ -3314,18 +3314,18 @@ discard block |
||
3314 | 3314 | * where datestart and dateend are in yyyyMMddhhmmss format. |
3315 | 3315 | * @TODO Implement really personal events (from user DB) and global events (from main DB) |
3316 | 3316 | */ |
3317 | - public static function get_personal_agenda_items_between_dates($user_id, $date_start='', $date_end='') |
|
3317 | + public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '') |
|
3318 | 3318 | { |
3319 | - $items = array (); |
|
3319 | + $items = array(); |
|
3320 | 3320 | if ($user_id != strval(intval($user_id))) { return $items; } |
3321 | - if (empty($date_start)) { $date_start = date('Y-m-d H:i:s');} |
|
3322 | - if (empty($date_end)) { $date_end = date('Y-m-d H:i:s',mktime(0, 0, 0, date("m"), date("d"), date("Y")+1));} |
|
3321 | + if (empty($date_start)) { $date_start = date('Y-m-d H:i:s'); } |
|
3322 | + if (empty($date_end)) { $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); } |
|
3323 | 3323 | $expr = '/\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}/'; |
3324 | - if(!preg_match($expr,$date_start)) { return $items; } |
|
3325 | - if(!preg_match($expr,$date_end)) { return $items; } |
|
3324 | + if (!preg_match($expr, $date_start)) { return $items; } |
|
3325 | + if (!preg_match($expr, $date_end)) { return $items; } |
|
3326 | 3326 | |
3327 | 3327 | // get agenda-items for every course |
3328 | - $courses = api_get_user_courses($user_id,false); |
|
3328 | + $courses = api_get_user_courses($user_id, false); |
|
3329 | 3329 | foreach ($courses as $id => $course) { |
3330 | 3330 | $c = api_get_course_info_by_id($course['real_id']); |
3331 | 3331 | //databases of the courses |
@@ -3349,9 +3349,9 @@ discard block |
||
3349 | 3349 | " ORDER BY start_date "; |
3350 | 3350 | } else { |
3351 | 3351 | // if the user is not an administrator of that course, then... |
3352 | - if (is_array($group_memberships) && count($group_memberships)>0) |
|
3352 | + if (is_array($group_memberships) && count($group_memberships) > 0) |
|
3353 | 3353 | { |
3354 | - $sqlquery = "SELECT " . |
|
3354 | + $sqlquery = "SELECT ". |
|
3355 | 3355 | "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref ". |
3356 | 3356 | " FROM ".$t_a." agenda, ". |
3357 | 3357 | $t_ip." ip ". |
@@ -3379,13 +3379,13 @@ discard block |
||
3379 | 3379 | |
3380 | 3380 | $result = Database::query($sqlquery); |
3381 | 3381 | while ($item = Database::fetch_array($result)) { |
3382 | - $agendaday = date("j",strtotime($item['start_date'])); |
|
3383 | - $month = date("n",strtotime($item['start_date'])); |
|
3384 | - $year = date("Y",strtotime($item['start_date'])); |
|
3382 | + $agendaday = date("j", strtotime($item['start_date'])); |
|
3383 | + $month = date("n", strtotime($item['start_date'])); |
|
3384 | + $year = date("Y", strtotime($item['start_date'])); |
|
3385 | 3385 | $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
3386 | - list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']); |
|
3386 | + list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']); |
|
3387 | 3387 | $start_date = $year.$month.$day.$hour.$min; |
3388 | - list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']); |
|
3388 | + list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']); |
|
3389 | 3389 | $end_date = $year.$month.$day.$hour.$min; |
3390 | 3390 | |
3391 | 3391 | $items[] = array( |
@@ -3414,7 +3414,7 @@ discard block |
||
3414 | 3414 | $user = api_get_user_id(); |
3415 | 3415 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE id=".$id." AND user = ".$user; |
3416 | 3416 | $result = Database::query($sql); |
3417 | - if(Database::num_rows($result)==1) { |
|
3417 | + if (Database::num_rows($result) == 1) { |
|
3418 | 3418 | $item = Database::fetch_array($result); |
3419 | 3419 | } else { |
3420 | 3420 | $item = null; |
@@ -3436,9 +3436,9 @@ discard block |
||
3436 | 3436 | // step 2: we which day this is (0=sunday, 1=monday, ...) |
3437 | 3437 | $number_day_in_week = date('w', $random_day_in_week); |
3438 | 3438 | // step 3: we calculate the timestamp of the monday of the week we are in |
3439 | - $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60); |
|
3439 | + $start_timestamp = $random_day_in_week - (($number_day_in_week - 1) * 24 * 60 * 60); |
|
3440 | 3440 | // step 4: we calculate the timestamp of the sunday of the week we are in |
3441 | - $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600; |
|
3441 | + $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week + 1) * 24 * 60 * 60) - 3600; |
|
3442 | 3442 | // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year |
3443 | 3443 | $start_day = date('j', $start_timestamp); |
3444 | 3444 | $start_month = date('n', $start_timestamp); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * |
18 | 18 | * @param int|array $course |
19 | - * @param int|array $annoucement |
|
19 | + * @param integer $announcement |
|
20 | 20 | * |
21 | 21 | * @return AnnouncementEmail |
22 | 22 | */ |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param string $key |
52 | 52 | * |
53 | - * @return array |
|
53 | + * @return string|null |
|
54 | 54 | */ |
55 | 55 | public function course($key = '') |
56 | 56 | { |
@@ -196,7 +196,7 @@ |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | - public function sender($key = '', $userId = '') |
|
199 | + public function sender($key = '', $userId = '') |
|
200 | 200 | { |
201 | 201 | $_user = api_get_user_info($userId); |
202 | 202 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @return array |
|
21 | + * @return string[] |
|
22 | 22 | */ |
23 | 23 | public static function get_tags() |
24 | 24 | { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string $course_code |
41 | 41 | * @param int $session_id |
42 | 42 | * |
43 | - * @return mixed |
|
43 | + * @return string |
|
44 | 44 | */ |
45 | 45 | public static function parse_content($userId, $content, $course_code, $session_id = 0) |
46 | 46 | { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @param array uploaded file $_FILES |
350 | 350 | * @param string Comment describing the attachment |
351 | 351 | * @param bool $sendToUsersInSession |
352 | - * @return int false on failure, ID of the announcement on success |
|
352 | + * @return false|string false on failure, ID of the announcement on success |
|
353 | 353 | */ |
354 | 354 | public static function add_announcement( |
355 | 355 | $emailTitle, |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param $to_users |
461 | 461 | * @param array $file |
462 | 462 | * @param string $file_comment |
463 | - * @return bool|int |
|
463 | + * @return false|string |
|
464 | 464 | */ |
465 | 465 | public static function add_group_announcement( |
466 | 466 | $emailTitle, |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | /** |
701 | 701 | * @param int $insert_id |
702 | - * @return bool |
|
702 | + * @return false|null |
|
703 | 703 | */ |
704 | 704 | public static function update_mail_sent($insert_id) |
705 | 705 | { |
@@ -719,6 +719,7 @@ discard block |
||
719 | 719 | * Gets all announcements from a user by course |
720 | 720 | * @param string course db |
721 | 721 | * @param int user id |
722 | + * @param integer $user_id |
|
722 | 723 | * @return array html with the content and count of announcements or false otherwise |
723 | 724 | */ |
724 | 725 | public static function get_all_annoucement_by_user_course($course_code, $user_id) |
@@ -1184,6 +1185,7 @@ discard block |
||
1184 | 1185 | * has been sent to |
1185 | 1186 | * @param string The tool (announcement, agenda, ...) |
1186 | 1187 | * @param int ID of the element of the corresponding type |
1188 | + * @param string $tool |
|
1187 | 1189 | * @return array Array of users and groups to whom the element has been sent |
1188 | 1190 | */ |
1189 | 1191 | public static function sent_to($tool, $id) |
@@ -1308,6 +1310,8 @@ discard block |
||
1308 | 1310 | * @param int attach id |
1309 | 1311 | * @param array uploaded file $_FILES |
1310 | 1312 | * @param string file comment |
1313 | + * @param integer $id_attach |
|
1314 | + * @param string $file_comment |
|
1311 | 1315 | * @return int |
1312 | 1316 | */ |
1313 | 1317 | public static function edit_announcement_attachment_file($id_attach, $file, $file_comment) |
@@ -1510,7 +1510,7 @@ |
||
1510 | 1510 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
1511 | 1511 | ) "; |
1512 | 1512 | } else { |
1513 | - $cond_user_id = " AND ( |
|
1513 | + $cond_user_id = " AND ( |
|
1514 | 1514 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".api_get_group_id().")) |
1515 | 1515 | )"; |
1516 | 1516 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | announcement.id = '$announcement_id' AND |
217 | 217 | toolitemproperties.tool='announcement' AND |
218 | 218 | ( |
219 | - toolitemproperties.to_user_id='" . api_get_user_id() . "' OR |
|
220 | - toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list) . "') OR |
|
219 | + toolitemproperties.to_user_id='".api_get_user_id()."' OR |
|
220 | + toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list)."') OR |
|
221 | 221 | toolitemproperties.to_group_id IS NULL |
222 | 222 | ) AND |
223 | 223 | toolitemproperties.visibility='1' AND |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | $title = $result['title']; |
247 | 247 | $content = $result['content']; |
248 | 248 | $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">"; |
249 | - $html .= "<tr><td><h2>" . $title . "</h2></td></tr>"; |
|
249 | + $html .= "<tr><td><h2>".$title."</h2></td></tr>"; |
|
250 | 250 | |
251 | 251 | if (api_is_allowed_to_edit(false, true) || |
252 | 252 | (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
253 | 253 | ) { |
254 | - $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $announcement_id . "\">" . |
|
255 | - Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>"; |
|
254 | + $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$announcement_id."\">". |
|
255 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
256 | 256 | if ($result['visibility'] == 1) { |
257 | 257 | $image_visibility = "visible"; |
258 | 258 | $alt_visibility = get_lang('Hide'); |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | } |
263 | 263 | global $stok; |
264 | 264 | |
265 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . (!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '') . "&action=showhide&id=" . $announcement_id . "&sec_token=" . $stok . "\">" . |
|
266 | - Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>"; |
|
265 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '')."&action=showhide&id=".$announcement_id."&sec_token=".$stok."\">". |
|
266 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
267 | 267 | |
268 | 268 | if (api_is_allowed_to_edit(false, true)) { |
269 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $announcement_id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . |
|
270 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . |
|
269 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$announcement_id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">". |
|
270 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
271 | 271 | "</a>"; |
272 | 272 | } |
273 | 273 | $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>"; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $content = self::parse_content($result['to_user_id'], $content, api_get_course_id(), api_get_session_id()); |
277 | 277 | |
278 | 278 | $html .= "<tr><td>$content</td></tr>"; |
279 | - $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG) . "</td></tr>"; |
|
279 | + $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG)."</td></tr>"; |
|
280 | 280 | |
281 | 281 | // User or group icon |
282 | 282 | $sent_to_icon = ''; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $sent_to_form = self::sent_to_form($sent_to); |
289 | 289 | $html .= Display::tag( |
290 | 290 | 'td', |
291 | - get_lang('SentTo') . ' : ' . $sent_to_form, |
|
291 | + get_lang('SentTo').' : '.$sent_to_form, |
|
292 | 292 | array('class' => 'announcements_datum') |
293 | 293 | ); |
294 | 294 | } |
@@ -298,15 +298,15 @@ discard block |
||
298 | 298 | $html .= "<tr><td>"; |
299 | 299 | $realname = $attachment_list['path']; |
300 | 300 | $user_filename = $attachment_list['filename']; |
301 | - $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname; |
|
301 | + $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname; |
|
302 | 302 | $html .= '<br/>'; |
303 | 303 | $html .= Display::return_icon('attachment.gif', get_lang('Attachment')); |
304 | - $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>'; |
|
305 | - $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; |
|
304 | + $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>'; |
|
305 | + $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
|
306 | 306 | if (api_is_allowed_to_edit(false, true)) { |
307 | 307 | $html .= Display::url( |
308 | 308 | Display::return_icon('delete.png', get_lang('Delete'), '', 16), |
309 | - api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok |
|
309 | + api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | $html .= '</td></tr>'; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $order = 0; |
335 | 335 | if (Database::num_rows($res_max)) { |
336 | 336 | $row_max = Database::fetch_array($res_max); |
337 | - $order = intval($row_max[0])+1; |
|
337 | + $order = intval($row_max[0]) + 1; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $order; |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | $result = array(); |
755 | 755 | if ($num_rows > 0) { |
756 | 756 | while ($myrow = Database::fetch_array($rs)) { |
757 | - $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />'; |
|
758 | - $content.= $myrow['content']; |
|
757 | + $content .= '<strong>'.$myrow['title'].'</strong><br /><br />'; |
|
758 | + $content .= $myrow['content']; |
|
759 | 759 | $i++; |
760 | 760 | } |
761 | 761 | $result['content'] = $content; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | echo "<table id=\"recipient_list\" >"; |
787 | 787 | echo '<tr>'; |
788 | 788 | echo '<td>'; |
789 | - echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>"; |
|
789 | + echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers')."</label>"; |
|
790 | 790 | echo "</td>"; |
791 | 791 | echo '</tr>'; |
792 | 792 | echo '<tr>'; |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | // the form containing all the groups and all the users of the course |
796 | 796 | echo '<td>'; |
797 | - echo "<strong>" . get_lang('Users') . "</strong><br />"; |
|
797 | + echo "<strong>".get_lang('Users')."</strong><br />"; |
|
798 | 798 | |
799 | 799 | self::construct_not_selected_select_form($groupList, $userList, $to_already_selected); |
800 | 800 | echo "</td>"; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | echo "<td>"; |
810 | 810 | |
811 | 811 | // the form containing the selected groups and users |
812 | - echo "<strong>" . get_lang('DestinationUsers') . "</strong><br />"; |
|
812 | + echo "<strong>".get_lang('DestinationUsers')."</strong><br />"; |
|
813 | 813 | self::construct_selected_select_form($groupList, $userList, $to_already_selected); |
814 | 814 | echo "</td>"; |
815 | 815 | echo "</tr>"; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>"; |
828 | 828 | $group_users = GroupManager::getStudentsAndTutors($group_id); |
829 | 829 | foreach ($group_users as $user) { |
830 | - echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . |
|
831 | - api_get_person_name($user['firstname'], $user['lastname']) . |
|
830 | + echo '<option value="'.$user['user_id'].'" title="'.sprintf(get_lang('LoginX'), $user['username']).'" >'. |
|
831 | + api_get_person_name($user['firstname'], $user['lastname']). |
|
832 | 832 | '</option>'; |
833 | 833 | } |
834 | 834 | echo '</select>'; |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | if (!empty($groupList)) { |
867 | 867 | foreach ($groupList as $this_group) { |
868 | 868 | if (is_array($to_already_selected)) { |
869 | - if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { |
|
869 | + if (!in_array("GROUP:".$this_group['id'], $to_already_selected)) { |
|
870 | 870 | // $to_already_selected is the array containing the groups (and users) that are already selected |
871 | - $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ; |
|
872 | - $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ; |
|
873 | - echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">", |
|
874 | - "G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label . |
|
871 | + $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser'); |
|
872 | + $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled"; |
|
873 | + echo "<option $user_disabled value=\"GROUP:".$this_group['id']."\">", |
|
874 | + "G: ", $this_group['name'], " - ".$this_group['userNb']." ".$user_label. |
|
875 | 875 | "</option>"; |
876 | 876 | } |
877 | 877 | } |
@@ -885,15 +885,15 @@ discard block |
||
885 | 885 | if (!empty($userList)) { |
886 | 886 | foreach ($userList as $user) { |
887 | 887 | if (is_array($to_already_selected)) { |
888 | - if (!in_array("USER:" . $user['user_id'], $to_already_selected)) { |
|
888 | + if (!in_array("USER:".$user['user_id'], $to_already_selected)) { |
|
889 | 889 | // $to_already_selected is the array containing the users (and groups) that are already selected |
890 | - echo "<option value=\"USER:" . $user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $user['username']) . "'>", |
|
890 | + echo "<option value=\"USER:".$user['user_id']."\" title='".sprintf(get_lang('LoginX'), $user['username'])."'>", |
|
891 | 891 | "", api_get_person_name($user['firstname'], $user['lastname']), |
892 | 892 | "</option>"; |
893 | 893 | |
894 | 894 | if (isset($user['drh_list']) && !empty($user['drh_list'])) { |
895 | 895 | foreach ($user['drh_list'] as $drh) { |
896 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
896 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
897 | 897 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
898 | 898 | "</option>"; |
899 | 899 | } |
@@ -925,16 +925,16 @@ discard block |
||
925 | 925 | foreach ($to_already_selected as $groupuser) { |
926 | 926 | list($type, $id) = explode(":", $groupuser); |
927 | 927 | if ($type == "GROUP") { |
928 | - echo "<option value=\"" . $groupuser . "\">G: " . $ref_array_groups[$id]['name'] . "</option>"; |
|
928 | + echo "<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>"; |
|
929 | 929 | } else { |
930 | 930 | foreach ($ref_array_users as $key => $value) { |
931 | 931 | if ($value['user_id'] == $id) { |
932 | - echo "<option value=\"" . $groupuser . "\" title='" . sprintf(get_lang('LoginX'), $value['username']) . "'>" . |
|
933 | - api_get_person_name($value['firstname'], $value['lastname']) . "</option>"; |
|
932 | + echo "<option value=\"".$groupuser."\" title='".sprintf(get_lang('LoginX'), $value['username'])."'>". |
|
933 | + api_get_person_name($value['firstname'], $value['lastname'])."</option>"; |
|
934 | 934 | |
935 | 935 | if (isset($value['drh_list']) && !empty($value['drh_list'])) { |
936 | 936 | foreach ($value['drh_list'] as $drh) { |
937 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
937 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
938 | 938 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
939 | 939 | "</option>"; |
940 | 940 | } |
@@ -950,17 +950,17 @@ discard block |
||
950 | 950 | if (is_array($ref_array_groups)) { |
951 | 951 | foreach ($ref_array_groups as $this_group) { |
952 | 952 | //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]); |
953 | - if (!is_array($to_already_selected) || !in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | - echo "<option value=\"GROUP:" . $this_group['id'] . "\">", |
|
955 | - "G: ", $this_group['name'], " – " . $this_group['userNb'] . " " . get_lang('Users') . |
|
953 | + if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | + echo "<option value=\"GROUP:".$this_group['id']."\">", |
|
955 | + "G: ", $this_group['name'], " – ".$this_group['userNb']." ".get_lang('Users'). |
|
956 | 956 | "</option>"; |
957 | 957 | } |
958 | 958 | } |
959 | 959 | } |
960 | 960 | // adding the individual users to the select form |
961 | 961 | foreach ($ref_array_users as $this_user) { |
962 | - if (!is_array($to_already_selected) || !in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | - echo "<option value=\"USER:", $this_user['user_id'], "\" title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>", |
|
962 | + if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | + echo "<option value=\"USER:", $this_user['user_id'], "\" title='".sprintf(get_lang('LoginX'), $this_user['username'])."'>", |
|
964 | 964 | "", api_get_person_name($this_user['firstname'], $this_user['lastname']), |
965 | 965 | "</option>"; |
966 | 966 | } |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | switch ($to_group) { |
1074 | 1074 | // it was send to one specific user |
1075 | 1075 | case null: |
1076 | - $to[] = "USER:" . $row['to_user_id']; |
|
1076 | + $to[] = "USER:".$row['to_user_id']; |
|
1077 | 1077 | break; |
1078 | 1078 | // it was sent to everyone |
1079 | 1079 | case 0: |
1080 | 1080 | return "everyone"; |
1081 | 1081 | break; |
1082 | 1082 | default: |
1083 | - $to[] = "GROUP:" . $row['to_group_id']; |
|
1083 | + $to[] = "GROUP:".$row['to_group_id']; |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | return $to; |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | $sent_to_array['groups'][0] !== 0 |
1162 | 1162 | ) { |
1163 | 1163 | $group_id = $sent_to_array['groups'][0]; |
1164 | - $output[] = " " . $group_names[$group_id]['name']; |
|
1164 | + $output[] = " ".$group_names[$group_id]['name']; |
|
1165 | 1165 | } |
1166 | 1166 | if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) { |
1167 | - $output[] = " " . get_lang('Everybody'); |
|
1167 | + $output[] = " ".get_lang('Everybody'); |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | |
1200 | 1200 | $sql = "SELECT to_group_id, to_user_id |
1201 | 1201 | FROM $tbl_item_property |
1202 | - WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id; |
|
1202 | + WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id; |
|
1203 | 1203 | $result = Database::query($sql); |
1204 | 1204 | |
1205 | 1205 | while ($row = Database::fetch_array($result)) { |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | $announcement_id = intval($announcement_id); |
1239 | 1239 | $course_id = api_get_course_int_id(); |
1240 | 1240 | $row = array(); |
1241 | - $sql = 'SELECT id, path, filename, comment FROM ' . $tbl_announcement_attachment . ' |
|
1242 | - WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcement_id . ''; |
|
1241 | + $sql = 'SELECT id, path, filename, comment FROM '.$tbl_announcement_attachment.' |
|
1242 | + WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcement_id.''; |
|
1243 | 1243 | $result = Database::query($sql); |
1244 | 1244 | if (Database::num_rows($result) != 0) { |
1245 | 1245 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -1264,9 +1264,9 @@ discard block |
||
1264 | 1264 | |
1265 | 1265 | if (is_array($file) && $file['error'] == 0) { |
1266 | 1266 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1267 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1267 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1268 | 1268 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1269 | - $updir = $sys_course_path . $courseDir; |
|
1269 | + $updir = $sys_course_path.$courseDir; |
|
1270 | 1270 | |
1271 | 1271 | // Try to add an extension to the file if it hasn't one |
1272 | 1272 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1279 | 1279 | } else { |
1280 | 1280 | $new_file_name = uniqid(''); |
1281 | - $new_path = $updir . '/' . $new_file_name; |
|
1281 | + $new_path = $updir.'/'.$new_file_name; |
|
1282 | 1282 | move_uploaded_file($file['tmp_name'], $new_path); |
1283 | 1283 | |
1284 | 1284 | $params = [ |
@@ -1319,9 +1319,9 @@ discard block |
||
1319 | 1319 | |
1320 | 1320 | if (is_array($file) && $file['error'] == 0) { |
1321 | 1321 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1322 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1322 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1323 | 1323 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1324 | - $updir = $sys_course_path . $courseDir; |
|
1324 | + $updir = $sys_course_path.$courseDir; |
|
1325 | 1325 | |
1326 | 1326 | // Try to add an extension to the file if it hasn't one |
1327 | 1327 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1333,13 +1333,13 @@ discard block |
||
1333 | 1333 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1334 | 1334 | } else { |
1335 | 1335 | $new_file_name = uniqid(''); |
1336 | - $new_path = $updir . '/' . $new_file_name; |
|
1336 | + $new_path = $updir.'/'.$new_file_name; |
|
1337 | 1337 | @move_uploaded_file($file['tmp_name'], $new_path); |
1338 | 1338 | $safe_file_comment = Database::escape_string($file_comment); |
1339 | 1339 | $safe_file_name = Database::escape_string($file_name); |
1340 | 1340 | $safe_new_file_name = Database::escape_string($new_file_name); |
1341 | 1341 | $id_attach = intval($id_attach); |
1342 | - $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='" . intval($file['size']) . "' |
|
1342 | + $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."' |
|
1343 | 1343 | WHERE c_id = $course_id AND id = '$id_attach'"; |
1344 | 1344 | $result = Database::query($sql); |
1345 | 1345 | if ($result === false) { |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | //if (!empty($user_id)) { |
1409 | 1409 | if (0) { |
1410 | - if (is_array($group_memberships) && count($group_memberships) > 0 ) { |
|
1410 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1411 | 1411 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
1412 | 1412 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1413 | 1413 | WHERE |
@@ -1456,8 +1456,8 @@ discard block |
||
1456 | 1456 | // A.3 you are a course admin without any group or user filter |
1457 | 1457 | // A.3.a you are a course admin without user or group filter but WITH studentview |
1458 | 1458 | // => see all the messages of all the users and groups without editing possibilities |
1459 | - if (isset($isStudentView) and $isStudentView=="true") { |
|
1460 | - $sql="SELECT |
|
1459 | + if (isset($isStudentView) and $isStudentView == "true") { |
|
1460 | + $sql = "SELECT |
|
1461 | 1461 | announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
1462 | 1462 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1463 | 1463 | WHERE |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | } |
1488 | 1488 | } else { |
1489 | 1489 | // STUDENT |
1490 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
1490 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1491 | 1491 | if ($allowUserEditSetting && !api_is_anonymous()) { |
1492 | 1492 | |
1493 | 1493 | if (api_get_group_id() == 0) { |
@@ -1591,12 +1591,12 @@ discard block |
||
1591 | 1591 | (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') |
1592 | 1592 | ) { |
1593 | 1593 | $html .= '<div id="no-data-view">'; |
1594 | - $html .= '<h3>' . get_lang('Announcements') . '</h3>'; |
|
1594 | + $html .= '<h3>'.get_lang('Announcements').'</h3>'; |
|
1595 | 1595 | $html .= Display::return_icon('valves.png', '', array(), 64); |
1596 | 1596 | $html .= '<div class="controls">'; |
1597 | 1597 | $html .= Display::url( |
1598 | 1598 | get_lang('AddAnnouncement'), |
1599 | - api_get_self() . "?" . api_get_cidreq() . "&action=add", |
|
1599 | + api_get_self()."?".api_get_cidreq()."&action=add", |
|
1600 | 1600 | array('class' => 'btn btn-primary') |
1601 | 1601 | ); |
1602 | 1602 | $html .= '</div>'; |
@@ -1613,9 +1613,9 @@ discard block |
||
1613 | 1613 | |
1614 | 1614 | $html .= '<table width="100%" class="data_table announcements-list">'; |
1615 | 1615 | $ths = Display::tag('th', get_lang('Title')); |
1616 | - $ths .= Display::tag('th', get_lang('By') ); |
|
1617 | - $ths .= Display::tag('th', get_lang('LastUpdateDate') ); |
|
1618 | - if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && |
|
1616 | + $ths .= Display::tag('th', get_lang('By')); |
|
1617 | + $ths .= Display::tag('th', get_lang('LastUpdateDate')); |
|
1618 | + if (api_is_allowed_to_edit(false, true) OR (api_is_course_coach() && |
|
1619 | 1619 | api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) |
1620 | 1620 | OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { |
1621 | 1621 | $ths .= Display::tag('th', get_lang('Modify')); |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | |
1638 | 1638 | // the styles |
1639 | 1639 | if ($myrow['visibility'] == '0') { |
1640 | - $style='invisible'; |
|
1640 | + $style = 'invisible'; |
|
1641 | 1641 | } else { |
1642 | 1642 | $style = ''; |
1643 | 1643 | } |
@@ -1648,8 +1648,8 @@ discard block |
||
1648 | 1648 | $attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
1649 | 1649 | |
1650 | 1650 | $attachment_icon = ''; |
1651 | - if (count($attachment_list)>0) { |
|
1652 | - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1651 | + if (count($attachment_list) > 0) { |
|
1652 | + $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | /* TITLE */ |
@@ -1664,22 +1664,22 @@ discard block |
||
1664 | 1664 | |
1665 | 1665 | // we can edit if : we are the teacher OR the element belongs to |
1666 | 1666 | // the session we are coaching OR the option to allow users to edit is on |
1667 | - if (api_is_allowed_to_edit(false,true) OR |
|
1667 | + if (api_is_allowed_to_edit(false, true) OR |
|
1668 | 1668 | (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) |
1669 | 1669 | OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
1670 | 1670 | ) { |
1671 | 1671 | |
1672 | 1672 | $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">". |
1673 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
1674 | - if ($myrow['visibility']==1) { |
|
1675 | - $image_visibility="visible"; |
|
1676 | - $alt_visibility=get_lang('Hide'); |
|
1673 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
1674 | + if ($myrow['visibility'] == 1) { |
|
1675 | + $image_visibility = "visible"; |
|
1676 | + $alt_visibility = get_lang('Hide'); |
|
1677 | 1677 | } else { |
1678 | - $image_visibility="invisible"; |
|
1679 | - $alt_visibility=get_lang('Visible'); |
|
1678 | + $image_visibility = "invisible"; |
|
1679 | + $alt_visibility = get_lang('Visible'); |
|
1680 | 1680 | } |
1681 | - $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1682 | - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>"; |
|
1681 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1682 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
1683 | 1683 | |
1684 | 1684 | // DISPLAY MOVE UP COMMAND only if it is not the top announcement |
1685 | 1685 | if ($iterator != 1) { |
@@ -1694,12 +1694,12 @@ discard block |
||
1694 | 1694 | } else { |
1695 | 1695 | $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
1696 | 1696 | } |
1697 | - if (api_is_allowed_to_edit(false,true)) { |
|
1698 | - $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">". |
|
1699 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
1697 | + if (api_is_allowed_to_edit(false, true)) { |
|
1698 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
1699 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
1700 | 1700 | "</a>"; |
1701 | 1701 | } |
1702 | - $iterator ++; |
|
1702 | + $iterator++; |
|
1703 | 1703 | $html .= Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions')); |
1704 | 1704 | } |
1705 | 1705 | $html .= "</tr>"; |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | public static function getNumberAnnouncements() |
1718 | 1718 | { |
1719 | 1719 | // Maximum title messages to display |
1720 | - $maximum = '12'; |
|
1720 | + $maximum = '12'; |
|
1721 | 1721 | // Database Table Definitions |
1722 | 1722 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
1723 | 1723 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | $userId = api_get_user_id(); |
1729 | 1729 | $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); |
1730 | 1730 | |
1731 | - if (api_is_allowed_to_edit(false,true)) { |
|
1731 | + if (api_is_allowed_to_edit(false, true)) { |
|
1732 | 1732 | // check teacher status |
1733 | 1733 | if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { |
1734 | 1734 | |
@@ -1791,7 +1791,7 @@ discard block |
||
1791 | 1791 | } |
1792 | 1792 | |
1793 | 1793 | // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements |
1794 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
1794 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1795 | 1795 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
1796 | 1796 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1797 | 1797 | WHERE |
@@ -1841,7 +1841,7 @@ discard block |
||
1841 | 1841 | } |
1842 | 1842 | |
1843 | 1843 | // the user is not identiefied => show only the general announcements |
1844 | - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1844 | + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1845 | 1845 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1846 | 1846 | WHERE |
1847 | 1847 | announcement.c_id = $course_id AND |
@@ -18,6 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Constructor, init tool path for rendering |
20 | 20 | * @param string tool name (optional) |
21 | + * @param string $template_path |
|
21 | 22 | */ |
22 | 23 | public function __construct($toolname = '', $template_path=null) |
23 | 24 | { |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | /** |
51 | 52 | * Set layout view sent from a controller |
52 | 53 | * @param string layout view |
54 | + * @param string $layout |
|
53 | 55 | */ |
54 | 56 | public function set_layout( $layout ) |
55 | 57 | { |
@@ -59,6 +61,7 @@ discard block |
||
59 | 61 | /** |
60 | 62 | * Set template view sent from a controller |
61 | 63 | * @param string template view |
64 | + * @param string $template |
|
62 | 65 | */ |
63 | 66 | public function set_template($template) |
64 | 67 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * Constructor, init tool path for rendering |
20 | 20 | * @param string tool name (optional) |
21 | 21 | */ |
22 | - public function __construct($toolname = '', $template_path=null) |
|
22 | + public function __construct($toolname = '', $template_path = null) |
|
23 | 23 | { |
24 | 24 | if (!empty($toolname)) { |
25 | 25 | if (isset($template_path)) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (is_dir($path)) { |
31 | 31 | $this->tool_path = $path; |
32 | 32 | } else { |
33 | - throw new ViewException('View::__construct() $path directory does not exist ' . $path); |
|
33 | + throw new ViewException('View::__construct() $path directory does not exist '.$path); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function set_data($data) |
43 | 43 | { |
44 | 44 | if (!is_array($data)) { |
45 | - throw new ViewException('View::set_data() $data must to be an array, you have sent a' . gettype( $data )); |
|
45 | + throw new ViewException('View::set_data() $data must to be an array, you have sent a'.gettype($data)); |
|
46 | 46 | } |
47 | 47 | $this->data = $data; |
48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Set layout view sent from a controller |
52 | 52 | * @param string layout view |
53 | 53 | */ |
54 | - public function set_layout( $layout ) |
|
54 | + public function set_layout($layout) |
|
55 | 55 | { |
56 | 56 | $this->layout = $layout; |
57 | 57 | } |
@@ -96,9 +96,7 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Creates a new blog in the given course |
98 | 98 | * @author Toon Keppens |
99 | - * @param Integer $course_id Id |
|
100 | 99 | * @param String $title |
101 | - * @param Text $description |
|
102 | 100 | */ |
103 | 101 | public static function create_blog($title, $subtitle) |
104 | 102 | { |
@@ -186,9 +184,7 @@ discard block |
||
186 | 184 | /** |
187 | 185 | * Update title and subtitle of a blog in the given course |
188 | 186 | * @author Toon Keppens |
189 | - * @param Integer $course_id Id |
|
190 | 187 | * @param String $title |
191 | - * @param Text $description |
|
192 | 188 | */ |
193 | 189 | public static function edit_blog($blog_id, $title, $subtitle) |
194 | 190 | { |
@@ -714,7 +710,6 @@ discard block |
||
714 | 710 | /** |
715 | 711 | * Deletes an assigned task from a blog |
716 | 712 | * @param Integer $blog_id |
717 | - * @param Integer $assignment_id |
|
718 | 713 | */ |
719 | 714 | public static function delete_assigned_task($blog_id, $task_id, $user_id) |
720 | 715 | { |
@@ -1126,9 +1121,7 @@ discard block |
||
1126 | 1121 | * |
1127 | 1122 | * @param String $type |
1128 | 1123 | * @param Integer $blog_id |
1129 | - * @param Integer $item_id |
|
1130 | - * |
|
1131 | - *@return String |
|
1124 | + * @param integer $post_id |
|
1132 | 1125 | */ |
1133 | 1126 | public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
1134 | 1127 | { |
@@ -2113,7 +2106,7 @@ discard block |
||
2113 | 2106 | * |
2114 | 2107 | * @param Integer $blog_id |
2115 | 2108 | * |
2116 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
2109 | + * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
2117 | 2110 | */ |
2118 | 2111 | public static function display_form_user_unsubscribe ($blog_id) |
2119 | 2112 | { |
@@ -2234,6 +2227,7 @@ discard block |
||
2234 | 2227 | * @author Toon Keppens |
2235 | 2228 | * |
2236 | 2229 | * @param Integer $blog_id |
2230 | + * @param integer $post_id |
|
2237 | 2231 | */ |
2238 | 2232 | public static function display_new_comment_form($blog_id, $post_id, $title) |
2239 | 2233 | { |
@@ -2282,10 +2276,8 @@ discard block |
||
2282 | 2276 | * @author Patrick Cool |
2283 | 2277 | * @author Toon Keppens |
2284 | 2278 | * |
2285 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
2286 | 2279 | * @param Integer $month: the integer value of the month we are viewing |
2287 | 2280 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
2288 | - * @param String $monthName: the language variable for the mont name |
|
2289 | 2281 | * |
2290 | 2282 | * @return html code |
2291 | 2283 | */ |
@@ -2579,6 +2571,7 @@ discard block |
||
2579 | 2571 | * @param the blog's id |
2580 | 2572 | * @param the post's id |
2581 | 2573 | * @param the comment's id |
2574 | + * @param integer $blog_id |
|
2582 | 2575 | * @return array with the post info according the parameters |
2583 | 2576 | * @author Julio Montoya Dokeos |
2584 | 2577 | * @version avril 2008, dokeos 1.8.5 |
@@ -2620,6 +2613,9 @@ discard block |
||
2620 | 2613 | * @param the blog's id |
2621 | 2614 | * @param the post's id |
2622 | 2615 | * @param the comment's id |
2616 | + * @param integer $blog_id |
|
2617 | + * @param integer $post_id |
|
2618 | + * @param integer $comment_id |
|
2623 | 2619 | * @author Julio Montoya Dokeos |
2624 | 2620 | * @version avril 2008, dokeos 1.8.5 |
2625 | 2621 | */ |
@@ -6,115 +6,114 @@ discard block |
||
6 | 6 | * |
7 | 7 | * Contains several functions dealing with displaying, |
8 | 8 | * editing,... of a blog |
9 | - |
|
10 | 9 | * @package chamilo.blogs |
11 | 10 | * @author Toon Keppens <[email protected]> |
12 | 11 | * @author Julio Montoya - Cleaning code |
13 | 12 | */ |
14 | 13 | class Blog |
15 | 14 | { |
16 | - /** |
|
17 | - * Get the title of a blog |
|
18 | - * @author Toon Keppens |
|
19 | - * |
|
20 | - * @param int $blog_id |
|
21 | - * |
|
22 | - * @return String Blog Title |
|
23 | - */ |
|
24 | - public static function get_blog_title ($blog_id) |
|
25 | - { |
|
26 | - $course_id = api_get_course_int_id(); |
|
27 | - |
|
28 | - if (is_numeric($blog_id)) { |
|
29 | - // init |
|
30 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
31 | - |
|
32 | - $sql = "SELECT blog_name |
|
15 | + /** |
|
16 | + * Get the title of a blog |
|
17 | + * @author Toon Keppens |
|
18 | + * |
|
19 | + * @param int $blog_id |
|
20 | + * |
|
21 | + * @return String Blog Title |
|
22 | + */ |
|
23 | + public static function get_blog_title ($blog_id) |
|
24 | + { |
|
25 | + $course_id = api_get_course_int_id(); |
|
26 | + |
|
27 | + if (is_numeric($blog_id)) { |
|
28 | + // init |
|
29 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
30 | + |
|
31 | + $sql = "SELECT blog_name |
|
33 | 32 | FROM " . $tbl_blogs . " |
34 | 33 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
35 | 34 | |
36 | - $result = Database::query($sql); |
|
37 | - $blog = Database::fetch_array($result); |
|
38 | - return stripslashes($blog['blog_name']); |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Get the description of a blog |
|
45 | - * @author Toon Keppens |
|
46 | - * |
|
47 | - * @param Integer $blog_id |
|
48 | - * |
|
49 | - * @return String Blog description |
|
50 | - */ |
|
51 | - public static function get_blog_subtitle($blog_id) |
|
52 | - { |
|
53 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
54 | - $course_id = api_get_course_int_id(); |
|
55 | - $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
35 | + $result = Database::query($sql); |
|
36 | + $blog = Database::fetch_array($result); |
|
37 | + return stripslashes($blog['blog_name']); |
|
38 | + } |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Get the description of a blog |
|
44 | + * @author Toon Keppens |
|
45 | + * |
|
46 | + * @param Integer $blog_id |
|
47 | + * |
|
48 | + * @return String Blog description |
|
49 | + */ |
|
50 | + public static function get_blog_subtitle($blog_id) |
|
51 | + { |
|
52 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
53 | + $course_id = api_get_course_int_id(); |
|
54 | + $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
56 | 55 | WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; |
57 | - $result = Database::query($sql); |
|
58 | - $blog = Database::fetch_array($result); |
|
59 | - |
|
60 | - return stripslashes($blog['blog_subtitle']); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get the users of a blog |
|
65 | - * @author Toon Keppens |
|
66 | - * |
|
67 | - * @param Integer $blog_id |
|
68 | - * |
|
69 | - * @return Array Returns an array with [userid]=>[username] |
|
70 | - */ |
|
71 | - public static function get_blog_users($blog_id) |
|
72 | - { |
|
73 | - // Database table definitions |
|
74 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
75 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
76 | - |
|
77 | - $course_id = api_get_course_int_id(); |
|
78 | - |
|
79 | - // Get blog members |
|
80 | - $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
56 | + $result = Database::query($sql); |
|
57 | + $blog = Database::fetch_array($result); |
|
58 | + |
|
59 | + return stripslashes($blog['blog_subtitle']); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Get the users of a blog |
|
64 | + * @author Toon Keppens |
|
65 | + * |
|
66 | + * @param Integer $blog_id |
|
67 | + * |
|
68 | + * @return Array Returns an array with [userid]=>[username] |
|
69 | + */ |
|
70 | + public static function get_blog_users($blog_id) |
|
71 | + { |
|
72 | + // Database table definitions |
|
73 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
74 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
75 | + |
|
76 | + $course_id = api_get_course_int_id(); |
|
77 | + |
|
78 | + // Get blog members |
|
79 | + $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
81 | 80 | FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
82 | 81 | INNER JOIN " . $tbl_users . " user |
83 | 82 | ON blogs_rel_user.user_id = user.user_id |
84 | 83 | WHERE |
85 | 84 | blogs_rel_user.c_id = $course_id AND |
86 | 85 | blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
87 | - $result = Database::query($sql); |
|
88 | - $blog_members = array (); |
|
89 | - while($user = Database::fetch_array($result)) { |
|
90 | - $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
91 | - } |
|
92 | - |
|
93 | - return $blog_members; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Creates a new blog in the given course |
|
98 | - * @author Toon Keppens |
|
99 | - * @param Integer $course_id Id |
|
100 | - * @param String $title |
|
101 | - * @param Text $description |
|
102 | - */ |
|
103 | - public static function create_blog($title, $subtitle) |
|
104 | - { |
|
105 | - $_user = api_get_user_info(); |
|
86 | + $result = Database::query($sql); |
|
87 | + $blog_members = array (); |
|
88 | + while($user = Database::fetch_array($result)) { |
|
89 | + $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
90 | + } |
|
91 | + |
|
92 | + return $blog_members; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Creates a new blog in the given course |
|
97 | + * @author Toon Keppens |
|
98 | + * @param Integer $course_id Id |
|
99 | + * @param String $title |
|
100 | + * @param Text $description |
|
101 | + */ |
|
102 | + public static function create_blog($title, $subtitle) |
|
103 | + { |
|
104 | + $_user = api_get_user_info(); |
|
106 | 105 | $course_id = api_get_course_int_id(); |
107 | 106 | |
108 | - $current_date=date('Y-m-d H:i:s',time()); |
|
109 | - $session_id = api_get_session_id(); |
|
110 | - // Tabel definitions |
|
107 | + $current_date=date('Y-m-d H:i:s',time()); |
|
108 | + $session_id = api_get_session_id(); |
|
109 | + // Tabel definitions |
|
111 | 110 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
112 | 111 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
113 | 112 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
114 | 113 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
115 | 114 | |
116 | - //verified if exist blog |
|
117 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
115 | + //verified if exist blog |
|
116 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
118 | 117 | WHERE |
119 | 118 | c_id = '.$course_id.' AND |
120 | 119 | blog_name="'.Database::escape_string($title).'" AND |
@@ -123,9 +122,9 @@ discard block |
||
123 | 122 | $info_count = Database::result($res, 0, 0); |
124 | 123 | |
125 | 124 | if ($info_count == 0) { |
126 | - // Create the blog |
|
125 | + // Create the blog |
|
127 | 126 | $params = [ |
128 | - 'blog_id' => 0, |
|
127 | + 'blog_id' => 0, |
|
129 | 128 | 'c_id' => $course_id, |
130 | 129 | 'blog_name' => $title, |
131 | 130 | 'blog_subtitle' => $subtitle, |
@@ -133,14 +132,14 @@ discard block |
||
133 | 132 | 'visibility' => 1 , |
134 | 133 | 'session_id' => $session_id, |
135 | 134 | ]; |
136 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
135 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
137 | 136 | |
138 | - if ($this_blog_id > 0) { |
|
137 | + if ($this_blog_id > 0) { |
|
139 | 138 | |
140 | 139 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
141 | 140 | Database::query($sql); |
142 | 141 | |
143 | - // insert into item_property |
|
142 | + // insert into item_property |
|
144 | 143 | api_item_property_update( |
145 | 144 | api_get_course_info(), |
146 | 145 | TOOL_BLOGS, |
@@ -148,12 +147,12 @@ discard block |
||
148 | 147 | 'BlogAdded', |
149 | 148 | api_get_user_id() |
150 | 149 | ); |
151 | - } |
|
150 | + } |
|
152 | 151 | |
153 | - // Make first post. :) |
|
152 | + // Make first post. :) |
|
154 | 153 | |
155 | 154 | $params = [ |
156 | - 'post_id' => 0, |
|
155 | + 'post_id' => 0, |
|
157 | 156 | 'c_id' => $course_id, |
158 | 157 | 'title' => get_lang("Welcome"), |
159 | 158 | 'full_text' => get_lang('FirstPostText'), |
@@ -167,10 +166,10 @@ discard block |
||
167 | 166 | Database::query($sql); |
168 | 167 | } |
169 | 168 | |
170 | - // Put it on course homepage |
|
171 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
169 | + // Put it on course homepage |
|
170 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
172 | 171 | VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
173 | - Database::query($sql); |
|
172 | + Database::query($sql); |
|
174 | 173 | |
175 | 174 | $toolId = Database::insert_id(); |
176 | 175 | if ($toolId) { |
@@ -178,37 +177,37 @@ discard block |
||
178 | 177 | Database::query($sql); |
179 | 178 | } |
180 | 179 | |
181 | - // Subscribe the teacher to this blog |
|
182 | - Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Update title and subtitle of a blog in the given course |
|
188 | - * @author Toon Keppens |
|
189 | - * @param Integer $course_id Id |
|
190 | - * @param String $title |
|
191 | - * @param Text $description |
|
192 | - */ |
|
193 | - public static function edit_blog($blog_id, $title, $subtitle) |
|
194 | - { |
|
195 | - // Table definitions |
|
196 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
197 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
180 | + // Subscribe the teacher to this blog |
|
181 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Update title and subtitle of a blog in the given course |
|
187 | + * @author Toon Keppens |
|
188 | + * @param Integer $course_id Id |
|
189 | + * @param String $title |
|
190 | + * @param Text $description |
|
191 | + */ |
|
192 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
193 | + { |
|
194 | + // Table definitions |
|
195 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
196 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
198 | 197 | |
199 | 198 | $course_id = api_get_course_int_id(); |
200 | 199 | |
201 | - // Update the blog |
|
202 | - $sql = "UPDATE $tbl_blogs SET |
|
200 | + // Update the blog |
|
201 | + $sql = "UPDATE $tbl_blogs SET |
|
203 | 202 | blog_name = '".Database::escape_string($title)."', |
204 | 203 | blog_subtitle = '".Database::escape_string($subtitle)."' |
205 | 204 | WHERE |
206 | 205 | c_id = $course_id AND |
207 | 206 | blog_id ='".Database::escape_string((int)$blog_id)."' |
208 | 207 | LIMIT 1"; |
209 | - Database::query($sql); |
|
208 | + Database::query($sql); |
|
210 | 209 | |
211 | - //update item_property (update) |
|
210 | + //update item_property (update) |
|
212 | 211 | api_item_property_update( |
213 | 212 | api_get_course_info(), |
214 | 213 | TOOL_BLOGS, |
@@ -217,60 +216,60 @@ discard block |
||
217 | 216 | api_get_user_id() |
218 | 217 | ); |
219 | 218 | |
220 | - // Update course homepage link |
|
221 | - $sql = "UPDATE $tbl_tool SET |
|
219 | + // Update course homepage link |
|
220 | + $sql = "UPDATE $tbl_tool SET |
|
222 | 221 | name = '".Database::escape_string($title)."' |
223 | 222 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
224 | - Database::query($sql); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Deletes a blog and it's posts from the course database |
|
229 | - * @author Toon Keppens |
|
230 | - * @param Integer $blog_id |
|
231 | - */ |
|
232 | - public static function delete_blog($blog_id) |
|
233 | - { |
|
234 | - // Init |
|
223 | + Database::query($sql); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Deletes a blog and it's posts from the course database |
|
228 | + * @author Toon Keppens |
|
229 | + * @param Integer $blog_id |
|
230 | + */ |
|
231 | + public static function delete_blog($blog_id) |
|
232 | + { |
|
233 | + // Init |
|
235 | 234 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
236 | 235 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
237 | 236 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
238 | 237 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
239 | 238 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
240 | 239 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
241 | - $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
240 | + $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
242 | 241 | |
243 | 242 | $course_id = api_get_course_int_id(); |
244 | 243 | $blog_id = intval($blog_id); |
245 | 244 | |
246 | - // Delete posts from DB and the attachments |
|
247 | - delete_all_blog_attachment($blog_id); |
|
245 | + // Delete posts from DB and the attachments |
|
246 | + delete_all_blog_attachment($blog_id); |
|
248 | 247 | |
249 | - //Delete comments |
|
250 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
251 | - Database::query($sql); |
|
248 | + //Delete comments |
|
249 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
250 | + Database::query($sql); |
|
252 | 251 | |
253 | - // Delete posts |
|
254 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
255 | - Database::query($sql); |
|
252 | + // Delete posts |
|
253 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
254 | + Database::query($sql); |
|
256 | 255 | |
257 | - // Delete tasks |
|
258 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
259 | - Database::query($sql); |
|
256 | + // Delete tasks |
|
257 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
258 | + Database::query($sql); |
|
260 | 259 | |
261 | - // Delete ratings |
|
262 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
263 | - Database::query($sql); |
|
260 | + // Delete ratings |
|
261 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
262 | + Database::query($sql); |
|
264 | 263 | |
265 | - // Delete blog |
|
266 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
267 | - Database::query($sql); |
|
264 | + // Delete blog |
|
265 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
266 | + Database::query($sql); |
|
268 | 267 | |
269 | - // Delete from course homepage |
|
270 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
271 | - Database::query($sql); |
|
268 | + // Delete from course homepage |
|
269 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
270 | + Database::query($sql); |
|
272 | 271 | |
273 | - //update item_property (delete) |
|
272 | + //update item_property (delete) |
|
274 | 273 | api_item_property_update( |
275 | 274 | api_get_course_info(), |
276 | 275 | TOOL_BLOGS, |
@@ -278,152 +277,152 @@ discard block |
||
278 | 277 | 'delete', |
279 | 278 | api_get_user_id() |
280 | 279 | ); |
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * Creates a new post in a given blog |
|
285 | - * @author Toon Keppens |
|
286 | - * @param String $title |
|
287 | - * @param String $full_text |
|
288 | - * @param Integer $blog_id |
|
289 | - */ |
|
290 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
291 | - { |
|
292 | - $_user = api_get_user_info(); |
|
293 | - $_course = api_get_course_info(); |
|
294 | - $course_id = $_course['real_id']; |
|
295 | - |
|
296 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
297 | - $upload_ok=true; |
|
298 | - $has_attachment=false; |
|
299 | - $current_date = api_get_utc_datetime(); |
|
300 | - |
|
301 | - if (!empty($_FILES['user_upload']['name'])) { |
|
302 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
303 | - $has_attachment=true; |
|
304 | - } |
|
305 | - |
|
306 | - if ($upload_ok) { |
|
307 | - // Table Definitions |
|
308 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
309 | - |
|
310 | - // Create the post |
|
311 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Creates a new post in a given blog |
|
284 | + * @author Toon Keppens |
|
285 | + * @param String $title |
|
286 | + * @param String $full_text |
|
287 | + * @param Integer $blog_id |
|
288 | + */ |
|
289 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
290 | + { |
|
291 | + $_user = api_get_user_info(); |
|
292 | + $_course = api_get_course_info(); |
|
293 | + $course_id = $_course['real_id']; |
|
294 | + |
|
295 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
296 | + $upload_ok=true; |
|
297 | + $has_attachment=false; |
|
298 | + $current_date = api_get_utc_datetime(); |
|
299 | + |
|
300 | + if (!empty($_FILES['user_upload']['name'])) { |
|
301 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
302 | + $has_attachment=true; |
|
303 | + } |
|
304 | + |
|
305 | + if ($upload_ok) { |
|
306 | + // Table Definitions |
|
307 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
308 | + |
|
309 | + // Create the post |
|
310 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
312 | 311 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
313 | 312 | |
314 | - Database::query($sql); |
|
315 | - $last_post_id = Database::insert_id(); |
|
313 | + Database::query($sql); |
|
314 | + $last_post_id = Database::insert_id(); |
|
316 | 315 | |
317 | 316 | if ($last_post_id) { |
318 | 317 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
319 | 318 | Database::query($sql); |
320 | 319 | } |
321 | 320 | |
322 | - if ($has_attachment) { |
|
323 | - $courseDir = $_course['path'].'/upload/blog'; |
|
324 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
325 | - $updir = $sys_course_path.$courseDir; |
|
326 | - |
|
327 | - // Try to add an extension to the file if it hasn't one |
|
328 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
329 | - |
|
330 | - // user's file name |
|
331 | - $file_name = $_FILES['user_upload']['name']; |
|
332 | - |
|
333 | - if (!filter_extension($new_file_name)) { |
|
334 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
335 | - } else { |
|
336 | - $new_file_name = uniqid(''); |
|
337 | - $new_path = $updir.'/'.$new_file_name; |
|
338 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
339 | - $comment = Database::escape_string($file_comment); |
|
340 | - |
|
341 | - // Storing the attachments if any |
|
342 | - if ($result) { |
|
343 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
344 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
345 | - Database::query($sql); |
|
321 | + if ($has_attachment) { |
|
322 | + $courseDir = $_course['path'].'/upload/blog'; |
|
323 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
324 | + $updir = $sys_course_path.$courseDir; |
|
325 | + |
|
326 | + // Try to add an extension to the file if it hasn't one |
|
327 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
328 | + |
|
329 | + // user's file name |
|
330 | + $file_name = $_FILES['user_upload']['name']; |
|
331 | + |
|
332 | + if (!filter_extension($new_file_name)) { |
|
333 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
334 | + } else { |
|
335 | + $new_file_name = uniqid(''); |
|
336 | + $new_path = $updir.'/'.$new_file_name; |
|
337 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
338 | + $comment = Database::escape_string($file_comment); |
|
339 | + |
|
340 | + // Storing the attachments if any |
|
341 | + if ($result) { |
|
342 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
343 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
344 | + Database::query($sql); |
|
346 | 345 | $id = Database::insert_id(); |
347 | 346 | if ($id) { |
348 | 347 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
349 | 348 | Database::query($sql); |
350 | 349 | } |
351 | - } |
|
352 | - } |
|
353 | - } |
|
354 | - } else { |
|
355 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Edits a post in a given blog |
|
361 | - * @author Toon Keppens |
|
362 | - * @param Integer $blog_id |
|
363 | - * @param String $title |
|
364 | - * @param String $full_text |
|
365 | - * @param Integer $blog_id |
|
366 | - */ |
|
367 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
368 | - { |
|
369 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
350 | + } |
|
351 | + } |
|
352 | + } |
|
353 | + } else { |
|
354 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
355 | + } |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * Edits a post in a given blog |
|
360 | + * @author Toon Keppens |
|
361 | + * @param Integer $blog_id |
|
362 | + * @param String $title |
|
363 | + * @param String $full_text |
|
364 | + * @param Integer $blog_id |
|
365 | + */ |
|
366 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
367 | + { |
|
368 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
370 | 369 | $course_id = api_get_course_int_id(); |
371 | 370 | |
372 | - // Create the post |
|
373 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
371 | + // Create the post |
|
372 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
374 | 373 | title = '" . Database::escape_string($title)."', |
375 | 374 | full_text = '" . Database::escape_string($full_text)."' |
376 | 375 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
377 | 376 | LIMIT 1 "; |
378 | - Database::query($sql); |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * Deletes an article and it's comments |
|
383 | - * @author Toon Keppens |
|
384 | - * @param int $blog_id |
|
385 | - * @param int $post_id |
|
386 | - */ |
|
387 | - public static function delete_post($blog_id, $post_id) |
|
388 | - { |
|
389 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
390 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
391 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
377 | + Database::query($sql); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Deletes an article and it's comments |
|
382 | + * @author Toon Keppens |
|
383 | + * @param int $blog_id |
|
384 | + * @param int $post_id |
|
385 | + */ |
|
386 | + public static function delete_post($blog_id, $post_id) |
|
387 | + { |
|
388 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
389 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
390 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
392 | 391 | |
393 | 392 | $course_id = api_get_course_int_id(); |
394 | 393 | |
395 | - // Delete ratings on this comment |
|
396 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
394 | + // Delete ratings on this comment |
|
395 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
397 | 396 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
398 | - Database::query($sql); |
|
397 | + Database::query($sql); |
|
399 | 398 | |
400 | - // Delete the post |
|
401 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
399 | + // Delete the post |
|
400 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
402 | 401 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
403 | - Database::query($sql); |
|
402 | + Database::query($sql); |
|
404 | 403 | |
405 | - // Delete the comments |
|
406 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
404 | + // Delete the comments |
|
405 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
407 | 406 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
408 | - Database::query($sql); |
|
409 | - |
|
410 | - // Delete posts and attachments |
|
411 | - delete_all_blog_attachment($blog_id,$post_id); |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * Creates a comment on a post in a given blog |
|
416 | - * @author Toon Keppens |
|
417 | - * @param String $title |
|
418 | - * @param String $full_text |
|
419 | - * @param Integer $blog_id |
|
420 | - * @param Integer $post_id |
|
421 | - * @param Integer $parent_id |
|
422 | - */ |
|
423 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
424 | - { |
|
425 | - $_user = api_get_user_info(); |
|
426 | - $_course = api_get_course_info(); |
|
407 | + Database::query($sql); |
|
408 | + |
|
409 | + // Delete posts and attachments |
|
410 | + delete_all_blog_attachment($blog_id,$post_id); |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Creates a comment on a post in a given blog |
|
415 | + * @author Toon Keppens |
|
416 | + * @param String $title |
|
417 | + * @param String $full_text |
|
418 | + * @param Integer $blog_id |
|
419 | + * @param Integer $post_id |
|
420 | + * @param Integer $parent_id |
|
421 | + */ |
|
422 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
423 | + { |
|
424 | + $_user = api_get_user_info(); |
|
425 | + $_course = api_get_course_info(); |
|
427 | 426 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
428 | 427 | |
429 | 428 | $upload_ok = true; |
@@ -431,55 +430,55 @@ discard block |
||
431 | 430 | $current_date = api_get_utc_datetime(); |
432 | 431 | $course_id = api_get_course_int_id(); |
433 | 432 | |
434 | - if (!empty($_FILES['user_upload']['name'])) { |
|
435 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
436 | - $has_attachment=true; |
|
437 | - } |
|
433 | + if (!empty($_FILES['user_upload']['name'])) { |
|
434 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
435 | + $has_attachment=true; |
|
436 | + } |
|
438 | 437 | |
439 | - if ($upload_ok) { |
|
440 | - // Table Definition |
|
441 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
438 | + if ($upload_ok) { |
|
439 | + // Table Definition |
|
440 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
442 | 441 | |
443 | - // Create the comment |
|
444 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
442 | + // Create the comment |
|
443 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
445 | 444 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
446 | - Database::query($sql); |
|
445 | + Database::query($sql); |
|
447 | 446 | |
448 | - // Empty post values, or they are shown on the page again |
|
449 | - $last_id = Database::insert_id(); |
|
447 | + // Empty post values, or they are shown on the page again |
|
448 | + $last_id = Database::insert_id(); |
|
450 | 449 | |
451 | 450 | if ($last_id) { |
452 | 451 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
453 | 452 | Database::query($sql); |
454 | 453 | } |
455 | 454 | |
456 | - if ($has_attachment) { |
|
457 | - $courseDir = $_course['path'].'/upload/blog'; |
|
458 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
459 | - $updir = $sys_course_path.$courseDir; |
|
460 | - |
|
461 | - // Try to add an extension to the file if it hasn't one |
|
462 | - $new_file_name = add_ext_on_mime( |
|
463 | - stripslashes($_FILES['user_upload']['name']), |
|
464 | - $_FILES['user_upload']['type'] |
|
465 | - ); |
|
466 | - |
|
467 | - // user's file name |
|
468 | - $file_name =$_FILES['user_upload']['name']; |
|
469 | - |
|
470 | - if (!filter_extension($new_file_name)) { |
|
471 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
472 | - } else { |
|
473 | - $new_file_name = uniqid(''); |
|
474 | - $new_path=$updir.'/'.$new_file_name; |
|
475 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
476 | - $comment = Database::escape_string($file_comment); |
|
477 | - |
|
478 | - // Storing the attachments if any |
|
479 | - if ($result) { |
|
480 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
481 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
482 | - Database::query($sql); |
|
455 | + if ($has_attachment) { |
|
456 | + $courseDir = $_course['path'].'/upload/blog'; |
|
457 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
458 | + $updir = $sys_course_path.$courseDir; |
|
459 | + |
|
460 | + // Try to add an extension to the file if it hasn't one |
|
461 | + $new_file_name = add_ext_on_mime( |
|
462 | + stripslashes($_FILES['user_upload']['name']), |
|
463 | + $_FILES['user_upload']['type'] |
|
464 | + ); |
|
465 | + |
|
466 | + // user's file name |
|
467 | + $file_name =$_FILES['user_upload']['name']; |
|
468 | + |
|
469 | + if (!filter_extension($new_file_name)) { |
|
470 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
471 | + } else { |
|
472 | + $new_file_name = uniqid(''); |
|
473 | + $new_path=$updir.'/'.$new_file_name; |
|
474 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
475 | + $comment = Database::escape_string($file_comment); |
|
476 | + |
|
477 | + // Storing the attachments if any |
|
478 | + if ($result) { |
|
479 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
480 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
481 | + Database::query($sql); |
|
483 | 482 | |
484 | 483 | $id = Database::insert_id(); |
485 | 484 | |
@@ -487,92 +486,92 @@ discard block |
||
487 | 486 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
488 | 487 | Database::query($sql); |
489 | 488 | } |
490 | - } |
|
491 | - } |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * Deletes a comment from a blogpost |
|
498 | - * @author Toon Keppens |
|
499 | - * @param int $blog_id |
|
500 | - * @param int $comment_id |
|
501 | - */ |
|
502 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
503 | - { |
|
504 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
505 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
506 | - $blog_id = intval($blog_id); |
|
507 | - $post_id = intval($post_id); |
|
508 | - $comment_id = intval($comment_id); |
|
489 | + } |
|
490 | + } |
|
491 | + } |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * Deletes a comment from a blogpost |
|
497 | + * @author Toon Keppens |
|
498 | + * @param int $blog_id |
|
499 | + * @param int $comment_id |
|
500 | + */ |
|
501 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
502 | + { |
|
503 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
504 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
505 | + $blog_id = intval($blog_id); |
|
506 | + $post_id = intval($post_id); |
|
507 | + $comment_id = intval($comment_id); |
|
509 | 508 | $course_id = api_get_course_int_id(); |
510 | 509 | |
511 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
510 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
512 | 511 | |
513 | - // Delete ratings on this comment |
|
514 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
512 | + // Delete ratings on this comment |
|
513 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
515 | 514 | WHERE |
516 | 515 | c_id = $course_id AND |
517 | 516 | blog_id = '".$blog_id."' AND |
518 | 517 | item_id = '".$comment_id."' AND |
519 | 518 | rating_type = 'comment'"; |
520 | - Database::query($sql); |
|
519 | + Database::query($sql); |
|
521 | 520 | |
522 | - // select comments that have the selected comment as their parent |
|
523 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
521 | + // select comments that have the selected comment as their parent |
|
522 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
524 | 523 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
525 | - $result = Database::query($sql); |
|
524 | + $result = Database::query($sql); |
|
526 | 525 | |
527 | - // Delete them recursively |
|
528 | - while ($comment = Database::fetch_array($result)) { |
|
529 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
530 | - } |
|
526 | + // Delete them recursively |
|
527 | + while ($comment = Database::fetch_array($result)) { |
|
528 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
529 | + } |
|
531 | 530 | |
532 | - // Finally, delete the selected comment to |
|
533 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
531 | + // Finally, delete the selected comment to |
|
532 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
534 | 533 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
535 | - Database::query($sql); |
|
536 | - } |
|
537 | - |
|
538 | - /** |
|
539 | - * Creates a new task in a blog |
|
540 | - * @author Toon Keppens |
|
541 | - * @param Integer $blog_id |
|
542 | - * @param String $title |
|
543 | - * @param String $description |
|
544 | - * @param String $color |
|
545 | - */ |
|
546 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
547 | - { |
|
548 | - // Init |
|
549 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
550 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
551 | - |
|
552 | - $course_id = api_get_course_int_id(); |
|
553 | - |
|
554 | - // Create the task |
|
555 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
534 | + Database::query($sql); |
|
535 | + } |
|
536 | + |
|
537 | + /** |
|
538 | + * Creates a new task in a blog |
|
539 | + * @author Toon Keppens |
|
540 | + * @param Integer $blog_id |
|
541 | + * @param String $title |
|
542 | + * @param String $description |
|
543 | + * @param String $color |
|
544 | + */ |
|
545 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
546 | + { |
|
547 | + // Init |
|
548 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
549 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
550 | + |
|
551 | + $course_id = api_get_course_int_id(); |
|
552 | + |
|
553 | + // Create the task |
|
554 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
556 | 555 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
557 | - Database::query($sql); |
|
556 | + Database::query($sql); |
|
558 | 557 | |
559 | - $task_id = Database::insert_id(); |
|
558 | + $task_id = Database::insert_id(); |
|
560 | 559 | |
561 | 560 | if ($task_id) { |
562 | 561 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
563 | 562 | Database::query($sql); |
564 | 563 | } |
565 | 564 | |
566 | - $tool = 'BLOG_' . $blog_id; |
|
565 | + $tool = 'BLOG_' . $blog_id; |
|
567 | 566 | |
568 | - if ($articleDelete == 'on') { |
|
569 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
567 | + if ($articleDelete == 'on') { |
|
568 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
570 | 569 | '" . (int)$course_id . "', |
571 | 570 | '" . (int)$task_id . "', |
572 | 571 | '" . Database::escape_string($tool) . "', |
573 | 572 | 'article_delete' |
574 | 573 | )"; |
575 | - Database::query($sql); |
|
574 | + Database::query($sql); |
|
576 | 575 | |
577 | 576 | $id = Database::insert_id(); |
578 | 577 | |
@@ -582,172 +581,172 @@ discard block |
||
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
585 | - if ($articleEdit == 'on') { |
|
586 | - $sql = " |
|
584 | + if ($articleEdit == 'on') { |
|
585 | + $sql = " |
|
587 | 586 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
588 | 587 | '" . (int)$course_id . "', |
589 | 588 | '" . (int)$task_id . "', |
590 | 589 | '" . Database::escape_string($tool) . "', |
591 | 590 | 'article_edit' |
592 | 591 | )"; |
593 | - Database::query($sql); |
|
592 | + Database::query($sql); |
|
594 | 593 | $id = Database::insert_id(); |
595 | 594 | |
596 | 595 | if ($id) { |
597 | 596 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
598 | 597 | Database::query($sql); |
599 | 598 | } |
600 | - } |
|
599 | + } |
|
601 | 600 | |
602 | - if ($commentsDelete == 'on') { |
|
603 | - $sql = " |
|
601 | + if ($commentsDelete == 'on') { |
|
602 | + $sql = " |
|
604 | 603 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
605 | 604 | '" . (int)$course_id . "', |
606 | 605 | '" . (int)$task_id . "', |
607 | 606 | '" . Database::escape_string($tool) . "', |
608 | 607 | 'article_comments_delete' |
609 | 608 | )"; |
610 | - Database::query($sql); |
|
609 | + Database::query($sql); |
|
611 | 610 | $id = Database::insert_id(); |
612 | 611 | |
613 | 612 | if ($id) { |
614 | 613 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
615 | 614 | Database::query($sql); |
616 | 615 | } |
617 | - } |
|
618 | - } |
|
619 | - |
|
620 | - /** |
|
621 | - * Edit a task in a blog |
|
622 | - * @author Toon Keppens |
|
623 | - * @param Integer $task_id |
|
624 | - * @param String $title |
|
625 | - * @param String $description |
|
626 | - * @param String $color |
|
627 | - */ |
|
628 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
629 | - { |
|
630 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
631 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
616 | + } |
|
617 | + } |
|
618 | + |
|
619 | + /** |
|
620 | + * Edit a task in a blog |
|
621 | + * @author Toon Keppens |
|
622 | + * @param Integer $task_id |
|
623 | + * @param String $title |
|
624 | + * @param String $description |
|
625 | + * @param String $color |
|
626 | + */ |
|
627 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
628 | + { |
|
629 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
630 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
632 | 631 | |
633 | 632 | $course_id = api_get_course_int_id(); |
634 | 633 | |
635 | - // Create the task |
|
636 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
634 | + // Create the task |
|
635 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
637 | 636 | title = '".Database::escape_string($title)."', |
638 | 637 | description = '".Database::escape_string($description)."', |
639 | 638 | color = '".Database::escape_string($color)."' |
640 | 639 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
641 | - Database::query($sql); |
|
640 | + Database::query($sql); |
|
642 | 641 | |
643 | - $tool = 'BLOG_' . $blog_id; |
|
642 | + $tool = 'BLOG_' . $blog_id; |
|
644 | 643 | |
645 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
644 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
646 | 645 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
647 | - Database::query($sql); |
|
646 | + Database::query($sql); |
|
648 | 647 | |
649 | - if ($articleDelete == 'on') { |
|
650 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
648 | + if ($articleDelete == 'on') { |
|
649 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
651 | 650 | '" . (int)$course_id . "', |
652 | 651 | '" . (int)$task_id . "', |
653 | 652 | '" . Database::escape_string($tool) . "', |
654 | 653 | 'article_delete' |
655 | 654 | )"; |
656 | - Database::query($sql); |
|
655 | + Database::query($sql); |
|
657 | 656 | $id = Database::insert_id(); |
658 | 657 | |
659 | 658 | if ($id) { |
660 | 659 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
661 | 660 | Database::query($sql); |
662 | 661 | } |
663 | - } |
|
662 | + } |
|
664 | 663 | |
665 | - if ($articleEdit == 'on') { |
|
666 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
664 | + if ($articleEdit == 'on') { |
|
665 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
667 | 666 | '" . (int)$course_id . "', |
668 | 667 | '" . (int)$task_id . "', |
669 | 668 | '" . Database::escape_string($tool) . "', |
670 | 669 | 'article_edit' |
671 | 670 | )"; |
672 | - Database::query($sql); |
|
671 | + Database::query($sql); |
|
673 | 672 | $id = Database::insert_id(); |
674 | 673 | |
675 | 674 | if ($id) { |
676 | 675 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
677 | 676 | Database::query($sql); |
678 | 677 | } |
679 | - } |
|
678 | + } |
|
680 | 679 | |
681 | - if ($commentsDelete == 'on') { |
|
682 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
680 | + if ($commentsDelete == 'on') { |
|
681 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
683 | 682 | '" . (int)$course_id . "', |
684 | 683 | '" . (int)$task_id . "', |
685 | 684 | '" . Database::escape_string($tool) . "', |
686 | 685 | 'article_comments_delete' |
687 | 686 | )"; |
688 | - Database::query($sql); |
|
687 | + Database::query($sql); |
|
689 | 688 | $id = Database::insert_id(); |
690 | 689 | |
691 | 690 | if ($id) { |
692 | 691 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
693 | 692 | Database::query($sql); |
694 | 693 | } |
695 | - } |
|
696 | - } |
|
697 | - |
|
698 | - /** |
|
699 | - * Deletes a task from a blog |
|
700 | - * @param Integer $blog_id |
|
701 | - * @param Integer $task_id |
|
702 | - */ |
|
703 | - public static function delete_task($blog_id, $task_id) |
|
704 | - { |
|
705 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
706 | - $course_id = api_get_course_int_id(); |
|
707 | - |
|
708 | - // Delete posts |
|
709 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
694 | + } |
|
695 | + } |
|
696 | + |
|
697 | + /** |
|
698 | + * Deletes a task from a blog |
|
699 | + * @param Integer $blog_id |
|
700 | + * @param Integer $task_id |
|
701 | + */ |
|
702 | + public static function delete_task($blog_id, $task_id) |
|
703 | + { |
|
704 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
705 | + $course_id = api_get_course_int_id(); |
|
706 | + |
|
707 | + // Delete posts |
|
708 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
710 | 709 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
711 | - Database::query($sql); |
|
712 | - } |
|
713 | - |
|
714 | - /** |
|
715 | - * Deletes an assigned task from a blog |
|
716 | - * @param Integer $blog_id |
|
717 | - * @param Integer $assignment_id |
|
718 | - */ |
|
719 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
720 | - { |
|
721 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
710 | + Database::query($sql); |
|
711 | + } |
|
712 | + |
|
713 | + /** |
|
714 | + * Deletes an assigned task from a blog |
|
715 | + * @param Integer $blog_id |
|
716 | + * @param Integer $assignment_id |
|
717 | + */ |
|
718 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
719 | + { |
|
720 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
722 | 721 | $course_id = api_get_course_int_id(); |
723 | 722 | |
724 | - // Delete posts |
|
725 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
723 | + // Delete posts |
|
724 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
726 | 725 | WHERE |
727 | 726 | c_id = $course_id AND |
728 | 727 | blog_id = '".(int)$blog_id."' AND |
729 | 728 | task_id = '".(int)$task_id."' AND |
730 | 729 | user_id = '".(int)$user_id."'"; |
731 | - Database::query($sql); |
|
732 | - } |
|
733 | - |
|
734 | - /** |
|
735 | - * Get personal task list |
|
736 | - * @author Toon Keppens |
|
737 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
738 | - */ |
|
739 | - public static function get_personal_task_list() |
|
740 | - { |
|
741 | - $_user = api_get_user_info(); |
|
742 | - |
|
743 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
744 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
745 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
746 | - |
|
747 | - $course_id = api_get_course_int_id(); |
|
748 | - |
|
749 | - if ($_user['user_id']) { |
|
750 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
730 | + Database::query($sql); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Get personal task list |
|
735 | + * @author Toon Keppens |
|
736 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
737 | + */ |
|
738 | + public static function get_personal_task_list() |
|
739 | + { |
|
740 | + $_user = api_get_user_info(); |
|
741 | + |
|
742 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
743 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
744 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
745 | + |
|
746 | + $course_id = api_get_course_int_id(); |
|
747 | + |
|
748 | + if ($_user['user_id']) { |
|
749 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
751 | 750 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
752 | 751 | INNER JOIN $tbl_blogs_tasks task |
753 | 752 | ON task_rel_user.task_id = task.task_id |
@@ -761,93 +760,93 @@ discard block |
||
761 | 760 | task_rel_user.user_id = ".(int)$_user['user_id']." |
762 | 761 | ORDER BY target_date ASC"; |
763 | 762 | |
764 | - $result = Database::query($sql); |
|
763 | + $result = Database::query($sql); |
|
765 | 764 | |
766 | - if (Database::num_rows($result) > 0) { |
|
767 | - echo '<ul>'; |
|
768 | - while ($mytask = Database::fetch_array($result)) { |
|
769 | - echo '<li> |
|
765 | + if (Database::num_rows($result) > 0) { |
|
766 | + echo '<ul>'; |
|
767 | + while ($mytask = Database::fetch_array($result)) { |
|
768 | + echo '<li> |
|
770 | 769 | <a href="blog.php?'.api_get_cidreq( |
771 | - ).'action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes( |
|
772 | - $mytask['task_id'] |
|
773 | - ).'" title="[Blog: '.stripslashes( |
|
774 | - $mytask['blog_name'] |
|
775 | - ).'] '.get_lang('ExecuteThisTask').'"> |
|
770 | + ).'action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes( |
|
771 | + $mytask['task_id'] |
|
772 | + ).'" title="[Blog: '.stripslashes( |
|
773 | + $mytask['blog_name'] |
|
774 | + ).'] '.get_lang('ExecuteThisTask').'"> |
|
776 | 775 | '.stripslashes($mytask['title']).'</a> |
777 | 776 | </li>'; |
778 | - } |
|
779 | - echo '<ul>'; |
|
780 | - } else { |
|
781 | - echo get_lang('NoTasks'); |
|
782 | - } |
|
783 | - } else { |
|
784 | - echo get_lang('NoTasks'); |
|
785 | - } |
|
786 | - } |
|
787 | - |
|
788 | - /** |
|
789 | - * Changes the visibility of a blog |
|
790 | - * @author Toon Keppens |
|
791 | - * @param Integer $blog_id |
|
792 | - */ |
|
793 | - public static function change_blog_visibility($blog_id) |
|
794 | - { |
|
795 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
796 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
797 | - $course_id = api_get_course_int_id(); |
|
798 | - |
|
799 | - // Get blog properties |
|
800 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
777 | + } |
|
778 | + echo '<ul>'; |
|
779 | + } else { |
|
780 | + echo get_lang('NoTasks'); |
|
781 | + } |
|
782 | + } else { |
|
783 | + echo get_lang('NoTasks'); |
|
784 | + } |
|
785 | + } |
|
786 | + |
|
787 | + /** |
|
788 | + * Changes the visibility of a blog |
|
789 | + * @author Toon Keppens |
|
790 | + * @param Integer $blog_id |
|
791 | + */ |
|
792 | + public static function change_blog_visibility($blog_id) |
|
793 | + { |
|
794 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
795 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
796 | + $course_id = api_get_course_int_id(); |
|
797 | + |
|
798 | + // Get blog properties |
|
799 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
801 | 800 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
802 | - $result = Database::query($sql); |
|
803 | - $blog = Database::fetch_array($result); |
|
804 | - $visibility = $blog['visibility']; |
|
805 | - $title = $blog['blog_name']; |
|
806 | - |
|
807 | - if ($visibility == 1) { |
|
808 | - // Change visibility state, remove from course home. |
|
809 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
801 | + $result = Database::query($sql); |
|
802 | + $blog = Database::fetch_array($result); |
|
803 | + $visibility = $blog['visibility']; |
|
804 | + $title = $blog['blog_name']; |
|
805 | + |
|
806 | + if ($visibility == 1) { |
|
807 | + // Change visibility state, remove from course home. |
|
808 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
810 | 809 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
811 | - Database::query($sql); |
|
810 | + Database::query($sql); |
|
812 | 811 | |
813 | - $sql = "DELETE FROM $tbl_tool |
|
812 | + $sql = "DELETE FROM $tbl_tool |
|
814 | 813 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
815 | - Database::query($sql); |
|
816 | - } else { |
|
817 | - // Change visibility state, add to course home. |
|
818 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
814 | + Database::query($sql); |
|
815 | + } else { |
|
816 | + // Change visibility state, add to course home. |
|
817 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
819 | 818 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
820 | - Database::query($sql); |
|
819 | + Database::query($sql); |
|
821 | 820 | |
822 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
821 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
823 | 822 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
824 | - Database::query($sql); |
|
823 | + Database::query($sql); |
|
825 | 824 | $id = Database::insert_id(); |
826 | 825 | |
827 | 826 | if ($id) { |
828 | 827 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
829 | 828 | Database::query($sql); |
830 | 829 | } |
831 | - } |
|
832 | - } |
|
833 | - |
|
834 | - /** |
|
835 | - * Shows the posts of a blog |
|
836 | - * @author Toon Keppens |
|
837 | - * |
|
838 | - * @param Integer $blog_id |
|
839 | - */ |
|
840 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
830 | + } |
|
831 | + } |
|
832 | + |
|
833 | + /** |
|
834 | + * Shows the posts of a blog |
|
835 | + * @author Toon Keppens |
|
836 | + * |
|
837 | + * @param Integer $blog_id |
|
838 | + */ |
|
839 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
841 | 840 | { |
842 | - // Init |
|
843 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
844 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
845 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
841 | + // Init |
|
842 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
843 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
844 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
846 | 845 | |
847 | - $course_id = api_get_course_int_id(); |
|
846 | + $course_id = api_get_course_int_id(); |
|
848 | 847 | |
849 | - // Get posts and authors |
|
850 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
848 | + // Get posts and authors |
|
849 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
851 | 850 | FROM $tbl_blogs_posts post |
852 | 851 | INNER JOIN $tbl_users user |
853 | 852 | ON post.author_id = user.user_id |
@@ -855,151 +854,151 @@ discard block |
||
855 | 854 | post.c_id = $course_id AND |
856 | 855 | $filter |
857 | 856 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
858 | - $result = Database::query($sql); |
|
859 | - |
|
860 | - // Display |
|
861 | - if(Database::num_rows($result) > 0) { |
|
862 | - $limit = 200; |
|
863 | - while ($blog_post = Database::fetch_array($result)) { |
|
864 | - // Get number of comments |
|
865 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
857 | + $result = Database::query($sql); |
|
858 | + |
|
859 | + // Display |
|
860 | + if(Database::num_rows($result) > 0) { |
|
861 | + $limit = 200; |
|
862 | + while ($blog_post = Database::fetch_array($result)) { |
|
863 | + // Get number of comments |
|
864 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
866 | 865 | FROM $tbl_blogs_comments |
867 | 866 | WHERE |
868 | 867 | c_id = $course_id AND |
869 | 868 | blog_id = '".(int)$blog_id."' AND |
870 | 869 | post_id = '" . (int)$blog_post['post_id']."'"; |
871 | - $tmp = Database::query($sql); |
|
872 | - $blog_post_comments = Database::fetch_array($tmp); |
|
873 | - |
|
874 | - // Prepare data |
|
875 | - $blog_post_id = $blog_post['post_id']; |
|
876 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
877 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
878 | - |
|
879 | - // Create an introduction text (but keep FULL sentences) |
|
880 | - $words = 0; |
|
881 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
882 | - $words = strlen($blog_post_text); |
|
883 | - |
|
884 | - if ($words >= $limit) { |
|
885 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
886 | - $introduction_text = $blog_post_text_cut; |
|
887 | - } else { |
|
888 | - $introduction_text = $blog_post_text; |
|
889 | - $readMoreLink = ''; |
|
890 | - } |
|
891 | - |
|
892 | - $introduction_text = stripslashes($introduction_text); |
|
893 | - |
|
894 | - echo '<div class="blogpost">'; |
|
895 | - echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq( |
|
896 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
897 | - 'ReadPost' |
|
898 | - ).'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
899 | - echo '<span class="blogpost_date"><a href="blog.php?'.api_get_cidreq( |
|
900 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
901 | - 'ReadPost' |
|
902 | - ).'" >'.$blog_post_date.'</a></span>'; |
|
903 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
904 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
905 | - |
|
906 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
907 | - |
|
908 | - if (!empty($file_name_array)) { |
|
909 | - echo '<br /><br />'; |
|
910 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
911 | - echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
912 | - echo $file_name_array['path']; |
|
913 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
914 | - echo '</span>'; |
|
915 | - } |
|
916 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
917 | - echo '<span class="blogpost_info">'.get_lang('Author').': '. |
|
918 | - Display::tag( |
|
919 | - 'span', |
|
920 | - api_get_person_name( |
|
921 | - $blog_post['firstname'], |
|
922 | - $blog_post['lastname'] |
|
923 | - ), |
|
924 | - array('title' => $username) |
|
925 | - ). |
|
926 | - ' - <a href="blog.php?'.api_get_cidreq( |
|
927 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
928 | - 'ReadPost' |
|
929 | - ).'" >'.get_lang( |
|
930 | - 'Comments' |
|
931 | - ).': '.$blog_post_comments['number_of_comments'].'</a></span>'; |
|
932 | - echo '</div>'; |
|
933 | - } |
|
934 | - } else { |
|
935 | - if ($filter == '1=1') { |
|
936 | - echo get_lang('NoArticles'); |
|
937 | - } else { |
|
938 | - echo get_lang('NoArticleMatches'); |
|
939 | - } |
|
940 | - } |
|
870 | + $tmp = Database::query($sql); |
|
871 | + $blog_post_comments = Database::fetch_array($tmp); |
|
872 | + |
|
873 | + // Prepare data |
|
874 | + $blog_post_id = $blog_post['post_id']; |
|
875 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
876 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
877 | + |
|
878 | + // Create an introduction text (but keep FULL sentences) |
|
879 | + $words = 0; |
|
880 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
881 | + $words = strlen($blog_post_text); |
|
882 | + |
|
883 | + if ($words >= $limit) { |
|
884 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
885 | + $introduction_text = $blog_post_text_cut; |
|
886 | + } else { |
|
887 | + $introduction_text = $blog_post_text; |
|
888 | + $readMoreLink = ''; |
|
889 | + } |
|
890 | + |
|
891 | + $introduction_text = stripslashes($introduction_text); |
|
892 | + |
|
893 | + echo '<div class="blogpost">'; |
|
894 | + echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq( |
|
895 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
896 | + 'ReadPost' |
|
897 | + ).'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
898 | + echo '<span class="blogpost_date"><a href="blog.php?'.api_get_cidreq( |
|
899 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
900 | + 'ReadPost' |
|
901 | + ).'" >'.$blog_post_date.'</a></span>'; |
|
902 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
903 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
904 | + |
|
905 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
906 | + |
|
907 | + if (!empty($file_name_array)) { |
|
908 | + echo '<br /><br />'; |
|
909 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
910 | + echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
911 | + echo $file_name_array['path']; |
|
912 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
913 | + echo '</span>'; |
|
914 | + } |
|
915 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
916 | + echo '<span class="blogpost_info">'.get_lang('Author').': '. |
|
917 | + Display::tag( |
|
918 | + 'span', |
|
919 | + api_get_person_name( |
|
920 | + $blog_post['firstname'], |
|
921 | + $blog_post['lastname'] |
|
922 | + ), |
|
923 | + array('title' => $username) |
|
924 | + ). |
|
925 | + ' - <a href="blog.php?'.api_get_cidreq( |
|
926 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
|
927 | + 'ReadPost' |
|
928 | + ).'" >'.get_lang( |
|
929 | + 'Comments' |
|
930 | + ).': '.$blog_post_comments['number_of_comments'].'</a></span>'; |
|
931 | + echo '</div>'; |
|
932 | + } |
|
933 | + } else { |
|
934 | + if ($filter == '1=1') { |
|
935 | + echo get_lang('NoArticles'); |
|
936 | + } else { |
|
937 | + echo get_lang('NoArticleMatches'); |
|
938 | + } |
|
939 | + } |
|
941 | 940 | } |
942 | 941 | |
943 | - /** |
|
944 | - * Display the search results |
|
945 | - * |
|
946 | - * @param Integer $blog_id |
|
947 | - * @param String $query_string |
|
948 | - */ |
|
949 | - public static function display_search_results ($blog_id, $query_string) |
|
950 | - { |
|
951 | - // Init |
|
952 | - $query_string = Database::escape_string($query_string); |
|
953 | - $query_string_parts = explode(' ',$query_string); |
|
954 | - $query_string = array(); |
|
955 | - foreach ($query_string_parts as $query_part) { |
|
956 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
957 | - } |
|
958 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
959 | - |
|
960 | - // Display the posts |
|
961 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
962 | - Blog::display_blog_posts($blog_id, $query_string); |
|
963 | - } |
|
964 | - |
|
965 | - /** |
|
966 | - * Display posts from a certain date |
|
967 | - * |
|
968 | - * @param Integer $blog_id |
|
969 | - * @param String $query_string |
|
970 | - */ |
|
971 | - public static function display_day_results($blog_id, $query_string) |
|
972 | - { |
|
973 | - $date_output = $query_string; |
|
974 | - $date = explode('-',$query_string); |
|
975 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
976 | - |
|
977 | - // Put date in correct output format |
|
978 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
979 | - |
|
980 | - // Display the posts |
|
981 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
982 | - Blog::display_blog_posts($blog_id, $query_string); |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * Displays a post and his comments |
|
987 | - * |
|
988 | - * @param Integer $blog_id |
|
989 | - * @param Integer $post_id |
|
990 | - */ |
|
991 | - public static function display_post($blog_id, $post_id) |
|
992 | - { |
|
993 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
994 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
995 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
996 | - |
|
997 | - global $charset, $dateFormatLong; |
|
998 | - |
|
999 | - $course_id = api_get_course_int_id(); |
|
1000 | - |
|
1001 | - // Get posts and author |
|
1002 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
942 | + /** |
|
943 | + * Display the search results |
|
944 | + * |
|
945 | + * @param Integer $blog_id |
|
946 | + * @param String $query_string |
|
947 | + */ |
|
948 | + public static function display_search_results ($blog_id, $query_string) |
|
949 | + { |
|
950 | + // Init |
|
951 | + $query_string = Database::escape_string($query_string); |
|
952 | + $query_string_parts = explode(' ',$query_string); |
|
953 | + $query_string = array(); |
|
954 | + foreach ($query_string_parts as $query_part) { |
|
955 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
956 | + } |
|
957 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
958 | + |
|
959 | + // Display the posts |
|
960 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
961 | + Blog::display_blog_posts($blog_id, $query_string); |
|
962 | + } |
|
963 | + |
|
964 | + /** |
|
965 | + * Display posts from a certain date |
|
966 | + * |
|
967 | + * @param Integer $blog_id |
|
968 | + * @param String $query_string |
|
969 | + */ |
|
970 | + public static function display_day_results($blog_id, $query_string) |
|
971 | + { |
|
972 | + $date_output = $query_string; |
|
973 | + $date = explode('-',$query_string); |
|
974 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
975 | + |
|
976 | + // Put date in correct output format |
|
977 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
978 | + |
|
979 | + // Display the posts |
|
980 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
981 | + Blog::display_blog_posts($blog_id, $query_string); |
|
982 | + } |
|
983 | + |
|
984 | + /** |
|
985 | + * Displays a post and his comments |
|
986 | + * |
|
987 | + * @param Integer $blog_id |
|
988 | + * @param Integer $post_id |
|
989 | + */ |
|
990 | + public static function display_post($blog_id, $post_id) |
|
991 | + { |
|
992 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
993 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
994 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
995 | + |
|
996 | + global $charset, $dateFormatLong; |
|
997 | + |
|
998 | + $course_id = api_get_course_int_id(); |
|
999 | + |
|
1000 | + // Get posts and author |
|
1001 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1003 | 1002 | FROM $tbl_blogs_posts post |
1004 | 1003 | INNER JOIN $tbl_users user |
1005 | 1004 | ON post.author_id = user.user_id |
@@ -1008,34 +1007,34 @@ discard block |
||
1008 | 1007 | post.blog_id = '".(int)$blog_id."' AND |
1009 | 1008 | post.post_id = '".(int)$post_id."' |
1010 | 1009 | ORDER BY post_id DESC"; |
1011 | - $result = Database::query($sql); |
|
1012 | - $blog_post = Database::fetch_array($result); |
|
1010 | + $result = Database::query($sql); |
|
1011 | + $blog_post = Database::fetch_array($result); |
|
1013 | 1012 | |
1014 | - // Get number of comments |
|
1015 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
1013 | + // Get number of comments |
|
1014 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
1016 | 1015 | FROM $tbl_blogs_comments |
1017 | 1016 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
1018 | - $result = Database::query($sql); |
|
1019 | - $blog_post_comments = Database::fetch_array($result); |
|
1017 | + $result = Database::query($sql); |
|
1018 | + $blog_post_comments = Database::fetch_array($result); |
|
1020 | 1019 | |
1021 | - // Prepare data |
|
1022 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
1023 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
1024 | - $blog_post_actions = ""; |
|
1020 | + // Prepare data |
|
1021 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
1022 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
1023 | + $blog_post_actions = ""; |
|
1025 | 1024 | |
1026 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
1025 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
1027 | 1026 | |
1028 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1029 | - $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1030 | - ).'&action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1027 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1028 | + $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1029 | + ).'&action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1031 | 1030 | 'EditThisPost' |
1032 | 1031 | ).'"> |
1033 | 1032 | '.Display::return_icon('edit.png').' |
1034 | 1033 | </a>'; |
1035 | 1034 | |
1036 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1037 | - $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1038 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1035 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1036 | + $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1037 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1039 | 1038 | 'DeleteThisArticle' |
1040 | 1039 | ).'" onclick="javascript:if(!confirm(\''.addslashes( |
1041 | 1040 | api_htmlentities( |
@@ -1048,35 +1047,35 @@ discard block |
||
1048 | 1047 | '.Display::return_icon('delete.png').' |
1049 | 1048 | </a>'; |
1050 | 1049 | |
1051 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1052 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1050 | + if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1051 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1053 | 1052 | |
1054 | - $blog_post_text=stripslashes($blog_post_text); |
|
1053 | + $blog_post_text=stripslashes($blog_post_text); |
|
1055 | 1054 | |
1056 | - // Display post |
|
1057 | - echo '<div class="blogpost">'; |
|
1058 | - echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq( |
|
1059 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang( |
|
1055 | + // Display post |
|
1056 | + echo '<div class="blogpost">'; |
|
1057 | + echo '<span class="blogpost_title"><a href="blog.php?'.api_get_cidreq( |
|
1058 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang( |
|
1060 | 1059 | 'ReadPost' |
1061 | 1060 | ).'" >'. |
1062 | 1061 | stripslashes($blog_post['title']).'</a></span>'; |
1063 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1064 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1062 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1063 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1065 | 1064 | |
1066 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1065 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1067 | 1066 | |
1068 | 1067 | if (!empty($file_name_array)) { |
1069 | - echo ' <br />'; |
|
1070 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1071 | - echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
1072 | - echo $file_name_array['path']; |
|
1073 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1074 | - echo '</span>'; |
|
1075 | - echo '<span class="attachment_comment">'; |
|
1076 | - echo $file_name_array['comment']; |
|
1077 | - echo '</span>'; |
|
1078 | - echo '<br />'; |
|
1079 | - } |
|
1068 | + echo ' <br />'; |
|
1069 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1070 | + echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
1071 | + echo $file_name_array['path']; |
|
1072 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1073 | + echo '</span>'; |
|
1074 | + echo '<span class="attachment_comment">'; |
|
1075 | + echo $file_name_array['comment']; |
|
1076 | + echo '</span>'; |
|
1077 | + echo '<br />'; |
|
1078 | + } |
|
1080 | 1079 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
1081 | 1080 | echo '<span class="blogpost_info">'.get_lang('Author').': '. |
1082 | 1081 | Display::tag( |
@@ -1095,57 +1094,57 @@ discard block |
||
1095 | 1094 | $blog_id, |
1096 | 1095 | $post_id |
1097 | 1096 | ).$rating_select.'</span>'; |
1098 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1099 | - echo '</div>'; |
|
1097 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1098 | + echo '</div>'; |
|
1100 | 1099 | |
1101 | - // Display comments if there are any |
|
1100 | + // Display comments if there are any |
|
1102 | 1101 | if ($blog_post_comments['number_of_comments'] > 0) { |
1103 | - echo '<div class="comments">'; |
|
1104 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1105 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1106 | - echo '</div>'; |
|
1107 | - } |
|
1108 | - |
|
1109 | - // Display comment form |
|
1110 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1111 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1112 | - } |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * Adds rating to a certain post or comment |
|
1117 | - * @author Toon Keppens |
|
1118 | - * |
|
1119 | - * @param String $type |
|
1120 | - * @param Integer $blog_id |
|
1121 | - * @param Integer $item_id |
|
1122 | - * @param Integer $rating |
|
1123 | - * |
|
1124 | - * @return Boolean success |
|
1125 | - */ |
|
1126 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1127 | - { |
|
1128 | - $_user = api_get_user_info(); |
|
1129 | - |
|
1130 | - // Init |
|
1131 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1132 | - $course_id = api_get_course_int_id(); |
|
1133 | - |
|
1134 | - // Check if the user has already rated this post/comment |
|
1135 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1102 | + echo '<div class="comments">'; |
|
1103 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1104 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1105 | + echo '</div>'; |
|
1106 | + } |
|
1107 | + |
|
1108 | + // Display comment form |
|
1109 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1110 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1111 | + } |
|
1112 | + } |
|
1113 | + |
|
1114 | + /** |
|
1115 | + * Adds rating to a certain post or comment |
|
1116 | + * @author Toon Keppens |
|
1117 | + * |
|
1118 | + * @param String $type |
|
1119 | + * @param Integer $blog_id |
|
1120 | + * @param Integer $item_id |
|
1121 | + * @param Integer $rating |
|
1122 | + * |
|
1123 | + * @return Boolean success |
|
1124 | + */ |
|
1125 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1126 | + { |
|
1127 | + $_user = api_get_user_info(); |
|
1128 | + |
|
1129 | + // Init |
|
1130 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1131 | + $course_id = api_get_course_int_id(); |
|
1132 | + |
|
1133 | + // Check if the user has already rated this post/comment |
|
1134 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1136 | 1135 | WHERE |
1137 | 1136 | c_id = $course_id AND |
1138 | 1137 | blog_id = '".(int)$blog_id."' AND |
1139 | 1138 | item_id = '".(int)$item_id."' AND |
1140 | 1139 | rating_type = '".Database::escape_string($type)."' AND |
1141 | 1140 | user_id = '".(int)$_user['user_id']."'"; |
1142 | - $result = Database::query($sql); |
|
1141 | + $result = Database::query($sql); |
|
1143 | 1142 | |
1144 | 1143 | // Add rating |
1145 | - if (Database::num_rows($result) == 0) { |
|
1146 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1144 | + if (Database::num_rows($result) == 0) { |
|
1145 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1147 | 1146 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
1148 | - Database::query($sql); |
|
1147 | + Database::query($sql); |
|
1149 | 1148 | |
1150 | 1149 | $id = Database::insert_id(); |
1151 | 1150 | if ($id) { |
@@ -1153,113 +1152,113 @@ discard block |
||
1153 | 1152 | Database::query($sql); |
1154 | 1153 | } |
1155 | 1154 | |
1156 | - return true; |
|
1155 | + return true; |
|
1157 | 1156 | } else { |
1158 | - return false; |
|
1159 | - } |
|
1160 | - } |
|
1161 | - |
|
1162 | - /** |
|
1163 | - * Shows the rating of user |
|
1164 | - * |
|
1165 | - * @param String $type |
|
1166 | - * @param Integer $blog_id |
|
1167 | - * @param Integer $item_id |
|
1168 | - * |
|
1169 | - * @return array() |
|
1170 | - */ |
|
1171 | - public static function display_rating($type, $blog_id, $item_id) |
|
1172 | - { |
|
1173 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1174 | - $course_id = api_get_course_int_id(); |
|
1175 | - |
|
1176 | - // Calculate rating |
|
1177 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1157 | + return false; |
|
1158 | + } |
|
1159 | + } |
|
1160 | + |
|
1161 | + /** |
|
1162 | + * Shows the rating of user |
|
1163 | + * |
|
1164 | + * @param String $type |
|
1165 | + * @param Integer $blog_id |
|
1166 | + * @param Integer $item_id |
|
1167 | + * |
|
1168 | + * @return array() |
|
1169 | + */ |
|
1170 | + public static function display_rating($type, $blog_id, $item_id) |
|
1171 | + { |
|
1172 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1173 | + $course_id = api_get_course_int_id(); |
|
1174 | + |
|
1175 | + // Calculate rating |
|
1176 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1178 | 1177 | WHERE |
1179 | 1178 | c_id = $course_id AND |
1180 | 1179 | blog_id = '".(int)$blog_id."' AND |
1181 | 1180 | item_id = '".(int)$item_id."' AND |
1182 | 1181 | rating_type = '".Database::escape_string($type)."' "; |
1183 | - $result = Database::query($sql); |
|
1184 | - $result = Database::fetch_array($result); |
|
1185 | - return round($result['rating'], 2); |
|
1186 | - } |
|
1187 | - |
|
1188 | - /** |
|
1189 | - * Shows the rating form if not already rated by that user |
|
1190 | - * @author Toon Keppens |
|
1191 | - * |
|
1192 | - * @param String $type |
|
1193 | - * @param Integer $blog_id |
|
1194 | - * @param Integer $item_id |
|
1195 | - * |
|
1196 | - *@return String |
|
1197 | - */ |
|
1198 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1199 | - { |
|
1200 | - $_user = api_get_user_info(); |
|
1201 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1182 | + $result = Database::query($sql); |
|
1183 | + $result = Database::fetch_array($result); |
|
1184 | + return round($result['rating'], 2); |
|
1185 | + } |
|
1186 | + |
|
1187 | + /** |
|
1188 | + * Shows the rating form if not already rated by that user |
|
1189 | + * @author Toon Keppens |
|
1190 | + * |
|
1191 | + * @param String $type |
|
1192 | + * @param Integer $blog_id |
|
1193 | + * @param Integer $item_id |
|
1194 | + * |
|
1195 | + *@return String |
|
1196 | + */ |
|
1197 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1198 | + { |
|
1199 | + $_user = api_get_user_info(); |
|
1200 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1202 | 1201 | $course_id = api_get_course_int_id(); |
1203 | 1202 | |
1204 | 1203 | if ($type == 'post') { |
1205 | - // Check if the user has already rated this post |
|
1206 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1204 | + // Check if the user has already rated this post |
|
1205 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1207 | 1206 | WHERE c_id = $course_id AND |
1208 | 1207 | blog_id = '".(int)$blog_id."' |
1209 | 1208 | AND item_id = '".(int)$post_id."' |
1210 | 1209 | AND rating_type = '".Database::escape_string($type)."' |
1211 | 1210 | AND user_id = '".(int)$_user['user_id']."'"; |
1212 | - $result = Database::query($sql); |
|
1211 | + $result = Database::query($sql); |
|
1213 | 1212 | // Add rating |
1214 | 1213 | if (Database::num_rows($result) == 0) { |
1215 | - return ' - '.get_lang( |
|
1216 | - 'RateThis' |
|
1217 | - ).': <form method="get" action="blog.php?'.api_get_cidreq( |
|
1218 | - ).'" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>'; |
|
1214 | + return ' - '.get_lang( |
|
1215 | + 'RateThis' |
|
1216 | + ).': <form method="get" action="blog.php?'.api_get_cidreq( |
|
1217 | + ).'" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>'; |
|
1219 | 1218 | } else { |
1220 | - return ''; |
|
1221 | - } |
|
1222 | - } |
|
1219 | + return ''; |
|
1220 | + } |
|
1221 | + } |
|
1223 | 1222 | |
1224 | 1223 | if ($type = 'comment') { |
1225 | - // Check if the user has already rated this comment |
|
1226 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1224 | + // Check if the user has already rated this comment |
|
1225 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1227 | 1226 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
1228 | 1227 | AND item_id = '".(int)$comment_id."' |
1229 | 1228 | AND rating_type = '".Database::escape_string($type)."' |
1230 | 1229 | AND user_id = '".(int)$_user['user_id']."'"; |
1231 | - $result = Database::query($sql); |
|
1230 | + $result = Database::query($sql); |
|
1232 | 1231 | |
1233 | 1232 | if (Database::num_rows($result) == 0) { |
1234 | - return ' - '.get_lang( |
|
1235 | - 'RateThis' |
|
1236 | - ).': <form method="get" action="blog.php?'.api_get_cidreq( |
|
1237 | - ).'" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>'; |
|
1233 | + return ' - '.get_lang( |
|
1234 | + 'RateThis' |
|
1235 | + ).': <form method="get" action="blog.php?'.api_get_cidreq( |
|
1236 | + ).'" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>'; |
|
1238 | 1237 | } else { |
1239 | - return ''; |
|
1240 | - } |
|
1241 | - } |
|
1242 | - } |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * This functions gets all replys to a post, threaded. |
|
1246 | - * |
|
1247 | - * @param Integer $current |
|
1248 | - * @param Integer $current_level |
|
1249 | - * @param Integer $blog_id |
|
1250 | - * @param Integer $post_id |
|
1251 | - */ |
|
1252 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1253 | - { |
|
1254 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1255 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1256 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1257 | - global $charset; |
|
1258 | - |
|
1259 | - $course_id = api_get_course_int_id(); |
|
1260 | - |
|
1261 | - // Select top level comments |
|
1262 | - $next_level = $current_level + 1; |
|
1238 | + return ''; |
|
1239 | + } |
|
1240 | + } |
|
1241 | + } |
|
1242 | + |
|
1243 | + /** |
|
1244 | + * This functions gets all replys to a post, threaded. |
|
1245 | + * |
|
1246 | + * @param Integer $current |
|
1247 | + * @param Integer $current_level |
|
1248 | + * @param Integer $blog_id |
|
1249 | + * @param Integer $post_id |
|
1250 | + */ |
|
1251 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1252 | + { |
|
1253 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1254 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1255 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1256 | + global $charset; |
|
1257 | + |
|
1258 | + $course_id = api_get_course_int_id(); |
|
1259 | + |
|
1260 | + // Select top level comments |
|
1261 | + $next_level = $current_level + 1; |
|
1263 | 1262 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
1264 | 1263 | FROM $tbl_blogs_comments comments |
1265 | 1264 | INNER JOIN $tbl_users user |
@@ -1271,11 +1270,11 @@ discard block |
||
1271 | 1270 | parent_comment_id = $current AND |
1272 | 1271 | comments.blog_id = '".(int)$blog_id."' AND |
1273 | 1272 | comments.post_id = '".(int)$post_id."'"; |
1274 | - $result = Database::query($sql); |
|
1273 | + $result = Database::query($sql); |
|
1275 | 1274 | |
1276 | - while($comment = Database::fetch_array($result)) { |
|
1277 | - // Select the children recursivly |
|
1278 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1275 | + while($comment = Database::fetch_array($result)) { |
|
1276 | + // Select the children recursivly |
|
1277 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1279 | 1278 | FROM $tbl_blogs_comments comments |
1280 | 1279 | INNER JOIN $tbl_users user |
1281 | 1280 | ON comments.author_id = user.user_id |
@@ -1284,132 +1283,132 @@ discard block |
||
1284 | 1283 | comment_id = $current |
1285 | 1284 | AND blog_id = '".(int)$blog_id."' |
1286 | 1285 | AND post_id = '".(int)$post_id."'"; |
1287 | - $tmp = Database::query($tmp); |
|
1288 | - $tmp = Database::fetch_array($tmp); |
|
1289 | - $parent_cat = $tmp['parent_comment_id']; |
|
1290 | - $border_color = ''; |
|
1291 | - |
|
1292 | - // Prepare data |
|
1293 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1294 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1295 | - $blog_comment_actions = ""; |
|
1296 | - if (api_is_allowed( |
|
1297 | - 'BLOG_'.$blog_id, |
|
1298 | - 'article_comments_delete', |
|
1299 | - $task_id |
|
1300 | - )) { |
|
1301 | - $blog_comment_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1302 | - ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1303 | - 'DeleteThisComment' |
|
1304 | - ).'" onclick="javascript:if(!confirm(\''.addslashes( |
|
1305 | - api_htmlentities( |
|
1306 | - get_lang("ConfirmYourChoice"), |
|
1307 | - ENT_QUOTES, |
|
1308 | - $charset |
|
1309 | - ) |
|
1310 | - ).'\')) return false;"> |
|
1286 | + $tmp = Database::query($tmp); |
|
1287 | + $tmp = Database::fetch_array($tmp); |
|
1288 | + $parent_cat = $tmp['parent_comment_id']; |
|
1289 | + $border_color = ''; |
|
1290 | + |
|
1291 | + // Prepare data |
|
1292 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1293 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1294 | + $blog_comment_actions = ""; |
|
1295 | + if (api_is_allowed( |
|
1296 | + 'BLOG_'.$blog_id, |
|
1297 | + 'article_comments_delete', |
|
1298 | + $task_id |
|
1299 | + )) { |
|
1300 | + $blog_comment_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1301 | + ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang( |
|
1302 | + 'DeleteThisComment' |
|
1303 | + ).'" onclick="javascript:if(!confirm(\''.addslashes( |
|
1304 | + api_htmlentities( |
|
1305 | + get_lang("ConfirmYourChoice"), |
|
1306 | + ENT_QUOTES, |
|
1307 | + $charset |
|
1308 | + ) |
|
1309 | + ).'\')) return false;"> |
|
1311 | 1310 | '.Display::return_icon('delete.png').'</a>'; |
1312 | - } |
|
1313 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) { |
|
1314 | - $rating_select = Blog::display_rating_form( |
|
1315 | - 'comment', |
|
1316 | - $blog_id, |
|
1317 | - $post_id, |
|
1318 | - $comment['comment_id'] |
|
1319 | - ); |
|
1320 | - } |
|
1321 | - |
|
1322 | - if (!is_null($comment['task_id'])) { |
|
1323 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1324 | - } |
|
1325 | - |
|
1326 | - $comment_text = stripslashes($comment_text); |
|
1327 | - |
|
1328 | - // Output... |
|
1329 | - $margin = $current_level * 30; |
|
1330 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1331 | - echo '<span class="blogpost_comment_title"> |
|
1311 | + } |
|
1312 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) { |
|
1313 | + $rating_select = Blog::display_rating_form( |
|
1314 | + 'comment', |
|
1315 | + $blog_id, |
|
1316 | + $post_id, |
|
1317 | + $comment['comment_id'] |
|
1318 | + ); |
|
1319 | + } |
|
1320 | + |
|
1321 | + if (!is_null($comment['task_id'])) { |
|
1322 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1323 | + } |
|
1324 | + |
|
1325 | + $comment_text = stripslashes($comment_text); |
|
1326 | + |
|
1327 | + // Output... |
|
1328 | + $margin = $current_level * 30; |
|
1329 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1330 | + echo '<span class="blogpost_comment_title"> |
|
1332 | 1331 | <a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes( |
1333 | - $comment['title'] |
|
1334 | - ).'\'" title="'.get_lang( |
|
1335 | - 'ReplyToThisComment' |
|
1336 | - ).'" >'.stripslashes($comment['title']).'</a></span>'; |
|
1337 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1338 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1339 | - |
|
1340 | - $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1341 | - if (!empty($file_name_array)) { |
|
1342 | - echo '<br /><br />'; |
|
1343 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1344 | - echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
1345 | - echo $file_name_array['path']; |
|
1346 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1347 | - echo '<span class="attachment_comment">'; |
|
1348 | - echo $file_name_array['comment']; |
|
1349 | - echo '</span><br />'; |
|
1350 | - } |
|
1332 | + $comment['title'] |
|
1333 | + ).'\'" title="'.get_lang( |
|
1334 | + 'ReplyToThisComment' |
|
1335 | + ).'" >'.stripslashes($comment['title']).'</a></span>'; |
|
1336 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1337 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1338 | + |
|
1339 | + $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1340 | + if (!empty($file_name_array)) { |
|
1341 | + echo '<br /><br />'; |
|
1342 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1343 | + echo '<a href="download.php?'.api_get_cidreq().'&file='; |
|
1344 | + echo $file_name_array['path']; |
|
1345 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1346 | + echo '<span class="attachment_comment">'; |
|
1347 | + echo $file_name_array['comment']; |
|
1348 | + echo '</span><br />'; |
|
1349 | + } |
|
1351 | 1350 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
1352 | - echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1353 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1354 | - echo '</div>'; |
|
1355 | - |
|
1356 | - // Go further down the tree. |
|
1357 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1358 | - } |
|
1359 | - } |
|
1360 | - |
|
1361 | - /** |
|
1362 | - * Displays the form to create a new post |
|
1363 | - * @author Toon Keppens |
|
1364 | - * |
|
1365 | - * @param Integer $blog_id |
|
1366 | - */ |
|
1367 | - public static function display_form_new_post($blog_id) |
|
1368 | - { |
|
1369 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1370 | - $form = new FormValidator( |
|
1371 | - 'add_post', |
|
1372 | - 'post', |
|
1373 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1374 | - null, |
|
1375 | - array('enctype' => 'multipart/form-data') |
|
1376 | - ); |
|
1377 | - $form->addHidden('post_title_edited', 'false'); |
|
1378 | - $form->addHeader(get_lang('NewPost')); |
|
1379 | - $form->addText('title', get_lang('Title')); |
|
1380 | - $config = array(); |
|
1381 | - if (!api_is_allowed_to_edit()) { |
|
1382 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1383 | - } else { |
|
1384 | - $config['ToolbarSet'] = 'Project'; |
|
1385 | - } |
|
1386 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1387 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1388 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1389 | - $form->addHidden('new_post_submit', 'true'); |
|
1390 | - $form->addButton('save', get_lang('Save')); |
|
1391 | - |
|
1392 | - $form->display(); |
|
1393 | - } else { |
|
1394 | - api_not_allowed(); |
|
1395 | - } |
|
1396 | - } |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * Displays the form to edit a post |
|
1400 | - * @author Toon Keppens |
|
1401 | - * |
|
1402 | - * @param Integer $blog_id |
|
1403 | - */ |
|
1404 | - public static function display_form_edit_post($blog_id, $post_id) |
|
1405 | - { |
|
1406 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1407 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1408 | - |
|
1409 | - $course_id = api_get_course_int_id(); |
|
1410 | - |
|
1411 | - // Get posts and author |
|
1412 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
1351 | + echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1352 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1353 | + echo '</div>'; |
|
1354 | + |
|
1355 | + // Go further down the tree. |
|
1356 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1357 | + } |
|
1358 | + } |
|
1359 | + |
|
1360 | + /** |
|
1361 | + * Displays the form to create a new post |
|
1362 | + * @author Toon Keppens |
|
1363 | + * |
|
1364 | + * @param Integer $blog_id |
|
1365 | + */ |
|
1366 | + public static function display_form_new_post($blog_id) |
|
1367 | + { |
|
1368 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1369 | + $form = new FormValidator( |
|
1370 | + 'add_post', |
|
1371 | + 'post', |
|
1372 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1373 | + null, |
|
1374 | + array('enctype' => 'multipart/form-data') |
|
1375 | + ); |
|
1376 | + $form->addHidden('post_title_edited', 'false'); |
|
1377 | + $form->addHeader(get_lang('NewPost')); |
|
1378 | + $form->addText('title', get_lang('Title')); |
|
1379 | + $config = array(); |
|
1380 | + if (!api_is_allowed_to_edit()) { |
|
1381 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1382 | + } else { |
|
1383 | + $config['ToolbarSet'] = 'Project'; |
|
1384 | + } |
|
1385 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1386 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1387 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1388 | + $form->addHidden('new_post_submit', 'true'); |
|
1389 | + $form->addButton('save', get_lang('Save')); |
|
1390 | + |
|
1391 | + $form->display(); |
|
1392 | + } else { |
|
1393 | + api_not_allowed(); |
|
1394 | + } |
|
1395 | + } |
|
1396 | + |
|
1397 | + /** |
|
1398 | + * Displays the form to edit a post |
|
1399 | + * @author Toon Keppens |
|
1400 | + * |
|
1401 | + * @param Integer $blog_id |
|
1402 | + */ |
|
1403 | + public static function display_form_edit_post($blog_id, $post_id) |
|
1404 | + { |
|
1405 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1406 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1407 | + |
|
1408 | + $course_id = api_get_course_int_id(); |
|
1409 | + |
|
1410 | + // Get posts and author |
|
1411 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
1413 | 1412 | FROM $tbl_blogs_posts post |
1414 | 1413 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1415 | 1414 | WHERE |
@@ -1417,74 +1416,74 @@ discard block |
||
1417 | 1416 | post.blog_id = '".(int)$blog_id ."' |
1418 | 1417 | AND post.post_id = '".(int)$post_id."' |
1419 | 1418 | ORDER BY post_id DESC"; |
1420 | - $result = Database::query($sql); |
|
1421 | - $blog_post = Database::fetch_array($result); |
|
1422 | - |
|
1423 | - // Form |
|
1424 | - $form = new FormValidator( |
|
1425 | - 'edit_post', |
|
1426 | - 'post', |
|
1427 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?'.api_get_cidreq( |
|
1428 | - ).'&action=edit_post&post_id='.intval( |
|
1429 | - $_GET['post_id'] |
|
1430 | - ).'&blog_id='.intval($blog_id).'&article_id='.intval( |
|
1431 | - $_GET['article_id'] |
|
1432 | - ).'&task_id='.intval($_GET['task_id']) |
|
1433 | - ); |
|
1434 | - |
|
1435 | - $form->addHeader(get_lang('EditPost')); |
|
1436 | - $form->addText('title', get_lang('Title')); |
|
1437 | - |
|
1438 | - if (!api_is_allowed_to_edit()) { |
|
1439 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1440 | - } else { |
|
1441 | - $config['ToolbarSet'] = 'Project'; |
|
1442 | - } |
|
1443 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1444 | - |
|
1445 | - $form->addHidden('action', ''); |
|
1446 | - $form->addHidden('edit_post_submit', 'true'); |
|
1447 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1448 | - $form->addButton('save', get_lang('Save')); |
|
1449 | - $form->setDefaults($blog_post); |
|
1450 | - $form->display(); |
|
1451 | - } |
|
1452 | - |
|
1453 | - /** |
|
1454 | - * Displays a list of tasks in this blog |
|
1455 | - * @author Toon Keppens |
|
1456 | - * |
|
1457 | - * @param Integer $blog_id |
|
1458 | - */ |
|
1459 | - public static function display_task_list($blog_id) |
|
1419 | + $result = Database::query($sql); |
|
1420 | + $blog_post = Database::fetch_array($result); |
|
1421 | + |
|
1422 | + // Form |
|
1423 | + $form = new FormValidator( |
|
1424 | + 'edit_post', |
|
1425 | + 'post', |
|
1426 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?'.api_get_cidreq( |
|
1427 | + ).'&action=edit_post&post_id='.intval( |
|
1428 | + $_GET['post_id'] |
|
1429 | + ).'&blog_id='.intval($blog_id).'&article_id='.intval( |
|
1430 | + $_GET['article_id'] |
|
1431 | + ).'&task_id='.intval($_GET['task_id']) |
|
1432 | + ); |
|
1433 | + |
|
1434 | + $form->addHeader(get_lang('EditPost')); |
|
1435 | + $form->addText('title', get_lang('Title')); |
|
1436 | + |
|
1437 | + if (!api_is_allowed_to_edit()) { |
|
1438 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1439 | + } else { |
|
1440 | + $config['ToolbarSet'] = 'Project'; |
|
1441 | + } |
|
1442 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1443 | + |
|
1444 | + $form->addHidden('action', ''); |
|
1445 | + $form->addHidden('edit_post_submit', 'true'); |
|
1446 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1447 | + $form->addButton('save', get_lang('Save')); |
|
1448 | + $form->setDefaults($blog_post); |
|
1449 | + $form->display(); |
|
1450 | + } |
|
1451 | + |
|
1452 | + /** |
|
1453 | + * Displays a list of tasks in this blog |
|
1454 | + * @author Toon Keppens |
|
1455 | + * |
|
1456 | + * @param Integer $blog_id |
|
1457 | + */ |
|
1458 | + public static function display_task_list($blog_id) |
|
1460 | 1459 | { |
1461 | - global $charset; |
|
1460 | + global $charset; |
|
1462 | 1461 | $course_id = api_get_course_int_id(); |
1463 | 1462 | |
1464 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1465 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1466 | - $counter = 0; |
|
1467 | - global $color2; |
|
1463 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1464 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1465 | + $counter = 0; |
|
1466 | + global $color2; |
|
1468 | 1467 | |
1469 | - echo '<div class="actions">'; |
|
1470 | - echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> '; |
|
1471 | - echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>'; |
|
1472 | - ?> |
|
1468 | + echo '<div class="actions">'; |
|
1469 | + echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> '; |
|
1470 | + echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>'; |
|
1471 | + ?> |
|
1473 | 1472 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
1474 | 1473 | <?php |
1475 | - echo '</div>'; |
|
1474 | + echo '</div>'; |
|
1476 | 1475 | |
1477 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1478 | - echo "<table class=\"data_table\">"; |
|
1479 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1480 | - "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
1481 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1482 | - "<th><b>",get_lang('Color'),"</b></th>\n", |
|
1483 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1484 | - "</tr>\n"; |
|
1476 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1477 | + echo "<table class=\"data_table\">"; |
|
1478 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1479 | + "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
1480 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1481 | + "<th><b>",get_lang('Color'),"</b></th>\n", |
|
1482 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1483 | + "</tr>\n"; |
|
1485 | 1484 | |
1486 | 1485 | |
1487 | - $sql = " SELECT |
|
1486 | + $sql = " SELECT |
|
1488 | 1487 | blog_id, |
1489 | 1488 | task_id, |
1490 | 1489 | blog_id, |
@@ -1495,64 +1494,64 @@ discard block |
||
1495 | 1494 | FROM " . $tbl_blogs_tasks . " |
1496 | 1495 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1497 | 1496 | ORDER BY system_task, title"; |
1498 | - $result = Database::query($sql); |
|
1499 | - |
|
1500 | - |
|
1501 | - while($task = Database::fetch_array($result)) { |
|
1502 | - $counter++; |
|
1503 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1504 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1505 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1506 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1507 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1508 | - |
|
1509 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1510 | - '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
1511 | - '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
1512 | - '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
1513 | - '<td width="50">', |
|
1514 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
1515 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1516 | - "</a>\n", |
|
1517 | - '<a href="' . $delete_link . '"', |
|
1518 | - $delete_confirm, |
|
1519 | - '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1520 | - "</a>\n", |
|
1521 | - '</td>', |
|
1522 | - '</tr>'; |
|
1523 | - } |
|
1524 | - echo "</table>"; |
|
1525 | - } |
|
1526 | - } |
|
1527 | - |
|
1528 | - /** |
|
1529 | - * Displays a list of tasks assigned to a user in this blog |
|
1530 | - * @author Toon Keppens |
|
1531 | - * |
|
1532 | - * @param Integer $blog_id |
|
1533 | - */ |
|
1534 | - public static function display_assigned_task_list ($blog_id) |
|
1497 | + $result = Database::query($sql); |
|
1498 | + |
|
1499 | + |
|
1500 | + while($task = Database::fetch_array($result)) { |
|
1501 | + $counter++; |
|
1502 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1503 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1504 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1505 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1506 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1507 | + |
|
1508 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
1509 | + '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
1510 | + '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
1511 | + '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
1512 | + '<td width="50">', |
|
1513 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
1514 | + '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1515 | + "</a>\n", |
|
1516 | + '<a href="' . $delete_link . '"', |
|
1517 | + $delete_confirm, |
|
1518 | + '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1519 | + "</a>\n", |
|
1520 | + '</td>', |
|
1521 | + '</tr>'; |
|
1522 | + } |
|
1523 | + echo "</table>"; |
|
1524 | + } |
|
1525 | + } |
|
1526 | + |
|
1527 | + /** |
|
1528 | + * Displays a list of tasks assigned to a user in this blog |
|
1529 | + * @author Toon Keppens |
|
1530 | + * |
|
1531 | + * @param Integer $blog_id |
|
1532 | + */ |
|
1533 | + public static function display_assigned_task_list ($blog_id) |
|
1535 | 1534 | { |
1536 | - // Init |
|
1537 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1538 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1539 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1540 | - $counter = 0; |
|
1541 | - global $charset,$color2; |
|
1542 | - |
|
1543 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1544 | - echo "<table class=\"data_table\">"; |
|
1545 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1546 | - "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
1547 | - "<th><b>",get_lang('Task'),"</b></th>\n", |
|
1548 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1549 | - "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
1550 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1551 | - "</tr>"; |
|
1552 | - |
|
1553 | - $course_id = api_get_course_int_id(); |
|
1554 | - |
|
1555 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1535 | + // Init |
|
1536 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1537 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1538 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1539 | + $counter = 0; |
|
1540 | + global $charset,$color2; |
|
1541 | + |
|
1542 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1543 | + echo "<table class=\"data_table\">"; |
|
1544 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1545 | + "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
1546 | + "<th><b>",get_lang('Task'),"</b></th>\n", |
|
1547 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1548 | + "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
1549 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1550 | + "</tr>"; |
|
1551 | + |
|
1552 | + $course_id = api_get_course_int_id(); |
|
1553 | + |
|
1554 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1556 | 1555 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
1557 | 1556 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
1558 | 1557 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1561,45 +1560,45 @@ discard block |
||
1561 | 1560 | task.c_id = $course_id AND |
1562 | 1561 | task_rel_user.blog_id = '".(int)$blog_id."' |
1563 | 1562 | ORDER BY target_date ASC"; |
1564 | - $result = Database::query($sql); |
|
1563 | + $result = Database::query($sql); |
|
1565 | 1564 | |
1566 | - while ($assignment = Database::fetch_array($result)) { |
|
1567 | - $counter++; |
|
1568 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1569 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1570 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1571 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1572 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1565 | + while ($assignment = Database::fetch_array($result)) { |
|
1566 | + $counter++; |
|
1567 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1568 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
1569 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1570 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1571 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1573 | 1572 | |
1574 | 1573 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
1575 | 1574 | |
1576 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1577 | - '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
1578 | - '<td>'.stripslashes($assignment['title']) . '</td>', |
|
1579 | - '<td>'.stripslashes($assignment['description']) . '</td>', |
|
1580 | - '<td>' . $assignment['target_date'] . '</td>', |
|
1581 | - '<td width="50">', |
|
1582 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
1583 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1584 | - "</a>\n", |
|
1585 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
1586 | - 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
1587 | - '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1588 | - "</a>\n", |
|
1589 | - '</td>', |
|
1590 | - '</tr>'; |
|
1591 | - } |
|
1592 | - echo "</table>"; |
|
1593 | - } |
|
1594 | - |
|
1595 | - /** |
|
1596 | - * Displays new task form |
|
1597 | - * @author Toon Keppens |
|
1598 | - * |
|
1599 | - */ |
|
1600 | - public static function display_new_task_form ($blog_id) |
|
1601 | - { |
|
1602 | - // Init |
|
1575 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
1576 | + '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
1577 | + '<td>'.stripslashes($assignment['title']) . '</td>', |
|
1578 | + '<td>'.stripslashes($assignment['description']) . '</td>', |
|
1579 | + '<td>' . $assignment['target_date'] . '</td>', |
|
1580 | + '<td width="50">', |
|
1581 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
1582 | + '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1583 | + "</a>\n", |
|
1584 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
1585 | + 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
1586 | + '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1587 | + "</a>\n", |
|
1588 | + '</td>', |
|
1589 | + '</tr>'; |
|
1590 | + } |
|
1591 | + echo "</table>"; |
|
1592 | + } |
|
1593 | + |
|
1594 | + /** |
|
1595 | + * Displays new task form |
|
1596 | + * @author Toon Keppens |
|
1597 | + * |
|
1598 | + */ |
|
1599 | + public static function display_new_task_form ($blog_id) |
|
1600 | + { |
|
1601 | + // Init |
|
1603 | 1602 | $colors = array( |
1604 | 1603 | 'FFFFFF', |
1605 | 1604 | 'FFFF99', |
@@ -1618,15 +1617,15 @@ discard block |
||
1618 | 1617 | '000000' |
1619 | 1618 | ); |
1620 | 1619 | |
1621 | - // form |
|
1622 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq( |
|
1623 | - ).'">'; |
|
1620 | + // form |
|
1621 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq( |
|
1622 | + ).'">'; |
|
1624 | 1623 | |
1625 | - // form title |
|
1626 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1624 | + // form title |
|
1625 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1627 | 1626 | |
1628 | - // task title |
|
1629 | - echo ' <div class="control-group"> |
|
1627 | + // task title |
|
1628 | + echo ' <div class="control-group"> |
|
1630 | 1629 | <label class="control-label"> |
1631 | 1630 | <span class="form_required">*</span>' . get_lang('Title') . ' |
1632 | 1631 | </label> |
@@ -1635,8 +1634,8 @@ discard block |
||
1635 | 1634 | </div> |
1636 | 1635 | </div>'; |
1637 | 1636 | |
1638 | - // task comment |
|
1639 | - echo ' <div class="control-group"> |
|
1637 | + // task comment |
|
1638 | + echo ' <div class="control-group"> |
|
1640 | 1639 | <label class="control-label"> |
1641 | 1640 | ' . get_lang('Description') . ' |
1642 | 1641 | </label> |
@@ -1645,8 +1644,8 @@ discard block |
||
1645 | 1644 | </div> |
1646 | 1645 | </div>'; |
1647 | 1646 | |
1648 | - // task management |
|
1649 | - echo ' <div class="control-group"> |
|
1647 | + // task management |
|
1648 | + echo ' <div class="control-group"> |
|
1650 | 1649 | <label class="control-label"> |
1651 | 1650 | ' . get_lang('TaskManager') . ' |
1652 | 1651 | </label> |
@@ -1667,12 +1666,12 @@ discard block |
||
1667 | 1666 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
1668 | 1667 | echo '</tr>'; |
1669 | 1668 | echo '</table>'; |
1670 | - echo ' </div> |
|
1669 | + echo ' </div> |
|
1671 | 1670 | </div>'; |
1672 | 1671 | |
1673 | 1672 | |
1674 | - // task color |
|
1675 | - echo ' <div class="control-group"> |
|
1673 | + // task color |
|
1674 | + echo ' <div class="control-group"> |
|
1676 | 1675 | <label class="control-label"> |
1677 | 1676 | ' . get_lang('Color') . ' |
1678 | 1677 | </label> |
@@ -1683,124 +1682,124 @@ discard block |
||
1683 | 1682 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
1684 | 1683 | } |
1685 | 1684 | echo '</select>'; |
1686 | - echo ' </div> |
|
1685 | + echo ' </div> |
|
1687 | 1686 | </div>'; |
1688 | 1687 | |
1689 | - // submit |
|
1690 | - echo ' <div class="control-group"> |
|
1688 | + // submit |
|
1689 | + echo ' <div class="control-group"> |
|
1691 | 1690 | <div class="controls"> |
1692 | 1691 | <input type="hidden" name="action" value="" /> |
1693 | 1692 | <input type="hidden" name="new_task_submit" value="true" /> |
1694 | 1693 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
1695 | 1694 | </div> |
1696 | 1695 | </div>'; |
1697 | - echo '</form>'; |
|
1696 | + echo '</form>'; |
|
1698 | 1697 | |
1699 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1700 | - } |
|
1698 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1699 | + } |
|
1701 | 1700 | |
1702 | 1701 | |
1703 | - /** |
|
1704 | - * Displays edit task form |
|
1705 | - * @author Toon Keppens |
|
1706 | - * |
|
1707 | - */ |
|
1708 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
1709 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1702 | + /** |
|
1703 | + * Displays edit task form |
|
1704 | + * @author Toon Keppens |
|
1705 | + * |
|
1706 | + */ |
|
1707 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
1708 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1710 | 1709 | $course_id = api_get_course_int_id(); |
1711 | 1710 | |
1712 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1711 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1713 | 1712 | |
1714 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks |
|
1713 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks |
|
1715 | 1714 | WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
1716 | - $result = Database::query($sql); |
|
1717 | - $task = Database::fetch_array($result); |
|
1715 | + $result = Database::query($sql); |
|
1716 | + $task = Database::fetch_array($result); |
|
1718 | 1717 | |
1719 | - // Display |
|
1720 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq( |
|
1721 | - ).'"> |
|
1718 | + // Display |
|
1719 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq( |
|
1720 | + ).'"> |
|
1722 | 1721 | <legend>'.get_lang('EditTask').'</legend> |
1723 | 1722 | <table width="100%" border="0" cellspacing="2"> |
1724 | 1723 | <tr> |
1725 | 1724 | <td align="right">'.get_lang('Title').': </td> |
1726 | 1725 | <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS( |
1727 | - $task['title'] |
|
1728 | - ).'" /></td> |
|
1726 | + $task['title'] |
|
1727 | + ).'" /></td> |
|
1729 | 1728 | </tr> |
1730 | 1729 | <tr> |
1731 | 1730 | <td align="right">'.get_lang('Description').': </td> |
1732 | 1731 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS( |
1733 | - $task['description'] |
|
1734 | - ).'</textarea></td> |
|
1732 | + $task['description'] |
|
1733 | + ).'</textarea></td> |
|
1735 | 1734 | </tr>'; |
1736 | 1735 | |
1737 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1738 | - $tbl_tasks_permissions = Database::get_course_table( |
|
1739 | - TABLE_BLOGS_TASKS_PERMISSIONS |
|
1740 | - ); |
|
1736 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1737 | + $tbl_tasks_permissions = Database::get_course_table( |
|
1738 | + TABLE_BLOGS_TASKS_PERMISSIONS |
|
1739 | + ); |
|
1741 | 1740 | |
1742 | - $sql = " SELECT id, action FROM ".$tbl_tasks_permissions." |
|
1741 | + $sql = " SELECT id, action FROM ".$tbl_tasks_permissions." |
|
1743 | 1742 | WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
1744 | - $result = Database::query($sql); |
|
1745 | - |
|
1746 | - $arrPermissions = array(); |
|
1747 | - |
|
1748 | - while ($row = Database::fetch_array($result)) { |
|
1749 | - $arrPermissions[] = $row['action']; |
|
1750 | - } |
|
1751 | - |
|
1752 | - echo '<tr>'; |
|
1753 | - echo '<td style="text-align:right; vertical-align:top;">'.get_lang( |
|
1754 | - 'TaskManager' |
|
1755 | - ).': </td>'; |
|
1756 | - echo '<td>'; |
|
1757 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1758 | - echo '<tr>'; |
|
1759 | - echo '<th colspan="2" style="width:223px;">'.get_lang( |
|
1760 | - 'ArticleManager' |
|
1761 | - ).'</th>'; |
|
1762 | - echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
1763 | - echo '</tr>'; |
|
1764 | - echo '<tr>'; |
|
1765 | - echo '<th style="width:111px;"><label for="articleDelete">'.get_lang( |
|
1766 | - 'Delete' |
|
1767 | - ).'</label></th>'; |
|
1768 | - echo '<th style="width:112px;"><label for="articleEdit">'.get_lang( |
|
1769 | - 'Edit' |
|
1770 | - ).'</label></th>'; |
|
1771 | - echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang( |
|
1772 | - 'Delete' |
|
1773 | - ).'</label></th>'; |
|
1774 | - echo '</tr>'; |
|
1775 | - echo '<tr>'; |
|
1776 | - echo '<td style="text-align:center;"><input '.((in_array( |
|
1777 | - 'article_delete', |
|
1778 | - $arrPermissions |
|
1779 | - )) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1780 | - echo '<td style="text-align:center;"><input '.((in_array( |
|
1781 | - 'article_edit', |
|
1782 | - $arrPermissions |
|
1783 | - )) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1784 | - echo '<td style="text-align:center;"><input '.((in_array( |
|
1785 | - 'article_comments_delete', |
|
1786 | - $arrPermissions |
|
1787 | - )) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1788 | - echo '</tr>'; |
|
1789 | - echo '</table>'; |
|
1790 | - echo '</td>'; |
|
1791 | - echo '</tr>'; |
|
1792 | - /* end of edit */ |
|
1793 | - |
|
1794 | - echo '<tr> |
|
1743 | + $result = Database::query($sql); |
|
1744 | + |
|
1745 | + $arrPermissions = array(); |
|
1746 | + |
|
1747 | + while ($row = Database::fetch_array($result)) { |
|
1748 | + $arrPermissions[] = $row['action']; |
|
1749 | + } |
|
1750 | + |
|
1751 | + echo '<tr>'; |
|
1752 | + echo '<td style="text-align:right; vertical-align:top;">'.get_lang( |
|
1753 | + 'TaskManager' |
|
1754 | + ).': </td>'; |
|
1755 | + echo '<td>'; |
|
1756 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1757 | + echo '<tr>'; |
|
1758 | + echo '<th colspan="2" style="width:223px;">'.get_lang( |
|
1759 | + 'ArticleManager' |
|
1760 | + ).'</th>'; |
|
1761 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
1762 | + echo '</tr>'; |
|
1763 | + echo '<tr>'; |
|
1764 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang( |
|
1765 | + 'Delete' |
|
1766 | + ).'</label></th>'; |
|
1767 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang( |
|
1768 | + 'Edit' |
|
1769 | + ).'</label></th>'; |
|
1770 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang( |
|
1771 | + 'Delete' |
|
1772 | + ).'</label></th>'; |
|
1773 | + echo '</tr>'; |
|
1774 | + echo '<tr>'; |
|
1775 | + echo '<td style="text-align:center;"><input '.((in_array( |
|
1776 | + 'article_delete', |
|
1777 | + $arrPermissions |
|
1778 | + )) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1779 | + echo '<td style="text-align:center;"><input '.((in_array( |
|
1780 | + 'article_edit', |
|
1781 | + $arrPermissions |
|
1782 | + )) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1783 | + echo '<td style="text-align:center;"><input '.((in_array( |
|
1784 | + 'article_comments_delete', |
|
1785 | + $arrPermissions |
|
1786 | + )) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1787 | + echo '</tr>'; |
|
1788 | + echo '</table>'; |
|
1789 | + echo '</td>'; |
|
1790 | + echo '</tr>'; |
|
1791 | + /* end of edit */ |
|
1792 | + |
|
1793 | + echo '<tr> |
|
1795 | 1794 | <td align="right">'.get_lang('Color').': </td> |
1796 | 1795 | <td> |
1797 | 1796 | <select name="task_color" id="color" style="width: 150px; background-color: #'.$task['color'].'" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
1798 | - foreach ($colors as $color) { |
|
1799 | - $selected = ($color == $task['color']) ? ' selected' : ''; |
|
1800 | - $style = 'style="background-color: #'.$color.'"'; |
|
1801 | - echo '<option value="'.$color.'" '.$style.' '.$selected.' > </option>'; |
|
1802 | - } |
|
1803 | - echo ' </select> |
|
1797 | + foreach ($colors as $color) { |
|
1798 | + $selected = ($color == $task['color']) ? ' selected' : ''; |
|
1799 | + $style = 'style="background-color: #'.$color.'"'; |
|
1800 | + echo '<option value="'.$color.'" '.$style.' '.$selected.' > </option>'; |
|
1801 | + } |
|
1802 | + echo ' </select> |
|
1804 | 1803 | </td> |
1805 | 1804 | </tr> |
1806 | 1805 | <tr> |
@@ -1810,39 +1809,39 @@ discard block |
||
1810 | 1809 | <input type="hidden" name="task_id" value="'.$task['task_id'].'" /> |
1811 | 1810 | <input type="hidden" name="blog_id" value="'.$task['blog_id'].'" /> |
1812 | 1811 | <button class="save" type="submit" name="Submit">'.get_lang( |
1813 | - 'Save' |
|
1814 | - ).'</button></td> |
|
1812 | + 'Save' |
|
1813 | + ).'</button></td> |
|
1815 | 1814 | </tr> |
1816 | 1815 | </table> |
1817 | 1816 | </form>'; |
1818 | - } |
|
1819 | - |
|
1820 | - /** |
|
1821 | - * @param $blog_id |
|
1822 | - * @return FormValidator |
|
1823 | - */ |
|
1824 | - public static function getTaskForm($blog_id) |
|
1825 | - { |
|
1826 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1827 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1828 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1829 | - $course_id = api_get_course_int_id(); |
|
1830 | - |
|
1831 | - // Get users in this blog / make select list of it |
|
1832 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1817 | + } |
|
1818 | + |
|
1819 | + /** |
|
1820 | + * @param $blog_id |
|
1821 | + * @return FormValidator |
|
1822 | + */ |
|
1823 | + public static function getTaskForm($blog_id) |
|
1824 | + { |
|
1825 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1826 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1827 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1828 | + $course_id = api_get_course_int_id(); |
|
1829 | + |
|
1830 | + // Get users in this blog / make select list of it |
|
1831 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1833 | 1832 | FROM $tbl_users user |
1834 | 1833 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
1835 | 1834 | ON user.user_id = blogs_rel_user.user_id |
1836 | 1835 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
1837 | - $result = Database::query($sql); |
|
1836 | + $result = Database::query($sql); |
|
1838 | 1837 | |
1839 | - $options = array(); |
|
1840 | - while ($user = Database::fetch_array($result)) { |
|
1841 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1842 | - } |
|
1838 | + $options = array(); |
|
1839 | + while ($user = Database::fetch_array($result)) { |
|
1840 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1841 | + } |
|
1843 | 1842 | |
1844 | - // Get tasks in this blog / make select list of it |
|
1845 | - $sql = " |
|
1843 | + // Get tasks in this blog / make select list of it |
|
1844 | + $sql = " |
|
1846 | 1845 | SELECT |
1847 | 1846 | blog_id, |
1848 | 1847 | task_id, |
@@ -1854,96 +1853,96 @@ discard block |
||
1854 | 1853 | FROM $tbl_blogs_tasks |
1855 | 1854 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1856 | 1855 | ORDER BY system_task, title"; |
1857 | - $result = Database::query($sql); |
|
1858 | - |
|
1859 | - $taskOptions = array(); |
|
1860 | - while ($task = Database::fetch_array($result)) { |
|
1861 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1862 | - } |
|
1863 | - |
|
1864 | - $form = new FormValidator( |
|
1865 | - 'assign_task', |
|
1866 | - 'post', |
|
1867 | - api_get_path(WEB_CODE_PATH). |
|
1868 | - 'blog/blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq() |
|
1869 | - ); |
|
1870 | - |
|
1871 | - $form->addHeader(get_lang('AssignTask')); |
|
1872 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1873 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1874 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1875 | - |
|
1876 | - $form->addHidden('action', ''); |
|
1877 | - $form->addButtonSave(get_lang('Ok')); |
|
1878 | - |
|
1879 | - return $form; |
|
1880 | - } |
|
1881 | - |
|
1882 | - /** |
|
1883 | - * Displays assign task form |
|
1884 | - * @author Toon Keppens |
|
1885 | - * |
|
1886 | - */ |
|
1887 | - public static function display_assign_task_form($blog_id) |
|
1888 | - { |
|
1889 | - $form = self::getTaskForm($blog_id); |
|
1890 | - $form->addHidden('assign_task_submit', 'true'); |
|
1891 | - $form->display(); |
|
1892 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1893 | - } |
|
1894 | - |
|
1895 | - /** |
|
1896 | - * Displays assign task form |
|
1897 | - * @author Toon Keppens |
|
1898 | - * |
|
1899 | - */ |
|
1900 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1901 | - { |
|
1902 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1903 | - |
|
1904 | - $course_id = api_get_course_int_id(); |
|
1905 | - |
|
1906 | - // Get assignd date; |
|
1907 | - $sql = " |
|
1856 | + $result = Database::query($sql); |
|
1857 | + |
|
1858 | + $taskOptions = array(); |
|
1859 | + while ($task = Database::fetch_array($result)) { |
|
1860 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1861 | + } |
|
1862 | + |
|
1863 | + $form = new FormValidator( |
|
1864 | + 'assign_task', |
|
1865 | + 'post', |
|
1866 | + api_get_path(WEB_CODE_PATH). |
|
1867 | + 'blog/blog.php?action=manage_tasks&blog_id='.$blog_id.'&'.api_get_cidreq() |
|
1868 | + ); |
|
1869 | + |
|
1870 | + $form->addHeader(get_lang('AssignTask')); |
|
1871 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1872 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1873 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1874 | + |
|
1875 | + $form->addHidden('action', ''); |
|
1876 | + $form->addButtonSave(get_lang('Ok')); |
|
1877 | + |
|
1878 | + return $form; |
|
1879 | + } |
|
1880 | + |
|
1881 | + /** |
|
1882 | + * Displays assign task form |
|
1883 | + * @author Toon Keppens |
|
1884 | + * |
|
1885 | + */ |
|
1886 | + public static function display_assign_task_form($blog_id) |
|
1887 | + { |
|
1888 | + $form = self::getTaskForm($blog_id); |
|
1889 | + $form->addHidden('assign_task_submit', 'true'); |
|
1890 | + $form->display(); |
|
1891 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1892 | + } |
|
1893 | + |
|
1894 | + /** |
|
1895 | + * Displays assign task form |
|
1896 | + * @author Toon Keppens |
|
1897 | + * |
|
1898 | + */ |
|
1899 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1900 | + { |
|
1901 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1902 | + |
|
1903 | + $course_id = api_get_course_int_id(); |
|
1904 | + |
|
1905 | + // Get assignd date; |
|
1906 | + $sql = " |
|
1908 | 1907 | SELECT target_date |
1909 | 1908 | FROM $tbl_blogs_tasks_rel_user |
1910 | 1909 | WHERE c_id = $course_id AND |
1911 | 1910 | blog_id = '".(int)$blog_id."' AND |
1912 | 1911 | user_id = '".(int)$user_id."' AND |
1913 | 1912 | task_id = '".(int)$task_id."'"; |
1914 | - $result = Database::query($sql); |
|
1915 | - $row = Database::fetch_assoc($result); |
|
1916 | - |
|
1917 | - $date = $row['target_date']; |
|
1918 | - |
|
1919 | - $defaults = [ |
|
1920 | - 'task_user_id' => $user_id, |
|
1921 | - 'task_task_id' => $task_id, |
|
1922 | - 'task_day' => $date |
|
1923 | - ]; |
|
1924 | - $form = self::getTaskForm($blog_id); |
|
1925 | - $form->addHidden('old_task_id', $task_id); |
|
1926 | - $form->addHidden('old_user_id', $user_id); |
|
1927 | - $form->addHidden('old_target_date', $date); |
|
1928 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
1929 | - $form->setDefaults($defaults); |
|
1930 | - $form->display(); |
|
1931 | - } |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * Assigns a task to a user in a blog |
|
1935 | - * |
|
1936 | - * @param Integer $blog_id |
|
1937 | - * @param Integer $user_id |
|
1938 | - * @param Integer $task_id |
|
1939 | - * @param Date $target_date |
|
1940 | - */ |
|
1941 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1942 | - { |
|
1943 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1944 | - $course_id = api_get_course_int_id(); |
|
1945 | - |
|
1946 | - $sql = " |
|
1913 | + $result = Database::query($sql); |
|
1914 | + $row = Database::fetch_assoc($result); |
|
1915 | + |
|
1916 | + $date = $row['target_date']; |
|
1917 | + |
|
1918 | + $defaults = [ |
|
1919 | + 'task_user_id' => $user_id, |
|
1920 | + 'task_task_id' => $task_id, |
|
1921 | + 'task_day' => $date |
|
1922 | + ]; |
|
1923 | + $form = self::getTaskForm($blog_id); |
|
1924 | + $form->addHidden('old_task_id', $task_id); |
|
1925 | + $form->addHidden('old_user_id', $user_id); |
|
1926 | + $form->addHidden('old_target_date', $date); |
|
1927 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
1928 | + $form->setDefaults($defaults); |
|
1929 | + $form->display(); |
|
1930 | + } |
|
1931 | + |
|
1932 | + /** |
|
1933 | + * Assigns a task to a user in a blog |
|
1934 | + * |
|
1935 | + * @param Integer $blog_id |
|
1936 | + * @param Integer $user_id |
|
1937 | + * @param Integer $task_id |
|
1938 | + * @param Date $target_date |
|
1939 | + */ |
|
1940 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1941 | + { |
|
1942 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1943 | + $course_id = api_get_course_int_id(); |
|
1944 | + |
|
1945 | + $sql = " |
|
1947 | 1946 | SELECT COUNT(*) as 'number' |
1948 | 1947 | FROM " . $tbl_blogs_tasks_rel_user . " |
1949 | 1948 | WHERE c_id = $course_id AND |
@@ -1952,11 +1951,11 @@ discard block |
||
1952 | 1951 | AND task_id = " . (int)$task_id . " |
1953 | 1952 | "; |
1954 | 1953 | |
1955 | - $result = Database::query($sql); |
|
1956 | - $row = Database::fetch_assoc($result); |
|
1954 | + $result = Database::query($sql); |
|
1955 | + $row = Database::fetch_assoc($result); |
|
1957 | 1956 | |
1958 | - if ($row['number'] == 0) { |
|
1959 | - $sql = " |
|
1957 | + if ($row['number'] == 0) { |
|
1958 | + $sql = " |
|
1960 | 1959 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
1961 | 1960 | c_id, |
1962 | 1961 | blog_id, |
@@ -1971,9 +1970,9 @@ discard block |
||
1971 | 1970 | '" . Database::escape_string($target_date) . "' |
1972 | 1971 | )"; |
1973 | 1972 | |
1974 | - Database::query($sql); |
|
1975 | - } |
|
1976 | - } |
|
1973 | + Database::query($sql); |
|
1974 | + } |
|
1975 | + } |
|
1977 | 1976 | |
1978 | 1977 | /** |
1979 | 1978 | * @param $blog_id |
@@ -1993,11 +1992,11 @@ discard block |
||
1993 | 1992 | $old_task_id, |
1994 | 1993 | $old_target_date |
1995 | 1994 | ) { |
1996 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1995 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1997 | 1996 | |
1998 | - $course_id = api_get_course_int_id(); |
|
1997 | + $course_id = api_get_course_int_id(); |
|
1999 | 1998 | |
2000 | - $sql = "SELECT COUNT(*) as 'number' |
|
1999 | + $sql = "SELECT COUNT(*) as 'number' |
|
2001 | 2000 | FROM " . $tbl_blogs_tasks_rel_user . " |
2002 | 2001 | WHERE |
2003 | 2002 | c_id = $course_id AND |
@@ -2006,11 +2005,11 @@ discard block |
||
2006 | 2005 | task_id = " . (int)$task_id . " |
2007 | 2006 | "; |
2008 | 2007 | |
2009 | - $result = Database::query($sql); |
|
2010 | - $row = Database::fetch_assoc($result); |
|
2008 | + $result = Database::query($sql); |
|
2009 | + $row = Database::fetch_assoc($result); |
|
2011 | 2010 | |
2012 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
2013 | - $sql = " |
|
2011 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
2012 | + $sql = " |
|
2014 | 2013 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
2015 | 2014 | SET |
2016 | 2015 | user_id = " . (int)$user_id . ", |
@@ -2023,90 +2022,90 @@ discard block |
||
2023 | 2022 | task_id = " . (int)$old_task_id . " AND |
2024 | 2023 | target_date = '" . Database::escape_string($old_target_date) . "' |
2025 | 2024 | "; |
2026 | - Database::query($sql); |
|
2027 | - } |
|
2028 | - } |
|
2029 | - |
|
2030 | - /** |
|
2031 | - * Displays a list with posts a user can select to execute his task. |
|
2032 | - * |
|
2033 | - * @param Integer $blog_id |
|
2034 | - * @param unknown_type $task_id |
|
2035 | - */ |
|
2036 | - public static function display_select_task_post($blog_id, $task_id) |
|
2025 | + Database::query($sql); |
|
2026 | + } |
|
2027 | + } |
|
2028 | + |
|
2029 | + /** |
|
2030 | + * Displays a list with posts a user can select to execute his task. |
|
2031 | + * |
|
2032 | + * @param Integer $blog_id |
|
2033 | + * @param unknown_type $task_id |
|
2034 | + */ |
|
2035 | + public static function display_select_task_post($blog_id, $task_id) |
|
2037 | 2036 | { |
2038 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2039 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2040 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2041 | - $course_id = api_get_course_int_id(); |
|
2037 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2038 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2039 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2040 | + $course_id = api_get_course_int_id(); |
|
2042 | 2041 | |
2043 | 2042 | |
2044 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
2043 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
2045 | 2044 | WHERE task_id = '".(int)$task_id."' |
2046 | 2045 | AND c_id = $course_id"; |
2047 | - $result = Database::query($sql); |
|
2048 | - $row = Database::fetch_assoc($result); |
|
2049 | - // Get posts and authors |
|
2050 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
2046 | + $result = Database::query($sql); |
|
2047 | + $row = Database::fetch_assoc($result); |
|
2048 | + // Get posts and authors |
|
2049 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
2051 | 2050 | FROM $tbl_blogs_posts post |
2052 | 2051 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
2053 | 2052 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
2054 | 2053 | ORDER BY post_id DESC |
2055 | 2054 | LIMIT 0, 100"; |
2056 | - $result = Database::query($sql); |
|
2057 | - |
|
2058 | - // Display |
|
2059 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
2060 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
2061 | - |
|
2062 | - if (Database::num_rows($result) > 0) { |
|
2063 | - while($blog_post = Database::fetch_array($result)) { |
|
2064 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
2065 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2066 | - ).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'. |
|
2067 | - stripslashes($blog_post['title']).'</a>, '.get_lang( |
|
2068 | - 'WrittenBy' |
|
2069 | - ).' '. |
|
2070 | - stripslashes( |
|
2071 | - Display::tag( |
|
2072 | - 'span', |
|
2073 | - api_get_person_name( |
|
2074 | - $blog_post['firstname'], |
|
2075 | - $blog_post['lastname'] |
|
2076 | - ), |
|
2077 | - array('title' => $username) |
|
2078 | - ) |
|
2079 | - ).'<br />'; |
|
2080 | - } |
|
2055 | + $result = Database::query($sql); |
|
2056 | + |
|
2057 | + // Display |
|
2058 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
2059 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
2060 | + |
|
2061 | + if (Database::num_rows($result) > 0) { |
|
2062 | + while($blog_post = Database::fetch_array($result)) { |
|
2063 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
2064 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2065 | + ).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'. |
|
2066 | + stripslashes($blog_post['title']).'</a>, '.get_lang( |
|
2067 | + 'WrittenBy' |
|
2068 | + ).' '. |
|
2069 | + stripslashes( |
|
2070 | + Display::tag( |
|
2071 | + 'span', |
|
2072 | + api_get_person_name( |
|
2073 | + $blog_post['firstname'], |
|
2074 | + $blog_post['lastname'] |
|
2075 | + ), |
|
2076 | + array('title' => $username) |
|
2077 | + ) |
|
2078 | + ).'<br />'; |
|
2079 | + } |
|
2081 | 2080 | } else { |
2082 | 2081 | echo get_lang('NoArticles'); |
2083 | 2082 | } |
2084 | - } |
|
2085 | - |
|
2086 | - /** |
|
2087 | - * Subscribes a user to a given blog |
|
2088 | - * @author Toon Keppens |
|
2089 | - * |
|
2090 | - * @param Integer $blog_id |
|
2091 | - * @param Integer $user_id |
|
2092 | - */ |
|
2093 | - public static function set_user_subscribed($blog_id, $user_id) |
|
2083 | + } |
|
2084 | + |
|
2085 | + /** |
|
2086 | + * Subscribes a user to a given blog |
|
2087 | + * @author Toon Keppens |
|
2088 | + * |
|
2089 | + * @param Integer $blog_id |
|
2090 | + * @param Integer $user_id |
|
2091 | + */ |
|
2092 | + public static function set_user_subscribed($blog_id, $user_id) |
|
2094 | 2093 | { |
2095 | - // Init |
|
2096 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2097 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
2094 | + // Init |
|
2095 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2096 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
2098 | 2097 | |
2099 | - $course_id = api_get_course_int_id(); |
|
2098 | + $course_id = api_get_course_int_id(); |
|
2100 | 2099 | |
2101 | - // Subscribe the user |
|
2102 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
2100 | + // Subscribe the user |
|
2101 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
2103 | 2102 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
2104 | - Database::query($sql); |
|
2103 | + Database::query($sql); |
|
2105 | 2104 | |
2106 | - // Give this user basic rights |
|
2107 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
2105 | + // Give this user basic rights |
|
2106 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
2108 | 2107 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
2109 | - Database::query($sql); |
|
2108 | + Database::query($sql); |
|
2110 | 2109 | |
2111 | 2110 | $id = Database::insert_id(); |
2112 | 2111 | if ($id) { |
@@ -2114,9 +2113,9 @@ discard block |
||
2114 | 2113 | Database::query($sql); |
2115 | 2114 | } |
2116 | 2115 | |
2117 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
2116 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
2118 | 2117 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
2119 | - Database::query($sql); |
|
2118 | + Database::query($sql); |
|
2120 | 2119 | |
2121 | 2120 | $id = Database::insert_id(); |
2122 | 2121 | if ($id) { |
@@ -2124,202 +2123,202 @@ discard block |
||
2124 | 2123 | Database::query($sql); |
2125 | 2124 | } |
2126 | 2125 | |
2127 | - } |
|
2126 | + } |
|
2128 | 2127 | |
2129 | - /** |
|
2130 | - * Unsubscribe a user from a given blog |
|
2131 | - * @author Toon Keppens |
|
2132 | - * |
|
2133 | - * @param Integer $blog_id |
|
2134 | - * @param Integer $user_id |
|
2135 | - */ |
|
2136 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
2128 | + /** |
|
2129 | + * Unsubscribe a user from a given blog |
|
2130 | + * @author Toon Keppens |
|
2131 | + * |
|
2132 | + * @param Integer $blog_id |
|
2133 | + * @param Integer $user_id |
|
2134 | + */ |
|
2135 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
2137 | 2136 | { |
2138 | - // Init |
|
2137 | + // Init |
|
2139 | 2138 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
2140 | 2139 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
2141 | 2140 | |
2142 | - // Unsubscribe the user |
|
2143 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2141 | + // Unsubscribe the user |
|
2142 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2144 | 2143 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
2145 | - Database::query($sql); |
|
2144 | + Database::query($sql); |
|
2146 | 2145 | |
2147 | - // Remove this user's permissions. |
|
2148 | - $sql = "DELETE FROM $tbl_user_permissions |
|
2146 | + // Remove this user's permissions. |
|
2147 | + $sql = "DELETE FROM $tbl_user_permissions |
|
2149 | 2148 | WHERE user_id = '".(int)$user_id."'"; |
2150 | - Database::query($sql); |
|
2151 | - } |
|
2152 | - |
|
2153 | - /** |
|
2154 | - * Displays the form to register users in a blog (in a course) |
|
2155 | - * The listed users are users subcribed in the course. |
|
2156 | - * @author Toon Keppens |
|
2157 | - * |
|
2158 | - * @param Integer $blog_id |
|
2159 | - * |
|
2160 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2161 | - */ |
|
2162 | - public static function display_form_user_subscribe($blog_id) |
|
2163 | - { |
|
2164 | - $_course = api_get_course_info(); |
|
2165 | - $is_western_name_order = api_is_western_name_order(); |
|
2166 | - $session_id = api_get_session_id(); |
|
2167 | - $course_id = $_course['real_id']; |
|
2168 | - |
|
2169 | - $currentCourse = $_course['code']; |
|
2170 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2171 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2172 | - |
|
2173 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2174 | - |
|
2175 | - $properties["width"] = "100%"; |
|
2176 | - |
|
2177 | - // Get blog members' id. |
|
2178 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
2149 | + Database::query($sql); |
|
2150 | + } |
|
2151 | + |
|
2152 | + /** |
|
2153 | + * Displays the form to register users in a blog (in a course) |
|
2154 | + * The listed users are users subcribed in the course. |
|
2155 | + * @author Toon Keppens |
|
2156 | + * |
|
2157 | + * @param Integer $blog_id |
|
2158 | + * |
|
2159 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2160 | + */ |
|
2161 | + public static function display_form_user_subscribe($blog_id) |
|
2162 | + { |
|
2163 | + $_course = api_get_course_info(); |
|
2164 | + $is_western_name_order = api_is_western_name_order(); |
|
2165 | + $session_id = api_get_session_id(); |
|
2166 | + $course_id = $_course['real_id']; |
|
2167 | + |
|
2168 | + $currentCourse = $_course['code']; |
|
2169 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2170 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2171 | + |
|
2172 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2173 | + |
|
2174 | + $properties["width"] = "100%"; |
|
2175 | + |
|
2176 | + // Get blog members' id. |
|
2177 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
2179 | 2178 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2180 | 2179 | ON user.user_id = blogs_rel_user.user_id |
2181 | 2180 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
2182 | - $result = Database::query($sql); |
|
2183 | - |
|
2184 | - $blog_member_ids = array(); |
|
2185 | - while($user = Database::fetch_array($result)) { |
|
2186 | - $blog_member_ids[] = $user['user_id']; |
|
2187 | - } |
|
2188 | - |
|
2189 | - // Set table headers |
|
2190 | - $column_header[] = array ('', false, ''); |
|
2191 | - if ($is_western_name_order) { |
|
2192 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2193 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2194 | - } else { |
|
2195 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2196 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2197 | - } |
|
2198 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
2199 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
2181 | + $result = Database::query($sql); |
|
2182 | + |
|
2183 | + $blog_member_ids = array(); |
|
2184 | + while($user = Database::fetch_array($result)) { |
|
2185 | + $blog_member_ids[] = $user['user_id']; |
|
2186 | + } |
|
2187 | + |
|
2188 | + // Set table headers |
|
2189 | + $column_header[] = array ('', false, ''); |
|
2190 | + if ($is_western_name_order) { |
|
2191 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2192 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2193 | + } else { |
|
2194 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2195 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2196 | + } |
|
2197 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
2198 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
2200 | 2199 | |
2201 | 2200 | $student_list = CourseManager:: get_student_list_from_course_code( |
2202 | 2201 | $currentCourse, |
2203 | 2202 | false, |
2204 | 2203 | $session_id |
2205 | 2204 | ); |
2206 | - $user_data = array(); |
|
2207 | - |
|
2208 | - // Add users that are not in this blog to the list. |
|
2209 | - foreach ($student_list as $key=>$user) { |
|
2210 | - if(isset($user['id_user'])) { |
|
2211 | - $user['user_id'] = $user['id_user']; |
|
2212 | - } |
|
2213 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2214 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
2215 | - $row = array (); |
|
2216 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2217 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2218 | - if ($is_western_name_order) { |
|
2219 | - $row[] = $a_infosUser["firstname"]; |
|
2220 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2221 | - } else { |
|
2222 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2223 | - $row[] = $a_infosUser["firstname"]; |
|
2224 | - } |
|
2225 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2226 | - |
|
2227 | - //Link to register users |
|
2228 | - $currentUserId = api_get_user_id(); |
|
2229 | - if ($a_infosUser["user_id"] != $currentUserId) { |
|
2230 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2231 | - } else { |
|
2232 | - $row[] = ''; |
|
2233 | - } |
|
2234 | - $user_data[] = $row; |
|
2235 | - } |
|
2236 | - } |
|
2237 | - |
|
2238 | - // Display |
|
2239 | - $query_vars['action'] = 'manage_members'; |
|
2240 | - $query_vars['blog_id'] = $blog_id; |
|
2241 | - echo '<form method="post" action="blog.php?'.api_get_cidreq( |
|
2242 | - ).'&action=manage_members&blog_id='.$blog_id.'">'; |
|
2243 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2244 | - $link = ''; |
|
2245 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2246 | - $link .= "blog_id=$blog_id&"; |
|
2247 | - |
|
2248 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2249 | - ).'&'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - '; |
|
2250 | - echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
|
2251 | - 'UnSelectAll' |
|
2252 | - ).'</a> '; |
|
2253 | - echo get_lang('WithSelected') . ' : '; |
|
2254 | - echo '<select name="action">'; |
|
2255 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2256 | - echo '</select>'; |
|
2257 | - echo '<input type="hidden" name="register" value="true" />'; |
|
2258 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2259 | - echo '</form>'; |
|
2260 | - } |
|
2261 | - |
|
2262 | - /** |
|
2263 | - * Displays the form to register users in a blog (in a course) |
|
2264 | - * The listed users are users subcribed in the course. |
|
2265 | - * @author Toon Keppens |
|
2266 | - * |
|
2267 | - * @param Integer $blog_id |
|
2268 | - * |
|
2269 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
2270 | - */ |
|
2271 | - public static function display_form_user_unsubscribe ($blog_id) |
|
2272 | - { |
|
2273 | - $_user = api_get_user_info(); |
|
2274 | - $is_western_name_order = api_is_western_name_order(); |
|
2275 | - |
|
2276 | - // Init |
|
2277 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2278 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2279 | - |
|
2280 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2281 | - |
|
2282 | - $properties["width"] = "100%"; |
|
2283 | - //table column titles |
|
2284 | - $column_header[] = array ('', false, ''); |
|
2285 | - if ($is_western_name_order) { |
|
2286 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2287 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2288 | - } else { |
|
2289 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2290 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2291 | - } |
|
2292 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
2293 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2294 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2295 | - |
|
2296 | - $course_id = api_get_course_int_id(); |
|
2297 | - |
|
2298 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2205 | + $user_data = array(); |
|
2206 | + |
|
2207 | + // Add users that are not in this blog to the list. |
|
2208 | + foreach ($student_list as $key=>$user) { |
|
2209 | + if(isset($user['id_user'])) { |
|
2210 | + $user['user_id'] = $user['id_user']; |
|
2211 | + } |
|
2212 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2213 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
2214 | + $row = array (); |
|
2215 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2216 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2217 | + if ($is_western_name_order) { |
|
2218 | + $row[] = $a_infosUser["firstname"]; |
|
2219 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2220 | + } else { |
|
2221 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2222 | + $row[] = $a_infosUser["firstname"]; |
|
2223 | + } |
|
2224 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2225 | + |
|
2226 | + //Link to register users |
|
2227 | + $currentUserId = api_get_user_id(); |
|
2228 | + if ($a_infosUser["user_id"] != $currentUserId) { |
|
2229 | + $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2230 | + } else { |
|
2231 | + $row[] = ''; |
|
2232 | + } |
|
2233 | + $user_data[] = $row; |
|
2234 | + } |
|
2235 | + } |
|
2236 | + |
|
2237 | + // Display |
|
2238 | + $query_vars['action'] = 'manage_members'; |
|
2239 | + $query_vars['blog_id'] = $blog_id; |
|
2240 | + echo '<form method="post" action="blog.php?'.api_get_cidreq( |
|
2241 | + ).'&action=manage_members&blog_id='.$blog_id.'">'; |
|
2242 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2243 | + $link = ''; |
|
2244 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2245 | + $link .= "blog_id=$blog_id&"; |
|
2246 | + |
|
2247 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2248 | + ).'&'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - '; |
|
2249 | + echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
|
2250 | + 'UnSelectAll' |
|
2251 | + ).'</a> '; |
|
2252 | + echo get_lang('WithSelected') . ' : '; |
|
2253 | + echo '<select name="action">'; |
|
2254 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2255 | + echo '</select>'; |
|
2256 | + echo '<input type="hidden" name="register" value="true" />'; |
|
2257 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2258 | + echo '</form>'; |
|
2259 | + } |
|
2260 | + |
|
2261 | + /** |
|
2262 | + * Displays the form to register users in a blog (in a course) |
|
2263 | + * The listed users are users subcribed in the course. |
|
2264 | + * @author Toon Keppens |
|
2265 | + * |
|
2266 | + * @param Integer $blog_id |
|
2267 | + * |
|
2268 | + * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
2269 | + */ |
|
2270 | + public static function display_form_user_unsubscribe ($blog_id) |
|
2271 | + { |
|
2272 | + $_user = api_get_user_info(); |
|
2273 | + $is_western_name_order = api_is_western_name_order(); |
|
2274 | + |
|
2275 | + // Init |
|
2276 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2277 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2278 | + |
|
2279 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2280 | + |
|
2281 | + $properties["width"] = "100%"; |
|
2282 | + //table column titles |
|
2283 | + $column_header[] = array ('', false, ''); |
|
2284 | + if ($is_western_name_order) { |
|
2285 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2286 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2287 | + } else { |
|
2288 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2289 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2290 | + } |
|
2291 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
2292 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2293 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2294 | + |
|
2295 | + $course_id = api_get_course_int_id(); |
|
2296 | + |
|
2297 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2299 | 2298 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2300 | 2299 | ON user.user_id = blogs_rel_user.user_id |
2301 | 2300 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
2302 | 2301 | |
2303 | - if (!($sql_result = Database::query($sql))) { |
|
2304 | - return false; |
|
2305 | - } |
|
2306 | - |
|
2307 | - $user_data = array (); |
|
2308 | - |
|
2309 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
2310 | - $row = array (); |
|
2311 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2312 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2313 | - if ($is_western_name_order) { |
|
2314 | - $row[] = $myrow["firstname"]; |
|
2315 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2316 | - } else { |
|
2317 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2318 | - $row[] = $myrow["firstname"]; |
|
2319 | - } |
|
2320 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2321 | - |
|
2322 | - $sql = "SELECT bt.title task |
|
2302 | + if (!($sql_result = Database::query($sql))) { |
|
2303 | + return false; |
|
2304 | + } |
|
2305 | + |
|
2306 | + $user_data = array (); |
|
2307 | + |
|
2308 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
2309 | + $row = array (); |
|
2310 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2311 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2312 | + if ($is_western_name_order) { |
|
2313 | + $row[] = $myrow["firstname"]; |
|
2314 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2315 | + } else { |
|
2316 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2317 | + $row[] = $myrow["firstname"]; |
|
2318 | + } |
|
2319 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2320 | + |
|
2321 | + $sql = "SELECT bt.title task |
|
2323 | 2322 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
2324 | 2323 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
2325 | 2324 | ON btu.task_id = bt.task_id |
@@ -2327,166 +2326,166 @@ discard block |
||
2327 | 2326 | bt.c_id = $course_id AND |
2328 | 2327 | btu.blog_id = $blog_id AND |
2329 | 2328 | btu.user_id = " . $myrow['user_id']; |
2330 | - $sql_res = Database::query($sql); |
|
2331 | - |
|
2332 | - $task = ''; |
|
2333 | - |
|
2334 | - while($r = Database::fetch_array($sql_res)) { |
|
2335 | - $task .= stripslashes($r['task']) . ', '; |
|
2336 | - } |
|
2337 | - //echo $task; |
|
2338 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2339 | - $row[] = $task; |
|
2340 | - //Link to register users |
|
2341 | - |
|
2342 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
2343 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2344 | - } else { |
|
2345 | - $row[] = ''; |
|
2346 | - } |
|
2347 | - |
|
2348 | - $user_data[] = $row; |
|
2349 | - } |
|
2350 | - |
|
2351 | - $query_vars['action'] = 'manage_members'; |
|
2352 | - $query_vars['blog_id'] = $blog_id; |
|
2353 | - echo '<form method="post" action="blog.php?'.api_get_cidreq( |
|
2354 | - ).'&action=manage_members&blog_id='.$blog_id.'">'; |
|
2355 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2356 | - $link = ''; |
|
2357 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2358 | - $link .= "blog_id=$blog_id&"; |
|
2359 | - |
|
2360 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2361 | - ).'&'.$link.'selectall=unsubscribe">'.get_lang( |
|
2362 | - 'SelectAll' |
|
2363 | - ).'</a> - '; |
|
2364 | - echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
|
2365 | - 'UnSelectAll' |
|
2366 | - ).'</a> '; |
|
2367 | - echo get_lang('WithSelected') . ' : '; |
|
2368 | - echo '<select name="action">'; |
|
2369 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2370 | - echo '</select>'; |
|
2371 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
2372 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2373 | - echo '</form>'; |
|
2374 | - } |
|
2375 | - |
|
2376 | - /** |
|
2377 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2378 | - * The blog admin can thus select what a certain user can do in the current blog |
|
2379 | - * |
|
2380 | - * @param Integer $blog_id |
|
2381 | - */ |
|
2382 | - public static function display_form_user_rights ($blog_id) |
|
2329 | + $sql_res = Database::query($sql); |
|
2330 | + |
|
2331 | + $task = ''; |
|
2332 | + |
|
2333 | + while($r = Database::fetch_array($sql_res)) { |
|
2334 | + $task .= stripslashes($r['task']) . ', '; |
|
2335 | + } |
|
2336 | + //echo $task; |
|
2337 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2338 | + $row[] = $task; |
|
2339 | + //Link to register users |
|
2340 | + |
|
2341 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
2342 | + $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2343 | + } else { |
|
2344 | + $row[] = ''; |
|
2345 | + } |
|
2346 | + |
|
2347 | + $user_data[] = $row; |
|
2348 | + } |
|
2349 | + |
|
2350 | + $query_vars['action'] = 'manage_members'; |
|
2351 | + $query_vars['blog_id'] = $blog_id; |
|
2352 | + echo '<form method="post" action="blog.php?'.api_get_cidreq( |
|
2353 | + ).'&action=manage_members&blog_id='.$blog_id.'">'; |
|
2354 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2355 | + $link = ''; |
|
2356 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2357 | + $link .= "blog_id=$blog_id&"; |
|
2358 | + |
|
2359 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2360 | + ).'&'.$link.'selectall=unsubscribe">'.get_lang( |
|
2361 | + 'SelectAll' |
|
2362 | + ).'</a> - '; |
|
2363 | + echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
|
2364 | + 'UnSelectAll' |
|
2365 | + ).'</a> '; |
|
2366 | + echo get_lang('WithSelected') . ' : '; |
|
2367 | + echo '<select name="action">'; |
|
2368 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2369 | + echo '</select>'; |
|
2370 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
2371 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2372 | + echo '</form>'; |
|
2373 | + } |
|
2374 | + |
|
2375 | + /** |
|
2376 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2377 | + * The blog admin can thus select what a certain user can do in the current blog |
|
2378 | + * |
|
2379 | + * @param Integer $blog_id |
|
2380 | + */ |
|
2381 | + public static function display_form_user_rights ($blog_id) |
|
2383 | 2382 | { |
2384 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2385 | - echo '<br />'; |
|
2386 | - |
|
2387 | - // Integration of patricks permissions system. |
|
2388 | - require_once api_get_path(SYS_CODE_PATH).'blog/permissions/blog_permissions.inc.php'; |
|
2389 | - } |
|
2390 | - |
|
2391 | - /** |
|
2392 | - * Displays the form to create a new post |
|
2393 | - * @author Toon Keppens |
|
2394 | - * |
|
2395 | - * @param Integer $blog_id |
|
2396 | - */ |
|
2397 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2398 | - { |
|
2399 | - $form = new FormValidator( |
|
2400 | - 'add_post', |
|
2401 | - 'post', |
|
2402 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2403 | - null, |
|
2404 | - array('enctype' => 'multipart/form-data') |
|
2405 | - ); |
|
2406 | - |
|
2407 | - $header = get_lang('AddNewComment'); |
|
2408 | - if (isset($_GET['task_id'])) { |
|
2409 | - $header = get_lang('ExecuteThisTask'); |
|
2410 | - } |
|
2411 | - $form->addHeader($header); |
|
2412 | - $form->addText('title', get_lang('Title')); |
|
2413 | - |
|
2414 | - $config = array(); |
|
2415 | - if (!api_is_allowed_to_edit()) { |
|
2416 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
2417 | - } else { |
|
2418 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2419 | - } |
|
2420 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2421 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2422 | - |
|
2423 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2424 | - |
|
2425 | - $form->addHidden('action', null); |
|
2426 | - $form->addHidden('comment_parent_id', 0); |
|
2427 | - |
|
2428 | - if (isset($_GET['task_id'])) { |
|
2429 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
2430 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2431 | - } else { |
|
2432 | - $form->addHidden('new_comment_submit', 'true'); |
|
2433 | - } |
|
2434 | - $form->addButton('save', get_lang('Save')); |
|
2435 | - $form->display(); |
|
2436 | - } |
|
2437 | - |
|
2438 | - |
|
2439 | - /** |
|
2440 | - * show the calender of the given month |
|
2441 | - * @author Patrick Cool |
|
2442 | - * @author Toon Keppens |
|
2443 | - * |
|
2444 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
2445 | - * @param Integer $month: the integer value of the month we are viewing |
|
2446 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2447 | - * @param String $monthName: the language variable for the mont name |
|
2448 | - * |
|
2449 | - * @return html code |
|
2450 | - */ |
|
2451 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2452 | - { |
|
2453 | - // Init |
|
2454 | - $_user = api_get_user_info(); |
|
2455 | - global $DaysShort; |
|
2456 | - global $MonthsLong; |
|
2457 | - |
|
2458 | - $posts = array(); |
|
2459 | - $tasks = array(); |
|
2460 | - |
|
2461 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2462 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2463 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2464 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2465 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2466 | - |
|
2467 | - $course_id = api_get_course_int_id(); |
|
2468 | - |
|
2469 | - //Handle leap year |
|
2470 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2471 | - |
|
2472 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2473 | - $numberofdays[2] = 29; |
|
2474 | - |
|
2475 | - //Get the first day of the month |
|
2476 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2477 | - $monthName = $MonthsLong[$month-1]; |
|
2478 | - |
|
2479 | - //Start the week on monday |
|
2480 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2481 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2482 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2483 | - $backwardsURL = api_get_self()."?".api_get_cidreq( |
|
2484 | - )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year); |
|
2485 | - $forewardsURL = api_get_self()."?".api_get_cidreq( |
|
2486 | - )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year); |
|
2487 | - |
|
2488 | - // Get posts for this month |
|
2489 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2383 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2384 | + echo '<br />'; |
|
2385 | + |
|
2386 | + // Integration of patricks permissions system. |
|
2387 | + require_once api_get_path(SYS_CODE_PATH).'blog/permissions/blog_permissions.inc.php'; |
|
2388 | + } |
|
2389 | + |
|
2390 | + /** |
|
2391 | + * Displays the form to create a new post |
|
2392 | + * @author Toon Keppens |
|
2393 | + * |
|
2394 | + * @param Integer $blog_id |
|
2395 | + */ |
|
2396 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2397 | + { |
|
2398 | + $form = new FormValidator( |
|
2399 | + 'add_post', |
|
2400 | + 'post', |
|
2401 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2402 | + null, |
|
2403 | + array('enctype' => 'multipart/form-data') |
|
2404 | + ); |
|
2405 | + |
|
2406 | + $header = get_lang('AddNewComment'); |
|
2407 | + if (isset($_GET['task_id'])) { |
|
2408 | + $header = get_lang('ExecuteThisTask'); |
|
2409 | + } |
|
2410 | + $form->addHeader($header); |
|
2411 | + $form->addText('title', get_lang('Title')); |
|
2412 | + |
|
2413 | + $config = array(); |
|
2414 | + if (!api_is_allowed_to_edit()) { |
|
2415 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
2416 | + } else { |
|
2417 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2418 | + } |
|
2419 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2420 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2421 | + |
|
2422 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2423 | + |
|
2424 | + $form->addHidden('action', null); |
|
2425 | + $form->addHidden('comment_parent_id', 0); |
|
2426 | + |
|
2427 | + if (isset($_GET['task_id'])) { |
|
2428 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
2429 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2430 | + } else { |
|
2431 | + $form->addHidden('new_comment_submit', 'true'); |
|
2432 | + } |
|
2433 | + $form->addButton('save', get_lang('Save')); |
|
2434 | + $form->display(); |
|
2435 | + } |
|
2436 | + |
|
2437 | + |
|
2438 | + /** |
|
2439 | + * show the calender of the given month |
|
2440 | + * @author Patrick Cool |
|
2441 | + * @author Toon Keppens |
|
2442 | + * |
|
2443 | + * @param Array $blogitems an array containing all the blog items for the given month |
|
2444 | + * @param Integer $month: the integer value of the month we are viewing |
|
2445 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2446 | + * @param String $monthName: the language variable for the mont name |
|
2447 | + * |
|
2448 | + * @return html code |
|
2449 | + */ |
|
2450 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2451 | + { |
|
2452 | + // Init |
|
2453 | + $_user = api_get_user_info(); |
|
2454 | + global $DaysShort; |
|
2455 | + global $MonthsLong; |
|
2456 | + |
|
2457 | + $posts = array(); |
|
2458 | + $tasks = array(); |
|
2459 | + |
|
2460 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2461 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2462 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2463 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2464 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2465 | + |
|
2466 | + $course_id = api_get_course_int_id(); |
|
2467 | + |
|
2468 | + //Handle leap year |
|
2469 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2470 | + |
|
2471 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2472 | + $numberofdays[2] = 29; |
|
2473 | + |
|
2474 | + //Get the first day of the month |
|
2475 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2476 | + $monthName = $MonthsLong[$month-1]; |
|
2477 | + |
|
2478 | + //Start the week on monday |
|
2479 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2480 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2481 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2482 | + $backwardsURL = api_get_self()."?".api_get_cidreq( |
|
2483 | + )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year); |
|
2484 | + $forewardsURL = api_get_self()."?".api_get_cidreq( |
|
2485 | + )."&blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year); |
|
2486 | + |
|
2487 | + // Get posts for this month |
|
2488 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2490 | 2489 | FROM $tbl_blogs_posts post |
2491 | 2490 | INNER JOIN $tbl_users user |
2492 | 2491 | ON post.author_id = user.user_id |
@@ -2496,20 +2495,20 @@ discard block |
||
2496 | 2495 | MONTH(date_creation) = '".(int)$month."' AND |
2497 | 2496 | YEAR(date_creation) = '".(int)$year."' |
2498 | 2497 | ORDER BY date_creation"; |
2499 | - $result = Database::query($sql); |
|
2500 | - |
|
2501 | - // We will create an array of days on which there are posts. |
|
2502 | - if( Database::num_rows($result) > 0) { |
|
2503 | - while($blog_post = Database::fetch_array($result)) { |
|
2504 | - // If the day of this post is not yet in the array, add it. |
|
2505 | - if (!in_array($blog_post['post_day'], $posts)) |
|
2506 | - $posts[] = $blog_post['post_day']; |
|
2507 | - } |
|
2508 | - } |
|
2509 | - |
|
2510 | - // Get tasks for this month |
|
2511 | - if ($_user['user_id']) { |
|
2512 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2498 | + $result = Database::query($sql); |
|
2499 | + |
|
2500 | + // We will create an array of days on which there are posts. |
|
2501 | + if( Database::num_rows($result) > 0) { |
|
2502 | + while($blog_post = Database::fetch_array($result)) { |
|
2503 | + // If the day of this post is not yet in the array, add it. |
|
2504 | + if (!in_array($blog_post['post_day'], $posts)) |
|
2505 | + $posts[] = $blog_post['post_day']; |
|
2506 | + } |
|
2507 | + } |
|
2508 | + |
|
2509 | + // Get tasks for this month |
|
2510 | + if ($_user['user_id']) { |
|
2511 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2513 | 2512 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
2514 | 2513 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
2515 | 2514 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2521,99 +2520,99 @@ discard block |
||
2521 | 2520 | MONTH(target_date) = '".(int)$month."' AND |
2522 | 2521 | YEAR(target_date) = '".(int)$year."' |
2523 | 2522 | ORDER BY target_date ASC"; |
2524 | - $result = Database::query($sql); |
|
2525 | - |
|
2526 | - if (Database::num_rows($result) > 0) { |
|
2527 | - while ($mytask = Database::fetch_array($result)) { |
|
2528 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2529 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2530 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2531 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2532 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2533 | - } |
|
2534 | - } |
|
2535 | - } |
|
2536 | - |
|
2537 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
2538 | - "<tr id=\"title\">\n", |
|
2539 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
2540 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
2541 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
2542 | - |
|
2543 | - echo "<tr>\n"; |
|
2544 | - |
|
2545 | - for($ii = 1; $ii < 8; $ii ++) |
|
2546 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2547 | - |
|
2548 | - echo "</tr>"; |
|
2549 | - |
|
2550 | - $curday = -1; |
|
2551 | - $today = getdate(); |
|
2552 | - |
|
2553 | - while ($curday <= $numberofdays[$month]) { |
|
2554 | - echo "<tr>"; |
|
2555 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
2556 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
2557 | - $curday = 1; |
|
2558 | - |
|
2559 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2560 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2561 | - $dayheader = "$curday"; |
|
2562 | - |
|
2563 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2564 | - $dayheader = "$curday"; |
|
2565 | - $class = "class=\"days_today\""; |
|
2566 | - } |
|
2567 | - |
|
2568 | - echo "<td " . $class.">"; |
|
2569 | - |
|
2570 | - // If there are posts on this day, create a filter link. |
|
2571 | - if(in_array($curday, $posts)) |
|
2572 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2573 | - ).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang( |
|
2574 | - 'ViewPostsOfThisDay' |
|
2575 | - ).'">'. |
|
2576 | - $curday.'</a>'; |
|
2577 | - else |
|
2578 | - echo $dayheader; |
|
2579 | - |
|
2580 | - if (count($tasks) > 0) { |
|
2581 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2582 | - // Add tasks to calendar |
|
2583 | - foreach ($tasks[$curday] as $task) { |
|
2584 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2585 | - ).'&action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes( |
|
2586 | - $task['task_id'] |
|
2587 | - ).'" title="'.$task['title'].' : '.get_lang( |
|
2588 | - 'InBlog' |
|
2589 | - ).' : '.$task['blog_name'].' - '.get_lang( |
|
2590 | - 'ExecuteThisTask' |
|
2591 | - ).'"> |
|
2523 | + $result = Database::query($sql); |
|
2524 | + |
|
2525 | + if (Database::num_rows($result) > 0) { |
|
2526 | + while ($mytask = Database::fetch_array($result)) { |
|
2527 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2528 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2529 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2530 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2531 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2532 | + } |
|
2533 | + } |
|
2534 | + } |
|
2535 | + |
|
2536 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
2537 | + "<tr id=\"title\">\n", |
|
2538 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
2539 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
2540 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
2541 | + |
|
2542 | + echo "<tr>\n"; |
|
2543 | + |
|
2544 | + for($ii = 1; $ii < 8; $ii ++) |
|
2545 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2546 | + |
|
2547 | + echo "</tr>"; |
|
2548 | + |
|
2549 | + $curday = -1; |
|
2550 | + $today = getdate(); |
|
2551 | + |
|
2552 | + while ($curday <= $numberofdays[$month]) { |
|
2553 | + echo "<tr>"; |
|
2554 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
2555 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
2556 | + $curday = 1; |
|
2557 | + |
|
2558 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2559 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2560 | + $dayheader = "$curday"; |
|
2561 | + |
|
2562 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2563 | + $dayheader = "$curday"; |
|
2564 | + $class = "class=\"days_today\""; |
|
2565 | + } |
|
2566 | + |
|
2567 | + echo "<td " . $class.">"; |
|
2568 | + |
|
2569 | + // If there are posts on this day, create a filter link. |
|
2570 | + if(in_array($curday, $posts)) |
|
2571 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2572 | + ).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang( |
|
2573 | + 'ViewPostsOfThisDay' |
|
2574 | + ).'">'. |
|
2575 | + $curday.'</a>'; |
|
2576 | + else |
|
2577 | + echo $dayheader; |
|
2578 | + |
|
2579 | + if (count($tasks) > 0) { |
|
2580 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2581 | + // Add tasks to calendar |
|
2582 | + foreach ($tasks[$curday] as $task) { |
|
2583 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2584 | + ).'&action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes( |
|
2585 | + $task['task_id'] |
|
2586 | + ).'" title="'.$task['title'].' : '.get_lang( |
|
2587 | + 'InBlog' |
|
2588 | + ).' : '.$task['blog_name'].' - '.get_lang( |
|
2589 | + 'ExecuteThisTask' |
|
2590 | + ).'"> |
|
2592 | 2591 | <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; |
2593 | - } |
|
2594 | - } |
|
2595 | - } |
|
2596 | - |
|
2597 | - echo "</td>"; |
|
2598 | - $curday ++; |
|
2599 | - } else |
|
2600 | - echo "<td> </td>"; |
|
2601 | - } |
|
2602 | - echo "</tr>"; |
|
2603 | - } |
|
2604 | - echo "</table>"; |
|
2605 | - } |
|
2606 | - |
|
2607 | - /** |
|
2608 | - * Blog admin | Display the form to add a new blog. |
|
2609 | - * |
|
2610 | - */ |
|
2611 | - public static function display_new_blog_form() |
|
2612 | - { |
|
2613 | - $form = new FormValidator( |
|
2614 | - 'add_blog', |
|
2615 | - 'post', |
|
2616 | - 'blog_admin.php?action=add&'.api_get_cidreq()); |
|
2592 | + } |
|
2593 | + } |
|
2594 | + } |
|
2595 | + |
|
2596 | + echo "</td>"; |
|
2597 | + $curday ++; |
|
2598 | + } else |
|
2599 | + echo "<td> </td>"; |
|
2600 | + } |
|
2601 | + echo "</tr>"; |
|
2602 | + } |
|
2603 | + echo "</table>"; |
|
2604 | + } |
|
2605 | + |
|
2606 | + /** |
|
2607 | + * Blog admin | Display the form to add a new blog. |
|
2608 | + * |
|
2609 | + */ |
|
2610 | + public static function display_new_blog_form() |
|
2611 | + { |
|
2612 | + $form = new FormValidator( |
|
2613 | + 'add_blog', |
|
2614 | + 'post', |
|
2615 | + 'blog_admin.php?action=add&'.api_get_cidreq()); |
|
2617 | 2616 | $form->addElement('header', get_lang('AddBlog')); |
2618 | 2617 | $form->addElement('text', 'blog_name', get_lang('Title')); |
2619 | 2618 | $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle')); |
@@ -2622,42 +2621,42 @@ discard block |
||
2622 | 2621 | $form->addButtonSave(get_lang('SaveProject')); |
2623 | 2622 | |
2624 | 2623 | $defaults = array( |
2625 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2626 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2627 | - ); |
|
2624 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2625 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2626 | + ); |
|
2628 | 2627 | $form->setDefaults($defaults); |
2629 | 2628 | $form->display(); |
2630 | - } |
|
2631 | - |
|
2632 | - /** |
|
2633 | - * Blog admin | Display the form to edit a blog. |
|
2634 | - * |
|
2635 | - */ |
|
2636 | - public static function display_edit_blog_form($blog_id) |
|
2637 | - { |
|
2638 | - $course_id = api_get_course_int_id(); |
|
2639 | - $blog_id= intval($blog_id); |
|
2640 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2641 | - |
|
2642 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2629 | + } |
|
2630 | + |
|
2631 | + /** |
|
2632 | + * Blog admin | Display the form to edit a blog. |
|
2633 | + * |
|
2634 | + */ |
|
2635 | + public static function display_edit_blog_form($blog_id) |
|
2636 | + { |
|
2637 | + $course_id = api_get_course_int_id(); |
|
2638 | + $blog_id= intval($blog_id); |
|
2639 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2640 | + |
|
2641 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2643 | 2642 | FROM $tbl_blogs |
2644 | 2643 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
2645 | - $result = Database::query($sql); |
|
2646 | - $blog = Database::fetch_array($result); |
|
2647 | - |
|
2648 | - // the form contained errors but we do not want to lose the changes the user already did |
|
2649 | - if ($_POST) { |
|
2650 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2651 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2652 | - } |
|
2653 | - |
|
2654 | - $form = new FormValidator( |
|
2655 | - 'edit_blog', |
|
2656 | - 'post', |
|
2657 | - 'blog_admin.php?action=edit&blog_id='.intval( |
|
2658 | - $_GET['blog_id'] |
|
2659 | - ).'&'.api_get_cidreq() |
|
2660 | - ); |
|
2644 | + $result = Database::query($sql); |
|
2645 | + $blog = Database::fetch_array($result); |
|
2646 | + |
|
2647 | + // the form contained errors but we do not want to lose the changes the user already did |
|
2648 | + if ($_POST) { |
|
2649 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2650 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2651 | + } |
|
2652 | + |
|
2653 | + $form = new FormValidator( |
|
2654 | + 'edit_blog', |
|
2655 | + 'post', |
|
2656 | + 'blog_admin.php?action=edit&blog_id='.intval( |
|
2657 | + $_GET['blog_id'] |
|
2658 | + ).'&'.api_get_cidreq() |
|
2659 | + ); |
|
2661 | 2660 | $form->addElement('header', get_lang('EditBlog')); |
2662 | 2661 | $form->addElement('text', 'blog_name', get_lang('Title')); |
2663 | 2662 | $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle')); |
@@ -2671,87 +2670,87 @@ discard block |
||
2671 | 2670 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
2672 | 2671 | $form->setDefaults($defaults); |
2673 | 2672 | $form->display(); |
2674 | - } |
|
2673 | + } |
|
2675 | 2674 | |
2676 | - /** |
|
2677 | - * Blog admin | Returns table with blogs in this course |
|
2678 | - */ |
|
2679 | - public static function display_blog_list() |
|
2675 | + /** |
|
2676 | + * Blog admin | Returns table with blogs in this course |
|
2677 | + */ |
|
2678 | + public static function display_blog_list() |
|
2680 | 2679 | { |
2681 | - global $charset; |
|
2682 | - $_user = api_get_user_info(); |
|
2680 | + global $charset; |
|
2681 | + $_user = api_get_user_info(); |
|
2683 | 2682 | $course_id = api_get_course_int_id(); |
2684 | 2683 | |
2685 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2684 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2686 | 2685 | |
2687 | - //condition for the session |
|
2688 | - $session_id = api_get_session_id(); |
|
2689 | - $condition_session = api_get_session_condition($session_id, false); |
|
2686 | + //condition for the session |
|
2687 | + $session_id = api_get_session_id(); |
|
2688 | + $condition_session = api_get_session_condition($session_id, false); |
|
2690 | 2689 | |
2691 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2690 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2692 | 2691 | FROM $tbl_blogs WHERE c_id = $course_id |
2693 | 2692 | ORDER BY date_creation DESC"; |
2694 | - $result = Database::query($sql); |
|
2695 | - $list_info = array(); |
|
2696 | - if (Database::num_rows($result)) { |
|
2697 | - while ($row_project=Database::fetch_row($result)) { |
|
2698 | - $list_info[]=$row_project; |
|
2699 | - } |
|
2700 | - } |
|
2701 | - |
|
2702 | - $list_content_blog = array(); |
|
2703 | - $list_body_blog = array(); |
|
2704 | - |
|
2705 | - if (is_array($list_info)) { |
|
2706 | - foreach ($list_info as $key => $info_log) { |
|
2707 | - // Validation when belongs to a session |
|
2708 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2709 | - |
|
2710 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2711 | - $title = $info_log[0]; |
|
2693 | + $result = Database::query($sql); |
|
2694 | + $list_info = array(); |
|
2695 | + if (Database::num_rows($result)) { |
|
2696 | + while ($row_project=Database::fetch_row($result)) { |
|
2697 | + $list_info[]=$row_project; |
|
2698 | + } |
|
2699 | + } |
|
2700 | + |
|
2701 | + $list_content_blog = array(); |
|
2702 | + $list_body_blog = array(); |
|
2703 | + |
|
2704 | + if (is_array($list_info)) { |
|
2705 | + foreach ($list_info as $key => $info_log) { |
|
2706 | + // Validation when belongs to a session |
|
2707 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2708 | + |
|
2709 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2710 | + $title = $info_log[0]; |
|
2712 | 2711 | $image = Display::return_icon( |
2713 | 2712 | 'blog.gif' |
2714 | 2713 | );//'<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">'; |
2715 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2714 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2716 | 2715 | |
2717 | - $list_body_blog[] = $list_name; |
|
2718 | - $list_body_blog[] = $info_log[1]; |
|
2716 | + $list_body_blog[] = $list_name; |
|
2717 | + $list_body_blog[] = $info_log[1]; |
|
2719 | 2718 | |
2720 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2721 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2722 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2719 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2720 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2721 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2723 | 2722 | $my_image .= Display::return_icon( |
2724 | 2723 | 'edit.png' |
2725 | 2724 | );//'<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />'; |
2726 | - $my_image.= "</a>\n"; |
|
2727 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2728 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2725 | + $my_image.= "</a>\n"; |
|
2726 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2727 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2729 | 2728 | $my_image .= Display::return_icon( |
2730 | 2729 | 'delete.png' |
2731 | 2730 | ); //'<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />'; |
2732 | - $my_image.= "</a>\n"; |
|
2733 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2731 | + $my_image.= "</a>\n"; |
|
2732 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2734 | 2733 | $my_image .= Display::return_icon( |
2735 | 2734 | $visibility_icon.'.png' |
2736 | 2735 | );//'<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />'; |
2737 | - $my_image.= "</a>\n"; |
|
2738 | - |
|
2739 | - $list_body_blog[]=$my_image; |
|
2740 | - |
|
2741 | - $list_content_blog[]=$list_body_blog; |
|
2742 | - $list_body_blog = array(); |
|
2743 | - |
|
2744 | - } |
|
2745 | - $parameters=''; |
|
2746 | - //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
2747 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2748 | - //$table->set_additional_parameters($parameters); |
|
2749 | - $table->set_header(0, get_lang('Title')); |
|
2750 | - $table->set_header(1, get_lang('SubTitle')); |
|
2751 | - $table->set_header(2, get_lang('Modify')); |
|
2752 | - $table->display(); |
|
2753 | - } |
|
2754 | - } |
|
2736 | + $my_image.= "</a>\n"; |
|
2737 | + |
|
2738 | + $list_body_blog[]=$my_image; |
|
2739 | + |
|
2740 | + $list_content_blog[]=$list_body_blog; |
|
2741 | + $list_body_blog = array(); |
|
2742 | + |
|
2743 | + } |
|
2744 | + $parameters=''; |
|
2745 | + //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
2746 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2747 | + //$table->set_additional_parameters($parameters); |
|
2748 | + $table->set_header(0, get_lang('Title')); |
|
2749 | + $table->set_header(1, get_lang('SubTitle')); |
|
2750 | + $table->set_header(2, get_lang('Modify')); |
|
2751 | + $table->display(); |
|
2752 | + } |
|
2753 | + } |
|
2755 | 2754 | } |
2756 | 2755 | |
2757 | 2756 | /** |
@@ -2771,34 +2770,34 @@ discard block |
||
2771 | 2770 | */ |
2772 | 2771 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2773 | 2772 | { |
2774 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2775 | - |
|
2776 | - $blog_id = intval($blog_id); |
|
2777 | - $comment_id = intval($comment_id); |
|
2778 | - $post_id = intval($post_id); |
|
2779 | - $row=array(); |
|
2780 | - $where=''; |
|
2781 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2782 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2783 | - } |
|
2784 | - |
|
2785 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2786 | - if (!empty ($post_id)) { |
|
2787 | - $where.= ' AND '; |
|
2788 | - } |
|
2789 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2790 | - } |
|
2773 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2774 | + |
|
2775 | + $blog_id = intval($blog_id); |
|
2776 | + $comment_id = intval($comment_id); |
|
2777 | + $post_id = intval($post_id); |
|
2778 | + $row=array(); |
|
2779 | + $where=''; |
|
2780 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2781 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2782 | + } |
|
2783 | + |
|
2784 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2785 | + if (!empty ($post_id)) { |
|
2786 | + $where.= ' AND '; |
|
2787 | + } |
|
2788 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2789 | + } |
|
2791 | 2790 | |
2792 | 2791 | $course_id = api_get_course_int_id(); |
2793 | 2792 | |
2794 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2793 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2795 | 2794 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2796 | 2795 | |
2797 | - $result=Database::query($sql); |
|
2798 | - if (Database::num_rows($result)!=0) { |
|
2799 | - $row=Database::fetch_array($result); |
|
2800 | - } |
|
2801 | - return $row; |
|
2796 | + $result=Database::query($sql); |
|
2797 | + if (Database::num_rows($result)!=0) { |
|
2798 | + $row=Database::fetch_array($result); |
|
2799 | + } |
|
2800 | + return $row; |
|
2802 | 2801 | } |
2803 | 2802 | |
2804 | 2803 | /** |
@@ -2812,16 +2811,16 @@ discard block |
||
2812 | 2811 | |
2813 | 2812 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2814 | 2813 | { |
2815 | - $_course = api_get_course_info(); |
|
2816 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2817 | - $blog_id = intval($blog_id); |
|
2818 | - $comment_id = intval($comment_id); |
|
2819 | - $post_id = intval($post_id); |
|
2814 | + $_course = api_get_course_info(); |
|
2815 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2816 | + $blog_id = intval($blog_id); |
|
2817 | + $comment_id = intval($comment_id); |
|
2818 | + $post_id = intval($post_id); |
|
2820 | 2819 | |
2821 | 2820 | $course_id = api_get_course_int_id(); |
2822 | - $where = null; |
|
2821 | + $where = null; |
|
2823 | 2822 | |
2824 | - // delete files in DB |
|
2823 | + // delete files in DB |
|
2825 | 2824 | if (!empty ($post_id) && is_numeric($post_id)) { |
2826 | 2825 | $where .= ' AND post_id ="'.$post_id.'" '; |
2827 | 2826 | } |
@@ -2833,25 +2832,25 @@ discard block |
||
2833 | 2832 | $where .= ' comment_id ="'.$comment_id.'" '; |
2834 | 2833 | } |
2835 | 2834 | |
2836 | - // delete all files in directory |
|
2837 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2838 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2839 | - $updir = $sys_course_path.$courseDir; |
|
2835 | + // delete all files in directory |
|
2836 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2837 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2838 | + $updir = $sys_course_path.$courseDir; |
|
2840 | 2839 | |
2841 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2840 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2842 | 2841 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2843 | - $result=Database::query($sql); |
|
2844 | - |
|
2845 | - while ($row=Database::fetch_row($result)) { |
|
2846 | - $file=$updir.'/'.$row[0]; |
|
2847 | - if (Security::check_abs_path($file,$updir) ) |
|
2848 | - { |
|
2849 | - @ unlink($file); |
|
2850 | - } |
|
2851 | - } |
|
2852 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2842 | + $result=Database::query($sql); |
|
2843 | + |
|
2844 | + while ($row=Database::fetch_row($result)) { |
|
2845 | + $file=$updir.'/'.$row[0]; |
|
2846 | + if (Security::check_abs_path($file,$updir) ) |
|
2847 | + { |
|
2848 | + @ unlink($file); |
|
2849 | + } |
|
2850 | + } |
|
2851 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2853 | 2852 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2854 | - Database::query($sql); |
|
2853 | + Database::query($sql); |
|
2855 | 2854 | } |
2856 | 2855 | |
2857 | 2856 | /** |
@@ -2861,12 +2860,12 @@ discard block |
||
2861 | 2860 | */ |
2862 | 2861 | function get_blog_post_from_user($course_code, $user_id) |
2863 | 2862 | { |
2864 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2865 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2866 | - $course_info = api_get_course_info($course_code); |
|
2867 | - $course_id = $course_info['real_id']; |
|
2863 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2864 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2865 | + $course_info = api_get_course_info($course_code); |
|
2866 | + $course_id = $course_info['real_id']; |
|
2868 | 2867 | |
2869 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2868 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2870 | 2869 | FROM $tbl_blogs blog |
2871 | 2870 | INNER JOIN $tbl_blog_post post |
2872 | 2871 | ON (blog.blog_id = post.blog_id) |
@@ -2875,23 +2874,23 @@ discard block |
||
2875 | 2874 | post.c_id = $course_id AND |
2876 | 2875 | author_id = $user_id AND visibility = 1 |
2877 | 2876 | ORDER BY post.date_creation DESC "; |
2878 | - $result = Database::query($sql); |
|
2879 | - $return_data = ''; |
|
2880 | - |
|
2881 | - if (Database::num_rows($result)!=0) { |
|
2882 | - while ($row=Database::fetch_array($result)) { |
|
2883 | - $return_data.= '<div class="clear"></div><br />'; |
|
2884 | - $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'. |
|
2885 | - Display::return_icon('blog_article.png', get_lang('BlogPosts')). |
|
2886 | - ' '.$row['title'].' <div style="float:right;margin-top:-18px"> |
|
2877 | + $result = Database::query($sql); |
|
2878 | + $return_data = ''; |
|
2879 | + |
|
2880 | + if (Database::num_rows($result)!=0) { |
|
2881 | + while ($row=Database::fetch_array($result)) { |
|
2882 | + $return_data.= '<div class="clear"></div><br />'; |
|
2883 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'. |
|
2884 | + Display::return_icon('blog_article.png', get_lang('BlogPosts')). |
|
2885 | + ' '.$row['title'].' <div style="float:right;margin-top:-18px"> |
|
2887 | 2886 | <a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq( |
2888 | - ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2889 | - $return_data.= '<br / >'; |
|
2890 | - $return_data.= $row['full_text']; |
|
2891 | - $return_data.= '<br /><br />'; |
|
2892 | - } |
|
2893 | - } |
|
2894 | - return $return_data; |
|
2887 | + ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2888 | + $return_data.= '<br / >'; |
|
2889 | + $return_data.= $row['full_text']; |
|
2890 | + $return_data.= '<br /><br />'; |
|
2891 | + } |
|
2892 | + } |
|
2893 | + return $return_data; |
|
2895 | 2894 | } |
2896 | 2895 | |
2897 | 2896 | /** |
@@ -2908,7 +2907,7 @@ discard block |
||
2908 | 2907 | $course_info = api_get_course_info($course_code); |
2909 | 2908 | $course_id = $course_info['real_id']; |
2910 | 2909 | |
2911 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2910 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2912 | 2911 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2913 | 2912 | ON (blog.blog_id = comment.blog_id) |
2914 | 2913 | WHERE blog.c_id = $course_id AND |
@@ -2916,20 +2915,20 @@ discard block |
||
2916 | 2915 | author_id = $user_id AND |
2917 | 2916 | visibility = 1 |
2918 | 2917 | ORDER BY blog_name"; |
2919 | - $result = Database::query($sql); |
|
2920 | - $return_data = ''; |
|
2921 | - if (Database::num_rows($result)!=0) { |
|
2922 | - while ($row=Database::fetch_array($result)) { |
|
2923 | - $return_data.= '<div class="clear"></div><br />'; |
|
2924 | - $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"> |
|
2918 | + $result = Database::query($sql); |
|
2919 | + $return_data = ''; |
|
2920 | + if (Database::num_rows($result)!=0) { |
|
2921 | + while ($row=Database::fetch_array($result)) { |
|
2922 | + $return_data.= '<div class="clear"></div><br />'; |
|
2923 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"> |
|
2925 | 2924 | <a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq( |
2926 | - ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2927 | - $return_data.= '<br / >'; |
|
2928 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2929 | - $return_data.= $row['comment']; |
|
2930 | - $return_data.= '<br />'; |
|
2931 | - } |
|
2932 | - } |
|
2933 | - return $return_data; |
|
2925 | + ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2926 | + $return_data.= '<br / >'; |
|
2927 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2928 | + $return_data.= $row['comment']; |
|
2929 | + $return_data.= '<br />'; |
|
2930 | + } |
|
2931 | + } |
|
2932 | + return $return_data; |
|
2934 | 2933 | } |
2935 | 2934 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return String Blog Title |
23 | 23 | */ |
24 | - public static function get_blog_title ($blog_id) |
|
24 | + public static function get_blog_title($blog_id) |
|
25 | 25 | { |
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
31 | 31 | |
32 | 32 | $sql = "SELECT blog_name |
33 | - FROM " . $tbl_blogs . " |
|
34 | - WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
|
33 | + FROM " . $tbl_blogs." |
|
34 | + WHERE c_id = $course_id AND blog_id = ".intval($blog_id); |
|
35 | 35 | |
36 | 36 | $result = Database::query($sql); |
37 | 37 | $blog = Database::fetch_array($result); |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | |
79 | 79 | // Get blog members |
80 | 80 | $sql = "SELECT user.user_id, user.firstname, user.lastname |
81 | - FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
|
82 | - INNER JOIN " . $tbl_users . " user |
|
81 | + FROM " . $tbl_blogs_rel_user." blogs_rel_user |
|
82 | + INNER JOIN " . $tbl_users." user |
|
83 | 83 | ON blogs_rel_user.user_id = user.user_id |
84 | 84 | WHERE |
85 | 85 | blogs_rel_user.c_id = $course_id AND |
86 | - blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
|
86 | + blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
87 | 87 | $result = Database::query($sql); |
88 | - $blog_members = array (); |
|
89 | - while($user = Database::fetch_array($result)) { |
|
88 | + $blog_members = array(); |
|
89 | + while ($user = Database::fetch_array($result)) { |
|
90 | 90 | $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
91 | 91 | } |
92 | 92 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $_user = api_get_user_info(); |
106 | 106 | $course_id = api_get_course_int_id(); |
107 | 107 | |
108 | - $current_date=date('Y-m-d H:i:s',time()); |
|
108 | + $current_date = date('Y-m-d H:i:s', time()); |
|
109 | 109 | $session_id = api_get_session_id(); |
110 | 110 | // Tabel definitions |
111 | 111 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'blog_name' => $title, |
131 | 131 | 'blog_subtitle' => $subtitle, |
132 | 132 | 'date_creation' => $current_date, |
133 | - 'visibility' => 1 , |
|
133 | + 'visibility' => 1, |
|
134 | 134 | 'session_id' => $session_id, |
135 | 135 | ]; |
136 | 136 | $this_blog_id = Database::insert($tbl_blogs, $params); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | // Put it on course homepage |
171 | 171 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
172 | - VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
|
172 | + VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int) $this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
|
173 | 173 | Database::query($sql); |
174 | 174 | |
175 | 175 | $toolId = Database::insert_id(); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | blog_subtitle = '".Database::escape_string($subtitle)."' |
205 | 205 | WHERE |
206 | 206 | c_id = $course_id AND |
207 | - blog_id ='".Database::escape_string((int)$blog_id)."' |
|
207 | + blog_id ='".Database::escape_string((int) $blog_id)."' |
|
208 | 208 | LIMIT 1"; |
209 | 209 | Database::query($sql); |
210 | 210 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | // Update course homepage link |
221 | 221 | $sql = "UPDATE $tbl_tool SET |
222 | 222 | name = '".Database::escape_string($title)."' |
223 | - WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
|
223 | + WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int) $blog_id."' LIMIT 1"; |
|
224 | 224 | Database::query($sql); |
225 | 225 | } |
226 | 226 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | Database::query($sql); |
264 | 264 | |
265 | 265 | // Delete blog |
266 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
266 | + $sql = "DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
267 | 267 | Database::query($sql); |
268 | 268 | |
269 | 269 | // Delete from course homepage |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | $course_id = $_course['real_id']; |
295 | 295 | |
296 | 296 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
297 | - $upload_ok=true; |
|
298 | - $has_attachment=false; |
|
297 | + $upload_ok = true; |
|
298 | + $has_attachment = false; |
|
299 | 299 | $current_date = api_get_utc_datetime(); |
300 | 300 | |
301 | 301 | if (!empty($_FILES['user_upload']['name'])) { |
302 | 302 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
303 | - $has_attachment=true; |
|
303 | + $has_attachment = true; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if ($upload_ok) { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | // Create the post |
311 | 311 | $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
312 | - VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
|
312 | + VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int) $blog_id."', '".(int) $_user['user_id']."');"; |
|
313 | 313 | |
314 | 314 | Database::query($sql); |
315 | 315 | $last_post_id = Database::insert_id(); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | if ($has_attachment) { |
323 | - $courseDir = $_course['path'].'/upload/blog'; |
|
323 | + $courseDir = $_course['path'].'/upload/blog'; |
|
324 | 324 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
325 | 325 | $updir = $sys_course_path.$courseDir; |
326 | 326 | |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | |
372 | 372 | // Create the post |
373 | 373 | $sql = "UPDATE $tbl_blogs_posts SET |
374 | - title = '" . Database::escape_string($title)."', |
|
374 | + title = '".Database::escape_string($title)."', |
|
375 | 375 | full_text = '" . Database::escape_string($full_text)."' |
376 | - WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
|
376 | + WHERE c_id = $course_id AND post_id ='".(int) $post_id."' AND blog_id ='".(int) $blog_id."' |
|
377 | 377 | LIMIT 1 "; |
378 | 378 | Database::query($sql); |
379 | 379 | } |
@@ -394,21 +394,21 @@ discard block |
||
394 | 394 | |
395 | 395 | // Delete ratings on this comment |
396 | 396 | $sql = "DELETE FROM $tbl_blogs_rating |
397 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
|
397 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND item_id = '".(int) $post_id."' AND rating_type = 'post'"; |
|
398 | 398 | Database::query($sql); |
399 | 399 | |
400 | 400 | // Delete the post |
401 | 401 | $sql = "DELETE FROM $tbl_blogs_posts |
402 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
|
402 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."'"; |
|
403 | 403 | Database::query($sql); |
404 | 404 | |
405 | 405 | // Delete the comments |
406 | 406 | $sql = "DELETE FROM $tbl_blogs_comments |
407 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
|
407 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."' AND blog_id = '".(int) $blog_id."'"; |
|
408 | 408 | Database::query($sql); |
409 | 409 | |
410 | 410 | // Delete posts and attachments |
411 | - delete_all_blog_attachment($blog_id,$post_id); |
|
411 | + delete_all_blog_attachment($blog_id, $post_id); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | { |
425 | 425 | $_user = api_get_user_info(); |
426 | 426 | $_course = api_get_course_info(); |
427 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
427 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
428 | 428 | |
429 | 429 | $upload_ok = true; |
430 | 430 | $has_attachment = false; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | if (!empty($_FILES['user_upload']['name'])) { |
435 | 435 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
436 | - $has_attachment=true; |
|
436 | + $has_attachment = true; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | if ($upload_ok) { |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | // Create the comment |
444 | 444 | $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
445 | - VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
|
445 | + VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int) $_user['user_id']."','".$current_date."', '".(int) $blog_id."', '".(int) $post_id."', '".(int) $parent_id."', '".(int) $task_id."')"; |
|
446 | 446 | Database::query($sql); |
447 | 447 | |
448 | 448 | // Empty post values, or they are shown on the page again |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | if ($has_attachment) { |
457 | - $courseDir = $_course['path'].'/upload/blog'; |
|
457 | + $courseDir = $_course['path'].'/upload/blog'; |
|
458 | 458 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
459 | 459 | $updir = $sys_course_path.$courseDir; |
460 | 460 | |
@@ -465,19 +465,19 @@ discard block |
||
465 | 465 | ); |
466 | 466 | |
467 | 467 | // user's file name |
468 | - $file_name =$_FILES['user_upload']['name']; |
|
468 | + $file_name = $_FILES['user_upload']['name']; |
|
469 | 469 | |
470 | 470 | if (!filter_extension($new_file_name)) { |
471 | 471 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
472 | 472 | } else { |
473 | 473 | $new_file_name = uniqid(''); |
474 | - $new_path=$updir.'/'.$new_file_name; |
|
475 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
474 | + $new_path = $updir.'/'.$new_file_name; |
|
475 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
476 | 476 | $comment = Database::escape_string($file_comment); |
477 | 477 | |
478 | 478 | // Storing the attachments if any |
479 | 479 | if ($result) { |
480 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
480 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
481 | 481 | "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
482 | 482 | Database::query($sql); |
483 | 483 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | // Delete them recursively |
528 | 528 | while ($comment = Database::fetch_array($result)) { |
529 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
529 | + Blog::delete_comment($blog_id, $post_id, $comment['comment_id']); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | // Finally, delete the selected comment to |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | // Create the task |
555 | 555 | $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
556 | - VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
|
556 | + VALUES ($course_id , '".(int) $blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');"; |
|
557 | 557 | Database::query($sql); |
558 | 558 | |
559 | 559 | $task_id = Database::insert_id(); |
@@ -563,13 +563,13 @@ discard block |
||
563 | 563 | Database::query($sql); |
564 | 564 | } |
565 | 565 | |
566 | - $tool = 'BLOG_' . $blog_id; |
|
566 | + $tool = 'BLOG_'.$blog_id; |
|
567 | 567 | |
568 | 568 | if ($articleDelete == 'on') { |
569 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
570 | - '" . (int)$course_id . "', |
|
571 | - '" . (int)$task_id . "', |
|
572 | - '" . Database::escape_string($tool) . "', |
|
569 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
570 | + '" . (int) $course_id."', |
|
571 | + '" . (int) $task_id."', |
|
572 | + '" . Database::escape_string($tool)."', |
|
573 | 573 | 'article_delete' |
574 | 574 | )"; |
575 | 575 | Database::query($sql); |
@@ -584,10 +584,10 @@ discard block |
||
584 | 584 | |
585 | 585 | if ($articleEdit == 'on') { |
586 | 586 | $sql = " |
587 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
588 | - '" . (int)$course_id . "', |
|
589 | - '" . (int)$task_id . "', |
|
590 | - '" . Database::escape_string($tool) . "', |
|
587 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
588 | + '" . (int) $course_id."', |
|
589 | + '" . (int) $task_id."', |
|
590 | + '" . Database::escape_string($tool)."', |
|
591 | 591 | 'article_edit' |
592 | 592 | )"; |
593 | 593 | Database::query($sql); |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($commentsDelete == 'on') { |
603 | 603 | $sql = " |
604 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
605 | - '" . (int)$course_id . "', |
|
606 | - '" . (int)$task_id . "', |
|
607 | - '" . Database::escape_string($tool) . "', |
|
604 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
605 | + '" . (int) $course_id."', |
|
606 | + '" . (int) $task_id."', |
|
607 | + '" . Database::escape_string($tool)."', |
|
608 | 608 | 'article_comments_delete' |
609 | 609 | )"; |
610 | 610 | Database::query($sql); |
@@ -637,20 +637,20 @@ discard block |
||
637 | 637 | title = '".Database::escape_string($title)."', |
638 | 638 | description = '".Database::escape_string($description)."', |
639 | 639 | color = '".Database::escape_string($color)."' |
640 | - WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
|
640 | + WHERE c_id = $course_id AND task_id ='".(int) $task_id."' LIMIT 1"; |
|
641 | 641 | Database::query($sql); |
642 | 642 | |
643 | - $tool = 'BLOG_' . $blog_id; |
|
643 | + $tool = 'BLOG_'.$blog_id; |
|
644 | 644 | |
645 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
646 | - WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
|
645 | + $sql = "DELETE FROM ".$tbl_tasks_permissions." |
|
646 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
647 | 647 | Database::query($sql); |
648 | 648 | |
649 | 649 | if ($articleDelete == 'on') { |
650 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
651 | - '" . (int)$course_id . "', |
|
652 | - '" . (int)$task_id . "', |
|
653 | - '" . Database::escape_string($tool) . "', |
|
650 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
651 | + '" . (int) $course_id."', |
|
652 | + '" . (int) $task_id."', |
|
653 | + '" . Database::escape_string($tool)."', |
|
654 | 654 | 'article_delete' |
655 | 655 | )"; |
656 | 656 | Database::query($sql); |
@@ -663,10 +663,10 @@ discard block |
||
663 | 663 | } |
664 | 664 | |
665 | 665 | if ($articleEdit == 'on') { |
666 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
667 | - '" . (int)$course_id . "', |
|
668 | - '" . (int)$task_id . "', |
|
669 | - '" . Database::escape_string($tool) . "', |
|
666 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
667 | + '" . (int) $course_id."', |
|
668 | + '" . (int) $task_id."', |
|
669 | + '" . Database::escape_string($tool)."', |
|
670 | 670 | 'article_edit' |
671 | 671 | )"; |
672 | 672 | Database::query($sql); |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | if ($commentsDelete == 'on') { |
682 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
683 | - '" . (int)$course_id . "', |
|
684 | - '" . (int)$task_id . "', |
|
685 | - '" . Database::escape_string($tool) . "', |
|
682 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
683 | + '" . (int) $course_id."', |
|
684 | + '" . (int) $task_id."', |
|
685 | + '" . Database::escape_string($tool)."', |
|
686 | 686 | 'article_comments_delete' |
687 | 687 | )"; |
688 | 688 | Database::query($sql); |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | |
708 | 708 | // Delete posts |
709 | 709 | $sql = "DELETE FROM $tbl_blogs_tasks |
710 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
|
710 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND task_id = '".(int) $task_id."'"; |
|
711 | 711 | Database::query($sql); |
712 | 712 | } |
713 | 713 | |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
726 | 726 | WHERE |
727 | 727 | c_id = $course_id AND |
728 | - blog_id = '".(int)$blog_id."' AND |
|
729 | - task_id = '".(int)$task_id."' AND |
|
730 | - user_id = '".(int)$user_id."'"; |
|
728 | + blog_id = '".(int) $blog_id."' AND |
|
729 | + task_id = '".(int) $task_id."' AND |
|
730 | + user_id = '".(int) $user_id."'"; |
|
731 | 731 | Database::query($sql); |
732 | 732 | } |
733 | 733 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $_user = api_get_user_info(); |
742 | 742 | |
743 | 743 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
744 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
744 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
745 | 745 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
746 | 746 | |
747 | 747 | $course_id = api_get_course_int_id(); |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | task.c_id = $course_id AND |
759 | 759 | blog.c_id = $course_id AND |
760 | 760 | task_rel_user.c_id = $course_id AND |
761 | - task_rel_user.user_id = ".(int)$_user['user_id']." |
|
761 | + task_rel_user.user_id = ".(int) $_user['user_id']." |
|
762 | 762 | ORDER BY target_date ASC"; |
763 | 763 | |
764 | 764 | $result = Database::query($sql); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | |
799 | 799 | // Get blog properties |
800 | 800 | $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
801 | - WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
|
801 | + WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'"; |
|
802 | 802 | $result = Database::query($sql); |
803 | 803 | $blog = Database::fetch_array($result); |
804 | 804 | $visibility = $blog['visibility']; |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | if ($visibility == 1) { |
808 | 808 | // Change visibility state, remove from course home. |
809 | 809 | $sql = "UPDATE $tbl_blogs SET visibility = '0' |
810 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
810 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
811 | 811 | Database::query($sql); |
812 | 812 | |
813 | 813 | $sql = "DELETE FROM $tbl_tool |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | } else { |
817 | 817 | // Change visibility state, add to course home. |
818 | 818 | $sql = "UPDATE $tbl_blogs SET visibility = '1' |
819 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
819 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
820 | 820 | Database::query($sql); |
821 | 821 | |
822 | 822 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
823 | - VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
823 | + VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
824 | 824 | Database::query($sql); |
825 | 825 | $id = Database::insert_id(); |
826 | 826 | |
@@ -851,14 +851,14 @@ discard block |
||
851 | 851 | FROM $tbl_blogs_posts post |
852 | 852 | INNER JOIN $tbl_users user |
853 | 853 | ON post.author_id = user.user_id |
854 | - WHERE post.blog_id = '".(int)$blog_id."' AND |
|
854 | + WHERE post.blog_id = '".(int) $blog_id."' AND |
|
855 | 855 | post.c_id = $course_id AND |
856 | 856 | $filter |
857 | - ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
|
857 | + ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts; |
|
858 | 858 | $result = Database::query($sql); |
859 | 859 | |
860 | 860 | // Display |
861 | - if(Database::num_rows($result) > 0) { |
|
861 | + if (Database::num_rows($result) > 0) { |
|
862 | 862 | $limit = 200; |
863 | 863 | while ($blog_post = Database::fetch_array($result)) { |
864 | 864 | // Get number of comments |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | FROM $tbl_blogs_comments |
867 | 867 | WHERE |
868 | 868 | c_id = $course_id AND |
869 | - blog_id = '".(int)$blog_id."' AND |
|
870 | - post_id = '" . (int)$blog_post['post_id']."'"; |
|
869 | + blog_id = '".(int) $blog_id."' AND |
|
870 | + post_id = '" . (int) $blog_post['post_id']."'"; |
|
871 | 871 | $tmp = Database::query($sql); |
872 | 872 | $blog_post_comments = Database::fetch_array($tmp); |
873 | 873 | |
@@ -878,11 +878,11 @@ discard block |
||
878 | 878 | |
879 | 879 | // Create an introduction text (but keep FULL sentences) |
880 | 880 | $words = 0; |
881 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
881 | + $blog_post_text_cut = cut($blog_post_text, $limit); |
|
882 | 882 | $words = strlen($blog_post_text); |
883 | 883 | |
884 | 884 | if ($words >= $limit) { |
885 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
885 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_'.$blog_post_id.'\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_'.$blog_post_id.'\').style.display=\'none\'">'.get_lang('ReadMore').'</div>'; |
|
886 | 886 | $introduction_text = $blog_post_text_cut; |
887 | 887 | } else { |
888 | 888 | $introduction_text = $blog_post_text; |
@@ -900,14 +900,14 @@ discard block |
||
900 | 900 | ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang( |
901 | 901 | 'ReadPost' |
902 | 902 | ).'" >'.$blog_post_date.'</a></span>'; |
903 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
904 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
903 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>'; |
|
904 | + echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>'; |
|
905 | 905 | |
906 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
906 | + $file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0); |
|
907 | 907 | |
908 | 908 | if (!empty($file_name_array)) { |
909 | 909 | echo '<br /><br />'; |
910 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
910 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
911 | 911 | echo '<a href="download.php?'.api_get_cidreq().'&file='; |
912 | 912 | echo $file_name_array['path']; |
913 | 913 | echo ' "> '.$file_name_array['filename'].' </a><br />'; |
@@ -946,19 +946,19 @@ discard block |
||
946 | 946 | * @param Integer $blog_id |
947 | 947 | * @param String $query_string |
948 | 948 | */ |
949 | - public static function display_search_results ($blog_id, $query_string) |
|
949 | + public static function display_search_results($blog_id, $query_string) |
|
950 | 950 | { |
951 | 951 | // Init |
952 | 952 | $query_string = Database::escape_string($query_string); |
953 | - $query_string_parts = explode(' ',$query_string); |
|
953 | + $query_string_parts = explode(' ', $query_string); |
|
954 | 954 | $query_string = array(); |
955 | 955 | foreach ($query_string_parts as $query_part) { |
956 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
956 | + $query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' "; |
|
957 | 957 | } |
958 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
958 | + $query_string = '('.implode('OR', $query_string).')'; |
|
959 | 959 | |
960 | 960 | // Display the posts |
961 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
961 | + echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>'; |
|
962 | 962 | Blog::display_blog_posts($blog_id, $query_string); |
963 | 963 | } |
964 | 964 | |
@@ -971,14 +971,14 @@ discard block |
||
971 | 971 | public static function display_day_results($blog_id, $query_string) |
972 | 972 | { |
973 | 973 | $date_output = $query_string; |
974 | - $date = explode('-',$query_string); |
|
975 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
974 | + $date = explode('-', $query_string); |
|
975 | + $query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]); |
|
976 | 976 | |
977 | 977 | // Put date in correct output format |
978 | 978 | $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
979 | 979 | |
980 | 980 | // Display the posts |
981 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
981 | + echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>'; |
|
982 | 982 | Blog::display_blog_posts($blog_id, $query_string); |
983 | 983 | } |
984 | 984 | |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | ON post.author_id = user.user_id |
1006 | 1006 | WHERE |
1007 | 1007 | post.c_id = $course_id AND |
1008 | - post.blog_id = '".(int)$blog_id."' AND |
|
1009 | - post.post_id = '".(int)$post_id."' |
|
1008 | + post.blog_id = '".(int) $blog_id."' AND |
|
1009 | + post.post_id = '".(int) $post_id."' |
|
1010 | 1010 | ORDER BY post_id DESC"; |
1011 | 1011 | $result = Database::query($sql); |
1012 | 1012 | $blog_post = Database::fetch_array($result); |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | // Get number of comments |
1015 | 1015 | $sql = "SELECT COUNT(1) as number_of_comments |
1016 | 1016 | FROM $tbl_blogs_comments |
1017 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
|
1017 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'"; |
|
1018 | 1018 | $result = Database::query($sql); |
1019 | 1019 | $blog_post_comments = Database::fetch_array($result); |
1020 | 1020 | |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
1027 | 1027 | |
1028 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1028 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) |
|
1029 | 1029 | $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
1030 | 1030 | ).'&action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1031 | 1031 | 'EditThisPost' |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | '.Display::return_icon('edit.png').' |
1034 | 1034 | </a>'; |
1035 | 1035 | |
1036 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1036 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) |
|
1037 | 1037 | $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
1038 | 1038 | ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1039 | 1039 | 'DeleteThisArticle' |
@@ -1048,10 +1048,10 @@ discard block |
||
1048 | 1048 | '.Display::return_icon('delete.png').' |
1049 | 1049 | </a>'; |
1050 | 1050 | |
1051 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1052 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1051 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) |
|
1052 | + $rating_select = Blog::display_rating_form('post', $blog_id, $post_id); |
|
1053 | 1053 | |
1054 | - $blog_post_text=stripslashes($blog_post_text); |
|
1054 | + $blog_post_text = stripslashes($blog_post_text); |
|
1055 | 1055 | |
1056 | 1056 | // Display post |
1057 | 1057 | echo '<div class="blogpost">'; |
@@ -1060,14 +1060,14 @@ discard block |
||
1060 | 1060 | 'ReadPost' |
1061 | 1061 | ).'" >'. |
1062 | 1062 | stripslashes($blog_post['title']).'</a></span>'; |
1063 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1064 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1063 | + echo '<span class="blogpost_date">'.$blog_post_date.'</span>'; |
|
1064 | + echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />'; |
|
1065 | 1065 | |
1066 | 1066 | $file_name_array = get_blog_attachment($blog_id, $post_id); |
1067 | 1067 | |
1068 | 1068 | if (!empty($file_name_array)) { |
1069 | 1069 | echo ' <br />'; |
1070 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1070 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
1071 | 1071 | echo '<a href="download.php?'.api_get_cidreq().'&file='; |
1072 | 1072 | echo $file_name_array['path']; |
1073 | 1073 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1095,19 +1095,19 @@ discard block |
||
1095 | 1095 | $blog_id, |
1096 | 1096 | $post_id |
1097 | 1097 | ).$rating_select.'</span>'; |
1098 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1098 | + echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>'; |
|
1099 | 1099 | echo '</div>'; |
1100 | 1100 | |
1101 | 1101 | // Display comments if there are any |
1102 | 1102 | if ($blog_post_comments['number_of_comments'] > 0) { |
1103 | 1103 | echo '<div class="comments">'; |
1104 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1104 | + echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />'; |
|
1105 | 1105 | Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
1106 | 1106 | echo '</div>'; |
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | // Display comment form |
1110 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1110 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { |
|
1111 | 1111 | Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
1112 | 1112 | } |
1113 | 1113 | } |
@@ -1135,16 +1135,16 @@ discard block |
||
1135 | 1135 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
1136 | 1136 | WHERE |
1137 | 1137 | c_id = $course_id AND |
1138 | - blog_id = '".(int)$blog_id."' AND |
|
1139 | - item_id = '".(int)$item_id."' AND |
|
1138 | + blog_id = '".(int) $blog_id."' AND |
|
1139 | + item_id = '".(int) $item_id."' AND |
|
1140 | 1140 | rating_type = '".Database::escape_string($type)."' AND |
1141 | - user_id = '".(int)$_user['user_id']."'"; |
|
1141 | + user_id = '".(int) $_user['user_id']."'"; |
|
1142 | 1142 | $result = Database::query($sql); |
1143 | 1143 | |
1144 | 1144 | // Add rating |
1145 | 1145 | if (Database::num_rows($result) == 0) { |
1146 | 1146 | $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
1147 | - VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
1147 | + VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
1148 | 1148 | Database::query($sql); |
1149 | 1149 | |
1150 | 1150 | $id = Database::insert_id(); |
@@ -1177,8 +1177,8 @@ discard block |
||
1177 | 1177 | $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
1178 | 1178 | WHERE |
1179 | 1179 | c_id = $course_id AND |
1180 | - blog_id = '".(int)$blog_id."' AND |
|
1181 | - item_id = '".(int)$item_id."' AND |
|
1180 | + blog_id = '".(int) $blog_id."' AND |
|
1181 | + item_id = '".(int) $item_id."' AND |
|
1182 | 1182 | rating_type = '".Database::escape_string($type)."' "; |
1183 | 1183 | $result = Database::query($sql); |
1184 | 1184 | $result = Database::fetch_array($result); |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | * |
1196 | 1196 | *@return String |
1197 | 1197 | */ |
1198 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1198 | + public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL) |
|
1199 | 1199 | { |
1200 | 1200 | $_user = api_get_user_info(); |
1201 | 1201 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
@@ -1205,10 +1205,10 @@ discard block |
||
1205 | 1205 | // Check if the user has already rated this post |
1206 | 1206 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
1207 | 1207 | WHERE c_id = $course_id AND |
1208 | - blog_id = '".(int)$blog_id."' |
|
1209 | - AND item_id = '".(int)$post_id."' |
|
1208 | + blog_id = '".(int) $blog_id."' |
|
1209 | + AND item_id = '".(int) $post_id."' |
|
1210 | 1210 | AND rating_type = '".Database::escape_string($type)."' |
1211 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
1211 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
1212 | 1212 | $result = Database::query($sql); |
1213 | 1213 | // Add rating |
1214 | 1214 | if (Database::num_rows($result) == 0) { |
@@ -1224,10 +1224,10 @@ discard block |
||
1224 | 1224 | if ($type = 'comment') { |
1225 | 1225 | // Check if the user has already rated this comment |
1226 | 1226 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
1227 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
|
1228 | - AND item_id = '".(int)$comment_id."' |
|
1227 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' |
|
1228 | + AND item_id = '".(int) $comment_id."' |
|
1229 | 1229 | AND rating_type = '".Database::escape_string($type)."' |
1230 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
1230 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
1231 | 1231 | $result = Database::query($sql); |
1232 | 1232 | |
1233 | 1233 | if (Database::num_rows($result) == 0) { |
@@ -1269,11 +1269,11 @@ discard block |
||
1269 | 1269 | WHERE |
1270 | 1270 | comments.c_id = $course_id AND |
1271 | 1271 | parent_comment_id = $current AND |
1272 | - comments.blog_id = '".(int)$blog_id."' AND |
|
1273 | - comments.post_id = '".(int)$post_id."'"; |
|
1272 | + comments.blog_id = '".(int) $blog_id."' AND |
|
1273 | + comments.post_id = '".(int) $post_id."'"; |
|
1274 | 1274 | $result = Database::query($sql); |
1275 | 1275 | |
1276 | - while($comment = Database::fetch_array($result)) { |
|
1276 | + while ($comment = Database::fetch_array($result)) { |
|
1277 | 1277 | // Select the children recursivly |
1278 | 1278 | $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
1279 | 1279 | FROM $tbl_blogs_comments comments |
@@ -1282,8 +1282,8 @@ discard block |
||
1282 | 1282 | WHERE |
1283 | 1283 | comments.c_id = $course_id AND |
1284 | 1284 | comment_id = $current |
1285 | - AND blog_id = '".(int)$blog_id."' |
|
1286 | - AND post_id = '".(int)$post_id."'"; |
|
1285 | + AND blog_id = '".(int) $blog_id."' |
|
1286 | + AND post_id = '".(int) $post_id."'"; |
|
1287 | 1287 | $tmp = Database::query($tmp); |
1288 | 1288 | $tmp = Database::fetch_array($tmp); |
1289 | 1289 | $parent_cat = $tmp['parent_comment_id']; |
@@ -1320,27 +1320,27 @@ discard block |
||
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | if (!is_null($comment['task_id'])) { |
1323 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1323 | + $border_color = ' border-left: 3px solid #'.$comment['color']; |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | $comment_text = stripslashes($comment_text); |
1327 | 1327 | |
1328 | 1328 | // Output... |
1329 | 1329 | $margin = $current_level * 30; |
1330 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1330 | + echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">'; |
|
1331 | 1331 | echo '<span class="blogpost_comment_title"> |
1332 | 1332 | <a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes( |
1333 | 1333 | $comment['title'] |
1334 | 1334 | ).'\'" title="'.get_lang( |
1335 | 1335 | 'ReplyToThisComment' |
1336 | 1336 | ).'" >'.stripslashes($comment['title']).'</a></span>'; |
1337 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1338 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1337 | + echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>'; |
|
1338 | + echo '<span class="blogpost_text">'.$comment_text.'</span>'; |
|
1339 | 1339 | |
1340 | - $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1340 | + $file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']); |
|
1341 | 1341 | if (!empty($file_name_array)) { |
1342 | 1342 | echo '<br /><br />'; |
1343 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1343 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
1344 | 1344 | echo '<a href="download.php?'.api_get_cidreq().'&file='; |
1345 | 1345 | echo $file_name_array['path']; |
1346 | 1346 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | } |
1351 | 1351 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
1352 | 1352 | echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
1353 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1353 | + echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>'; |
|
1354 | 1354 | echo '</div>'; |
1355 | 1355 | |
1356 | 1356 | // Go further down the tree. |
@@ -1366,11 +1366,11 @@ discard block |
||
1366 | 1366 | */ |
1367 | 1367 | public static function display_form_new_post($blog_id) |
1368 | 1368 | { |
1369 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1369 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
1370 | 1370 | $form = new FormValidator( |
1371 | 1371 | 'add_post', |
1372 | 1372 | 'post', |
1373 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1373 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(), |
|
1374 | 1374 | null, |
1375 | 1375 | array('enctype' => 'multipart/form-data') |
1376 | 1376 | ); |
@@ -1414,8 +1414,8 @@ discard block |
||
1414 | 1414 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1415 | 1415 | WHERE |
1416 | 1416 | post.c_id = $course_id AND |
1417 | - post.blog_id = '".(int)$blog_id ."' |
|
1418 | - AND post.post_id = '".(int)$post_id."' |
|
1417 | + post.blog_id = '".(int) $blog_id."' |
|
1418 | + AND post.post_id = '".(int) $post_id."' |
|
1419 | 1419 | ORDER BY post_id DESC"; |
1420 | 1420 | $result = Database::query($sql); |
1421 | 1421 | $blog_post = Database::fetch_array($result); |
@@ -1461,26 +1461,26 @@ discard block |
||
1461 | 1461 | global $charset; |
1462 | 1462 | $course_id = api_get_course_int_id(); |
1463 | 1463 | |
1464 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1464 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
1465 | 1465 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
1466 | 1466 | $counter = 0; |
1467 | 1467 | global $color2; |
1468 | 1468 | |
1469 | 1469 | echo '<div class="actions">'; |
1470 | - echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> '; |
|
1471 | - echo '<a href="' .api_get_self(). '?'.api_get_cidreq().'&action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>'; |
|
1470 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=manage_tasks&blog_id='.$blog_id.'&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />'.get_lang('AddTasks').'</a> '; |
|
1471 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=manage_tasks&blog_id='.$blog_id.'&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />'.get_lang('AssignTasks').'</a>'; |
|
1472 | 1472 | ?> |
1473 | - <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
|
1473 | + <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a> |
|
1474 | 1474 | <?php |
1475 | 1475 | echo '</div>'; |
1476 | 1476 | |
1477 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1477 | + echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />'; |
|
1478 | 1478 | echo "<table class=\"data_table\">"; |
1479 | 1479 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1480 | - "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
1481 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1482 | - "<th><b>",get_lang('Color'),"</b></th>\n", |
|
1483 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1480 | + "<th width='240'><b>", get_lang('Title'), "</b></th>\n", |
|
1481 | + "<th><b>", get_lang('Description'), "</b></th>\n", |
|
1482 | + "<th><b>", get_lang('Color'), "</b></th>\n", |
|
1483 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>\n", |
|
1484 | 1484 | "</tr>\n"; |
1485 | 1485 | |
1486 | 1486 | |
@@ -1492,31 +1492,31 @@ discard block |
||
1492 | 1492 | description, |
1493 | 1493 | color, |
1494 | 1494 | system_task |
1495 | - FROM " . $tbl_blogs_tasks . " |
|
1496 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
1495 | + FROM " . $tbl_blogs_tasks." |
|
1496 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
1497 | 1497 | ORDER BY system_task, title"; |
1498 | 1498 | $result = Database::query($sql); |
1499 | 1499 | |
1500 | 1500 | |
1501 | - while($task = Database::fetch_array($result)) { |
|
1501 | + while ($task = Database::fetch_array($result)) { |
|
1502 | 1502 | $counter++; |
1503 | 1503 | $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
1504 | 1504 | $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
1505 | 1505 | $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
1506 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1507 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1506 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id']; |
|
1507 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1508 | 1508 | |
1509 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1510 | - '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
1511 | - '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
1512 | - '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
1509 | + echo '<tr class="'.$css_class.'" valign="top">', |
|
1510 | + '<td width="240">'.Security::remove_XSS($task['title']).'</td>', |
|
1511 | + '<td>'.Security::remove_XSS($task['description']).'</td>', |
|
1512 | + '<td><span style="background-color: #'.$task['color'].'"> </span></td>', |
|
1513 | 1513 | '<td width="50">', |
1514 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
1515 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1514 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">', |
|
1515 | + '<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />', |
|
1516 | 1516 | "</a>\n", |
1517 | - '<a href="' . $delete_link . '"', |
|
1517 | + '<a href="'.$delete_link.'"', |
|
1518 | 1518 | $delete_confirm, |
1519 | - '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1519 | + '><img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />', |
|
1520 | 1520 | "</a>\n", |
1521 | 1521 | '</td>', |
1522 | 1522 | '</tr>'; |
@@ -1531,23 +1531,23 @@ discard block |
||
1531 | 1531 | * |
1532 | 1532 | * @param Integer $blog_id |
1533 | 1533 | */ |
1534 | - public static function display_assigned_task_list ($blog_id) |
|
1534 | + public static function display_assigned_task_list($blog_id) |
|
1535 | 1535 | { |
1536 | 1536 | // Init |
1537 | 1537 | $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
1538 | 1538 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
1539 | 1539 | $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
1540 | 1540 | $counter = 0; |
1541 | - global $charset,$color2; |
|
1541 | + global $charset, $color2; |
|
1542 | 1542 | |
1543 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1543 | + echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />'; |
|
1544 | 1544 | echo "<table class=\"data_table\">"; |
1545 | 1545 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1546 | - "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
1547 | - "<th><b>",get_lang('Task'),"</b></th>\n", |
|
1548 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
1549 | - "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
1550 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
1546 | + "<th width='240'><b>", get_lang('Member'), "</b></th>\n", |
|
1547 | + "<th><b>", get_lang('Task'), "</b></th>\n", |
|
1548 | + "<th><b>", get_lang('Description'), "</b></th>\n", |
|
1549 | + "<th><b>", get_lang('TargetDate'), "</b></th>\n", |
|
1550 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>\n", |
|
1551 | 1551 | "</tr>"; |
1552 | 1552 | |
1553 | 1553 | $course_id = api_get_course_int_id(); |
@@ -1559,32 +1559,32 @@ discard block |
||
1559 | 1559 | WHERE |
1560 | 1560 | task_rel_user.c_id = $course_id AND |
1561 | 1561 | task.c_id = $course_id AND |
1562 | - task_rel_user.blog_id = '".(int)$blog_id."' |
|
1562 | + task_rel_user.blog_id = '".(int) $blog_id."' |
|
1563 | 1563 | ORDER BY target_date ASC"; |
1564 | 1564 | $result = Database::query($sql); |
1565 | 1565 | |
1566 | 1566 | while ($assignment = Database::fetch_array($result)) { |
1567 | 1567 | $counter++; |
1568 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1568 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1569 | 1569 | $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
1570 | 1570 | $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
1571 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1572 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1571 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id']; |
|
1572 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1573 | 1573 | |
1574 | 1574 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
1575 | 1575 | |
1576 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
1577 | - '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
1578 | - '<td>'.stripslashes($assignment['title']) . '</td>', |
|
1579 | - '<td>'.stripslashes($assignment['description']) . '</td>', |
|
1580 | - '<td>' . $assignment['target_date'] . '</td>', |
|
1576 | + echo '<tr class="'.$css_class.'" valign="top">', |
|
1577 | + '<td width="240">'.Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)).'</td>', |
|
1578 | + '<td>'.stripslashes($assignment['title']).'</td>', |
|
1579 | + '<td>'.stripslashes($assignment['description']).'</td>', |
|
1580 | + '<td>'.$assignment['target_date'].'</td>', |
|
1581 | 1581 | '<td width="50">', |
1582 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
1583 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
1582 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">', |
|
1583 | + '<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />', |
|
1584 | 1584 | "</a>\n", |
1585 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
1586 | - 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
1587 | - '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
1585 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ', |
|
1586 | + 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"', |
|
1587 | + '<img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />', |
|
1588 | 1588 | "</a>\n", |
1589 | 1589 | '</td>', |
1590 | 1590 | '</tr>'; |
@@ -1597,7 +1597,7 @@ discard block |
||
1597 | 1597 | * @author Toon Keppens |
1598 | 1598 | * |
1599 | 1599 | */ |
1600 | - public static function display_new_task_form ($blog_id) |
|
1600 | + public static function display_new_task_form($blog_id) |
|
1601 | 1601 | { |
1602 | 1602 | // Init |
1603 | 1603 | $colors = array( |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | // task title |
1629 | 1629 | echo ' <div class="control-group"> |
1630 | 1630 | <label class="control-label"> |
1631 | - <span class="form_required">*</span>' . get_lang('Title') . ' |
|
1631 | + <span class="form_required">*</span>' . get_lang('Title').' |
|
1632 | 1632 | </label> |
1633 | 1633 | <div class="controls"> |
1634 | 1634 | <input name="task_name" type="text" size="70" /> |
@@ -1638,7 +1638,7 @@ discard block |
||
1638 | 1638 | // task comment |
1639 | 1639 | echo ' <div class="control-group"> |
1640 | 1640 | <label class="control-label"> |
1641 | - ' . get_lang('Description') . ' |
|
1641 | + ' . get_lang('Description').' |
|
1642 | 1642 | </label> |
1643 | 1643 | <div class="controls"> |
1644 | 1644 | <textarea name="task_description" cols="45"></textarea> |
@@ -1648,18 +1648,18 @@ discard block |
||
1648 | 1648 | // task management |
1649 | 1649 | echo ' <div class="control-group"> |
1650 | 1650 | <label class="control-label"> |
1651 | - ' . get_lang('TaskManager') . ' |
|
1651 | + ' . get_lang('TaskManager').' |
|
1652 | 1652 | </label> |
1653 | 1653 | <div class="controls">'; |
1654 | 1654 | echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
1655 | 1655 | echo '<tr>'; |
1656 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1657 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1656 | + echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>'; |
|
1657 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
1658 | 1658 | echo '</tr>'; |
1659 | 1659 | echo '<tr>'; |
1660 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1661 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1662 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1660 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>'; |
|
1661 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>'; |
|
1662 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>'; |
|
1663 | 1663 | echo '</tr>'; |
1664 | 1664 | echo '<tr>'; |
1665 | 1665 | echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
@@ -1674,13 +1674,13 @@ discard block |
||
1674 | 1674 | // task color |
1675 | 1675 | echo ' <div class="control-group"> |
1676 | 1676 | <label class="control-label"> |
1677 | - ' . get_lang('Color') . ' |
|
1677 | + ' . get_lang('Color').' |
|
1678 | 1678 | </label> |
1679 | 1679 | <div class="controls">'; |
1680 | 1680 | echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
1681 | 1681 | foreach ($colors as $color) { |
1682 | - $style = 'style="background-color: #' . $color . '"'; |
|
1683 | - echo '<option value="' . $color . '" ' . $style . '> </option>'; |
|
1682 | + $style = 'style="background-color: #'.$color.'"'; |
|
1683 | + echo '<option value="'.$color.'" '.$style.'> </option>'; |
|
1684 | 1684 | } |
1685 | 1685 | echo '</select>'; |
1686 | 1686 | echo ' </div> |
@@ -1691,7 +1691,7 @@ discard block |
||
1691 | 1691 | <div class="controls"> |
1692 | 1692 | <input type="hidden" name="action" value="" /> |
1693 | 1693 | <input type="hidden" name="new_task_submit" value="true" /> |
1694 | - <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
|
1694 | + <button class="save" type="submit" name="Submit">' . get_lang('Save').'</button> |
|
1695 | 1695 | </div> |
1696 | 1696 | </div>'; |
1697 | 1697 | echo '</form>'; |
@@ -1705,14 +1705,14 @@ discard block |
||
1705 | 1705 | * @author Toon Keppens |
1706 | 1706 | * |
1707 | 1707 | */ |
1708 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
1708 | + public static function display_edit_task_form($blog_id, $task_id) { |
|
1709 | 1709 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
1710 | 1710 | $course_id = api_get_course_int_id(); |
1711 | 1711 | |
1712 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1712 | + $colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000'); |
|
1713 | 1713 | |
1714 | 1714 | $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks |
1715 | - WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1715 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
1716 | 1716 | $result = Database::query($sql); |
1717 | 1717 | $task = Database::fetch_array($result); |
1718 | 1718 | |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | ); |
1741 | 1741 | |
1742 | 1742 | $sql = " SELECT id, action FROM ".$tbl_tasks_permissions." |
1743 | - WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1743 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
1744 | 1744 | $result = Database::query($sql); |
1745 | 1745 | |
1746 | 1746 | $arrPermissions = array(); |
@@ -1833,7 +1833,7 @@ discard block |
||
1833 | 1833 | FROM $tbl_users user |
1834 | 1834 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
1835 | 1835 | ON user.user_id = blogs_rel_user.user_id |
1836 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
1836 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
1837 | 1837 | $result = Database::query($sql); |
1838 | 1838 | |
1839 | 1839 | $options = array(); |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | color, |
1853 | 1853 | system_task |
1854 | 1854 | FROM $tbl_blogs_tasks |
1855 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
1855 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
1856 | 1856 | ORDER BY system_task, title"; |
1857 | 1857 | $result = Database::query($sql); |
1858 | 1858 | |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | */ |
1900 | 1900 | public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
1901 | 1901 | { |
1902 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1902 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1903 | 1903 | |
1904 | 1904 | $course_id = api_get_course_int_id(); |
1905 | 1905 | |
@@ -1908,9 +1908,9 @@ discard block |
||
1908 | 1908 | SELECT target_date |
1909 | 1909 | FROM $tbl_blogs_tasks_rel_user |
1910 | 1910 | WHERE c_id = $course_id AND |
1911 | - blog_id = '".(int)$blog_id."' AND |
|
1912 | - user_id = '".(int)$user_id."' AND |
|
1913 | - task_id = '".(int)$task_id."'"; |
|
1911 | + blog_id = '".(int) $blog_id."' AND |
|
1912 | + user_id = '".(int) $user_id."' AND |
|
1913 | + task_id = '".(int) $task_id."'"; |
|
1914 | 1914 | $result = Database::query($sql); |
1915 | 1915 | $row = Database::fetch_assoc($result); |
1916 | 1916 | |
@@ -1945,11 +1945,11 @@ discard block |
||
1945 | 1945 | |
1946 | 1946 | $sql = " |
1947 | 1947 | SELECT COUNT(*) as 'number' |
1948 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
1948 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
1949 | 1949 | WHERE c_id = $course_id AND |
1950 | - blog_id = " . (int)$blog_id . " |
|
1951 | - AND user_id = " . (int)$user_id . " |
|
1952 | - AND task_id = " . (int)$task_id . " |
|
1950 | + blog_id = ".(int) $blog_id." |
|
1951 | + AND user_id = " . (int) $user_id." |
|
1952 | + AND task_id = " . (int) $task_id." |
|
1953 | 1953 | "; |
1954 | 1954 | |
1955 | 1955 | $result = Database::query($sql); |
@@ -1957,18 +1957,18 @@ discard block |
||
1957 | 1957 | |
1958 | 1958 | if ($row['number'] == 0) { |
1959 | 1959 | $sql = " |
1960 | - INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
|
1960 | + INSERT INTO " . $tbl_blogs_tasks_rel_user." ( |
|
1961 | 1961 | c_id, |
1962 | 1962 | blog_id, |
1963 | 1963 | user_id, |
1964 | 1964 | task_id, |
1965 | 1965 | target_date |
1966 | 1966 | ) VALUES ( |
1967 | - '" . (int)$course_id . "', |
|
1968 | - '" . (int)$blog_id . "', |
|
1969 | - '" . (int)$user_id . "', |
|
1970 | - '" . (int)$task_id . "', |
|
1971 | - '" . Database::escape_string($target_date) . "' |
|
1967 | + '" . (int) $course_id."', |
|
1968 | + '" . (int) $blog_id."', |
|
1969 | + '" . (int) $user_id."', |
|
1970 | + '" . (int) $task_id."', |
|
1971 | + '" . Database::escape_string($target_date)."' |
|
1972 | 1972 | )"; |
1973 | 1973 | |
1974 | 1974 | Database::query($sql); |
@@ -1998,12 +1998,12 @@ discard block |
||
1998 | 1998 | $course_id = api_get_course_int_id(); |
1999 | 1999 | |
2000 | 2000 | $sql = "SELECT COUNT(*) as 'number' |
2001 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
2001 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
2002 | 2002 | WHERE |
2003 | 2003 | c_id = $course_id AND |
2004 | - blog_id = " . (int)$blog_id . " AND |
|
2005 | - user_id = " . (int)$user_id . " AND |
|
2006 | - task_id = " . (int)$task_id . " |
|
2004 | + blog_id = ".(int) $blog_id." AND |
|
2005 | + user_id = " . (int) $user_id." AND |
|
2006 | + task_id = " . (int) $task_id." |
|
2007 | 2007 | "; |
2008 | 2008 | |
2009 | 2009 | $result = Database::query($sql); |
@@ -2011,17 +2011,17 @@ discard block |
||
2011 | 2011 | |
2012 | 2012 | if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
2013 | 2013 | $sql = " |
2014 | - UPDATE " . $tbl_blogs_tasks_rel_user . " |
|
2014 | + UPDATE " . $tbl_blogs_tasks_rel_user." |
|
2015 | 2015 | SET |
2016 | - user_id = " . (int)$user_id . ", |
|
2017 | - task_id = " . (int)$task_id . ", |
|
2018 | - target_date = '" . Database::escape_string($target_date) . "' |
|
2016 | + user_id = " . (int) $user_id.", |
|
2017 | + task_id = " . (int) $task_id.", |
|
2018 | + target_date = '" . Database::escape_string($target_date)."' |
|
2019 | 2019 | WHERE |
2020 | 2020 | c_id = $course_id AND |
2021 | - blog_id = " . (int)$blog_id . " AND |
|
2022 | - user_id = " . (int)$old_user_id . " AND |
|
2023 | - task_id = " . (int)$old_task_id . " AND |
|
2024 | - target_date = '" . Database::escape_string($old_target_date) . "' |
|
2021 | + blog_id = ".(int) $blog_id." AND |
|
2022 | + user_id = " . (int) $old_user_id." AND |
|
2023 | + task_id = " . (int) $old_task_id." AND |
|
2024 | + target_date = '" . Database::escape_string($old_target_date)."' |
|
2025 | 2025 | "; |
2026 | 2026 | Database::query($sql); |
2027 | 2027 | } |
@@ -2042,7 +2042,7 @@ discard block |
||
2042 | 2042 | |
2043 | 2043 | |
2044 | 2044 | $sql = "SELECT title, description FROM $tbl_blogs_tasks |
2045 | - WHERE task_id = '".(int)$task_id."' |
|
2045 | + WHERE task_id = '".(int) $task_id."' |
|
2046 | 2046 | AND c_id = $course_id"; |
2047 | 2047 | $result = Database::query($sql); |
2048 | 2048 | $row = Database::fetch_assoc($result); |
@@ -2050,17 +2050,17 @@ discard block |
||
2050 | 2050 | $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
2051 | 2051 | FROM $tbl_blogs_posts post |
2052 | 2052 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
2053 | - WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
|
2053 | + WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id |
|
2054 | 2054 | ORDER BY post_id DESC |
2055 | 2055 | LIMIT 0, 100"; |
2056 | 2056 | $result = Database::query($sql); |
2057 | 2057 | |
2058 | 2058 | // Display |
2059 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
2060 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
2059 | + echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>'; |
|
2060 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>'; |
|
2061 | 2061 | |
2062 | 2062 | if (Database::num_rows($result) > 0) { |
2063 | - while($blog_post = Database::fetch_array($result)) { |
|
2063 | + while ($blog_post = Database::fetch_array($result)) { |
|
2064 | 2064 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
2065 | 2065 | echo '<a href="blog.php?'.api_get_cidreq( |
2066 | 2066 | ).'&action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'. |
@@ -2100,12 +2100,12 @@ discard block |
||
2100 | 2100 | |
2101 | 2101 | // Subscribe the user |
2102 | 2102 | $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
2103 | - VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
|
2103 | + VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');"; |
|
2104 | 2104 | Database::query($sql); |
2105 | 2105 | |
2106 | 2106 | // Give this user basic rights |
2107 | 2107 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
2108 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
|
2108 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')"; |
|
2109 | 2109 | Database::query($sql); |
2110 | 2110 | |
2111 | 2111 | $id = Database::insert_id(); |
@@ -2115,7 +2115,7 @@ discard block |
||
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
2118 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
|
2118 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')"; |
|
2119 | 2119 | Database::query($sql); |
2120 | 2120 | |
2121 | 2121 | $id = Database::insert_id(); |
@@ -2141,12 +2141,12 @@ discard block |
||
2141 | 2141 | |
2142 | 2142 | // Unsubscribe the user |
2143 | 2143 | $sql = "DELETE FROM $tbl_blogs_rel_user |
2144 | - WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
|
2144 | + WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'"; |
|
2145 | 2145 | Database::query($sql); |
2146 | 2146 | |
2147 | 2147 | // Remove this user's permissions. |
2148 | 2148 | $sql = "DELETE FROM $tbl_user_permissions |
2149 | - WHERE user_id = '".(int)$user_id."'"; |
|
2149 | + WHERE user_id = '".(int) $user_id."'"; |
|
2150 | 2150 | Database::query($sql); |
2151 | 2151 | } |
2152 | 2152 | |
@@ -2167,7 +2167,7 @@ discard block |
||
2167 | 2167 | $course_id = $_course['real_id']; |
2168 | 2168 | |
2169 | 2169 | $currentCourse = $_course['code']; |
2170 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2170 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2171 | 2171 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
2172 | 2172 | |
2173 | 2173 | echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
@@ -2182,12 +2182,12 @@ discard block |
||
2182 | 2182 | $result = Database::query($sql); |
2183 | 2183 | |
2184 | 2184 | $blog_member_ids = array(); |
2185 | - while($user = Database::fetch_array($result)) { |
|
2185 | + while ($user = Database::fetch_array($result)) { |
|
2186 | 2186 | $blog_member_ids[] = $user['user_id']; |
2187 | 2187 | } |
2188 | 2188 | |
2189 | 2189 | // Set table headers |
2190 | - $column_header[] = array ('', false, ''); |
|
2190 | + $column_header[] = array('', false, ''); |
|
2191 | 2191 | if ($is_western_name_order) { |
2192 | 2192 | $column_header[] = array(get_lang('FirstName'), true, ''); |
2193 | 2193 | $column_header[] = array(get_lang('LastName'), true, ''); |
@@ -2207,13 +2207,13 @@ discard block |
||
2207 | 2207 | |
2208 | 2208 | // Add users that are not in this blog to the list. |
2209 | 2209 | foreach ($student_list as $key=>$user) { |
2210 | - if(isset($user['id_user'])) { |
|
2210 | + if (isset($user['id_user'])) { |
|
2211 | 2211 | $user['user_id'] = $user['id_user']; |
2212 | 2212 | } |
2213 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2213 | + if (!in_array($user['user_id'], $blog_member_ids)) { |
|
2214 | 2214 | $a_infosUser = api_get_user_info($user['user_id']); |
2215 | - $row = array (); |
|
2216 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2215 | + $row = array(); |
|
2216 | + $row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>'; |
|
2217 | 2217 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
2218 | 2218 | if ($is_western_name_order) { |
2219 | 2219 | $row[] = $a_infosUser["firstname"]; |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | //Link to register users |
2228 | 2228 | $currentUserId = api_get_user_id(); |
2229 | 2229 | if ($a_infosUser["user_id"] != $currentUserId) { |
2230 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2230 | + $row[] = "<a class=\"btn btn-primary \" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=".$a_infosUser["user_id"]."\">".get_lang('Register')."</a>"; |
|
2231 | 2231 | } else { |
2232 | 2232 | $row[] = ''; |
2233 | 2233 | } |
@@ -2240,9 +2240,9 @@ discard block |
||
2240 | 2240 | $query_vars['blog_id'] = $blog_id; |
2241 | 2241 | echo '<form method="post" action="blog.php?'.api_get_cidreq( |
2242 | 2242 | ).'&action=manage_members&blog_id='.$blog_id.'">'; |
2243 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2243 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
2244 | 2244 | $link = ''; |
2245 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2245 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
2246 | 2246 | $link .= "blog_id=$blog_id&"; |
2247 | 2247 | |
2248 | 2248 | echo '<a href="blog.php?'.api_get_cidreq( |
@@ -2250,12 +2250,12 @@ discard block |
||
2250 | 2250 | echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
2251 | 2251 | 'UnSelectAll' |
2252 | 2252 | ).'</a> '; |
2253 | - echo get_lang('WithSelected') . ' : '; |
|
2253 | + echo get_lang('WithSelected').' : '; |
|
2254 | 2254 | echo '<select name="action">'; |
2255 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2255 | + echo '<option value="select_subscribe">'.get_lang('Register').'</option>'; |
|
2256 | 2256 | echo '</select>'; |
2257 | 2257 | echo '<input type="hidden" name="register" value="true" />'; |
2258 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2258 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
2259 | 2259 | echo '</form>'; |
2260 | 2260 | } |
2261 | 2261 | |
@@ -2268,7 +2268,7 @@ discard block |
||
2268 | 2268 | * |
2269 | 2269 | * @return Html Form with sortable table with users to unsubcribe from a blog. |
2270 | 2270 | */ |
2271 | - public static function display_form_user_unsubscribe ($blog_id) |
|
2271 | + public static function display_form_user_unsubscribe($blog_id) |
|
2272 | 2272 | { |
2273 | 2273 | $_user = api_get_user_info(); |
2274 | 2274 | $is_western_name_order = api_is_western_name_order(); |
@@ -2281,34 +2281,34 @@ discard block |
||
2281 | 2281 | |
2282 | 2282 | $properties["width"] = "100%"; |
2283 | 2283 | //table column titles |
2284 | - $column_header[] = array ('', false, ''); |
|
2284 | + $column_header[] = array('', false, ''); |
|
2285 | 2285 | if ($is_western_name_order) { |
2286 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2287 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2286 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2287 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2288 | 2288 | } else { |
2289 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2290 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2289 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2290 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2291 | 2291 | } |
2292 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
2293 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2294 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2292 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
2293 | + $column_header[] = array(get_lang('TaskManager'), true, ''); |
|
2294 | + $column_header[] = array(get_lang('UnRegister'), false, ''); |
|
2295 | 2295 | |
2296 | 2296 | $course_id = api_get_course_int_id(); |
2297 | 2297 | |
2298 | 2298 | $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
2299 | 2299 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2300 | 2300 | ON user.user_id = blogs_rel_user.user_id |
2301 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
2301 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
2302 | 2302 | |
2303 | 2303 | if (!($sql_result = Database::query($sql))) { |
2304 | 2304 | return false; |
2305 | 2305 | } |
2306 | 2306 | |
2307 | - $user_data = array (); |
|
2307 | + $user_data = array(); |
|
2308 | 2308 | |
2309 | 2309 | while ($myrow = Database::fetch_array($sql_result)) { |
2310 | - $row = array (); |
|
2311 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2310 | + $row = array(); |
|
2311 | + $row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>'; |
|
2312 | 2312 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
2313 | 2313 | if ($is_western_name_order) { |
2314 | 2314 | $row[] = $myrow["firstname"]; |
@@ -2320,19 +2320,19 @@ discard block |
||
2320 | 2320 | $row[] = Display::icon_mailto_link($myrow["email"]); |
2321 | 2321 | |
2322 | 2322 | $sql = "SELECT bt.title task |
2323 | - FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
|
2324 | - INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
|
2323 | + FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu |
|
2324 | + INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt |
|
2325 | 2325 | ON btu.task_id = bt.task_id |
2326 | 2326 | WHERE btu.c_id = $course_id AND |
2327 | 2327 | bt.c_id = $course_id AND |
2328 | 2328 | btu.blog_id = $blog_id AND |
2329 | - btu.user_id = " . $myrow['user_id']; |
|
2329 | + btu.user_id = ".$myrow['user_id']; |
|
2330 | 2330 | $sql_res = Database::query($sql); |
2331 | 2331 | |
2332 | 2332 | $task = ''; |
2333 | 2333 | |
2334 | - while($r = Database::fetch_array($sql_res)) { |
|
2335 | - $task .= stripslashes($r['task']) . ', '; |
|
2334 | + while ($r = Database::fetch_array($sql_res)) { |
|
2335 | + $task .= stripslashes($r['task']).', '; |
|
2336 | 2336 | } |
2337 | 2337 | //echo $task; |
2338 | 2338 | $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
@@ -2340,7 +2340,7 @@ discard block |
||
2340 | 2340 | //Link to register users |
2341 | 2341 | |
2342 | 2342 | if ($myrow["user_id"] != $_user['user_id']) { |
2343 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2343 | + $row[] = "<a class=\"btn btn-primary\" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=".$myrow['user_id']."\">".get_lang('UnRegister')."</a>"; |
|
2344 | 2344 | } else { |
2345 | 2345 | $row[] = ''; |
2346 | 2346 | } |
@@ -2352,9 +2352,9 @@ discard block |
||
2352 | 2352 | $query_vars['blog_id'] = $blog_id; |
2353 | 2353 | echo '<form method="post" action="blog.php?'.api_get_cidreq( |
2354 | 2354 | ).'&action=manage_members&blog_id='.$blog_id.'">'; |
2355 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2355 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
2356 | 2356 | $link = ''; |
2357 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2357 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
2358 | 2358 | $link .= "blog_id=$blog_id&"; |
2359 | 2359 | |
2360 | 2360 | echo '<a href="blog.php?'.api_get_cidreq( |
@@ -2364,12 +2364,12 @@ discard block |
||
2364 | 2364 | echo '<a href="blog.php?'.api_get_cidreq().'&'.$link.'">'.get_lang( |
2365 | 2365 | 'UnSelectAll' |
2366 | 2366 | ).'</a> '; |
2367 | - echo get_lang('WithSelected') . ' : '; |
|
2367 | + echo get_lang('WithSelected').' : '; |
|
2368 | 2368 | echo '<select name="action">'; |
2369 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2369 | + echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>'; |
|
2370 | 2370 | echo '</select>'; |
2371 | 2371 | echo '<input type="hidden" name="unregister" value="true" />'; |
2372 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2372 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
2373 | 2373 | echo '</form>'; |
2374 | 2374 | } |
2375 | 2375 | |
@@ -2379,7 +2379,7 @@ discard block |
||
2379 | 2379 | * |
2380 | 2380 | * @param Integer $blog_id |
2381 | 2381 | */ |
2382 | - public static function display_form_user_rights ($blog_id) |
|
2382 | + public static function display_form_user_rights($blog_id) |
|
2383 | 2383 | { |
2384 | 2384 | echo '<legend>'.get_lang('RightsManager').'</legend>'; |
2385 | 2385 | echo '<br />'; |
@@ -2399,7 +2399,7 @@ discard block |
||
2399 | 2399 | $form = new FormValidator( |
2400 | 2400 | 'add_post', |
2401 | 2401 | 'post', |
2402 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2402 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=".intval($blog_id)."&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2403 | 2403 | null, |
2404 | 2404 | array('enctype' => 'multipart/form-data') |
2405 | 2405 | ); |
@@ -2467,14 +2467,14 @@ discard block |
||
2467 | 2467 | $course_id = api_get_course_int_id(); |
2468 | 2468 | |
2469 | 2469 | //Handle leap year |
2470 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2470 | + $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2471 | 2471 | |
2472 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2472 | + if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2473 | 2473 | $numberofdays[2] = 29; |
2474 | 2474 | |
2475 | 2475 | //Get the first day of the month |
2476 | 2476 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
2477 | - $monthName = $MonthsLong[$month-1]; |
|
2477 | + $monthName = $MonthsLong[$month - 1]; |
|
2478 | 2478 | |
2479 | 2479 | //Start the week on monday |
2480 | 2480 | $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
@@ -2492,15 +2492,15 @@ discard block |
||
2492 | 2492 | ON post.author_id = user.user_id |
2493 | 2493 | WHERE |
2494 | 2494 | post.c_id = $course_id AND |
2495 | - post.blog_id = '".(int)$blog_id."' AND |
|
2496 | - MONTH(date_creation) = '".(int)$month."' AND |
|
2497 | - YEAR(date_creation) = '".(int)$year."' |
|
2495 | + post.blog_id = '".(int) $blog_id."' AND |
|
2496 | + MONTH(date_creation) = '".(int) $month."' AND |
|
2497 | + YEAR(date_creation) = '".(int) $year."' |
|
2498 | 2498 | ORDER BY date_creation"; |
2499 | 2499 | $result = Database::query($sql); |
2500 | 2500 | |
2501 | 2501 | // We will create an array of days on which there are posts. |
2502 | - if( Database::num_rows($result) > 0) { |
|
2503 | - while($blog_post = Database::fetch_array($result)) { |
|
2502 | + if (Database::num_rows($result) > 0) { |
|
2503 | + while ($blog_post = Database::fetch_array($result)) { |
|
2504 | 2504 | // If the day of this post is not yet in the array, add it. |
2505 | 2505 | if (!in_array($blog_post['post_day'], $posts)) |
2506 | 2506 | $posts[] = $blog_post['post_day']; |
@@ -2517,9 +2517,9 @@ discard block |
||
2517 | 2517 | task_rel_user.c_id = $course_id AND |
2518 | 2518 | task.c_id = $course_id AND |
2519 | 2519 | blog.c_id = $course_id AND |
2520 | - task_rel_user.user_id = '".(int)$_user['user_id']."' AND |
|
2521 | - MONTH(target_date) = '".(int)$month."' AND |
|
2522 | - YEAR(target_date) = '".(int)$year."' |
|
2520 | + task_rel_user.user_id = '".(int) $_user['user_id']."' AND |
|
2521 | + MONTH(target_date) = '".(int) $month."' AND |
|
2522 | + YEAR(target_date) = '".(int) $year."' |
|
2523 | 2523 | ORDER BY target_date ASC"; |
2524 | 2524 | $result = Database::query($sql); |
2525 | 2525 | |
@@ -2542,7 +2542,7 @@ discard block |
||
2542 | 2542 | |
2543 | 2543 | echo "<tr>\n"; |
2544 | 2544 | |
2545 | - for($ii = 1; $ii < 8; $ii ++) |
|
2545 | + for ($ii = 1; $ii < 8; $ii++) |
|
2546 | 2546 | echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
2547 | 2547 | |
2548 | 2548 | echo "</tr>"; |
@@ -2552,23 +2552,23 @@ discard block |
||
2552 | 2552 | |
2553 | 2553 | while ($curday <= $numberofdays[$month]) { |
2554 | 2554 | echo "<tr>"; |
2555 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
2555 | + for ($ii = 0; $ii < 7; $ii++) { |
|
2556 | 2556 | if (($curday == -1) && ($ii == $startdayofweek)) |
2557 | 2557 | $curday = 1; |
2558 | 2558 | |
2559 | 2559 | if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
2560 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2560 | + $bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\""; |
|
2561 | 2561 | $dayheader = "$curday"; |
2562 | 2562 | |
2563 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2563 | + if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2564 | 2564 | $dayheader = "$curday"; |
2565 | 2565 | $class = "class=\"days_today\""; |
2566 | 2566 | } |
2567 | 2567 | |
2568 | - echo "<td " . $class.">"; |
|
2568 | + echo "<td ".$class.">"; |
|
2569 | 2569 | |
2570 | 2570 | // If there are posts on this day, create a filter link. |
2571 | - if(in_array($curday, $posts)) |
|
2571 | + if (in_array($curday, $posts)) |
|
2572 | 2572 | echo '<a href="blog.php?'.api_get_cidreq( |
2573 | 2573 | ).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang( |
2574 | 2574 | 'ViewPostsOfThisDay' |
@@ -2589,13 +2589,13 @@ discard block |
||
2589 | 2589 | ).' : '.$task['blog_name'].' - '.get_lang( |
2590 | 2590 | 'ExecuteThisTask' |
2591 | 2591 | ).'"> |
2592 | - <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; |
|
2592 | + <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask').'" /></a>'; |
|
2593 | 2593 | } |
2594 | 2594 | } |
2595 | 2595 | } |
2596 | 2596 | |
2597 | 2597 | echo "</td>"; |
2598 | - $curday ++; |
|
2598 | + $curday++; |
|
2599 | 2599 | } else |
2600 | 2600 | echo "<td> </td>"; |
2601 | 2601 | } |
@@ -2636,7 +2636,7 @@ discard block |
||
2636 | 2636 | public static function display_edit_blog_form($blog_id) |
2637 | 2637 | { |
2638 | 2638 | $course_id = api_get_course_int_id(); |
2639 | - $blog_id= intval($blog_id); |
|
2639 | + $blog_id = intval($blog_id); |
|
2640 | 2640 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
2641 | 2641 | |
2642 | 2642 | $sql = "SELECT blog_id, blog_name, blog_subtitle |
@@ -2694,8 +2694,8 @@ discard block |
||
2694 | 2694 | $result = Database::query($sql); |
2695 | 2695 | $list_info = array(); |
2696 | 2696 | if (Database::num_rows($result)) { |
2697 | - while ($row_project=Database::fetch_row($result)) { |
|
2698 | - $list_info[]=$row_project; |
|
2697 | + while ($row_project = Database::fetch_row($result)) { |
|
2698 | + $list_info[] = $row_project; |
|
2699 | 2699 | } |
2700 | 2700 | } |
2701 | 2701 | |
@@ -2707,44 +2707,44 @@ discard block |
||
2707 | 2707 | // Validation when belongs to a session |
2708 | 2708 | $session_img = api_get_session_image($info_log[4], $_user['status']); |
2709 | 2709 | |
2710 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2710 | + $url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq(); |
|
2711 | 2711 | $title = $info_log[0]; |
2712 | 2712 | $image = Display::return_icon( |
2713 | 2713 | 'blog.gif' |
2714 | - );//'<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">'; |
|
2715 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2714 | + ); //'<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">'; |
|
2715 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">'.$image.'</a></div><a href="'.$url_start_blog.'">'.$title.'</a>'.$session_img; |
|
2716 | 2716 | |
2717 | 2717 | $list_body_blog[] = $list_name; |
2718 | 2718 | $list_body_blog[] = $info_log[1]; |
2719 | 2719 | |
2720 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2721 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2722 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2720 | + $visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible'; |
|
2721 | + $visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible'; |
|
2722 | + $my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">'; |
|
2723 | 2723 | $my_image .= Display::return_icon( |
2724 | 2724 | 'edit.png' |
2725 | - );//'<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />'; |
|
2726 | - $my_image.= "</a>\n"; |
|
2727 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2728 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2725 | + ); //'<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />'; |
|
2726 | + $my_image .= "</a>\n"; |
|
2727 | + $my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" '; |
|
2728 | + $my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >'; |
|
2729 | 2729 | $my_image .= Display::return_icon( |
2730 | 2730 | 'delete.png' |
2731 | 2731 | ); //'<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />'; |
2732 | - $my_image.= "</a>\n"; |
|
2733 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2732 | + $my_image .= "</a>\n"; |
|
2733 | + $my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">'; |
|
2734 | 2734 | $my_image .= Display::return_icon( |
2735 | 2735 | $visibility_icon.'.png' |
2736 | - );//'<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />'; |
|
2737 | - $my_image.= "</a>\n"; |
|
2736 | + ); //'<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />'; |
|
2737 | + $my_image .= "</a>\n"; |
|
2738 | 2738 | |
2739 | - $list_body_blog[]=$my_image; |
|
2739 | + $list_body_blog[] = $my_image; |
|
2740 | 2740 | |
2741 | - $list_content_blog[]=$list_body_blog; |
|
2741 | + $list_content_blog[] = $list_body_blog; |
|
2742 | 2742 | $list_body_blog = array(); |
2743 | 2743 | |
2744 | 2744 | } |
2745 | - $parameters=''; |
|
2745 | + $parameters = ''; |
|
2746 | 2746 | //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
2747 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2747 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project'); |
|
2748 | 2748 | //$table->set_additional_parameters($parameters); |
2749 | 2749 | $table->set_header(0, get_lang('Title')); |
2750 | 2750 | $table->set_header(1, get_lang('SubTitle')); |
@@ -2769,34 +2769,34 @@ discard block |
||
2769 | 2769 | * @author Julio Montoya Dokeos |
2770 | 2770 | * @version avril 2008, dokeos 1.8.5 |
2771 | 2771 | */ |
2772 | -function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
|
2772 | +function get_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
2773 | 2773 | { |
2774 | 2774 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
2775 | 2775 | |
2776 | 2776 | $blog_id = intval($blog_id); |
2777 | 2777 | $comment_id = intval($comment_id); |
2778 | 2778 | $post_id = intval($post_id); |
2779 | - $row=array(); |
|
2780 | - $where=''; |
|
2779 | + $row = array(); |
|
2780 | + $where = ''; |
|
2781 | 2781 | if (!empty ($post_id) && is_numeric($post_id)) { |
2782 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2782 | + $where .= ' AND post_id ="'.$post_id.'" '; |
|
2783 | 2783 | } |
2784 | 2784 | |
2785 | 2785 | if (!empty ($comment_id) && is_numeric($comment_id)) { |
2786 | 2786 | if (!empty ($post_id)) { |
2787 | - $where.= ' AND '; |
|
2787 | + $where .= ' AND '; |
|
2788 | 2788 | } |
2789 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2789 | + $where .= ' comment_id ="'.$comment_id.'" '; |
|
2790 | 2790 | } |
2791 | 2791 | |
2792 | 2792 | $course_id = api_get_course_int_id(); |
2793 | 2793 | |
2794 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2794 | + $sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.' |
|
2795 | 2795 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2796 | 2796 | |
2797 | - $result=Database::query($sql); |
|
2798 | - if (Database::num_rows($result)!=0) { |
|
2799 | - $row=Database::fetch_array($result); |
|
2797 | + $result = Database::query($sql); |
|
2798 | + if (Database::num_rows($result) != 0) { |
|
2799 | + $row = Database::fetch_array($result); |
|
2800 | 2800 | } |
2801 | 2801 | return $row; |
2802 | 2802 | } |
@@ -2810,7 +2810,7 @@ discard block |
||
2810 | 2810 | * @version avril 2008, dokeos 1.8.5 |
2811 | 2811 | */ |
2812 | 2812 | |
2813 | -function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
|
2813 | +function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
2814 | 2814 | { |
2815 | 2815 | $_course = api_get_course_info(); |
2816 | 2816 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
@@ -2834,22 +2834,22 @@ discard block |
||
2834 | 2834 | } |
2835 | 2835 | |
2836 | 2836 | // delete all files in directory |
2837 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2837 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2838 | 2838 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
2839 | 2839 | $updir = $sys_course_path.$courseDir; |
2840 | 2840 | |
2841 | 2841 | $sql = 'SELECT path FROM '.$blog_table_attachment.' |
2842 | 2842 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2843 | - $result=Database::query($sql); |
|
2843 | + $result = Database::query($sql); |
|
2844 | 2844 | |
2845 | - while ($row=Database::fetch_row($result)) { |
|
2846 | - $file=$updir.'/'.$row[0]; |
|
2847 | - if (Security::check_abs_path($file,$updir) ) |
|
2845 | + while ($row = Database::fetch_row($result)) { |
|
2846 | + $file = $updir.'/'.$row[0]; |
|
2847 | + if (Security::check_abs_path($file, $updir)) |
|
2848 | 2848 | { |
2849 | 2849 | @ unlink($file); |
2850 | 2850 | } |
2851 | 2851 | } |
2852 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2852 | + $sql = 'DELETE FROM '.$blog_table_attachment.' |
|
2853 | 2853 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2854 | 2854 | Database::query($sql); |
2855 | 2855 | } |
@@ -2862,8 +2862,8 @@ discard block |
||
2862 | 2862 | function get_blog_post_from_user($course_code, $user_id) |
2863 | 2863 | { |
2864 | 2864 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
2865 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2866 | - $course_info = api_get_course_info($course_code); |
|
2865 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2866 | + $course_info = api_get_course_info($course_code); |
|
2867 | 2867 | $course_id = $course_info['real_id']; |
2868 | 2868 | |
2869 | 2869 | $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
@@ -2878,17 +2878,17 @@ discard block |
||
2878 | 2878 | $result = Database::query($sql); |
2879 | 2879 | $return_data = ''; |
2880 | 2880 | |
2881 | - if (Database::num_rows($result)!=0) { |
|
2882 | - while ($row=Database::fetch_array($result)) { |
|
2883 | - $return_data.= '<div class="clear"></div><br />'; |
|
2881 | + if (Database::num_rows($result) != 0) { |
|
2882 | + while ($row = Database::fetch_array($result)) { |
|
2883 | + $return_data .= '<div class="clear"></div><br />'; |
|
2884 | 2884 | $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'. |
2885 | 2885 | Display::return_icon('blog_article.png', get_lang('BlogPosts')). |
2886 | 2886 | ' '.$row['title'].' <div style="float:right;margin-top:-18px"> |
2887 | 2887 | <a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq( |
2888 | 2888 | ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
2889 | - $return_data.= '<br / >'; |
|
2890 | - $return_data.= $row['full_text']; |
|
2891 | - $return_data.= '<br /><br />'; |
|
2889 | + $return_data .= '<br / >'; |
|
2890 | + $return_data .= $row['full_text']; |
|
2891 | + $return_data .= '<br /><br />'; |
|
2892 | 2892 | } |
2893 | 2893 | } |
2894 | 2894 | return $return_data; |
@@ -2918,16 +2918,16 @@ discard block |
||
2918 | 2918 | ORDER BY blog_name"; |
2919 | 2919 | $result = Database::query($sql); |
2920 | 2920 | $return_data = ''; |
2921 | - if (Database::num_rows($result)!=0) { |
|
2922 | - while ($row=Database::fetch_array($result)) { |
|
2923 | - $return_data.= '<div class="clear"></div><br />'; |
|
2921 | + if (Database::num_rows($result) != 0) { |
|
2922 | + while ($row = Database::fetch_array($result)) { |
|
2923 | + $return_data .= '<div class="clear"></div><br />'; |
|
2924 | 2924 | $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"> |
2925 | 2925 | <a href="../blog/blog.php?blog_id='.$row['blog_id'].'&'.api_get_cidreq( |
2926 | 2926 | ).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
2927 | - $return_data.= '<br / >'; |
|
2927 | + $return_data .= '<br / >'; |
|
2928 | 2928 | //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
2929 | - $return_data.= $row['comment']; |
|
2930 | - $return_data.= '<br />'; |
|
2929 | + $return_data .= $row['comment']; |
|
2930 | + $return_data .= '<br />'; |
|
2931 | 2931 | } |
2932 | 2932 | } |
2933 | 2933 | return $return_data; |
@@ -1025,16 +1025,17 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
1027 | 1027 | |
1028 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) |
|
1029 | - $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1028 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
1029 | + $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1030 | 1030 | ).'&action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1031 | 1031 | 'EditThisPost' |
1032 | 1032 | ).'"> |
1033 | 1033 | '.Display::return_icon('edit.png').' |
1034 | 1034 | </a>'; |
1035 | + } |
|
1035 | 1036 | |
1036 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) |
|
1037 | - $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1037 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
1038 | + $blog_post_actions .= '<a href="blog.php?'.api_get_cidreq( |
|
1038 | 1039 | ).'&action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1039 | 1040 | 'DeleteThisArticle' |
1040 | 1041 | ).'" onclick="javascript:if(!confirm(\''.addslashes( |
@@ -1047,9 +1048,11 @@ discard block |
||
1047 | 1048 | |
1048 | 1049 | '.Display::return_icon('delete.png').' |
1049 | 1050 | </a>'; |
1051 | + } |
|
1050 | 1052 | |
1051 | - if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1052 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1053 | + if(api_is_allowed('BLOG_' . $blog_id, 'article_rate')) { |
|
1054 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1055 | + } |
|
1053 | 1056 | |
1054 | 1057 | $blog_post_text=stripslashes($blog_post_text); |
1055 | 1058 | |
@@ -2469,8 +2472,9 @@ discard block |
||
2469 | 2472 | //Handle leap year |
2470 | 2473 | $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
2471 | 2474 | |
2472 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2473 | - $numberofdays[2] = 29; |
|
2475 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) { |
|
2476 | + $numberofdays[2] = 29; |
|
2477 | + } |
|
2474 | 2478 | |
2475 | 2479 | //Get the first day of the month |
2476 | 2480 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
@@ -2502,8 +2506,9 @@ discard block |
||
2502 | 2506 | if( Database::num_rows($result) > 0) { |
2503 | 2507 | while($blog_post = Database::fetch_array($result)) { |
2504 | 2508 | // If the day of this post is not yet in the array, add it. |
2505 | - if (!in_array($blog_post['post_day'], $posts)) |
|
2506 | - $posts[] = $blog_post['post_day']; |
|
2509 | + if (!in_array($blog_post['post_day'], $posts)) { |
|
2510 | + $posts[] = $blog_post['post_day']; |
|
2511 | + } |
|
2507 | 2512 | } |
2508 | 2513 | } |
2509 | 2514 | |
@@ -2542,8 +2547,9 @@ discard block |
||
2542 | 2547 | |
2543 | 2548 | echo "<tr>\n"; |
2544 | 2549 | |
2545 | - for($ii = 1; $ii < 8; $ii ++) |
|
2546 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2550 | + for($ii = 1; $ii < 8; $ii ++) { |
|
2551 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2552 | + } |
|
2547 | 2553 | |
2548 | 2554 | echo "</tr>"; |
2549 | 2555 | |
@@ -2553,8 +2559,9 @@ discard block |
||
2553 | 2559 | while ($curday <= $numberofdays[$month]) { |
2554 | 2560 | echo "<tr>"; |
2555 | 2561 | for ($ii = 0; $ii < 7; $ii ++) { |
2556 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
2557 | - $curday = 1; |
|
2562 | + if (($curday == -1) && ($ii == $startdayofweek)) { |
|
2563 | + $curday = 1; |
|
2564 | + } |
|
2558 | 2565 | |
2559 | 2566 | if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
2560 | 2567 | $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
@@ -2568,14 +2575,15 @@ discard block |
||
2568 | 2575 | echo "<td " . $class.">"; |
2569 | 2576 | |
2570 | 2577 | // If there are posts on this day, create a filter link. |
2571 | - if(in_array($curday, $posts)) |
|
2572 | - echo '<a href="blog.php?'.api_get_cidreq( |
|
2578 | + if(in_array($curday, $posts)) { |
|
2579 | + echo '<a href="blog.php?'.api_get_cidreq( |
|
2573 | 2580 | ).'&blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang( |
2574 | 2581 | 'ViewPostsOfThisDay' |
2575 | 2582 | ).'">'. |
2576 | 2583 | $curday.'</a>'; |
2577 | - else |
|
2578 | - echo $dayheader; |
|
2584 | + } else { |
|
2585 | + echo $dayheader; |
|
2586 | + } |
|
2579 | 2587 | |
2580 | 2588 | if (count($tasks) > 0) { |
2581 | 2589 | if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
@@ -2596,8 +2604,9 @@ discard block |
||
2596 | 2604 | |
2597 | 2605 | echo "</td>"; |
2598 | 2606 | $curday ++; |
2599 | - } else |
|
2600 | - echo "<td> </td>"; |
|
2607 | + } else { |
|
2608 | + echo "<td> </td>"; |
|
2609 | + } |
|
2601 | 2610 | } |
2602 | 2611 | echo "</tr>"; |
2603 | 2612 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Set the name of the browser |
161 | - * @param $browser string The name of the Browser |
|
161 | + * @param string $browser string The name of the Browser |
|
162 | 162 | */ |
163 | 163 | public function setBrowser($browser) |
164 | 164 | { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Set the browser to be from AOL |
269 | - * @param $isAol |
|
269 | + * @param boolean $isAol |
|
270 | 270 | */ |
271 | 271 | public function setAol($isAol) |
272 | 272 | { |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Is the browser from facebook? |
|
260 | - * @return boolean True if the browser is from facebook otherwise false |
|
261 | - */ |
|
259 | + * Is the browser from facebook? |
|
260 | + * @return boolean True if the browser is from facebook otherwise false |
|
261 | + */ |
|
262 | 262 | public function isFacebook() |
263 | 263 | { |
264 | 264 | return $this->_is_facebook; |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | - $this->setBrowser(self::BROWSER_IE); |
|
596 | - $result = explode('rv:', $this->_agent); |
|
597 | - $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | - } // Test for Pocket IE |
|
594 | + else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | + $this->setBrowser(self::BROWSER_IE); |
|
596 | + $result = explode('rv:', $this->_agent); |
|
597 | + $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | + $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | + } // Test for Pocket IE |
|
600 | 600 | else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) { |
601 | 601 | $aresult = explode(' ', stristr($this->_agent, 'mspie')); |
602 | 602 | $this->setPlatform(self::PLATFORM_WINDOWS_CE); |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function __toString() |
347 | 347 | { |
348 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
349 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
350 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
348 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
349 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
350 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
351 | 351 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
352 | 352 | } |
353 | 353 | |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); |
586 | 586 | $this->setBrowser(self::BROWSER_IE); |
587 | 587 | $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
588 | - if(stripos($this->_agent, 'IEMobile') !== false) { |
|
588 | + if (stripos($this->_agent, 'IEMobile') !== false) { |
|
589 | 589 | $this->setBrowser(self::BROWSER_POCKET_IE); |
590 | 590 | $this->setMobile(true); |
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
594 | + else if (stripos($this->_agent, 'trident') !== false) { |
|
595 | 595 | $this->setBrowser(self::BROWSER_IE); |
596 | 596 | $result = explode('rv:', $this->_agent); |
597 | 597 | $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | protected function checkFacebookExternalHit() |
1014 | 1014 | { |
1015 | - if(stristr($this->_agent,'FacebookExternalHit')) |
|
1015 | + if (stristr($this->_agent, 'FacebookExternalHit')) |
|
1016 | 1016 | { |
1017 | 1017 | $this->setRobot(true); |
1018 | 1018 | $this->setFacebook(true); |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | */ |
1028 | 1028 | protected function checkForFacebookIos() |
1029 | 1029 | { |
1030 | - if(stristr($this->_agent,'FBIOS')) |
|
1030 | + if (stristr($this->_agent, 'FBIOS')) |
|
1031 | 1031 | { |
1032 | 1032 | $this->setFacebook(true); |
1033 | 1033 | return true; |
@@ -1041,10 +1041,10 @@ discard block |
||
1041 | 1041 | */ |
1042 | 1042 | protected function getSafariVersionOnIos() |
1043 | 1043 | { |
1044 | - $aresult = explode('/',stristr($this->_agent,'Version')); |
|
1045 | - if( isset($aresult[1]) ) |
|
1044 | + $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
1045 | + if (isset($aresult[1])) |
|
1046 | 1046 | { |
1047 | - $aversion = explode(' ',$aresult[1]); |
|
1047 | + $aversion = explode(' ', $aresult[1]); |
|
1048 | 1048 | $this->setVersion($aversion[0]); |
1049 | 1049 | return true; |
1050 | 1050 | } |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | protected function getChromeVersionOnIos() |
1059 | 1059 | { |
1060 | - $aresult = explode('/',stristr($this->_agent,'CriOS')); |
|
1061 | - if( isset($aresult[1]) ) |
|
1060 | + $aresult = explode('/', stristr($this->_agent, 'CriOS')); |
|
1061 | + if (isset($aresult[1])) |
|
1062 | 1062 | { |
1063 | - $aversion = explode(' ',$aresult[1]); |
|
1063 | + $aversion = explode(' ', $aresult[1]); |
|
1064 | 1064 | $this->setVersion($aversion[0]); |
1065 | 1065 | $this->setBrowser(self::BROWSER_CHROME); |
1066 | 1066 | return true; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @return boolean True if the browser is iPhone otherwise false |
1074 | 1074 | */ |
1075 | 1075 | protected function checkBrowseriPhone() { |
1076 | - if( stripos($this->_agent,'iPhone') !== false ) { |
|
1076 | + if (stripos($this->_agent, 'iPhone') !== false) { |
|
1077 | 1077 | $this->setVersion(self::VERSION_UNKNOWN); |
1078 | 1078 | $this->setBrowser(self::BROWSER_IPHONE); |
1079 | 1079 | $this->getSafariVersionOnIos(); |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | * @return boolean True if the browser is iPad otherwise false |
1091 | 1091 | */ |
1092 | 1092 | protected function checkBrowseriPad() { |
1093 | - if( stripos($this->_agent,'iPad') !== false ) { |
|
1093 | + if (stripos($this->_agent, 'iPad') !== false) { |
|
1094 | 1094 | $this->setVersion(self::VERSION_UNKNOWN); |
1095 | 1095 | $this->setBrowser(self::BROWSER_IPAD); |
1096 | 1096 | $this->getSafariVersionOnIos(); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | * @return boolean True if the browser is iPod otherwise false |
1108 | 1108 | */ |
1109 | 1109 | protected function checkBrowseriPod() { |
1110 | - if( stripos($this->_agent,'iPod') !== false ) { |
|
1110 | + if (stripos($this->_agent, 'iPod') !== false) { |
|
1111 | 1111 | $this->setVersion(self::VERSION_UNKNOWN); |
1112 | 1112 | $this->setBrowser(self::BROWSER_IPOD); |
1113 | 1113 | $this->getSafariVersionOnIos(); |
@@ -1152,68 +1152,52 @@ |
||
1152 | 1152 | if (stripos($this->_agent, 'windows') !== false) |
1153 | 1153 | { |
1154 | 1154 | $this->_platform = self::PLATFORM_WINDOWS; |
1155 | - } |
|
1156 | - else if (stripos($this->_agent, 'iPad') !== false) |
|
1155 | + } else if (stripos($this->_agent, 'iPad') !== false) |
|
1157 | 1156 | { |
1158 | 1157 | $this->_platform = self::PLATFORM_IPAD; |
1159 | - } |
|
1160 | - else if (stripos($this->_agent, 'iPod') !== false) |
|
1158 | + } else if (stripos($this->_agent, 'iPod') !== false) |
|
1161 | 1159 | { |
1162 | 1160 | $this->_platform = self::PLATFORM_IPOD; |
1163 | - } |
|
1164 | - else if (stripos($this->_agent, 'iPhone') !== false) |
|
1161 | + } else if (stripos($this->_agent, 'iPhone') !== false) |
|
1165 | 1162 | { |
1166 | 1163 | $this->_platform = self::PLATFORM_IPHONE; |
1167 | - } |
|
1168 | - elseif (stripos($this->_agent, 'mac') !== false) |
|
1164 | + } elseif (stripos($this->_agent, 'mac') !== false) |
|
1169 | 1165 | { |
1170 | 1166 | $this->_platform = self::PLATFORM_APPLE; |
1171 | - } |
|
1172 | - elseif (stripos($this->_agent, 'android') !== false) |
|
1167 | + } elseif (stripos($this->_agent, 'android') !== false) |
|
1173 | 1168 | { |
1174 | 1169 | $this->_platform = self::PLATFORM_ANDROID; |
1175 | - } |
|
1176 | - elseif (stripos($this->_agent, 'linux') !== false) |
|
1170 | + } elseif (stripos($this->_agent, 'linux') !== false) |
|
1177 | 1171 | { |
1178 | 1172 | $this->_platform = self::PLATFORM_LINUX; |
1179 | - } |
|
1180 | - else if (stripos($this->_agent, 'Nokia') !== false) |
|
1173 | + } else if (stripos($this->_agent, 'Nokia') !== false) |
|
1181 | 1174 | { |
1182 | 1175 | $this->_platform = self::PLATFORM_NOKIA; |
1183 | - } |
|
1184 | - else if (stripos($this->_agent, 'BlackBerry') !== false) |
|
1176 | + } else if (stripos($this->_agent, 'BlackBerry') !== false) |
|
1185 | 1177 | { |
1186 | 1178 | $this->_platform = self::PLATFORM_BLACKBERRY; |
1187 | - } |
|
1188 | - elseif (stripos($this->_agent, 'FreeBSD') !== false) |
|
1179 | + } elseif (stripos($this->_agent, 'FreeBSD') !== false) |
|
1189 | 1180 | { |
1190 | 1181 | $this->_platform = self::PLATFORM_FREEBSD; |
1191 | - } |
|
1192 | - elseif (stripos($this->_agent, 'OpenBSD') !== false) |
|
1182 | + } elseif (stripos($this->_agent, 'OpenBSD') !== false) |
|
1193 | 1183 | { |
1194 | 1184 | $this->_platform = self::PLATFORM_OPENBSD; |
1195 | - } |
|
1196 | - elseif (stripos($this->_agent, 'NetBSD') !== false) |
|
1185 | + } elseif (stripos($this->_agent, 'NetBSD') !== false) |
|
1197 | 1186 | { |
1198 | 1187 | $this->_platform = self::PLATFORM_NETBSD; |
1199 | - } |
|
1200 | - elseif (stripos($this->_agent, 'OpenSolaris') !== false) |
|
1188 | + } elseif (stripos($this->_agent, 'OpenSolaris') !== false) |
|
1201 | 1189 | { |
1202 | 1190 | $this->_platform = self::PLATFORM_OPENSOLARIS; |
1203 | - } |
|
1204 | - elseif (stripos($this->_agent, 'SunOS') !== false) |
|
1191 | + } elseif (stripos($this->_agent, 'SunOS') !== false) |
|
1205 | 1192 | { |
1206 | 1193 | $this->_platform = self::PLATFORM_SUNOS; |
1207 | - } |
|
1208 | - elseif (stripos($this->_agent, 'OS\/2') !== false) |
|
1194 | + } elseif (stripos($this->_agent, 'OS\/2') !== false) |
|
1209 | 1195 | { |
1210 | 1196 | $this->_platform = self::PLATFORM_OS2; |
1211 | - } |
|
1212 | - elseif (stripos($this->_agent, 'BeOS') !== false) |
|
1197 | + } elseif (stripos($this->_agent, 'BeOS') !== false) |
|
1213 | 1198 | { |
1214 | 1199 | $this->_platform = self::PLATFORM_BEOS; |
1215 | - } |
|
1216 | - elseif (stripos($this->_agent, 'win') !== false) |
|
1200 | + } elseif (stripos($this->_agent, 'win') !== false) |
|
1217 | 1201 | { |
1218 | 1202 | $this->_platform = self::PLATFORM_WINDOWS; |
1219 | 1203 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * @return array |
|
87 | + * @return string[] |
|
88 | 88 | */ |
89 | 89 | public function get_status_list() |
90 | 90 | { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @todo the form should be auto generated |
97 | 97 | * @param string $url |
98 | 98 | * @param string $action add, edit |
99 | - * @return obj form validator obj |
|
99 | + * @return FormValidator form validator obj |
|
100 | 100 | */ |
101 | 101 | public function return_form($url, $action) |
102 | 102 | { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->table = Database::get_main_table(TABLE_CAREER); |
|
24 | + $this->table = Database::get_main_table(TABLE_CAREER); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $promotion = new Promotion(); |
63 | 63 | $promotion_list = $promotion->get_all_promotions_by_career_id($career_id); |
64 | 64 | if (!empty($promotion_list)) { |
65 | - foreach($promotion_list as $item) { |
|
65 | + foreach ($promotion_list as $item) { |
|
66 | 66 | $params['id'] = $item['id']; |
67 | 67 | $params['status'] = $status; |
68 | 68 | $promotion->update($params); |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | public function display() |
78 | 78 | { |
79 | 79 | echo '<div class="actions" style="margin-bottom:20px">'; |
80 | - echo '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>'; |
|
81 | - echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_career.png',get_lang('Add'),'','32').'</a>'; |
|
80 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', get_lang('Back'), '', '32').'</a>'; |
|
81 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_career.png', get_lang('Add'), '', '32').'</a>'; |
|
82 | 82 | echo '</div>'; |
83 | 83 | echo Display::grid_html('careers'); |
84 | 84 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | $form->freeze('created_at'); |
131 | 131 | } |
132 | 132 | if ($action == 'edit') { |
133 | - $form->addButtonSave(get_lang('Modify'),'submit'); |
|
133 | + $form->addButtonSave(get_lang('Modify'), 'submit'); |
|
134 | 134 | } else { |
135 | - $form->addButtonCreate(get_lang('Add'),'submit'); |
|
135 | + $form->addButtonCreate(get_lang('Add'), 'submit'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Setting the defaults |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | if ($copy_promotions) { |
185 | 185 | //Now also copy each session of the promotion as a new session and register it inside the promotion |
186 | 186 | $promotion = new Promotion(); |
187 | - $promo_list = $promotion->get_all_promotions_by_career_id($id); |
|
187 | + $promo_list = $promotion->get_all_promotions_by_career_id($id); |
|
188 | 188 | if (!empty($promo_list)) { |
189 | - foreach($promo_list as $item) { |
|
189 | + foreach ($promo_list as $item) { |
|
190 | 190 | $pid = $promotion->copy($item['id'], $cid, true); |
191 | 191 | } |
192 | 192 | } |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function get_status($career_id) |
203 | 203 | { |
204 | - $TBL_CAREER = Database::get_main_table(TABLE_CAREER); |
|
204 | + $TBL_CAREER = Database::get_main_table(TABLE_CAREER); |
|
205 | 205 | $career_id = intval($career_id); |
206 | - $sql = "SELECT status FROM $TBL_CAREER WHERE id = '$career_id'"; |
|
206 | + $sql = "SELECT status FROM $TBL_CAREER WHERE id = '$career_id'"; |
|
207 | 207 | $result = Database::query($sql); |
208 | 208 | if (Database::num_rows($result) > 0) { |
209 | 209 | $data = Database::fetch_array($result); |
@@ -41,6 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Set user chat status |
43 | 43 | * @param int 0 if disconnected, 1 if connected |
44 | + * @param integer $status |
|
44 | 45 | * |
45 | 46 | * @return void |
46 | 47 | */ |
@@ -164,6 +165,7 @@ discard block |
||
164 | 165 | /** |
165 | 166 | * Saves into session the fact that a chat window exists with the given user |
166 | 167 | * @param int The ID of the user with whom the current user is chatting |
168 | + * @param integer $user_id |
|
167 | 169 | * @return void |
168 | 170 | */ |
169 | 171 | public function save_window($user_id) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $to_user_id, |
187 | 187 | $message, |
188 | 188 | $printResult = true, |
189 | - $sanitize = true |
|
189 | + $sanitize = true |
|
190 | 190 | ) |
191 | 191 | { |
192 | 192 | $user_friend_relation = SocialManager::get_relation_between_contacts( |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $messagesan = $message; |
207 | 207 | } |
208 | 208 | |
209 | - error_log(print_r($sanitize) . '----' . $messagesan); |
|
209 | + error_log(print_r($sanitize).'----'.$messagesan); |
|
210 | 210 | |
211 | 211 | if (!isset($_SESSION['chatHistory'][$to_user_id])) { |
212 | 212 | $_SESSION['chatHistory'][$to_user_id] = array(); |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public static function disableChat() |
291 | 291 | { |
292 | - if (!empty($_SESSION['disable_chat'])){ |
|
292 | + if (!empty($_SESSION['disable_chat'])) { |
|
293 | 293 | $status = $_SESSION['disable_chat']; |
294 | - if ($status == true){ |
|
294 | + if ($status == true) { |
|
295 | 295 | $_SESSION['disable_chat'] = null; |
296 | 296 | return true; |
297 | 297 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | - * Set user chat status |
|
48 | - * @param int 0 if disconnected, 1 if connected |
|
47 | + * Set user chat status |
|
48 | + * @param int 0 if disconnected, 1 if connected |
|
49 | 49 | * |
50 | - * @return void |
|
51 | - */ |
|
50 | + * @return void |
|
51 | + */ |
|
52 | 52 | public function setUserStatus($status) |
53 | 53 | { |
54 | 54 | UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * Returns an array of messages inside a chat session with a specific user |
|
153 | - * @param int The ID of the user with whom the current user is chatting |
|
154 | - * @return array Messages list |
|
155 | - */ |
|
152 | + * Returns an array of messages inside a chat session with a specific user |
|
153 | + * @param int The ID of the user with whom the current user is chatting |
|
154 | + * @return array Messages list |
|
155 | + */ |
|
156 | 156 | public function box_session($user_id) |
157 | 157 | { |
158 | 158 | $items = array(); |