@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @param string $color |
| 566 | 566 | * @param bool $addAnnouncement |
| 567 | 567 | * |
| 568 | - * @return bool |
|
| 568 | + * @return null|false |
|
| 569 | 569 | */ |
| 570 | 570 | public function editEvent( |
| 571 | 571 | $id, |
@@ -1308,6 +1308,7 @@ discard block |
||
| 1308 | 1308 | * |
| 1309 | 1309 | * @param int $eventId |
| 1310 | 1310 | * @param int $courseId |
| 1311 | + * @param integer $sessionId |
|
| 1311 | 1312 | * @paraù int $sessionId |
| 1312 | 1313 | * |
| 1313 | 1314 | * @return array |
@@ -2469,6 +2470,7 @@ discard block |
||
| 2469 | 2470 | * Adds x weeks to a UNIX timestamp |
| 2470 | 2471 | * @param int The timestamp |
| 2471 | 2472 | * @param int The number of weeks to add |
| 2473 | + * @param integer $timestamp |
|
| 2472 | 2474 | * @return int The new timestamp |
| 2473 | 2475 | */ |
| 2474 | 2476 | function addWeek($timestamp, $num = 1) |
@@ -2480,6 +2482,7 @@ discard block |
||
| 2480 | 2482 | * Adds x months to a UNIX timestamp |
| 2481 | 2483 | * @param int The timestamp |
| 2482 | 2484 | * @param int The number of years to add |
| 2485 | + * @param integer $timestamp |
|
| 2483 | 2486 | * @return int The new timestamp |
| 2484 | 2487 | */ |
| 2485 | 2488 | function addMonth($timestamp, $num = 1) |
@@ -2498,6 +2501,7 @@ discard block |
||
| 2498 | 2501 | * Adds x years to a UNIX timestamp |
| 2499 | 2502 | * @param int The timestamp |
| 2500 | 2503 | * @param int The number of years to add |
| 2504 | + * @param integer $timestamp |
|
| 2501 | 2505 | * @return int The new timestamp |
| 2502 | 2506 | */ |
| 2503 | 2507 | function addYear($timestamp, $num = 1) |
@@ -2697,7 +2701,7 @@ discard block |
||
| 2697 | 2701 | /** |
| 2698 | 2702 | * @param array $courseInfo |
| 2699 | 2703 | * @param $file |
| 2700 | - * @return array|bool|string |
|
| 2704 | + * @return false|string |
|
| 2701 | 2705 | */ |
| 2702 | 2706 | public function importEventFile($courseInfo, $file) |
| 2703 | 2707 | { |
@@ -2810,7 +2814,7 @@ discard block |
||
| 2810 | 2814 | |
| 2811 | 2815 | /** |
| 2812 | 2816 | * Parse filter turns USER:12 to ['users' => [12])] or G:1 ['groups' => [1]] |
| 2813 | - * @param $filter |
|
| 2817 | + * @param integer $filter |
|
| 2814 | 2818 | * @return array |
| 2815 | 2819 | */ |
| 2816 | 2820 | public function parseAgendaFilter($filter) |
@@ -3324,6 +3328,7 @@ discard block |
||
| 3324 | 3328 | * @param int user ID of the user |
| 3325 | 3329 | * @param string Optional start date in datetime format (if no start date is given, uses today) |
| 3326 | 3330 | * @param string Optional end date in datetime format (if no date is given, uses one year from now) |
| 3331 | + * @param integer $user_id |
|
| 3327 | 3332 | * @return array Array of events ordered by start date, in |
| 3328 | 3333 | * [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format, |
| 3329 | 3334 | * where datestart and dateend are in yyyyMMddhhmmss format. |
@@ -1499,12 +1499,12 @@ discard block |
||
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | if (empty($session_id)) { |
| 1502 | - $sessionCondition = " |
|
| 1502 | + $sessionCondition = " |
|
| 1503 | 1503 | ( |
| 1504 | 1504 | agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0) |
| 1505 | 1505 | ) "; |
| 1506 | 1506 | } else { |
| 1507 | - $sessionCondition = " |
|
| 1507 | + $sessionCondition = " |
|
| 1508 | 1508 | ( |
| 1509 | 1509 | agenda.session_id = $session_id AND |
| 1510 | 1510 | ip.session_id = $session_id |
@@ -1543,13 +1543,13 @@ discard block |
||
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | if (empty($session_id)) { |
| 1546 | - $sessionCondition = " |
|
| 1546 | + $sessionCondition = " |
|
| 1547 | 1547 | ( |
| 1548 | 1548 | agenda.session_id = 0 AND |
| 1549 | 1549 | (ip.session_id IS NULL OR ip.session_id = 0) |
| 1550 | 1550 | ) "; |
| 1551 | 1551 | } else { |
| 1552 | - $sessionCondition = " |
|
| 1552 | + $sessionCondition = " |
|
| 1553 | 1553 | ( |
| 1554 | 1554 | agenda.session_id = $session_id AND |
| 1555 | 1555 | ip.session_id = $session_id |
@@ -1601,7 +1601,7 @@ discard block |
||
| 1601 | 1601 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
| 1602 | 1602 | $event = array(); |
| 1603 | 1603 | $event['id'] = 'course_'.$row['id']; |
| 1604 | - $event['unique_id'] = $row['iid']; |
|
| 1604 | + $event['unique_id'] = $row['iid']; |
|
| 1605 | 1605 | // To avoid doubles |
| 1606 | 1606 | if (in_array($event['unique_id'], $eventsAdded)) { |
| 1607 | 1607 | continue; |
@@ -2151,7 +2151,7 @@ discard block |
||
| 2151 | 2151 | ); |
| 2152 | 2152 | |
| 2153 | 2153 | $form->addLabel('', |
| 2154 | - '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span> ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')'); |
|
| 2154 | + '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span> ('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')'); |
|
| 2155 | 2155 | |
| 2156 | 2156 | |
| 2157 | 2157 | //if ($showAttachmentForm) { |
@@ -2729,8 +2729,8 @@ discard block |
||
| 2729 | 2729 | |
| 2730 | 2730 | $startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e')); |
| 2731 | 2731 | $endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e')); |
| 2732 | - $title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8'); |
|
| 2733 | - $description = api_convert_encoding((string)$event->description, $charset, 'UTF-8'); |
|
| 2732 | + $title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8'); |
|
| 2733 | + $description = api_convert_encoding((string) $event->description, $charset, 'UTF-8'); |
|
| 2734 | 2734 | |
| 2735 | 2735 | $id = $this->addEvent( |
| 2736 | 2736 | $startDateTime, |
@@ -2872,7 +2872,7 @@ discard block |
||
| 2872 | 2872 | ORDER BY start_date "; |
| 2873 | 2873 | } else { |
| 2874 | 2874 | // if the user is not an administrator of that course |
| 2875 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
| 2875 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
| 2876 | 2876 | $sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref |
| 2877 | 2877 | FROM ".$TABLEAGENDA." agenda, |
| 2878 | 2878 | ".$TABLE_ITEMPROPERTY." ip |
@@ -2902,14 +2902,14 @@ discard block |
||
| 2902 | 2902 | $agendaday = -1; |
| 2903 | 2903 | if ($item['start_date'] != '0000-00-00 00:00:00') { |
| 2904 | 2904 | $item['start_date'] = api_get_local_time($item['start_date']); |
| 2905 | - $item['start_date_tms'] = api_strtotime($item['start_date']); |
|
| 2905 | + $item['start_date_tms'] = api_strtotime($item['start_date']); |
|
| 2906 | 2906 | $agendaday = date("j", $item['start_date_tms']); |
| 2907 | 2907 | } |
| 2908 | 2908 | if ($item['end_date'] != '0000-00-00 00:00:00') { |
| 2909 | 2909 | $item['end_date'] = api_get_local_time($item['end_date']); |
| 2910 | 2910 | } |
| 2911 | 2911 | |
| 2912 | - $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
|
| 2912 | + $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
|
| 2913 | 2913 | |
| 2914 | 2914 | $item['url'] = $url; |
| 2915 | 2915 | $item['course_name'] = $array_course_info['title']; |
@@ -2921,9 +2921,9 @@ discard block |
||
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | 2923 | // sorting by hour for every day |
| 2924 | - $agendaitems = array (); |
|
| 2924 | + $agendaitems = array(); |
|
| 2925 | 2925 | while (list ($agendaday, $tmpitems) = each($items)) { |
| 2926 | - if(!isset($agendaitems[$agendaday])) { |
|
| 2926 | + if (!isset($agendaitems[$agendaday])) { |
|
| 2927 | 2927 | $agendaitems[$agendaday] = ''; |
| 2928 | 2928 | } |
| 2929 | 2929 | sort($tmpitems); |
@@ -3097,9 +3097,9 @@ discard block |
||
| 3097 | 3097 | $end_year = $start_end_day_of_week['end']['year']; |
| 3098 | 3098 | // in sql statements you have to use year-month-day for date calculations |
| 3099 | 3099 | $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00"; |
| 3100 | - $start_filter = api_get_utc_datetime($start_filter); |
|
| 3100 | + $start_filter = api_get_utc_datetime($start_filter); |
|
| 3101 | 3101 | $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59"; |
| 3102 | - $end_filter = api_get_utc_datetime($end_filter); |
|
| 3102 | + $end_filter = api_get_utc_datetime($end_filter); |
|
| 3103 | 3103 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; |
| 3104 | 3104 | } |
| 3105 | 3105 | // 3. creating the SQL statement for getting the personal agenda items in DAY view |
@@ -3107,18 +3107,18 @@ discard block |
||
| 3107 | 3107 | // we are in day view |
| 3108 | 3108 | // we could use mysql date() function but this is only available from 4.1 and higher |
| 3109 | 3109 | $start_filter = $year."-".$month."-".$day." 00:00:00"; |
| 3110 | - $start_filter = api_get_utc_datetime($start_filter); |
|
| 3110 | + $start_filter = api_get_utc_datetime($start_filter); |
|
| 3111 | 3111 | $end_filter = $year."-".$month."-".$day." 23:59:59"; |
| 3112 | - $end_filter = api_get_utc_datetime($end_filter); |
|
| 3112 | + $end_filter = api_get_utc_datetime($end_filter); |
|
| 3113 | 3113 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'"; |
| 3114 | 3114 | } |
| 3115 | 3115 | |
| 3116 | 3116 | $result = Database::query($sql); |
| 3117 | 3117 | while ($item = Database::fetch_array($result, 'ASSOC')) { |
| 3118 | 3118 | |
| 3119 | - $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT); |
|
| 3120 | - $item['date'] = api_get_local_time($item['date']); |
|
| 3121 | - $item['start_date_tms'] = api_strtotime($item['date']); |
|
| 3119 | + $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT); |
|
| 3120 | + $item['date'] = api_get_local_time($item['date']); |
|
| 3121 | + $item['start_date_tms'] = api_strtotime($item['date']); |
|
| 3122 | 3122 | $item['content'] = $item['text']; |
| 3123 | 3123 | |
| 3124 | 3124 | // we break the date field in the database into a date and a time part |
@@ -3138,7 +3138,7 @@ discard block |
||
| 3138 | 3138 | $second = $agendatime[2]; |
| 3139 | 3139 | |
| 3140 | 3140 | if ($type == 'month_view') { |
| 3141 | - $item['calendar_type'] = 'personal'; |
|
| 3141 | + $item['calendar_type'] = 'personal'; |
|
| 3142 | 3142 | $item['start_date'] = $item['date']; |
| 3143 | 3143 | $agendaitems[$day][] = $item; |
| 3144 | 3144 | continue; |
@@ -3163,7 +3163,7 @@ discard block |
||
| 3163 | 3163 | // this is the array construction for the DAY view |
| 3164 | 3164 | $halfhour = 2 * $agendatime['0']; |
| 3165 | 3165 | if ($agendatime['1'] >= '30') { |
| 3166 | - $halfhour = $halfhour +1; |
|
| 3166 | + $halfhour = $halfhour + 1; |
|
| 3167 | 3167 | } |
| 3168 | 3168 | |
| 3169 | 3169 | //Display events by list |
@@ -3187,22 +3187,22 @@ discard block |
||
| 3187 | 3187 | { |
| 3188 | 3188 | global $DaysShort, $course_path; |
| 3189 | 3189 | //Handle leap year |
| 3190 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 3190 | + $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 3191 | 3191 | if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
| 3192 | 3192 | $numberofdays[2] = 29; |
| 3193 | 3193 | //Get the first day of the month |
| 3194 | 3194 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
| 3195 | 3195 | //Start the week on monday |
| 3196 | 3196 | $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
| 3197 | - $g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:''); |
|
| 3197 | + $g_cc = (isset($_GET['courseCode']) ? $_GET['courseCode'] : ''); |
|
| 3198 | 3198 | |
| 3199 | - $next_month = ($month == 1 ? 12 : $month -1); |
|
| 3200 | - $prev_month = ($month == 12 ? 1 : $month +1); |
|
| 3199 | + $next_month = ($month == 1 ? 12 : $month - 1); |
|
| 3200 | + $prev_month = ($month == 12 ? 1 : $month + 1); |
|
| 3201 | 3201 | |
| 3202 | - $next_year = ($month == 1 ? $year -1 : $year); |
|
| 3203 | - $prev_year = ($month == 12 ? $year +1 : $year); |
|
| 3202 | + $next_year = ($month == 1 ? $year - 1 : $year); |
|
| 3203 | + $prev_year = ($month == 12 ? $year + 1 : $year); |
|
| 3204 | 3204 | |
| 3205 | - if ($show_content) { |
|
| 3205 | + if ($show_content) { |
|
| 3206 | 3206 | $back_url = Display::url(get_lang('Previous'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year); |
| 3207 | 3207 | $next_url = Display::url(get_lang('Next'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year); |
| 3208 | 3208 | } else { |
@@ -3219,7 +3219,7 @@ discard block |
||
| 3219 | 3219 | $html .= '</div>'; |
| 3220 | 3220 | $html .= '<table id="agenda_list2" class="table table-bordered">'; |
| 3221 | 3221 | $html .= '<tr>'; |
| 3222 | - for ($ii = 1; $ii < 8; $ii ++) { |
|
| 3222 | + for ($ii = 1; $ii < 8; $ii++) { |
|
| 3223 | 3223 | $html .= '<td class="weekdays">'.$DaysShort[$ii % 7].'</td>'; |
| 3224 | 3224 | } |
| 3225 | 3225 | $html .= '</tr>'; |
@@ -3228,7 +3228,7 @@ discard block |
||
| 3228 | 3228 | $today = getdate(); |
| 3229 | 3229 | while ($curday <= $numberofdays[$month]) { |
| 3230 | 3230 | $html .= "<tr>"; |
| 3231 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
| 3231 | + for ($ii = 0; $ii < 7; $ii++) { |
|
| 3232 | 3232 | if (($curday == -1) && ($ii == $startdayofweek)) { |
| 3233 | 3233 | $curday = 1; |
| 3234 | 3234 | } |
@@ -3242,21 +3242,21 @@ discard block |
||
| 3242 | 3242 | $html .= "<td ".$class.">".$dayheader; |
| 3243 | 3243 | |
| 3244 | 3244 | if (!empty($agendaitems[$curday])) { |
| 3245 | - $items = $agendaitems[$curday]; |
|
| 3246 | - $items = msort($items, 'start_date_tms'); |
|
| 3245 | + $items = $agendaitems[$curday]; |
|
| 3246 | + $items = msort($items, 'start_date_tms'); |
|
| 3247 | 3247 | |
| 3248 | - foreach($items as $value) { |
|
| 3248 | + foreach ($items as $value) { |
|
| 3249 | 3249 | $value['title'] = Security::remove_XSS($value['title']); |
| 3250 | 3250 | $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT); |
| 3251 | 3251 | $end_time = ''; |
| 3252 | 3252 | |
| 3253 | 3253 | if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') { |
| 3254 | - $end_time = '- <i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>'; |
|
| 3254 | + $end_time = '- <i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>'; |
|
| 3255 | 3255 | } |
| 3256 | 3256 | $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i> '.$end_time; |
| 3257 | 3257 | $time = '<i>'.$start_time.'</i>'; |
| 3258 | 3258 | |
| 3259 | - switch($value['calendar_type']) { |
|
| 3259 | + switch ($value['calendar_type']) { |
|
| 3260 | 3260 | case 'personal': |
| 3261 | 3261 | $bg_color = '#D0E7F4'; |
| 3262 | 3262 | $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL); |
@@ -3308,7 +3308,7 @@ discard block |
||
| 3308 | 3308 | } |
| 3309 | 3309 | } |
| 3310 | 3310 | $html .= "</td>"; |
| 3311 | - $curday ++; |
|
| 3311 | + $curday++; |
|
| 3312 | 3312 | } else { |
| 3313 | 3313 | $html .= "<td></td>"; |
| 3314 | 3314 | } |
@@ -3329,18 +3329,18 @@ discard block |
||
| 3329 | 3329 | * where datestart and dateend are in yyyyMMddhhmmss format. |
| 3330 | 3330 | * @TODO Implement really personal events (from user DB) and global events (from main DB) |
| 3331 | 3331 | */ |
| 3332 | - public static function get_personal_agenda_items_between_dates($user_id, $date_start='', $date_end='') |
|
| 3332 | + public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '') |
|
| 3333 | 3333 | { |
| 3334 | - $items = array (); |
|
| 3334 | + $items = array(); |
|
| 3335 | 3335 | if ($user_id != strval(intval($user_id))) { return $items; } |
| 3336 | - if (empty($date_start)) { $date_start = date('Y-m-d H:i:s');} |
|
| 3337 | - if (empty($date_end)) { $date_end = date('Y-m-d H:i:s',mktime(0, 0, 0, date("m"), date("d"), date("Y")+1));} |
|
| 3336 | + if (empty($date_start)) { $date_start = date('Y-m-d H:i:s'); } |
|
| 3337 | + if (empty($date_end)) { $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); } |
|
| 3338 | 3338 | $expr = '/\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}/'; |
| 3339 | - if(!preg_match($expr,$date_start)) { return $items; } |
|
| 3340 | - if(!preg_match($expr,$date_end)) { return $items; } |
|
| 3339 | + if (!preg_match($expr, $date_start)) { return $items; } |
|
| 3340 | + if (!preg_match($expr, $date_end)) { return $items; } |
|
| 3341 | 3341 | |
| 3342 | 3342 | // get agenda-items for every course |
| 3343 | - $courses = api_get_user_courses($user_id,false); |
|
| 3343 | + $courses = api_get_user_courses($user_id, false); |
|
| 3344 | 3344 | foreach ($courses as $id => $course) { |
| 3345 | 3345 | $c = api_get_course_info_by_id($course['real_id']); |
| 3346 | 3346 | //databases of the courses |
@@ -3364,9 +3364,9 @@ discard block |
||
| 3364 | 3364 | " ORDER BY start_date "; |
| 3365 | 3365 | } else { |
| 3366 | 3366 | // if the user is not an administrator of that course, then... |
| 3367 | - if (is_array($group_memberships) && count($group_memberships)>0) |
|
| 3367 | + if (is_array($group_memberships) && count($group_memberships) > 0) |
|
| 3368 | 3368 | { |
| 3369 | - $sqlquery = "SELECT " . |
|
| 3369 | + $sqlquery = "SELECT ". |
|
| 3370 | 3370 | "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref ". |
| 3371 | 3371 | " FROM ".$t_a." agenda, ". |
| 3372 | 3372 | $t_ip." ip ". |
@@ -3394,13 +3394,13 @@ discard block |
||
| 3394 | 3394 | |
| 3395 | 3395 | $result = Database::query($sqlquery); |
| 3396 | 3396 | while ($item = Database::fetch_array($result)) { |
| 3397 | - $agendaday = date("j",strtotime($item['start_date'])); |
|
| 3398 | - $month = date("n",strtotime($item['start_date'])); |
|
| 3399 | - $year = date("Y",strtotime($item['start_date'])); |
|
| 3397 | + $agendaday = date("j", strtotime($item['start_date'])); |
|
| 3398 | + $month = date("n", strtotime($item['start_date'])); |
|
| 3399 | + $year = date("Y", strtotime($item['start_date'])); |
|
| 3400 | 3400 | $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; |
| 3401 | - list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']); |
|
| 3401 | + list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']); |
|
| 3402 | 3402 | $start_date = $year.$month.$day.$hour.$min; |
| 3403 | - list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']); |
|
| 3403 | + list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']); |
|
| 3404 | 3404 | $end_date = $year.$month.$day.$hour.$min; |
| 3405 | 3405 | |
| 3406 | 3406 | $items[] = array( |
@@ -3429,7 +3429,7 @@ discard block |
||
| 3429 | 3429 | $user = api_get_user_id(); |
| 3430 | 3430 | $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE id=".$id." AND user = ".$user; |
| 3431 | 3431 | $result = Database::query($sql); |
| 3432 | - if(Database::num_rows($result)==1) { |
|
| 3432 | + if (Database::num_rows($result) == 1) { |
|
| 3433 | 3433 | $item = Database::fetch_array($result); |
| 3434 | 3434 | } else { |
| 3435 | 3435 | $item = null; |
@@ -3451,9 +3451,9 @@ discard block |
||
| 3451 | 3451 | // step 2: we which day this is (0=sunday, 1=monday, ...) |
| 3452 | 3452 | $number_day_in_week = date('w', $random_day_in_week); |
| 3453 | 3453 | // step 3: we calculate the timestamp of the monday of the week we are in |
| 3454 | - $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60); |
|
| 3454 | + $start_timestamp = $random_day_in_week - (($number_day_in_week - 1) * 24 * 60 * 60); |
|
| 3455 | 3455 | // step 4: we calculate the timestamp of the sunday of the week we are in |
| 3456 | - $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600; |
|
| 3456 | + $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week + 1) * 24 * 60 * 60) - 3600; |
|
| 3457 | 3457 | // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year |
| 3458 | 3458 | $start_day = date('j', $start_timestamp); |
| 3459 | 3459 | $start_month = date('n', $start_timestamp); |
@@ -6,114 +6,113 @@ 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 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 30 | - |
|
| 31 | - $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 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 29 | + |
|
| 30 | + $sql = "SELECT blog_name |
|
| 32 | 31 | FROM " . $tbl_blogs . " |
| 33 | 32 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
| 34 | 33 | |
| 35 | - $result = Database::query($sql); |
|
| 36 | - $blog = Database::fetch_array($result); |
|
| 37 | - |
|
| 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 |
|
| 34 | + $result = Database::query($sql); |
|
| 35 | + $blog = Database::fetch_array($result); |
|
| 36 | + |
|
| 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 int $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 int $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 | |
| 115 | - //verified if exist blog |
|
| 116 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
| 114 | + //verified if exist blog |
|
| 115 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
| 117 | 116 | WHERE |
| 118 | 117 | c_id = '.$course_id.' AND |
| 119 | 118 | blog_name="'.Database::escape_string($title).'" AND |
@@ -122,9 +121,9 @@ discard block |
||
| 122 | 121 | $info_count = Database::result($res, 0, 0); |
| 123 | 122 | |
| 124 | 123 | if ($info_count == 0) { |
| 125 | - // Create the blog |
|
| 124 | + // Create the blog |
|
| 126 | 125 | $params = [ |
| 127 | - 'blog_id' => 0, |
|
| 126 | + 'blog_id' => 0, |
|
| 128 | 127 | 'c_id' => $course_id, |
| 129 | 128 | 'blog_name' => $title, |
| 130 | 129 | 'blog_subtitle' => $subtitle, |
@@ -132,14 +131,14 @@ discard block |
||
| 132 | 131 | 'visibility' => 1 , |
| 133 | 132 | 'session_id' => $session_id, |
| 134 | 133 | ]; |
| 135 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
| 134 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
| 136 | 135 | |
| 137 | - if ($this_blog_id > 0) { |
|
| 136 | + if ($this_blog_id > 0) { |
|
| 138 | 137 | |
| 139 | 138 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
| 140 | 139 | Database::query($sql); |
| 141 | 140 | |
| 142 | - // insert into item_property |
|
| 141 | + // insert into item_property |
|
| 143 | 142 | api_item_property_update( |
| 144 | 143 | api_get_course_info(), |
| 145 | 144 | TOOL_BLOGS, |
@@ -147,12 +146,12 @@ discard block |
||
| 147 | 146 | 'BlogAdded', |
| 148 | 147 | api_get_user_id() |
| 149 | 148 | ); |
| 150 | - } |
|
| 149 | + } |
|
| 151 | 150 | |
| 152 | - // Make first post. :) |
|
| 151 | + // Make first post. :) |
|
| 153 | 152 | |
| 154 | 153 | $params = [ |
| 155 | - 'post_id' => 0, |
|
| 154 | + 'post_id' => 0, |
|
| 156 | 155 | 'c_id' => $course_id, |
| 157 | 156 | 'title' => get_lang("Welcome"), |
| 158 | 157 | 'full_text' => get_lang('FirstPostText'), |
@@ -166,10 +165,10 @@ discard block |
||
| 166 | 165 | Database::query($sql); |
| 167 | 166 | } |
| 168 | 167 | |
| 169 | - // Put it on course homepage |
|
| 170 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
| 168 | + // Put it on course homepage |
|
| 169 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
| 171 | 170 | 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 | - Database::query($sql); |
|
| 171 | + Database::query($sql); |
|
| 173 | 172 | |
| 174 | 173 | $toolId = Database::insert_id(); |
| 175 | 174 | if ($toolId) { |
@@ -177,37 +176,37 @@ discard block |
||
| 177 | 176 | Database::query($sql); |
| 178 | 177 | } |
| 179 | 178 | |
| 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 int $course_id Id |
|
| 189 | - * @param string $title |
|
| 190 | - * @param string $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); |
|
| 179 | + // Subscribe the teacher to this blog |
|
| 180 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Update title and subtitle of a blog in the given course |
|
| 186 | + * @author Toon Keppens |
|
| 187 | + * @param int $course_id Id |
|
| 188 | + * @param string $title |
|
| 189 | + * @param string $description |
|
| 190 | + */ |
|
| 191 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
| 192 | + { |
|
| 193 | + // Table definitions |
|
| 194 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 195 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 197 | 196 | |
| 198 | 197 | $course_id = api_get_course_int_id(); |
| 199 | 198 | |
| 200 | - // Update the blog |
|
| 201 | - $sql = "UPDATE $tbl_blogs SET |
|
| 199 | + // Update the blog |
|
| 200 | + $sql = "UPDATE $tbl_blogs SET |
|
| 202 | 201 | blog_name = '".Database::escape_string($title)."', |
| 203 | 202 | blog_subtitle = '".Database::escape_string($subtitle)."' |
| 204 | 203 | WHERE |
| 205 | 204 | c_id = $course_id AND |
| 206 | 205 | blog_id ='".Database::escape_string((int)$blog_id)."' |
| 207 | 206 | LIMIT 1"; |
| 208 | - Database::query($sql); |
|
| 207 | + Database::query($sql); |
|
| 209 | 208 | |
| 210 | - //update item_property (update) |
|
| 209 | + //update item_property (update) |
|
| 211 | 210 | api_item_property_update( |
| 212 | 211 | api_get_course_info(), |
| 213 | 212 | TOOL_BLOGS, |
@@ -216,21 +215,21 @@ discard block |
||
| 216 | 215 | api_get_user_id() |
| 217 | 216 | ); |
| 218 | 217 | |
| 219 | - // Update course homepage link |
|
| 220 | - $sql = "UPDATE $tbl_tool SET |
|
| 218 | + // Update course homepage link |
|
| 219 | + $sql = "UPDATE $tbl_tool SET |
|
| 221 | 220 | name = '".Database::escape_string($title)."' |
| 222 | 221 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
| 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 |
|
| 222 | + Database::query($sql); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Deletes a blog and it's posts from the course database |
|
| 227 | + * @author Toon Keppens |
|
| 228 | + * @param Integer $blog_id |
|
| 229 | + */ |
|
| 230 | + public static function delete_blog($blog_id) |
|
| 231 | + { |
|
| 232 | + // Init |
|
| 234 | 233 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 235 | 234 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
| 236 | 235 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
@@ -241,34 +240,34 @@ discard block |
||
| 241 | 240 | $course_id = api_get_course_int_id(); |
| 242 | 241 | $blog_id = intval($blog_id); |
| 243 | 242 | |
| 244 | - // Delete posts from DB and the attachments |
|
| 245 | - delete_all_blog_attachment($blog_id); |
|
| 243 | + // Delete posts from DB and the attachments |
|
| 244 | + delete_all_blog_attachment($blog_id); |
|
| 246 | 245 | |
| 247 | - //Delete comments |
|
| 248 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 249 | - Database::query($sql); |
|
| 246 | + //Delete comments |
|
| 247 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 248 | + Database::query($sql); |
|
| 250 | 249 | |
| 251 | - // Delete posts |
|
| 252 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 253 | - Database::query($sql); |
|
| 250 | + // Delete posts |
|
| 251 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 252 | + Database::query($sql); |
|
| 254 | 253 | |
| 255 | - // Delete tasks |
|
| 256 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 257 | - Database::query($sql); |
|
| 254 | + // Delete tasks |
|
| 255 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 256 | + Database::query($sql); |
|
| 258 | 257 | |
| 259 | - // Delete ratings |
|
| 260 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 261 | - Database::query($sql); |
|
| 258 | + // Delete ratings |
|
| 259 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 260 | + Database::query($sql); |
|
| 262 | 261 | |
| 263 | - // Delete blog |
|
| 264 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 265 | - Database::query($sql); |
|
| 262 | + // Delete blog |
|
| 263 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 264 | + Database::query($sql); |
|
| 266 | 265 | |
| 267 | - // Delete from course homepage |
|
| 268 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
| 269 | - Database::query($sql); |
|
| 266 | + // Delete from course homepage |
|
| 267 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
| 268 | + Database::query($sql); |
|
| 270 | 269 | |
| 271 | - //update item_property (delete) |
|
| 270 | + //update item_property (delete) |
|
| 272 | 271 | api_item_property_update( |
| 273 | 272 | api_get_course_info(), |
| 274 | 273 | TOOL_BLOGS, |
@@ -276,152 +275,152 @@ discard block |
||
| 276 | 275 | 'delete', |
| 277 | 276 | api_get_user_id() |
| 278 | 277 | ); |
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Creates a new post in a given blog |
|
| 283 | - * @author Toon Keppens |
|
| 284 | - * @param String $title |
|
| 285 | - * @param String $full_text |
|
| 286 | - * @param Integer $blog_id |
|
| 287 | - */ |
|
| 288 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
| 289 | - { |
|
| 290 | - $_user = api_get_user_info(); |
|
| 291 | - $_course = api_get_course_info(); |
|
| 292 | - $course_id = $_course['real_id']; |
|
| 293 | - |
|
| 294 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 295 | - $upload_ok=true; |
|
| 296 | - $has_attachment=false; |
|
| 297 | - $current_date = api_get_utc_datetime(); |
|
| 298 | - |
|
| 299 | - if (!empty($_FILES['user_upload']['name'])) { |
|
| 300 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 301 | - $has_attachment=true; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - if ($upload_ok) { |
|
| 305 | - // Table Definitions |
|
| 306 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 307 | - |
|
| 308 | - // Create the post |
|
| 309 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Creates a new post in a given blog |
|
| 282 | + * @author Toon Keppens |
|
| 283 | + * @param String $title |
|
| 284 | + * @param String $full_text |
|
| 285 | + * @param Integer $blog_id |
|
| 286 | + */ |
|
| 287 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
| 288 | + { |
|
| 289 | + $_user = api_get_user_info(); |
|
| 290 | + $_course = api_get_course_info(); |
|
| 291 | + $course_id = $_course['real_id']; |
|
| 292 | + |
|
| 293 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 294 | + $upload_ok=true; |
|
| 295 | + $has_attachment=false; |
|
| 296 | + $current_date = api_get_utc_datetime(); |
|
| 297 | + |
|
| 298 | + if (!empty($_FILES['user_upload']['name'])) { |
|
| 299 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 300 | + $has_attachment=true; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + if ($upload_ok) { |
|
| 304 | + // Table Definitions |
|
| 305 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 306 | + |
|
| 307 | + // Create the post |
|
| 308 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
| 310 | 309 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
| 311 | 310 | |
| 312 | - Database::query($sql); |
|
| 313 | - $last_post_id = Database::insert_id(); |
|
| 311 | + Database::query($sql); |
|
| 312 | + $last_post_id = Database::insert_id(); |
|
| 314 | 313 | |
| 315 | 314 | if ($last_post_id) { |
| 316 | 315 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
| 317 | 316 | Database::query($sql); |
| 318 | 317 | } |
| 319 | 318 | |
| 320 | - if ($has_attachment) { |
|
| 321 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 322 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 323 | - $updir = $sys_course_path.$courseDir; |
|
| 324 | - |
|
| 325 | - // Try to add an extension to the file if it hasn't one |
|
| 326 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
| 327 | - |
|
| 328 | - // user's file name |
|
| 329 | - $file_name = $_FILES['user_upload']['name']; |
|
| 330 | - |
|
| 331 | - if (!filter_extension($new_file_name)) { |
|
| 332 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 333 | - } else { |
|
| 334 | - $new_file_name = uniqid(''); |
|
| 335 | - $new_path = $updir.'/'.$new_file_name; |
|
| 336 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 337 | - $comment = Database::escape_string($file_comment); |
|
| 338 | - |
|
| 339 | - // Storing the attachments if any |
|
| 340 | - if ($result) { |
|
| 341 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
| 342 | - "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' )"; |
|
| 343 | - Database::query($sql); |
|
| 319 | + if ($has_attachment) { |
|
| 320 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 321 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 322 | + $updir = $sys_course_path.$courseDir; |
|
| 323 | + |
|
| 324 | + // Try to add an extension to the file if it hasn't one |
|
| 325 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
| 326 | + |
|
| 327 | + // user's file name |
|
| 328 | + $file_name = $_FILES['user_upload']['name']; |
|
| 329 | + |
|
| 330 | + if (!filter_extension($new_file_name)) { |
|
| 331 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 332 | + } else { |
|
| 333 | + $new_file_name = uniqid(''); |
|
| 334 | + $new_path = $updir.'/'.$new_file_name; |
|
| 335 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 336 | + $comment = Database::escape_string($file_comment); |
|
| 337 | + |
|
| 338 | + // Storing the attachments if any |
|
| 339 | + if ($result) { |
|
| 340 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
| 341 | + "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' )"; |
|
| 342 | + Database::query($sql); |
|
| 344 | 343 | $id = Database::insert_id(); |
| 345 | 344 | if ($id) { |
| 346 | 345 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 347 | 346 | Database::query($sql); |
| 348 | 347 | } |
| 349 | - } |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - } else { |
|
| 353 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Edits a post in a given blog |
|
| 359 | - * @author Toon Keppens |
|
| 360 | - * @param Integer $blog_id |
|
| 361 | - * @param String $title |
|
| 362 | - * @param String $full_text |
|
| 363 | - * @param Integer $blog_id |
|
| 364 | - */ |
|
| 365 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
| 366 | - { |
|
| 367 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + } else { |
|
| 352 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Edits a post in a given blog |
|
| 358 | + * @author Toon Keppens |
|
| 359 | + * @param Integer $blog_id |
|
| 360 | + * @param String $title |
|
| 361 | + * @param String $full_text |
|
| 362 | + * @param Integer $blog_id |
|
| 363 | + */ |
|
| 364 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
| 365 | + { |
|
| 366 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 368 | 367 | $course_id = api_get_course_int_id(); |
| 369 | 368 | |
| 370 | - // Create the post |
|
| 371 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
| 369 | + // Create the post |
|
| 370 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
| 372 | 371 | title = '" . Database::escape_string($title)."', |
| 373 | 372 | full_text = '" . Database::escape_string($full_text)."' |
| 374 | 373 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
| 375 | 374 | LIMIT 1 "; |
| 376 | - Database::query($sql); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Deletes an article and it's comments |
|
| 381 | - * @author Toon Keppens |
|
| 382 | - * @param int $blog_id |
|
| 383 | - * @param int $post_id |
|
| 384 | - */ |
|
| 385 | - public static function delete_post($blog_id, $post_id) |
|
| 386 | - { |
|
| 387 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 388 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 389 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 375 | + Database::query($sql); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Deletes an article and it's comments |
|
| 380 | + * @author Toon Keppens |
|
| 381 | + * @param int $blog_id |
|
| 382 | + * @param int $post_id |
|
| 383 | + */ |
|
| 384 | + public static function delete_post($blog_id, $post_id) |
|
| 385 | + { |
|
| 386 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 387 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 388 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 390 | 389 | |
| 391 | 390 | $course_id = api_get_course_int_id(); |
| 392 | 391 | |
| 393 | - // Delete ratings on this comment |
|
| 394 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
| 392 | + // Delete ratings on this comment |
|
| 393 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
| 395 | 394 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
| 396 | - Database::query($sql); |
|
| 395 | + Database::query($sql); |
|
| 397 | 396 | |
| 398 | - // Delete the post |
|
| 399 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
| 397 | + // Delete the post |
|
| 398 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
| 400 | 399 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
| 401 | - Database::query($sql); |
|
| 400 | + Database::query($sql); |
|
| 402 | 401 | |
| 403 | - // Delete the comments |
|
| 404 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
| 402 | + // Delete the comments |
|
| 403 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
| 405 | 404 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
| 406 | - Database::query($sql); |
|
| 407 | - |
|
| 408 | - // Delete posts and attachments |
|
| 409 | - delete_all_blog_attachment($blog_id,$post_id); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * Creates a comment on a post in a given blog |
|
| 414 | - * @author Toon Keppens |
|
| 415 | - * @param String $title |
|
| 416 | - * @param String $full_text |
|
| 417 | - * @param Integer $blog_id |
|
| 418 | - * @param Integer $post_id |
|
| 419 | - * @param Integer $parent_id |
|
| 420 | - */ |
|
| 421 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
| 422 | - { |
|
| 423 | - $_user = api_get_user_info(); |
|
| 424 | - $_course = api_get_course_info(); |
|
| 405 | + Database::query($sql); |
|
| 406 | + |
|
| 407 | + // Delete posts and attachments |
|
| 408 | + delete_all_blog_attachment($blog_id,$post_id); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Creates a comment on a post in a given blog |
|
| 413 | + * @author Toon Keppens |
|
| 414 | + * @param String $title |
|
| 415 | + * @param String $full_text |
|
| 416 | + * @param Integer $blog_id |
|
| 417 | + * @param Integer $post_id |
|
| 418 | + * @param Integer $parent_id |
|
| 419 | + */ |
|
| 420 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
| 421 | + { |
|
| 422 | + $_user = api_get_user_info(); |
|
| 423 | + $_course = api_get_course_info(); |
|
| 425 | 424 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 426 | 425 | |
| 427 | 426 | $upload_ok = true; |
@@ -429,55 +428,55 @@ discard block |
||
| 429 | 428 | $current_date = api_get_utc_datetime(); |
| 430 | 429 | $course_id = api_get_course_int_id(); |
| 431 | 430 | |
| 432 | - if (!empty($_FILES['user_upload']['name'])) { |
|
| 433 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 434 | - $has_attachment=true; |
|
| 435 | - } |
|
| 431 | + if (!empty($_FILES['user_upload']['name'])) { |
|
| 432 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 433 | + $has_attachment=true; |
|
| 434 | + } |
|
| 436 | 435 | |
| 437 | - if ($upload_ok) { |
|
| 438 | - // Table Definition |
|
| 439 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 436 | + if ($upload_ok) { |
|
| 437 | + // Table Definition |
|
| 438 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 440 | 439 | |
| 441 | - // Create the comment |
|
| 442 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
| 440 | + // Create the comment |
|
| 441 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
| 443 | 442 | 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."')"; |
| 444 | - Database::query($sql); |
|
| 443 | + Database::query($sql); |
|
| 445 | 444 | |
| 446 | - // Empty post values, or they are shown on the page again |
|
| 447 | - $last_id = Database::insert_id(); |
|
| 445 | + // Empty post values, or they are shown on the page again |
|
| 446 | + $last_id = Database::insert_id(); |
|
| 448 | 447 | |
| 449 | 448 | if ($last_id) { |
| 450 | 449 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
| 451 | 450 | Database::query($sql); |
| 452 | 451 | } |
| 453 | 452 | |
| 454 | - if ($has_attachment) { |
|
| 455 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 456 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 457 | - $updir = $sys_course_path.$courseDir; |
|
| 458 | - |
|
| 459 | - // Try to add an extension to the file if it hasn't one |
|
| 460 | - $new_file_name = add_ext_on_mime( |
|
| 461 | - stripslashes($_FILES['user_upload']['name']), |
|
| 462 | - $_FILES['user_upload']['type'] |
|
| 463 | - ); |
|
| 464 | - |
|
| 465 | - // user's file name |
|
| 466 | - $file_name =$_FILES['user_upload']['name']; |
|
| 467 | - |
|
| 468 | - if (!filter_extension($new_file_name)) { |
|
| 469 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 470 | - } else { |
|
| 471 | - $new_file_name = uniqid(''); |
|
| 472 | - $new_path=$updir.'/'.$new_file_name; |
|
| 473 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 474 | - $comment = Database::escape_string($file_comment); |
|
| 475 | - |
|
| 476 | - // Storing the attachments if any |
|
| 477 | - if ($result) { |
|
| 478 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 479 | - "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."' )"; |
|
| 480 | - Database::query($sql); |
|
| 453 | + if ($has_attachment) { |
|
| 454 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 455 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 456 | + $updir = $sys_course_path.$courseDir; |
|
| 457 | + |
|
| 458 | + // Try to add an extension to the file if it hasn't one |
|
| 459 | + $new_file_name = add_ext_on_mime( |
|
| 460 | + stripslashes($_FILES['user_upload']['name']), |
|
| 461 | + $_FILES['user_upload']['type'] |
|
| 462 | + ); |
|
| 463 | + |
|
| 464 | + // user's file name |
|
| 465 | + $file_name =$_FILES['user_upload']['name']; |
|
| 466 | + |
|
| 467 | + if (!filter_extension($new_file_name)) { |
|
| 468 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 469 | + } else { |
|
| 470 | + $new_file_name = uniqid(''); |
|
| 471 | + $new_path=$updir.'/'.$new_file_name; |
|
| 472 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 473 | + $comment = Database::escape_string($file_comment); |
|
| 474 | + |
|
| 475 | + // Storing the attachments if any |
|
| 476 | + if ($result) { |
|
| 477 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 478 | + "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."' )"; |
|
| 479 | + Database::query($sql); |
|
| 481 | 480 | |
| 482 | 481 | $id = Database::insert_id(); |
| 483 | 482 | |
@@ -485,91 +484,91 @@ discard block |
||
| 485 | 484 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 486 | 485 | Database::query($sql); |
| 487 | 486 | } |
| 488 | - } |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * Deletes a comment from a blogpost |
|
| 496 | - * @author Toon Keppens |
|
| 497 | - * @param int $blog_id |
|
| 498 | - * @param int $comment_id |
|
| 499 | - */ |
|
| 500 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
| 501 | - { |
|
| 502 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 503 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 504 | - $blog_id = intval($blog_id); |
|
| 505 | - $post_id = intval($post_id); |
|
| 506 | - $comment_id = intval($comment_id); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * Deletes a comment from a blogpost |
|
| 495 | + * @author Toon Keppens |
|
| 496 | + * @param int $blog_id |
|
| 497 | + * @param int $comment_id |
|
| 498 | + */ |
|
| 499 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
| 500 | + { |
|
| 501 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 502 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 503 | + $blog_id = intval($blog_id); |
|
| 504 | + $post_id = intval($post_id); |
|
| 505 | + $comment_id = intval($comment_id); |
|
| 507 | 506 | $course_id = api_get_course_int_id(); |
| 508 | 507 | |
| 509 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
| 508 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
| 510 | 509 | |
| 511 | - // Delete ratings on this comment |
|
| 512 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
| 510 | + // Delete ratings on this comment |
|
| 511 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
| 513 | 512 | WHERE |
| 514 | 513 | c_id = $course_id AND |
| 515 | 514 | blog_id = '".$blog_id."' AND |
| 516 | 515 | item_id = '".$comment_id."' AND |
| 517 | 516 | rating_type = 'comment'"; |
| 518 | - Database::query($sql); |
|
| 517 | + Database::query($sql); |
|
| 519 | 518 | |
| 520 | - // select comments that have the selected comment as their parent |
|
| 521 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
| 519 | + // select comments that have the selected comment as their parent |
|
| 520 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
| 522 | 521 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
| 523 | - $result = Database::query($sql); |
|
| 522 | + $result = Database::query($sql); |
|
| 524 | 523 | |
| 525 | - // Delete them recursively |
|
| 526 | - while ($comment = Database::fetch_array($result)) { |
|
| 527 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 528 | - } |
|
| 524 | + // Delete them recursively |
|
| 525 | + while ($comment = Database::fetch_array($result)) { |
|
| 526 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 527 | + } |
|
| 529 | 528 | |
| 530 | - // Finally, delete the selected comment to |
|
| 531 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
| 529 | + // Finally, delete the selected comment to |
|
| 530 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
| 532 | 531 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
| 533 | - Database::query($sql); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * Creates a new task in a blog |
|
| 538 | - * @author Toon Keppens |
|
| 539 | - * @param Integer $blog_id |
|
| 540 | - * @param String $title |
|
| 541 | - * @param String $description |
|
| 542 | - * @param String $color |
|
| 543 | - */ |
|
| 544 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 545 | - { |
|
| 546 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 547 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 548 | - |
|
| 549 | - $course_id = api_get_course_int_id(); |
|
| 550 | - |
|
| 551 | - // Create the task |
|
| 552 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
| 532 | + Database::query($sql); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + /** |
|
| 536 | + * Creates a new task in a blog |
|
| 537 | + * @author Toon Keppens |
|
| 538 | + * @param Integer $blog_id |
|
| 539 | + * @param String $title |
|
| 540 | + * @param String $description |
|
| 541 | + * @param String $color |
|
| 542 | + */ |
|
| 543 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 544 | + { |
|
| 545 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 546 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 547 | + |
|
| 548 | + $course_id = api_get_course_int_id(); |
|
| 549 | + |
|
| 550 | + // Create the task |
|
| 551 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
| 553 | 552 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
| 554 | - Database::query($sql); |
|
| 553 | + Database::query($sql); |
|
| 555 | 554 | |
| 556 | - $task_id = Database::insert_id(); |
|
| 555 | + $task_id = Database::insert_id(); |
|
| 557 | 556 | |
| 558 | 557 | if ($task_id) { |
| 559 | 558 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
| 560 | 559 | Database::query($sql); |
| 561 | 560 | } |
| 562 | 561 | |
| 563 | - $tool = 'BLOG_' . $blog_id; |
|
| 562 | + $tool = 'BLOG_' . $blog_id; |
|
| 564 | 563 | |
| 565 | - if ($articleDelete == 'on') { |
|
| 566 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 564 | + if ($articleDelete == 'on') { |
|
| 565 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 567 | 566 | '" . (int)$course_id . "', |
| 568 | 567 | '" . (int)$task_id . "', |
| 569 | 568 | '" . Database::escape_string($tool) . "', |
| 570 | 569 | 'article_delete' |
| 571 | 570 | )"; |
| 572 | - Database::query($sql); |
|
| 571 | + Database::query($sql); |
|
| 573 | 572 | |
| 574 | 573 | $id = Database::insert_id(); |
| 575 | 574 | |
@@ -579,172 +578,172 @@ discard block |
||
| 579 | 578 | } |
| 580 | 579 | } |
| 581 | 580 | |
| 582 | - if ($articleEdit == 'on') { |
|
| 583 | - $sql = " |
|
| 581 | + if ($articleEdit == 'on') { |
|
| 582 | + $sql = " |
|
| 584 | 583 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
| 585 | 584 | '" . (int)$course_id . "', |
| 586 | 585 | '" . (int)$task_id . "', |
| 587 | 586 | '" . Database::escape_string($tool) . "', |
| 588 | 587 | 'article_edit' |
| 589 | 588 | )"; |
| 590 | - Database::query($sql); |
|
| 589 | + Database::query($sql); |
|
| 591 | 590 | $id = Database::insert_id(); |
| 592 | 591 | |
| 593 | 592 | if ($id) { |
| 594 | 593 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 595 | 594 | Database::query($sql); |
| 596 | 595 | } |
| 597 | - } |
|
| 596 | + } |
|
| 598 | 597 | |
| 599 | - if ($commentsDelete == 'on') { |
|
| 600 | - $sql = " |
|
| 598 | + if ($commentsDelete == 'on') { |
|
| 599 | + $sql = " |
|
| 601 | 600 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
| 602 | 601 | '" . (int)$course_id . "', |
| 603 | 602 | '" . (int)$task_id . "', |
| 604 | 603 | '" . Database::escape_string($tool) . "', |
| 605 | 604 | 'article_comments_delete' |
| 606 | 605 | )"; |
| 607 | - Database::query($sql); |
|
| 606 | + Database::query($sql); |
|
| 608 | 607 | $id = Database::insert_id(); |
| 609 | 608 | |
| 610 | 609 | if ($id) { |
| 611 | 610 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 612 | 611 | Database::query($sql); |
| 613 | 612 | } |
| 614 | - } |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - /** |
|
| 618 | - * Edit a task in a blog |
|
| 619 | - * @author Toon Keppens |
|
| 620 | - * @param Integer $task_id |
|
| 621 | - * @param String $title |
|
| 622 | - * @param String $description |
|
| 623 | - * @param String $color |
|
| 624 | - */ |
|
| 625 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 626 | - { |
|
| 627 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 628 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + /** |
|
| 617 | + * Edit a task in a blog |
|
| 618 | + * @author Toon Keppens |
|
| 619 | + * @param Integer $task_id |
|
| 620 | + * @param String $title |
|
| 621 | + * @param String $description |
|
| 622 | + * @param String $color |
|
| 623 | + */ |
|
| 624 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 625 | + { |
|
| 626 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 627 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 629 | 628 | |
| 630 | 629 | $course_id = api_get_course_int_id(); |
| 631 | 630 | |
| 632 | - // Create the task |
|
| 633 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
| 631 | + // Create the task |
|
| 632 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
| 634 | 633 | title = '".Database::escape_string($title)."', |
| 635 | 634 | description = '".Database::escape_string($description)."', |
| 636 | 635 | color = '".Database::escape_string($color)."' |
| 637 | 636 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
| 638 | - Database::query($sql); |
|
| 637 | + Database::query($sql); |
|
| 639 | 638 | |
| 640 | - $tool = 'BLOG_' . $blog_id; |
|
| 639 | + $tool = 'BLOG_' . $blog_id; |
|
| 641 | 640 | |
| 642 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 641 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 643 | 642 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
| 644 | - Database::query($sql); |
|
| 643 | + Database::query($sql); |
|
| 645 | 644 | |
| 646 | - if ($articleDelete == 'on') { |
|
| 647 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 645 | + if ($articleDelete == 'on') { |
|
| 646 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 648 | 647 | '" . (int)$course_id . "', |
| 649 | 648 | '" . (int)$task_id . "', |
| 650 | 649 | '" . Database::escape_string($tool) . "', |
| 651 | 650 | 'article_delete' |
| 652 | 651 | )"; |
| 653 | - Database::query($sql); |
|
| 652 | + Database::query($sql); |
|
| 654 | 653 | $id = Database::insert_id(); |
| 655 | 654 | |
| 656 | 655 | if ($id) { |
| 657 | 656 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 658 | 657 | Database::query($sql); |
| 659 | 658 | } |
| 660 | - } |
|
| 659 | + } |
|
| 661 | 660 | |
| 662 | - if ($articleEdit == 'on') { |
|
| 663 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 661 | + if ($articleEdit == 'on') { |
|
| 662 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 664 | 663 | '" . (int)$course_id . "', |
| 665 | 664 | '" . (int)$task_id . "', |
| 666 | 665 | '" . Database::escape_string($tool) . "', |
| 667 | 666 | 'article_edit' |
| 668 | 667 | )"; |
| 669 | - Database::query($sql); |
|
| 668 | + Database::query($sql); |
|
| 670 | 669 | $id = Database::insert_id(); |
| 671 | 670 | |
| 672 | 671 | if ($id) { |
| 673 | 672 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 674 | 673 | Database::query($sql); |
| 675 | 674 | } |
| 676 | - } |
|
| 675 | + } |
|
| 677 | 676 | |
| 678 | - if ($commentsDelete == 'on') { |
|
| 679 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 677 | + if ($commentsDelete == 'on') { |
|
| 678 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 680 | 679 | '" . (int)$course_id . "', |
| 681 | 680 | '" . (int)$task_id . "', |
| 682 | 681 | '" . Database::escape_string($tool) . "', |
| 683 | 682 | 'article_comments_delete' |
| 684 | 683 | )"; |
| 685 | - Database::query($sql); |
|
| 684 | + Database::query($sql); |
|
| 686 | 685 | $id = Database::insert_id(); |
| 687 | 686 | |
| 688 | 687 | if ($id) { |
| 689 | 688 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 690 | 689 | Database::query($sql); |
| 691 | 690 | } |
| 692 | - } |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * Deletes a task from a blog |
|
| 697 | - * @param Integer $blog_id |
|
| 698 | - * @param Integer $task_id |
|
| 699 | - */ |
|
| 700 | - public static function delete_task($blog_id, $task_id) |
|
| 701 | - { |
|
| 702 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 703 | - $course_id = api_get_course_int_id(); |
|
| 704 | - |
|
| 705 | - // Delete posts |
|
| 706 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * Deletes a task from a blog |
|
| 696 | + * @param Integer $blog_id |
|
| 697 | + * @param Integer $task_id |
|
| 698 | + */ |
|
| 699 | + public static function delete_task($blog_id, $task_id) |
|
| 700 | + { |
|
| 701 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 702 | + $course_id = api_get_course_int_id(); |
|
| 703 | + |
|
| 704 | + // Delete posts |
|
| 705 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
| 707 | 706 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
| 708 | - Database::query($sql); |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - /** |
|
| 712 | - * Deletes an assigned task from a blog |
|
| 713 | - * @param Integer $blog_id |
|
| 714 | - * @param Integer $assignment_id |
|
| 715 | - */ |
|
| 716 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
| 717 | - { |
|
| 718 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 707 | + Database::query($sql); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * Deletes an assigned task from a blog |
|
| 712 | + * @param Integer $blog_id |
|
| 713 | + * @param Integer $assignment_id |
|
| 714 | + */ |
|
| 715 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
| 716 | + { |
|
| 717 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 719 | 718 | $course_id = api_get_course_int_id(); |
| 720 | 719 | |
| 721 | - // Delete posts |
|
| 722 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
| 720 | + // Delete posts |
|
| 721 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
| 723 | 722 | WHERE |
| 724 | 723 | c_id = $course_id AND |
| 725 | 724 | blog_id = '".(int)$blog_id."' AND |
| 726 | 725 | task_id = '".(int)$task_id."' AND |
| 727 | 726 | user_id = '".(int)$user_id."'"; |
| 728 | - Database::query($sql); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - /** |
|
| 732 | - * Get personal task list |
|
| 733 | - * @author Toon Keppens |
|
| 734 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
| 735 | - */ |
|
| 736 | - public static function get_personal_task_list() |
|
| 737 | - { |
|
| 738 | - $_user = api_get_user_info(); |
|
| 739 | - |
|
| 740 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 741 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 742 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 743 | - |
|
| 744 | - $course_id = api_get_course_int_id(); |
|
| 745 | - |
|
| 746 | - if ($_user['user_id']) { |
|
| 747 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
| 727 | + Database::query($sql); |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Get personal task list |
|
| 732 | + * @author Toon Keppens |
|
| 733 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
| 734 | + */ |
|
| 735 | + public static function get_personal_task_list() |
|
| 736 | + { |
|
| 737 | + $_user = api_get_user_info(); |
|
| 738 | + |
|
| 739 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 740 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 741 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 742 | + |
|
| 743 | + $course_id = api_get_course_int_id(); |
|
| 744 | + |
|
| 745 | + if ($_user['user_id']) { |
|
| 746 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
| 748 | 747 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 749 | 748 | INNER JOIN $tbl_blogs_tasks task |
| 750 | 749 | ON task_rel_user.task_id = task.task_id |
@@ -758,85 +757,85 @@ discard block |
||
| 758 | 757 | task_rel_user.user_id = ".(int)$_user['user_id']." |
| 759 | 758 | ORDER BY target_date ASC"; |
| 760 | 759 | |
| 761 | - $result = Database::query($sql); |
|
| 762 | - |
|
| 763 | - if (Database::num_rows($result) > 0) { |
|
| 764 | - echo '<ul>'; |
|
| 765 | - while ($mytask = Database::fetch_array($result)) { |
|
| 766 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 767 | - } |
|
| 768 | - echo '<ul>'; |
|
| 769 | - } else { |
|
| 770 | - echo get_lang('NoTasks'); |
|
| 771 | - } |
|
| 772 | - } else { |
|
| 773 | - echo get_lang('NoTasks'); |
|
| 774 | - } |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - /** |
|
| 778 | - * Changes the visibility of a blog |
|
| 779 | - * @author Toon Keppens |
|
| 780 | - * @param Integer $blog_id |
|
| 781 | - */ |
|
| 782 | - public static function change_blog_visibility($blog_id) |
|
| 783 | - { |
|
| 784 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 785 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 786 | - $course_id = api_get_course_int_id(); |
|
| 787 | - |
|
| 788 | - // Get blog properties |
|
| 789 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
| 760 | + $result = Database::query($sql); |
|
| 761 | + |
|
| 762 | + if (Database::num_rows($result) > 0) { |
|
| 763 | + echo '<ul>'; |
|
| 764 | + while ($mytask = Database::fetch_array($result)) { |
|
| 765 | + echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 766 | + } |
|
| 767 | + echo '<ul>'; |
|
| 768 | + } else { |
|
| 769 | + echo get_lang('NoTasks'); |
|
| 770 | + } |
|
| 771 | + } else { |
|
| 772 | + echo get_lang('NoTasks'); |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Changes the visibility of a blog |
|
| 778 | + * @author Toon Keppens |
|
| 779 | + * @param Integer $blog_id |
|
| 780 | + */ |
|
| 781 | + public static function change_blog_visibility($blog_id) |
|
| 782 | + { |
|
| 783 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 784 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 785 | + $course_id = api_get_course_int_id(); |
|
| 786 | + |
|
| 787 | + // Get blog properties |
|
| 788 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
| 790 | 789 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
| 791 | - $result = Database::query($sql); |
|
| 792 | - $blog = Database::fetch_array($result); |
|
| 793 | - $visibility = $blog['visibility']; |
|
| 794 | - $title = $blog['blog_name']; |
|
| 795 | - |
|
| 796 | - if ($visibility == 1) { |
|
| 797 | - // Change visibility state, remove from course home. |
|
| 798 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
| 790 | + $result = Database::query($sql); |
|
| 791 | + $blog = Database::fetch_array($result); |
|
| 792 | + $visibility = $blog['visibility']; |
|
| 793 | + $title = $blog['blog_name']; |
|
| 794 | + |
|
| 795 | + if ($visibility == 1) { |
|
| 796 | + // Change visibility state, remove from course home. |
|
| 797 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
| 799 | 798 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
| 800 | - Database::query($sql); |
|
| 799 | + Database::query($sql); |
|
| 801 | 800 | |
| 802 | - $sql = "DELETE FROM $tbl_tool |
|
| 801 | + $sql = "DELETE FROM $tbl_tool |
|
| 803 | 802 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
| 804 | - Database::query($sql); |
|
| 805 | - } else { |
|
| 806 | - // Change visibility state, add to course home. |
|
| 807 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
| 803 | + Database::query($sql); |
|
| 804 | + } else { |
|
| 805 | + // Change visibility state, add to course home. |
|
| 806 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
| 808 | 807 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
| 809 | - Database::query($sql); |
|
| 808 | + Database::query($sql); |
|
| 810 | 809 | |
| 811 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
| 810 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
| 812 | 811 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
| 813 | - Database::query($sql); |
|
| 812 | + Database::query($sql); |
|
| 814 | 813 | $id = Database::insert_id(); |
| 815 | 814 | |
| 816 | 815 | if ($id) { |
| 817 | 816 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
| 818 | 817 | Database::query($sql); |
| 819 | 818 | } |
| 820 | - } |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - /** |
|
| 824 | - * Shows the posts of a blog |
|
| 825 | - * @author Toon Keppens |
|
| 826 | - * |
|
| 827 | - * @param Integer $blog_id |
|
| 828 | - */ |
|
| 829 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * Shows the posts of a blog |
|
| 824 | + * @author Toon Keppens |
|
| 825 | + * |
|
| 826 | + * @param Integer $blog_id |
|
| 827 | + */ |
|
| 828 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
| 830 | 829 | { |
| 831 | - // Init |
|
| 832 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 833 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 834 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 830 | + // Init |
|
| 831 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 832 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 833 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 835 | 834 | |
| 836 | - $course_id = api_get_course_int_id(); |
|
| 835 | + $course_id = api_get_course_int_id(); |
|
| 837 | 836 | |
| 838 | - // Get posts and authors |
|
| 839 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 837 | + // Get posts and authors |
|
| 838 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 840 | 839 | FROM $tbl_blogs_posts post |
| 841 | 840 | INNER JOIN $tbl_users user |
| 842 | 841 | ON post.author_id = user.user_id |
@@ -844,131 +843,131 @@ discard block |
||
| 844 | 843 | post.c_id = $course_id AND |
| 845 | 844 | $filter |
| 846 | 845 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
| 847 | - $result = Database::query($sql); |
|
| 848 | - |
|
| 849 | - // Display |
|
| 850 | - if(Database::num_rows($result) > 0) { |
|
| 851 | - $limit = 200; |
|
| 852 | - while ($blog_post = Database::fetch_array($result)) { |
|
| 853 | - // Get number of comments |
|
| 854 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
| 846 | + $result = Database::query($sql); |
|
| 847 | + |
|
| 848 | + // Display |
|
| 849 | + if(Database::num_rows($result) > 0) { |
|
| 850 | + $limit = 200; |
|
| 851 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 852 | + // Get number of comments |
|
| 853 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
| 855 | 854 | FROM $tbl_blogs_comments |
| 856 | 855 | WHERE |
| 857 | 856 | c_id = $course_id AND |
| 858 | 857 | blog_id = '".(int)$blog_id."' AND |
| 859 | 858 | post_id = '" . (int)$blog_post['post_id']."'"; |
| 860 | - $tmp = Database::query($sql); |
|
| 861 | - $blog_post_comments = Database::fetch_array($tmp); |
|
| 862 | - |
|
| 863 | - // Prepare data |
|
| 864 | - $blog_post_id = $blog_post['post_id']; |
|
| 865 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 866 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 867 | - |
|
| 868 | - // Create an introduction text (but keep FULL sentences) |
|
| 869 | - $words = 0; |
|
| 870 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 871 | - $words = strlen($blog_post_text); |
|
| 872 | - |
|
| 873 | - if ($words >= $limit) { |
|
| 874 | - $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>'; |
|
| 875 | - $introduction_text = $blog_post_text_cut; |
|
| 876 | - } else { |
|
| 877 | - $introduction_text = $blog_post_text; |
|
| 878 | - $readMoreLink = ''; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - $introduction_text = stripslashes($introduction_text); |
|
| 882 | - |
|
| 883 | - echo '<div class="blogpost">'; |
|
| 884 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 885 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 886 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 887 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 888 | - |
|
| 889 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 890 | - |
|
| 891 | - if (!empty($file_name_array)) { |
|
| 892 | - echo '<br /><br />'; |
|
| 893 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 894 | - echo '<a href="download.php?file='; |
|
| 895 | - echo $file_name_array['path']; |
|
| 896 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
| 897 | - echo '</span>'; |
|
| 898 | - } |
|
| 899 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 900 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 901 | - echo '</div>'; |
|
| 902 | - } |
|
| 903 | - } else { |
|
| 904 | - if($filter == '1=1') { |
|
| 905 | - echo get_lang('NoArticles'); |
|
| 906 | - } else { |
|
| 907 | - echo get_lang('NoArticleMatches'); |
|
| 908 | - } |
|
| 909 | - } |
|
| 859 | + $tmp = Database::query($sql); |
|
| 860 | + $blog_post_comments = Database::fetch_array($tmp); |
|
| 861 | + |
|
| 862 | + // Prepare data |
|
| 863 | + $blog_post_id = $blog_post['post_id']; |
|
| 864 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 865 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 866 | + |
|
| 867 | + // Create an introduction text (but keep FULL sentences) |
|
| 868 | + $words = 0; |
|
| 869 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 870 | + $words = strlen($blog_post_text); |
|
| 871 | + |
|
| 872 | + if ($words >= $limit) { |
|
| 873 | + $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>'; |
|
| 874 | + $introduction_text = $blog_post_text_cut; |
|
| 875 | + } else { |
|
| 876 | + $introduction_text = $blog_post_text; |
|
| 877 | + $readMoreLink = ''; |
|
| 878 | + } |
|
| 879 | + |
|
| 880 | + $introduction_text = stripslashes($introduction_text); |
|
| 881 | + |
|
| 882 | + echo '<div class="blogpost">'; |
|
| 883 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 884 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 885 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 886 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 887 | + |
|
| 888 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 889 | + |
|
| 890 | + if (!empty($file_name_array)) { |
|
| 891 | + echo '<br /><br />'; |
|
| 892 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 893 | + echo '<a href="download.php?file='; |
|
| 894 | + echo $file_name_array['path']; |
|
| 895 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
| 896 | + echo '</span>'; |
|
| 897 | + } |
|
| 898 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 899 | + echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 900 | + echo '</div>'; |
|
| 901 | + } |
|
| 902 | + } else { |
|
| 903 | + if($filter == '1=1') { |
|
| 904 | + echo get_lang('NoArticles'); |
|
| 905 | + } else { |
|
| 906 | + echo get_lang('NoArticleMatches'); |
|
| 907 | + } |
|
| 908 | + } |
|
| 910 | 909 | } |
| 911 | 910 | |
| 912 | - /** |
|
| 913 | - * Display the search results |
|
| 914 | - * |
|
| 915 | - * @param Integer $blog_id |
|
| 916 | - * @param String $query_string |
|
| 917 | - */ |
|
| 918 | - public static function display_search_results ($blog_id, $query_string) |
|
| 919 | - { |
|
| 920 | - // Init |
|
| 921 | - $query_string = Database::escape_string($query_string); |
|
| 922 | - $query_string_parts = explode(' ',$query_string); |
|
| 923 | - $query_string = array(); |
|
| 924 | - foreach ($query_string_parts as $query_part) { |
|
| 925 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 926 | - } |
|
| 927 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 928 | - |
|
| 929 | - // Display the posts |
|
| 930 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 931 | - Blog::display_blog_posts($blog_id, $query_string); |
|
| 932 | - } |
|
| 933 | - |
|
| 934 | - /** |
|
| 935 | - * Display posts from a certain date |
|
| 936 | - * |
|
| 937 | - * @param Integer $blog_id |
|
| 938 | - * @param String $query_string |
|
| 939 | - */ |
|
| 940 | - public static function display_day_results($blog_id, $query_string) |
|
| 941 | - { |
|
| 942 | - $date_output = $query_string; |
|
| 943 | - $date = explode('-',$query_string); |
|
| 944 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 945 | - |
|
| 946 | - // Put date in correct output format |
|
| 947 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
| 948 | - |
|
| 949 | - // Display the posts |
|
| 950 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 951 | - Blog::display_blog_posts($blog_id, $query_string); |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * Displays a post and his comments |
|
| 956 | - * |
|
| 957 | - * @param Integer $blog_id |
|
| 958 | - * @param Integer $post_id |
|
| 959 | - */ |
|
| 960 | - public static function display_post($blog_id, $post_id) |
|
| 961 | - { |
|
| 962 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 963 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 964 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 965 | - |
|
| 966 | - global $charset, $dateFormatLong; |
|
| 967 | - |
|
| 968 | - $course_id = api_get_course_int_id(); |
|
| 969 | - |
|
| 970 | - // Get posts and author |
|
| 971 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 911 | + /** |
|
| 912 | + * Display the search results |
|
| 913 | + * |
|
| 914 | + * @param Integer $blog_id |
|
| 915 | + * @param String $query_string |
|
| 916 | + */ |
|
| 917 | + public static function display_search_results ($blog_id, $query_string) |
|
| 918 | + { |
|
| 919 | + // Init |
|
| 920 | + $query_string = Database::escape_string($query_string); |
|
| 921 | + $query_string_parts = explode(' ',$query_string); |
|
| 922 | + $query_string = array(); |
|
| 923 | + foreach ($query_string_parts as $query_part) { |
|
| 924 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 925 | + } |
|
| 926 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 927 | + |
|
| 928 | + // Display the posts |
|
| 929 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 930 | + Blog::display_blog_posts($blog_id, $query_string); |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + /** |
|
| 934 | + * Display posts from a certain date |
|
| 935 | + * |
|
| 936 | + * @param Integer $blog_id |
|
| 937 | + * @param String $query_string |
|
| 938 | + */ |
|
| 939 | + public static function display_day_results($blog_id, $query_string) |
|
| 940 | + { |
|
| 941 | + $date_output = $query_string; |
|
| 942 | + $date = explode('-',$query_string); |
|
| 943 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 944 | + |
|
| 945 | + // Put date in correct output format |
|
| 946 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
| 947 | + |
|
| 948 | + // Display the posts |
|
| 949 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 950 | + Blog::display_blog_posts($blog_id, $query_string); |
|
| 951 | + } |
|
| 952 | + |
|
| 953 | + /** |
|
| 954 | + * Displays a post and his comments |
|
| 955 | + * |
|
| 956 | + * @param Integer $blog_id |
|
| 957 | + * @param Integer $post_id |
|
| 958 | + */ |
|
| 959 | + public static function display_post($blog_id, $post_id) |
|
| 960 | + { |
|
| 961 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 962 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 963 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 964 | + |
|
| 965 | + global $charset, $dateFormatLong; |
|
| 966 | + |
|
| 967 | + $course_id = api_get_course_int_id(); |
|
| 968 | + |
|
| 969 | + // Get posts and author |
|
| 970 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 972 | 971 | FROM $tbl_blogs_posts post |
| 973 | 972 | INNER JOIN $tbl_users user |
| 974 | 973 | ON post.author_id = user.user_id |
@@ -977,113 +976,113 @@ discard block |
||
| 977 | 976 | post.blog_id = '".(int)$blog_id."' AND |
| 978 | 977 | post.post_id = '".(int)$post_id."' |
| 979 | 978 | ORDER BY post_id DESC"; |
| 980 | - $result = Database::query($sql); |
|
| 981 | - $blog_post = Database::fetch_array($result); |
|
| 979 | + $result = Database::query($sql); |
|
| 980 | + $blog_post = Database::fetch_array($result); |
|
| 982 | 981 | |
| 983 | - // Get number of comments |
|
| 984 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
| 982 | + // Get number of comments |
|
| 983 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
| 985 | 984 | FROM $tbl_blogs_comments |
| 986 | 985 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
| 987 | - $result = Database::query($sql); |
|
| 988 | - $blog_post_comments = Database::fetch_array($result); |
|
| 986 | + $result = Database::query($sql); |
|
| 987 | + $blog_post_comments = Database::fetch_array($result); |
|
| 989 | 988 | |
| 990 | - // Prepare data |
|
| 991 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 992 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 993 | - $blog_post_actions = ""; |
|
| 989 | + // Prepare data |
|
| 990 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 991 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 992 | + $blog_post_actions = ""; |
|
| 994 | 993 | |
| 995 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
| 994 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
| 996 | 995 | |
| 997 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 998 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 999 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1000 | - $blog_post_actions .= '</a>'; |
|
| 996 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 997 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 998 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 999 | + $blog_post_actions .= '</a>'; |
|
| 1001 | 1000 | } |
| 1002 | 1001 | |
| 1003 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1004 | - $blog_post_actions .= '<a href="blog.php?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('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1002 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1003 | + $blog_post_actions .= '<a href="blog.php?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('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1005 | 1004 | $blog_post_actions .= Display::return_icon('delete.png'); |
| 1006 | 1005 | $blog_post_actions .= '</a>'; |
| 1007 | 1006 | } |
| 1008 | 1007 | |
| 1009 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1010 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1008 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1009 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1011 | 1010 | |
| 1012 | - $blog_post_text=stripslashes($blog_post_text); |
|
| 1011 | + $blog_post_text=stripslashes($blog_post_text); |
|
| 1013 | 1012 | |
| 1014 | - // Display post |
|
| 1015 | - echo '<div class="blogpost">'; |
|
| 1016 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1017 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1018 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1013 | + // Display post |
|
| 1014 | + echo '<div class="blogpost">'; |
|
| 1015 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1016 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1017 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1019 | 1018 | |
| 1020 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
| 1019 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
| 1021 | 1020 | |
| 1022 | 1021 | if (!empty($file_name_array)) { |
| 1023 | - echo ' <br />'; |
|
| 1024 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1025 | - echo '<a href="download.php?file='; |
|
| 1026 | - echo $file_name_array['path']; |
|
| 1027 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1028 | - echo '</span>'; |
|
| 1029 | - echo '<span class="attachment_comment">'; |
|
| 1030 | - echo $file_name_array['comment']; |
|
| 1031 | - echo '</span>'; |
|
| 1032 | - echo '<br />'; |
|
| 1033 | - } |
|
| 1022 | + echo ' <br />'; |
|
| 1023 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1024 | + echo '<a href="download.php?file='; |
|
| 1025 | + echo $file_name_array['path']; |
|
| 1026 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1027 | + echo '</span>'; |
|
| 1028 | + echo '<span class="attachment_comment">'; |
|
| 1029 | + echo $file_name_array['comment']; |
|
| 1030 | + echo '</span>'; |
|
| 1031 | + echo '<br />'; |
|
| 1032 | + } |
|
| 1034 | 1033 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1035 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1036 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1037 | - echo '</div>'; |
|
| 1038 | - |
|
| 1039 | - // Display comments if there are any |
|
| 1040 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1041 | - echo '<div class="comments">'; |
|
| 1042 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1043 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
| 1044 | - echo '</div>'; |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - // Display comment form |
|
| 1048 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1049 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
| 1050 | - } |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - /** |
|
| 1054 | - * Adds rating to a certain post or comment |
|
| 1055 | - * @author Toon Keppens |
|
| 1056 | - * |
|
| 1057 | - * @param String $type |
|
| 1058 | - * @param Integer $blog_id |
|
| 1059 | - * @param Integer $item_id |
|
| 1060 | - * @param Integer $rating |
|
| 1061 | - * |
|
| 1062 | - * @return Boolean success |
|
| 1063 | - */ |
|
| 1064 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
| 1065 | - { |
|
| 1066 | - $_user = api_get_user_info(); |
|
| 1067 | - |
|
| 1068 | - // Init |
|
| 1069 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1070 | - $course_id = api_get_course_int_id(); |
|
| 1071 | - |
|
| 1072 | - // Check if the user has already rated this post/comment |
|
| 1073 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1034 | + echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1035 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1036 | + echo '</div>'; |
|
| 1037 | + |
|
| 1038 | + // Display comments if there are any |
|
| 1039 | + if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1040 | + echo '<div class="comments">'; |
|
| 1041 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1042 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
| 1043 | + echo '</div>'; |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + // Display comment form |
|
| 1047 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1048 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1051 | + |
|
| 1052 | + /** |
|
| 1053 | + * Adds rating to a certain post or comment |
|
| 1054 | + * @author Toon Keppens |
|
| 1055 | + * |
|
| 1056 | + * @param String $type |
|
| 1057 | + * @param Integer $blog_id |
|
| 1058 | + * @param Integer $item_id |
|
| 1059 | + * @param Integer $rating |
|
| 1060 | + * |
|
| 1061 | + * @return Boolean success |
|
| 1062 | + */ |
|
| 1063 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
| 1064 | + { |
|
| 1065 | + $_user = api_get_user_info(); |
|
| 1066 | + |
|
| 1067 | + // Init |
|
| 1068 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1069 | + $course_id = api_get_course_int_id(); |
|
| 1070 | + |
|
| 1071 | + // Check if the user has already rated this post/comment |
|
| 1072 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1074 | 1073 | WHERE |
| 1075 | 1074 | c_id = $course_id AND |
| 1076 | 1075 | blog_id = '".(int)$blog_id."' AND |
| 1077 | 1076 | item_id = '".(int)$item_id."' AND |
| 1078 | 1077 | rating_type = '".Database::escape_string($type)."' AND |
| 1079 | 1078 | user_id = '".(int)$_user['user_id']."'"; |
| 1080 | - $result = Database::query($sql); |
|
| 1079 | + $result = Database::query($sql); |
|
| 1081 | 1080 | |
| 1082 | 1081 | // Add rating |
| 1083 | - if (Database::num_rows($result) == 0) { |
|
| 1084 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
| 1082 | + if (Database::num_rows($result) == 0) { |
|
| 1083 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
| 1085 | 1084 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
| 1086 | - Database::query($sql); |
|
| 1085 | + Database::query($sql); |
|
| 1087 | 1086 | |
| 1088 | 1087 | $id = Database::insert_id(); |
| 1089 | 1088 | if ($id) { |
@@ -1091,107 +1090,107 @@ discard block |
||
| 1091 | 1090 | Database::query($sql); |
| 1092 | 1091 | } |
| 1093 | 1092 | |
| 1094 | - return true; |
|
| 1093 | + return true; |
|
| 1095 | 1094 | } else { |
| 1096 | - return false; |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - /** |
|
| 1101 | - * Shows the rating of user |
|
| 1102 | - * |
|
| 1103 | - * @param String $type |
|
| 1104 | - * @param Integer $blog_id |
|
| 1105 | - * @param Integer $item_id |
|
| 1106 | - * |
|
| 1107 | - * @return array() |
|
| 1108 | - */ |
|
| 1109 | - public static function display_rating($type, $blog_id, $item_id) |
|
| 1110 | - { |
|
| 1111 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1112 | - $course_id = api_get_course_int_id(); |
|
| 1113 | - |
|
| 1114 | - // Calculate rating |
|
| 1115 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
| 1095 | + return false; |
|
| 1096 | + } |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + /** |
|
| 1100 | + * Shows the rating of user |
|
| 1101 | + * |
|
| 1102 | + * @param String $type |
|
| 1103 | + * @param Integer $blog_id |
|
| 1104 | + * @param Integer $item_id |
|
| 1105 | + * |
|
| 1106 | + * @return array() |
|
| 1107 | + */ |
|
| 1108 | + public static function display_rating($type, $blog_id, $item_id) |
|
| 1109 | + { |
|
| 1110 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1111 | + $course_id = api_get_course_int_id(); |
|
| 1112 | + |
|
| 1113 | + // Calculate rating |
|
| 1114 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
| 1116 | 1115 | WHERE |
| 1117 | 1116 | c_id = $course_id AND |
| 1118 | 1117 | blog_id = '".(int)$blog_id."' AND |
| 1119 | 1118 | item_id = '".(int)$item_id."' AND |
| 1120 | 1119 | rating_type = '".Database::escape_string($type)."' "; |
| 1121 | - $result = Database::query($sql); |
|
| 1122 | - $result = Database::fetch_array($result); |
|
| 1123 | - return round($result['rating'], 2); |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - /** |
|
| 1127 | - * Shows the rating form if not already rated by that user |
|
| 1128 | - * @author Toon Keppens |
|
| 1129 | - * |
|
| 1130 | - * @param String $type |
|
| 1131 | - * @param Integer $blog_id |
|
| 1132 | - * @param Integer $item_id |
|
| 1133 | - * |
|
| 1134 | - *@return String |
|
| 1135 | - */ |
|
| 1136 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1137 | - { |
|
| 1138 | - $_user = api_get_user_info(); |
|
| 1139 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1120 | + $result = Database::query($sql); |
|
| 1121 | + $result = Database::fetch_array($result); |
|
| 1122 | + return round($result['rating'], 2); |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + /** |
|
| 1126 | + * Shows the rating form if not already rated by that user |
|
| 1127 | + * @author Toon Keppens |
|
| 1128 | + * |
|
| 1129 | + * @param String $type |
|
| 1130 | + * @param Integer $blog_id |
|
| 1131 | + * @param Integer $item_id |
|
| 1132 | + * |
|
| 1133 | + *@return String |
|
| 1134 | + */ |
|
| 1135 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1136 | + { |
|
| 1137 | + $_user = api_get_user_info(); |
|
| 1138 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1140 | 1139 | $course_id = api_get_course_int_id(); |
| 1141 | 1140 | |
| 1142 | 1141 | if ($type == 'post') { |
| 1143 | - // Check if the user has already rated this post |
|
| 1144 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1142 | + // Check if the user has already rated this post |
|
| 1143 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1145 | 1144 | WHERE c_id = $course_id AND |
| 1146 | 1145 | blog_id = '".(int)$blog_id."' |
| 1147 | 1146 | AND item_id = '".(int)$post_id."' |
| 1148 | 1147 | AND rating_type = '".Database::escape_string($type)."' |
| 1149 | 1148 | AND user_id = '".(int)$_user['user_id']."'"; |
| 1150 | - $result = Database::query($sql); |
|
| 1149 | + $result = Database::query($sql); |
|
| 1151 | 1150 | // Add rating |
| 1152 | 1151 | if (Database::num_rows($result) == 0) { |
| 1153 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1152 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1154 | 1153 | } else { |
| 1155 | - return ''; |
|
| 1156 | - } |
|
| 1157 | - } |
|
| 1154 | + return ''; |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1158 | 1157 | |
| 1159 | 1158 | if ($type = 'comment') { |
| 1160 | - // Check if the user has already rated this comment |
|
| 1161 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1159 | + // Check if the user has already rated this comment |
|
| 1160 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1162 | 1161 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
| 1163 | 1162 | AND item_id = '".(int)$comment_id."' |
| 1164 | 1163 | AND rating_type = '".Database::escape_string($type)."' |
| 1165 | 1164 | AND user_id = '".(int)$_user['user_id']."'"; |
| 1166 | - $result = Database::query($sql); |
|
| 1165 | + $result = Database::query($sql); |
|
| 1167 | 1166 | |
| 1168 | 1167 | if (Database::num_rows($result) == 0) { |
| 1169 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1168 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1170 | 1169 | } else { |
| 1171 | - return ''; |
|
| 1172 | - } |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1175 | - |
|
| 1176 | - /** |
|
| 1177 | - * This functions gets all replys to a post, threaded. |
|
| 1178 | - * |
|
| 1179 | - * @param Integer $current |
|
| 1180 | - * @param Integer $current_level |
|
| 1181 | - * @param Integer $blog_id |
|
| 1182 | - * @param Integer $post_id |
|
| 1183 | - */ |
|
| 1184 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
| 1185 | - { |
|
| 1186 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 1187 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1188 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1189 | - global $charset; |
|
| 1190 | - |
|
| 1191 | - $course_id = api_get_course_int_id(); |
|
| 1192 | - |
|
| 1193 | - // Select top level comments |
|
| 1194 | - $next_level = $current_level + 1; |
|
| 1170 | + return ''; |
|
| 1171 | + } |
|
| 1172 | + } |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + /** |
|
| 1176 | + * This functions gets all replys to a post, threaded. |
|
| 1177 | + * |
|
| 1178 | + * @param Integer $current |
|
| 1179 | + * @param Integer $current_level |
|
| 1180 | + * @param Integer $blog_id |
|
| 1181 | + * @param Integer $post_id |
|
| 1182 | + */ |
|
| 1183 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
| 1184 | + { |
|
| 1185 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 1186 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1187 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1188 | + global $charset; |
|
| 1189 | + |
|
| 1190 | + $course_id = api_get_course_int_id(); |
|
| 1191 | + |
|
| 1192 | + // Select top level comments |
|
| 1193 | + $next_level = $current_level + 1; |
|
| 1195 | 1194 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
| 1196 | 1195 | FROM $tbl_blogs_comments comments |
| 1197 | 1196 | INNER JOIN $tbl_users user |
@@ -1203,11 +1202,11 @@ discard block |
||
| 1203 | 1202 | parent_comment_id = $current AND |
| 1204 | 1203 | comments.blog_id = '".(int)$blog_id."' AND |
| 1205 | 1204 | comments.post_id = '".(int)$post_id."'"; |
| 1206 | - $result = Database::query($sql); |
|
| 1205 | + $result = Database::query($sql); |
|
| 1207 | 1206 | |
| 1208 | - while($comment = Database::fetch_array($result)) { |
|
| 1209 | - // Select the children recursivly |
|
| 1210 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
| 1207 | + while($comment = Database::fetch_array($result)) { |
|
| 1208 | + // Select the children recursivly |
|
| 1209 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
| 1211 | 1210 | FROM $tbl_blogs_comments comments |
| 1212 | 1211 | INNER JOIN $tbl_users user |
| 1213 | 1212 | ON comments.author_id = user.user_id |
@@ -1216,15 +1215,15 @@ discard block |
||
| 1216 | 1215 | comment_id = $current |
| 1217 | 1216 | AND blog_id = '".(int)$blog_id."' |
| 1218 | 1217 | AND post_id = '".(int)$post_id."'"; |
| 1219 | - $tmp = Database::query($tmp); |
|
| 1220 | - $tmp = Database::fetch_array($tmp); |
|
| 1221 | - $parent_cat = $tmp['parent_comment_id']; |
|
| 1222 | - $border_color = ''; |
|
| 1223 | - |
|
| 1224 | - // Prepare data |
|
| 1225 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
| 1226 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
| 1227 | - $blog_comment_actions = ""; |
|
| 1218 | + $tmp = Database::query($tmp); |
|
| 1219 | + $tmp = Database::fetch_array($tmp); |
|
| 1220 | + $parent_cat = $tmp['parent_comment_id']; |
|
| 1221 | + $border_color = ''; |
|
| 1222 | + |
|
| 1223 | + // Prepare data |
|
| 1224 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
| 1225 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
| 1226 | + $blog_comment_actions = ""; |
|
| 1228 | 1227 | if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
| 1229 | 1228 | $blog_comment_actions .= '<a href="blog.php?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( |
| 1230 | 1229 | 'DeleteThisComment' |
@@ -1239,167 +1238,167 @@ discard block |
||
| 1239 | 1238 | $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); |
| 1240 | 1239 | } |
| 1241 | 1240 | |
| 1242 | - if (!is_null($comment['task_id'])) { |
|
| 1243 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - $comment_text = stripslashes($comment_text); |
|
| 1247 | - |
|
| 1248 | - // Output... |
|
| 1249 | - $margin = $current_level * 30; |
|
| 1250 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1251 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1252 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1253 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1254 | - |
|
| 1255 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1256 | - if (!empty($file_name_array)) { |
|
| 1257 | - echo '<br /><br />'; |
|
| 1258 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1259 | - echo '<a href="download.php?file='; |
|
| 1260 | - echo $file_name_array['path']; |
|
| 1261 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1262 | - echo '<span class="attachment_comment">'; |
|
| 1263 | - echo $file_name_array['comment']; |
|
| 1264 | - echo '</span><br />'; |
|
| 1265 | - } |
|
| 1266 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
| 1267 | - 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>'; |
|
| 1268 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1269 | - echo '</div>'; |
|
| 1270 | - |
|
| 1271 | - // Go further down the tree. |
|
| 1272 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
| 1273 | - } |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Displays the form to create a new post |
|
| 1278 | - * @author Toon Keppens |
|
| 1279 | - * |
|
| 1280 | - * @param Integer $blog_id |
|
| 1281 | - */ |
|
| 1282 | - public static function display_form_new_post($blog_id) |
|
| 1283 | - { |
|
| 1284 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1285 | - $form = new FormValidator( |
|
| 1286 | - 'add_post', |
|
| 1287 | - 'post', |
|
| 1288 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1289 | - null, |
|
| 1290 | - array('enctype' => 'multipart/form-data') |
|
| 1291 | - ); |
|
| 1292 | - $form->addHidden('post_title_edited', 'false'); |
|
| 1293 | - $form->addHeader(get_lang('NewPost')); |
|
| 1294 | - $form->addText('title', get_lang('Title')); |
|
| 1295 | - $config = array(); |
|
| 1296 | - if (!api_is_allowed_to_edit()) { |
|
| 1297 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1298 | - } else { |
|
| 1299 | - $config['ToolbarSet'] = 'Project'; |
|
| 1300 | - } |
|
| 1301 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1302 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 1303 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 1304 | - $form->addHidden('new_post_submit', 'true'); |
|
| 1305 | - $form->addButton('save', get_lang('Save')); |
|
| 1306 | - |
|
| 1307 | - $form->display(); |
|
| 1308 | - } else { |
|
| 1309 | - api_not_allowed(); |
|
| 1310 | - } |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - /** |
|
| 1314 | - * Displays the form to edit a post |
|
| 1315 | - * @author Toon Keppens |
|
| 1316 | - * |
|
| 1317 | - * @param Integer $blog_id |
|
| 1318 | - */ |
|
| 1319 | - public static function display_form_edit_post($blog_id, $post_id) |
|
| 1320 | - { |
|
| 1321 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1322 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1323 | - |
|
| 1324 | - $course_id = api_get_course_int_id(); |
|
| 1325 | - |
|
| 1326 | - // Get posts and author |
|
| 1327 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
| 1328 | - FROM $tbl_blogs_posts post |
|
| 1329 | - INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
| 1330 | - WHERE |
|
| 1331 | - post.c_id = $course_id AND |
|
| 1332 | - post.blog_id = '".(int)$blog_id ."' |
|
| 1333 | - AND post.post_id = '".(int)$post_id."' |
|
| 1334 | - ORDER BY post_id DESC"; |
|
| 1335 | - $result = Database::query($sql); |
|
| 1336 | - $blog_post = Database::fetch_array($result); |
|
| 1337 | - |
|
| 1338 | - // Form |
|
| 1339 | - $form = new FormValidator( |
|
| 1340 | - 'edit_post', |
|
| 1341 | - 'post', |
|
| 1342 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1343 | - ); |
|
| 1344 | - |
|
| 1345 | - $form->addHeader(get_lang('EditPost')); |
|
| 1346 | - $form->addText('title', get_lang('Title')); |
|
| 1347 | - |
|
| 1348 | - if (!api_is_allowed_to_edit()) { |
|
| 1349 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1350 | - } else { |
|
| 1351 | - $config['ToolbarSet'] = 'Project'; |
|
| 1352 | - } |
|
| 1353 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1354 | - |
|
| 1355 | - $form->addHidden('action', ''); |
|
| 1356 | - $form->addHidden('edit_post_submit', 'true'); |
|
| 1357 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
| 1358 | - $form->addButton('save', get_lang('Save')); |
|
| 1359 | - $form->setDefaults($blog_post); |
|
| 1360 | - $form->display(); |
|
| 1361 | - } |
|
| 1362 | - |
|
| 1363 | - /** |
|
| 1364 | - * Displays a list of tasks in this blog |
|
| 1365 | - * @author Toon Keppens |
|
| 1366 | - * |
|
| 1367 | - * @param Integer $blog_id |
|
| 1368 | - */ |
|
| 1369 | - public static function display_task_list($blog_id) |
|
| 1241 | + if (!is_null($comment['task_id'])) { |
|
| 1242 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1243 | + } |
|
| 1244 | + |
|
| 1245 | + $comment_text = stripslashes($comment_text); |
|
| 1246 | + |
|
| 1247 | + // Output... |
|
| 1248 | + $margin = $current_level * 30; |
|
| 1249 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1250 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1251 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1252 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1253 | + |
|
| 1254 | + $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1255 | + if (!empty($file_name_array)) { |
|
| 1256 | + echo '<br /><br />'; |
|
| 1257 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1258 | + echo '<a href="download.php?file='; |
|
| 1259 | + echo $file_name_array['path']; |
|
| 1260 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1261 | + echo '<span class="attachment_comment">'; |
|
| 1262 | + echo $file_name_array['comment']; |
|
| 1263 | + echo '</span><br />'; |
|
| 1264 | + } |
|
| 1265 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
| 1266 | + 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>'; |
|
| 1267 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1268 | + echo '</div>'; |
|
| 1269 | + |
|
| 1270 | + // Go further down the tree. |
|
| 1271 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
| 1272 | + } |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + /** |
|
| 1276 | + * Displays the form to create a new post |
|
| 1277 | + * @author Toon Keppens |
|
| 1278 | + * |
|
| 1279 | + * @param Integer $blog_id |
|
| 1280 | + */ |
|
| 1281 | + public static function display_form_new_post($blog_id) |
|
| 1282 | + { |
|
| 1283 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1284 | + $form = new FormValidator( |
|
| 1285 | + 'add_post', |
|
| 1286 | + 'post', |
|
| 1287 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1288 | + null, |
|
| 1289 | + array('enctype' => 'multipart/form-data') |
|
| 1290 | + ); |
|
| 1291 | + $form->addHidden('post_title_edited', 'false'); |
|
| 1292 | + $form->addHeader(get_lang('NewPost')); |
|
| 1293 | + $form->addText('title', get_lang('Title')); |
|
| 1294 | + $config = array(); |
|
| 1295 | + if (!api_is_allowed_to_edit()) { |
|
| 1296 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1297 | + } else { |
|
| 1298 | + $config['ToolbarSet'] = 'Project'; |
|
| 1299 | + } |
|
| 1300 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1301 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 1302 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 1303 | + $form->addHidden('new_post_submit', 'true'); |
|
| 1304 | + $form->addButton('save', get_lang('Save')); |
|
| 1305 | + |
|
| 1306 | + $form->display(); |
|
| 1307 | + } else { |
|
| 1308 | + api_not_allowed(); |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1311 | + |
|
| 1312 | + /** |
|
| 1313 | + * Displays the form to edit a post |
|
| 1314 | + * @author Toon Keppens |
|
| 1315 | + * |
|
| 1316 | + * @param Integer $blog_id |
|
| 1317 | + */ |
|
| 1318 | + public static function display_form_edit_post($blog_id, $post_id) |
|
| 1319 | + { |
|
| 1320 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1321 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1322 | + |
|
| 1323 | + $course_id = api_get_course_int_id(); |
|
| 1324 | + |
|
| 1325 | + // Get posts and author |
|
| 1326 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
| 1327 | + FROM $tbl_blogs_posts post |
|
| 1328 | + INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
| 1329 | + WHERE |
|
| 1330 | + post.c_id = $course_id AND |
|
| 1331 | + post.blog_id = '".(int)$blog_id ."' |
|
| 1332 | + AND post.post_id = '".(int)$post_id."' |
|
| 1333 | + ORDER BY post_id DESC"; |
|
| 1334 | + $result = Database::query($sql); |
|
| 1335 | + $blog_post = Database::fetch_array($result); |
|
| 1336 | + |
|
| 1337 | + // Form |
|
| 1338 | + $form = new FormValidator( |
|
| 1339 | + 'edit_post', |
|
| 1340 | + 'post', |
|
| 1341 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1342 | + ); |
|
| 1343 | + |
|
| 1344 | + $form->addHeader(get_lang('EditPost')); |
|
| 1345 | + $form->addText('title', get_lang('Title')); |
|
| 1346 | + |
|
| 1347 | + if (!api_is_allowed_to_edit()) { |
|
| 1348 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1349 | + } else { |
|
| 1350 | + $config['ToolbarSet'] = 'Project'; |
|
| 1351 | + } |
|
| 1352 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1353 | + |
|
| 1354 | + $form->addHidden('action', ''); |
|
| 1355 | + $form->addHidden('edit_post_submit', 'true'); |
|
| 1356 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
| 1357 | + $form->addButton('save', get_lang('Save')); |
|
| 1358 | + $form->setDefaults($blog_post); |
|
| 1359 | + $form->display(); |
|
| 1360 | + } |
|
| 1361 | + |
|
| 1362 | + /** |
|
| 1363 | + * Displays a list of tasks in this blog |
|
| 1364 | + * @author Toon Keppens |
|
| 1365 | + * |
|
| 1366 | + * @param Integer $blog_id |
|
| 1367 | + */ |
|
| 1368 | + public static function display_task_list($blog_id) |
|
| 1370 | 1369 | { |
| 1371 | - global $charset; |
|
| 1370 | + global $charset; |
|
| 1372 | 1371 | $course_id = api_get_course_int_id(); |
| 1373 | 1372 | |
| 1374 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1375 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1376 | - $counter = 0; |
|
| 1377 | - global $color2; |
|
| 1373 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1374 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1375 | + $counter = 0; |
|
| 1376 | + global $color2; |
|
| 1378 | 1377 | |
| 1379 | - echo '<div class="actions">'; |
|
| 1380 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1378 | + echo '<div class="actions">'; |
|
| 1379 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1381 | 1380 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
| 1382 | 1381 | echo get_lang('AddTasks') . '</a> '; |
| 1383 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1382 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1384 | 1383 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
| 1385 | 1384 | echo get_lang('AssignTasks') . '</a>'; |
| 1386 | - ?> |
|
| 1385 | + ?> |
|
| 1387 | 1386 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
| 1388 | 1387 | <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
| 1389 | 1388 | <?php |
| 1390 | - echo '</div>'; |
|
| 1389 | + echo '</div>'; |
|
| 1391 | 1390 | |
| 1392 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1393 | - echo "<table class=\"data_table\">"; |
|
| 1394 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1395 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
| 1396 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1397 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
| 1398 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1399 | - "</tr>"; |
|
| 1391 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1392 | + echo "<table class=\"data_table\">"; |
|
| 1393 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1394 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
| 1395 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1396 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
| 1397 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1398 | + "</tr>"; |
|
| 1400 | 1399 | |
| 1401 | 1400 | |
| 1402 | - $sql = " SELECT |
|
| 1401 | + $sql = " SELECT |
|
| 1403 | 1402 | blog_id, |
| 1404 | 1403 | task_id, |
| 1405 | 1404 | blog_id, |
@@ -1410,64 +1409,64 @@ discard block |
||
| 1410 | 1409 | FROM " . $tbl_blogs_tasks . " |
| 1411 | 1410 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
| 1412 | 1411 | ORDER BY system_task, title"; |
| 1413 | - $result = Database::query($sql); |
|
| 1412 | + $result = Database::query($sql); |
|
| 1414 | 1413 | |
| 1415 | - while ($task = Database::fetch_array($result)) { |
|
| 1416 | - $counter++; |
|
| 1417 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1418 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
| 1419 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1420 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1421 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1414 | + while ($task = Database::fetch_array($result)) { |
|
| 1415 | + $counter++; |
|
| 1416 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1417 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
| 1418 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1419 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1420 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1422 | 1421 | |
| 1423 | - echo '<tr class="' . $css_class . '" valign="top">'; |
|
| 1422 | + echo '<tr class="' . $css_class . '" valign="top">'; |
|
| 1424 | 1423 | echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>'; |
| 1425 | 1424 | echo '<td>'.Security::remove_XSS($task['description']).'</td>'; |
| 1426 | 1425 | echo '<td><span style="background-color: #'.$task['color'].'"> </span></td>'; |
| 1427 | 1426 | echo '<td width="50">'; |
| 1428 | 1427 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">', |
| 1429 | 1428 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
| 1430 | - echo "</a>"; |
|
| 1431 | - echo '<a href="'.$delete_link.'"'; |
|
| 1432 | - echo $delete_confirm; |
|
| 1433 | - echo '>'; |
|
| 1429 | + echo "</a>"; |
|
| 1430 | + echo '<a href="'.$delete_link.'"'; |
|
| 1431 | + echo $delete_confirm; |
|
| 1432 | + echo '>'; |
|
| 1434 | 1433 | echo Display::return_icon($delete_icon, $delete_title); |
| 1435 | - echo "</a>"; |
|
| 1436 | - echo '</td>'; |
|
| 1437 | - echo '</tr>'; |
|
| 1438 | - } |
|
| 1439 | - echo "</table>"; |
|
| 1440 | - } |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - /** |
|
| 1444 | - * Displays a list of tasks assigned to a user in this blog |
|
| 1445 | - * @author Toon Keppens |
|
| 1446 | - * |
|
| 1447 | - * @param Integer $blog_id |
|
| 1448 | - */ |
|
| 1449 | - public static function display_assigned_task_list ($blog_id) |
|
| 1434 | + echo "</a>"; |
|
| 1435 | + echo '</td>'; |
|
| 1436 | + echo '</tr>'; |
|
| 1437 | + } |
|
| 1438 | + echo "</table>"; |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | + |
|
| 1442 | + /** |
|
| 1443 | + * Displays a list of tasks assigned to a user in this blog |
|
| 1444 | + * @author Toon Keppens |
|
| 1445 | + * |
|
| 1446 | + * @param Integer $blog_id |
|
| 1447 | + */ |
|
| 1448 | + public static function display_assigned_task_list ($blog_id) |
|
| 1450 | 1449 | { |
| 1451 | - // Init |
|
| 1452 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1453 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1454 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1455 | - $counter = 0; |
|
| 1456 | - global $charset,$color2; |
|
| 1457 | - |
|
| 1458 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1459 | - echo "<table class=\"data_table\">"; |
|
| 1460 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1461 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
| 1462 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
| 1463 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1464 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
| 1465 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1466 | - "</tr>"; |
|
| 1467 | - |
|
| 1468 | - $course_id = api_get_course_int_id(); |
|
| 1469 | - |
|
| 1470 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
| 1450 | + // Init |
|
| 1451 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1452 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1453 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1454 | + $counter = 0; |
|
| 1455 | + global $charset,$color2; |
|
| 1456 | + |
|
| 1457 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1458 | + echo "<table class=\"data_table\">"; |
|
| 1459 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1460 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
| 1461 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
| 1462 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1463 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
| 1464 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1465 | + "</tr>"; |
|
| 1466 | + |
|
| 1467 | + $course_id = api_get_course_int_id(); |
|
| 1468 | + |
|
| 1469 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
| 1471 | 1470 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 1472 | 1471 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
| 1473 | 1472 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1476,15 +1475,15 @@ discard block |
||
| 1476 | 1475 | task.c_id = $course_id AND |
| 1477 | 1476 | task_rel_user.blog_id = '".(int)$blog_id."' |
| 1478 | 1477 | ORDER BY target_date ASC"; |
| 1479 | - $result = Database::query($sql); |
|
| 1478 | + $result = Database::query($sql); |
|
| 1480 | 1479 | |
| 1481 | - while ($assignment = Database::fetch_array($result)) { |
|
| 1482 | - $counter++; |
|
| 1483 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1484 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
| 1485 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1486 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1487 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1480 | + while ($assignment = Database::fetch_array($result)) { |
|
| 1481 | + $counter++; |
|
| 1482 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1483 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
| 1484 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1485 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1486 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1488 | 1487 | |
| 1489 | 1488 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
| 1490 | 1489 | |
@@ -1499,26 +1498,26 @@ discard block |
||
| 1499 | 1498 | echo '<td>'.$assignment['target_date'].'</td>'; |
| 1500 | 1499 | echo '<td width="50">'; |
| 1501 | 1500 | echo '<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'].'">', |
| 1502 | - echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
| 1503 | - echo "</a>"; |
|
| 1504 | - echo '<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'].'" '; |
|
| 1505 | - echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1501 | + echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
| 1502 | + echo "</a>"; |
|
| 1503 | + echo '<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'].'" '; |
|
| 1504 | + echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1506 | 1505 | echo Display::return_icon($delete_icon, $delete_title); |
| 1507 | - echo "</a>"; |
|
| 1508 | - echo '</td>'; |
|
| 1509 | - echo '</tr>'; |
|
| 1510 | - } |
|
| 1511 | - echo "</table>"; |
|
| 1512 | - } |
|
| 1513 | - |
|
| 1514 | - /** |
|
| 1515 | - * Displays new task form |
|
| 1516 | - * @author Toon Keppens |
|
| 1517 | - * |
|
| 1518 | - */ |
|
| 1519 | - public static function display_new_task_form ($blog_id) |
|
| 1520 | - { |
|
| 1521 | - // Init |
|
| 1506 | + echo "</a>"; |
|
| 1507 | + echo '</td>'; |
|
| 1508 | + echo '</tr>'; |
|
| 1509 | + } |
|
| 1510 | + echo "</table>"; |
|
| 1511 | + } |
|
| 1512 | + |
|
| 1513 | + /** |
|
| 1514 | + * Displays new task form |
|
| 1515 | + * @author Toon Keppens |
|
| 1516 | + * |
|
| 1517 | + */ |
|
| 1518 | + public static function display_new_task_form ($blog_id) |
|
| 1519 | + { |
|
| 1520 | + // Init |
|
| 1522 | 1521 | $colors = array( |
| 1523 | 1522 | 'FFFFFF', |
| 1524 | 1523 | 'FFFF99', |
@@ -1537,14 +1536,14 @@ discard block |
||
| 1537 | 1536 | '000000' |
| 1538 | 1537 | ); |
| 1539 | 1538 | |
| 1540 | - // form |
|
| 1541 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1539 | + // form |
|
| 1540 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1542 | 1541 | |
| 1543 | - // form title |
|
| 1544 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
| 1542 | + // form title |
|
| 1543 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
| 1545 | 1544 | |
| 1546 | - // task title |
|
| 1547 | - echo ' <div class="control-group"> |
|
| 1545 | + // task title |
|
| 1546 | + echo ' <div class="control-group"> |
|
| 1548 | 1547 | <label class="control-label"> |
| 1549 | 1548 | <span class="form_required">*</span>' . get_lang('Title') . ' |
| 1550 | 1549 | </label> |
@@ -1553,8 +1552,8 @@ discard block |
||
| 1553 | 1552 | </div> |
| 1554 | 1553 | </div>'; |
| 1555 | 1554 | |
| 1556 | - // task comment |
|
| 1557 | - echo ' <div class="control-group"> |
|
| 1555 | + // task comment |
|
| 1556 | + echo ' <div class="control-group"> |
|
| 1558 | 1557 | <label class="control-label"> |
| 1559 | 1558 | ' . get_lang('Description') . ' |
| 1560 | 1559 | </label> |
@@ -1563,8 +1562,8 @@ discard block |
||
| 1563 | 1562 | </div> |
| 1564 | 1563 | </div>'; |
| 1565 | 1564 | |
| 1566 | - // task management |
|
| 1567 | - echo ' <div class="control-group"> |
|
| 1565 | + // task management |
|
| 1566 | + echo ' <div class="control-group"> |
|
| 1568 | 1567 | <label class="control-label"> |
| 1569 | 1568 | ' . get_lang('TaskManager') . ' |
| 1570 | 1569 | </label> |
@@ -1585,12 +1584,12 @@ discard block |
||
| 1585 | 1584 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
| 1586 | 1585 | echo '</tr>'; |
| 1587 | 1586 | echo '</table>'; |
| 1588 | - echo ' </div> |
|
| 1587 | + echo ' </div> |
|
| 1589 | 1588 | </div>'; |
| 1590 | 1589 | |
| 1591 | 1590 | |
| 1592 | - // task color |
|
| 1593 | - echo ' <div class="control-group"> |
|
| 1591 | + // task color |
|
| 1592 | + echo ' <div class="control-group"> |
|
| 1594 | 1593 | <label class="control-label"> |
| 1595 | 1594 | ' . get_lang('Color') . ' |
| 1596 | 1595 | </label> |
@@ -1601,40 +1600,40 @@ discard block |
||
| 1601 | 1600 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
| 1602 | 1601 | } |
| 1603 | 1602 | echo '</select>'; |
| 1604 | - echo ' </div> |
|
| 1603 | + echo ' </div> |
|
| 1605 | 1604 | </div>'; |
| 1606 | 1605 | |
| 1607 | - // submit |
|
| 1608 | - echo ' <div class="control-group"> |
|
| 1606 | + // submit |
|
| 1607 | + echo ' <div class="control-group"> |
|
| 1609 | 1608 | <div class="controls"> |
| 1610 | 1609 | <input type="hidden" name="action" value="" /> |
| 1611 | 1610 | <input type="hidden" name="new_task_submit" value="true" /> |
| 1612 | 1611 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
| 1613 | 1612 | </div> |
| 1614 | 1613 | </div>'; |
| 1615 | - echo '</form>'; |
|
| 1614 | + echo '</form>'; |
|
| 1616 | 1615 | |
| 1617 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
| 1618 | - } |
|
| 1616 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
| 1617 | + } |
|
| 1619 | 1618 | |
| 1620 | 1619 | |
| 1621 | - /** |
|
| 1622 | - * Displays edit task form |
|
| 1623 | - * @author Toon Keppens |
|
| 1624 | - * |
|
| 1625 | - */ |
|
| 1626 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1627 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1620 | + /** |
|
| 1621 | + * Displays edit task form |
|
| 1622 | + * @author Toon Keppens |
|
| 1623 | + * |
|
| 1624 | + */ |
|
| 1625 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1626 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1628 | 1627 | $course_id = api_get_course_int_id(); |
| 1629 | 1628 | |
| 1630 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1629 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1631 | 1630 | |
| 1632 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1633 | - $result = Database::query($sql); |
|
| 1634 | - $task = Database::fetch_array($result); |
|
| 1631 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1632 | + $result = Database::query($sql); |
|
| 1633 | + $task = Database::fetch_array($result); |
|
| 1635 | 1634 | |
| 1636 | - // Display |
|
| 1637 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1635 | + // Display |
|
| 1636 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1638 | 1637 | <legend>' . get_lang('EditTask') . '</legend> |
| 1639 | 1638 | <table width="100%" border="0" cellspacing="2"> |
| 1640 | 1639 | <tr> |
@@ -1646,42 +1645,42 @@ discard block |
||
| 1646 | 1645 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
| 1647 | 1646 | </tr>'; |
| 1648 | 1647 | |
| 1649 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
| 1650 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 1648 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
| 1649 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 1651 | 1650 | |
| 1652 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1651 | + $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1653 | 1652 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
| 1654 | - $result = Database::query($sql); |
|
| 1655 | - |
|
| 1656 | - $arrPermissions = array(); |
|
| 1657 | - |
|
| 1658 | - while ($row = Database::fetch_array($result)) |
|
| 1659 | - $arrPermissions[] = $row['action']; |
|
| 1660 | - |
|
| 1661 | - echo '<tr>'; |
|
| 1662 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1663 | - echo '<td>'; |
|
| 1664 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
| 1665 | - echo '<tr>'; |
|
| 1666 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1667 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1668 | - echo '</tr>'; |
|
| 1669 | - echo '<tr>'; |
|
| 1670 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1671 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1672 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1673 | - echo '</tr>'; |
|
| 1674 | - echo '<tr>'; |
|
| 1675 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1676 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1677 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1678 | - echo '</tr>'; |
|
| 1679 | - echo '</table>'; |
|
| 1680 | - echo '</td>'; |
|
| 1681 | - echo '</tr>'; |
|
| 1682 | - /* end of edit */ |
|
| 1683 | - |
|
| 1684 | - echo '<tr> |
|
| 1653 | + $result = Database::query($sql); |
|
| 1654 | + |
|
| 1655 | + $arrPermissions = array(); |
|
| 1656 | + |
|
| 1657 | + while ($row = Database::fetch_array($result)) |
|
| 1658 | + $arrPermissions[] = $row['action']; |
|
| 1659 | + |
|
| 1660 | + echo '<tr>'; |
|
| 1661 | + echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1662 | + echo '<td>'; |
|
| 1663 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
| 1664 | + echo '<tr>'; |
|
| 1665 | + echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1666 | + echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1667 | + echo '</tr>'; |
|
| 1668 | + echo '<tr>'; |
|
| 1669 | + echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1670 | + echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1671 | + echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1672 | + echo '</tr>'; |
|
| 1673 | + echo '<tr>'; |
|
| 1674 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1675 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1676 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1677 | + echo '</tr>'; |
|
| 1678 | + echo '</table>'; |
|
| 1679 | + echo '</td>'; |
|
| 1680 | + echo '</tr>'; |
|
| 1681 | + /* end of edit */ |
|
| 1682 | + |
|
| 1683 | + echo '<tr> |
|
| 1685 | 1684 | <td align="right">' . get_lang('Color') . ': </td> |
| 1686 | 1685 | <td> |
| 1687 | 1686 | <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">'; |
@@ -1690,7 +1689,7 @@ discard block |
||
| 1690 | 1689 | $style = 'style="background-color: #' . $color . '"'; |
| 1691 | 1690 | echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
| 1692 | 1691 | } |
| 1693 | - echo ' </select> |
|
| 1692 | + echo ' </select> |
|
| 1694 | 1693 | </td> |
| 1695 | 1694 | </tr> |
| 1696 | 1695 | <tr> |
@@ -1703,34 +1702,34 @@ discard block |
||
| 1703 | 1702 | </tr> |
| 1704 | 1703 | </table> |
| 1705 | 1704 | </form>'; |
| 1706 | - } |
|
| 1707 | - |
|
| 1708 | - /** |
|
| 1709 | - * @param $blog_id |
|
| 1710 | - * @return FormValidator |
|
| 1711 | - */ |
|
| 1712 | - public static function getTaskForm($blog_id) |
|
| 1713 | - { |
|
| 1714 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1715 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1716 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1717 | - $course_id = api_get_course_int_id(); |
|
| 1718 | - |
|
| 1719 | - // Get users in this blog / make select list of it |
|
| 1720 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
| 1705 | + } |
|
| 1706 | + |
|
| 1707 | + /** |
|
| 1708 | + * @param $blog_id |
|
| 1709 | + * @return FormValidator |
|
| 1710 | + */ |
|
| 1711 | + public static function getTaskForm($blog_id) |
|
| 1712 | + { |
|
| 1713 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1714 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1715 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1716 | + $course_id = api_get_course_int_id(); |
|
| 1717 | + |
|
| 1718 | + // Get users in this blog / make select list of it |
|
| 1719 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
| 1721 | 1720 | FROM $tbl_users user |
| 1722 | 1721 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 1723 | 1722 | ON user.user_id = blogs_rel_user.user_id |
| 1724 | 1723 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
| 1725 | - $result = Database::query($sql); |
|
| 1724 | + $result = Database::query($sql); |
|
| 1726 | 1725 | |
| 1727 | - $options = array(); |
|
| 1728 | - while ($user = Database::fetch_array($result)) { |
|
| 1729 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 1730 | - } |
|
| 1726 | + $options = array(); |
|
| 1727 | + while ($user = Database::fetch_array($result)) { |
|
| 1728 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 1729 | + } |
|
| 1731 | 1730 | |
| 1732 | - // Get tasks in this blog / make select list of it |
|
| 1733 | - $sql = " |
|
| 1731 | + // Get tasks in this blog / make select list of it |
|
| 1732 | + $sql = " |
|
| 1734 | 1733 | SELECT |
| 1735 | 1734 | blog_id, |
| 1736 | 1735 | task_id, |
@@ -1742,97 +1741,97 @@ discard block |
||
| 1742 | 1741 | FROM $tbl_blogs_tasks |
| 1743 | 1742 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
| 1744 | 1743 | ORDER BY system_task, title"; |
| 1745 | - $result = Database::query($sql); |
|
| 1746 | - |
|
| 1747 | - $taskOptions = array(); |
|
| 1748 | - while ($task = Database::fetch_array($result)) { |
|
| 1749 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
| 1750 | - } |
|
| 1751 | - |
|
| 1752 | - $form = new FormValidator( |
|
| 1753 | - 'assign_task', |
|
| 1754 | - 'post', |
|
| 1755 | - api_get_path( |
|
| 1756 | - WEB_CODE_PATH |
|
| 1757 | - ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
| 1758 | - ); |
|
| 1759 | - |
|
| 1760 | - $form->addHeader(get_lang('AssignTask')); |
|
| 1761 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
| 1762 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
| 1763 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
| 1764 | - |
|
| 1765 | - $form->addHidden('action', ''); |
|
| 1766 | - $form->addButtonSave(get_lang('Ok')); |
|
| 1767 | - |
|
| 1768 | - return $form; |
|
| 1769 | - } |
|
| 1770 | - |
|
| 1771 | - /** |
|
| 1772 | - * Displays assign task form |
|
| 1773 | - * @author Toon Keppens |
|
| 1774 | - * |
|
| 1775 | - */ |
|
| 1776 | - public static function display_assign_task_form($blog_id) |
|
| 1777 | - { |
|
| 1778 | - $form = self::getTaskForm($blog_id); |
|
| 1779 | - $form->addHidden('assign_task_submit', 'true'); |
|
| 1780 | - $form->display(); |
|
| 1781 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
| 1782 | - } |
|
| 1783 | - |
|
| 1784 | - /** |
|
| 1785 | - * Displays assign task form |
|
| 1786 | - * @author Toon Keppens |
|
| 1787 | - * |
|
| 1788 | - */ |
|
| 1789 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
| 1790 | - { |
|
| 1791 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1792 | - |
|
| 1793 | - $course_id = api_get_course_int_id(); |
|
| 1794 | - |
|
| 1795 | - // Get assignd date; |
|
| 1796 | - $sql = " |
|
| 1744 | + $result = Database::query($sql); |
|
| 1745 | + |
|
| 1746 | + $taskOptions = array(); |
|
| 1747 | + while ($task = Database::fetch_array($result)) { |
|
| 1748 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
| 1749 | + } |
|
| 1750 | + |
|
| 1751 | + $form = new FormValidator( |
|
| 1752 | + 'assign_task', |
|
| 1753 | + 'post', |
|
| 1754 | + api_get_path( |
|
| 1755 | + WEB_CODE_PATH |
|
| 1756 | + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
| 1757 | + ); |
|
| 1758 | + |
|
| 1759 | + $form->addHeader(get_lang('AssignTask')); |
|
| 1760 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
| 1761 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
| 1762 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
| 1763 | + |
|
| 1764 | + $form->addHidden('action', ''); |
|
| 1765 | + $form->addButtonSave(get_lang('Ok')); |
|
| 1766 | + |
|
| 1767 | + return $form; |
|
| 1768 | + } |
|
| 1769 | + |
|
| 1770 | + /** |
|
| 1771 | + * Displays assign task form |
|
| 1772 | + * @author Toon Keppens |
|
| 1773 | + * |
|
| 1774 | + */ |
|
| 1775 | + public static function display_assign_task_form($blog_id) |
|
| 1776 | + { |
|
| 1777 | + $form = self::getTaskForm($blog_id); |
|
| 1778 | + $form->addHidden('assign_task_submit', 'true'); |
|
| 1779 | + $form->display(); |
|
| 1780 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + /** |
|
| 1784 | + * Displays assign task form |
|
| 1785 | + * @author Toon Keppens |
|
| 1786 | + * |
|
| 1787 | + */ |
|
| 1788 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
| 1789 | + { |
|
| 1790 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1791 | + |
|
| 1792 | + $course_id = api_get_course_int_id(); |
|
| 1793 | + |
|
| 1794 | + // Get assignd date; |
|
| 1795 | + $sql = " |
|
| 1797 | 1796 | SELECT target_date |
| 1798 | 1797 | FROM $tbl_blogs_tasks_rel_user |
| 1799 | 1798 | WHERE c_id = $course_id AND |
| 1800 | 1799 | blog_id = '".(int)$blog_id."' AND |
| 1801 | 1800 | user_id = '".(int)$user_id."' AND |
| 1802 | 1801 | task_id = '".(int)$task_id."'"; |
| 1803 | - $result = Database::query($sql); |
|
| 1804 | - $row = Database::fetch_assoc($result); |
|
| 1805 | - |
|
| 1806 | - $date = $row['target_date']; |
|
| 1807 | - |
|
| 1808 | - $defaults = [ |
|
| 1809 | - 'task_user_id' => $user_id, |
|
| 1810 | - 'task_task_id' => $task_id, |
|
| 1811 | - 'task_day' => $date |
|
| 1812 | - ]; |
|
| 1813 | - $form = self::getTaskForm($blog_id); |
|
| 1814 | - $form->addHidden('old_task_id', $task_id); |
|
| 1815 | - $form->addHidden('old_user_id', $user_id); |
|
| 1816 | - $form->addHidden('old_target_date', $date); |
|
| 1817 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
| 1818 | - $form->setDefaults($defaults); |
|
| 1819 | - $form->display(); |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - /** |
|
| 1823 | - * Assigns a task to a user in a blog |
|
| 1824 | - * |
|
| 1825 | - * @param Integer $blog_id |
|
| 1826 | - * @param Integer $user_id |
|
| 1827 | - * @param Integer $task_id |
|
| 1828 | - * @param Date $target_date |
|
| 1829 | - */ |
|
| 1830 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
| 1831 | - { |
|
| 1832 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1833 | - $course_id = api_get_course_int_id(); |
|
| 1834 | - |
|
| 1835 | - $sql = " |
|
| 1802 | + $result = Database::query($sql); |
|
| 1803 | + $row = Database::fetch_assoc($result); |
|
| 1804 | + |
|
| 1805 | + $date = $row['target_date']; |
|
| 1806 | + |
|
| 1807 | + $defaults = [ |
|
| 1808 | + 'task_user_id' => $user_id, |
|
| 1809 | + 'task_task_id' => $task_id, |
|
| 1810 | + 'task_day' => $date |
|
| 1811 | + ]; |
|
| 1812 | + $form = self::getTaskForm($blog_id); |
|
| 1813 | + $form->addHidden('old_task_id', $task_id); |
|
| 1814 | + $form->addHidden('old_user_id', $user_id); |
|
| 1815 | + $form->addHidden('old_target_date', $date); |
|
| 1816 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
| 1817 | + $form->setDefaults($defaults); |
|
| 1818 | + $form->display(); |
|
| 1819 | + } |
|
| 1820 | + |
|
| 1821 | + /** |
|
| 1822 | + * Assigns a task to a user in a blog |
|
| 1823 | + * |
|
| 1824 | + * @param Integer $blog_id |
|
| 1825 | + * @param Integer $user_id |
|
| 1826 | + * @param Integer $task_id |
|
| 1827 | + * @param Date $target_date |
|
| 1828 | + */ |
|
| 1829 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
| 1830 | + { |
|
| 1831 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1832 | + $course_id = api_get_course_int_id(); |
|
| 1833 | + |
|
| 1834 | + $sql = " |
|
| 1836 | 1835 | SELECT COUNT(*) as 'number' |
| 1837 | 1836 | FROM " . $tbl_blogs_tasks_rel_user . " |
| 1838 | 1837 | WHERE c_id = $course_id AND |
@@ -1841,11 +1840,11 @@ discard block |
||
| 1841 | 1840 | AND task_id = " . (int)$task_id . " |
| 1842 | 1841 | "; |
| 1843 | 1842 | |
| 1844 | - $result = Database::query($sql); |
|
| 1845 | - $row = Database::fetch_assoc($result); |
|
| 1843 | + $result = Database::query($sql); |
|
| 1844 | + $row = Database::fetch_assoc($result); |
|
| 1846 | 1845 | |
| 1847 | - if ($row['number'] == 0) { |
|
| 1848 | - $sql = " |
|
| 1846 | + if ($row['number'] == 0) { |
|
| 1847 | + $sql = " |
|
| 1849 | 1848 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
| 1850 | 1849 | c_id, |
| 1851 | 1850 | blog_id, |
@@ -1860,9 +1859,9 @@ discard block |
||
| 1860 | 1859 | '" . Database::escape_string($target_date) . "' |
| 1861 | 1860 | )"; |
| 1862 | 1861 | |
| 1863 | - Database::query($sql); |
|
| 1864 | - } |
|
| 1865 | - } |
|
| 1862 | + Database::query($sql); |
|
| 1863 | + } |
|
| 1864 | + } |
|
| 1866 | 1865 | |
| 1867 | 1866 | /** |
| 1868 | 1867 | * @param $blog_id |
@@ -1882,11 +1881,11 @@ discard block |
||
| 1882 | 1881 | $old_task_id, |
| 1883 | 1882 | $old_target_date |
| 1884 | 1883 | ) { |
| 1885 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1884 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1886 | 1885 | |
| 1887 | - $course_id = api_get_course_int_id(); |
|
| 1886 | + $course_id = api_get_course_int_id(); |
|
| 1888 | 1887 | |
| 1889 | - $sql = "SELECT COUNT(*) as 'number' |
|
| 1888 | + $sql = "SELECT COUNT(*) as 'number' |
|
| 1890 | 1889 | FROM " . $tbl_blogs_tasks_rel_user . " |
| 1891 | 1890 | WHERE |
| 1892 | 1891 | c_id = $course_id AND |
@@ -1895,11 +1894,11 @@ discard block |
||
| 1895 | 1894 | task_id = " . (int)$task_id . " |
| 1896 | 1895 | "; |
| 1897 | 1896 | |
| 1898 | - $result = Database::query($sql); |
|
| 1899 | - $row = Database::fetch_assoc($result); |
|
| 1897 | + $result = Database::query($sql); |
|
| 1898 | + $row = Database::fetch_assoc($result); |
|
| 1900 | 1899 | |
| 1901 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
| 1902 | - $sql = " |
|
| 1900 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
| 1901 | + $sql = " |
|
| 1903 | 1902 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
| 1904 | 1903 | SET |
| 1905 | 1904 | user_id = " . (int)$user_id . ", |
@@ -1912,76 +1911,76 @@ discard block |
||
| 1912 | 1911 | task_id = " . (int)$old_task_id . " AND |
| 1913 | 1912 | target_date = '" . Database::escape_string($old_target_date) . "' |
| 1914 | 1913 | "; |
| 1915 | - Database::query($sql); |
|
| 1916 | - } |
|
| 1917 | - } |
|
| 1918 | - |
|
| 1919 | - /** |
|
| 1920 | - * Displays a list with posts a user can select to execute his task. |
|
| 1921 | - * |
|
| 1922 | - * @param Integer $blog_id |
|
| 1923 | - * @param unknown_type $task_id |
|
| 1924 | - */ |
|
| 1925 | - public static function display_select_task_post($blog_id, $task_id) |
|
| 1914 | + Database::query($sql); |
|
| 1915 | + } |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * Displays a list with posts a user can select to execute his task. |
|
| 1920 | + * |
|
| 1921 | + * @param Integer $blog_id |
|
| 1922 | + * @param unknown_type $task_id |
|
| 1923 | + */ |
|
| 1924 | + public static function display_select_task_post($blog_id, $task_id) |
|
| 1926 | 1925 | { |
| 1927 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1928 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1929 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1930 | - $course_id = api_get_course_int_id(); |
|
| 1926 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1927 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1928 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1929 | + $course_id = api_get_course_int_id(); |
|
| 1931 | 1930 | |
| 1932 | 1931 | |
| 1933 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
| 1932 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
| 1934 | 1933 | WHERE task_id = '".(int)$task_id."' |
| 1935 | 1934 | AND c_id = $course_id"; |
| 1936 | - $result = Database::query($sql); |
|
| 1937 | - $row = Database::fetch_assoc($result); |
|
| 1938 | - // Get posts and authors |
|
| 1939 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 1935 | + $result = Database::query($sql); |
|
| 1936 | + $row = Database::fetch_assoc($result); |
|
| 1937 | + // Get posts and authors |
|
| 1938 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 1940 | 1939 | FROM $tbl_blogs_posts post |
| 1941 | 1940 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1942 | 1941 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
| 1943 | 1942 | ORDER BY post_id DESC |
| 1944 | 1943 | LIMIT 0, 100"; |
| 1945 | - $result = Database::query($sql); |
|
| 1944 | + $result = Database::query($sql); |
|
| 1946 | 1945 | |
| 1947 | - // Display |
|
| 1948 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1949 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1946 | + // Display |
|
| 1947 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1948 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1950 | 1949 | |
| 1951 | - if (Database::num_rows($result) > 0) { |
|
| 1952 | - while($blog_post = Database::fetch_array($result)) { |
|
| 1953 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 1954 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1955 | - } |
|
| 1950 | + if (Database::num_rows($result) > 0) { |
|
| 1951 | + while($blog_post = Database::fetch_array($result)) { |
|
| 1952 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 1953 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1954 | + } |
|
| 1956 | 1955 | } else { |
| 1957 | 1956 | echo get_lang('NoArticles'); |
| 1958 | 1957 | } |
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - /** |
|
| 1962 | - * Subscribes a user to a given blog |
|
| 1963 | - * @author Toon Keppens |
|
| 1964 | - * |
|
| 1965 | - * @param Integer $blog_id |
|
| 1966 | - * @param Integer $user_id |
|
| 1967 | - */ |
|
| 1968 | - public static function set_user_subscribed($blog_id, $user_id) |
|
| 1958 | + } |
|
| 1959 | + |
|
| 1960 | + /** |
|
| 1961 | + * Subscribes a user to a given blog |
|
| 1962 | + * @author Toon Keppens |
|
| 1963 | + * |
|
| 1964 | + * @param Integer $blog_id |
|
| 1965 | + * @param Integer $user_id |
|
| 1966 | + */ |
|
| 1967 | + public static function set_user_subscribed($blog_id, $user_id) |
|
| 1969 | 1968 | { |
| 1970 | - // Init |
|
| 1971 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1972 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 1969 | + // Init |
|
| 1970 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1971 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 1973 | 1972 | |
| 1974 | - $course_id = api_get_course_int_id(); |
|
| 1973 | + $course_id = api_get_course_int_id(); |
|
| 1975 | 1974 | |
| 1976 | - // Subscribe the user |
|
| 1977 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
| 1975 | + // Subscribe the user |
|
| 1976 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
| 1978 | 1977 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
| 1979 | - Database::query($sql); |
|
| 1978 | + Database::query($sql); |
|
| 1980 | 1979 | |
| 1981 | - // Give this user basic rights |
|
| 1982 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1980 | + // Give this user basic rights |
|
| 1981 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1983 | 1982 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
| 1984 | - Database::query($sql); |
|
| 1983 | + Database::query($sql); |
|
| 1985 | 1984 | |
| 1986 | 1985 | $id = Database::insert_id(); |
| 1987 | 1986 | if ($id) { |
@@ -1989,9 +1988,9 @@ discard block |
||
| 1989 | 1988 | Database::query($sql); |
| 1990 | 1989 | } |
| 1991 | 1990 | |
| 1992 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1991 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1993 | 1992 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
| 1994 | - Database::query($sql); |
|
| 1993 | + Database::query($sql); |
|
| 1995 | 1994 | |
| 1996 | 1995 | $id = Database::insert_id(); |
| 1997 | 1996 | if ($id) { |
@@ -1999,197 +1998,197 @@ discard block |
||
| 1999 | 1998 | Database::query($sql); |
| 2000 | 1999 | } |
| 2001 | 2000 | |
| 2002 | - } |
|
| 2001 | + } |
|
| 2003 | 2002 | |
| 2004 | - /** |
|
| 2005 | - * Unsubscribe a user from a given blog |
|
| 2006 | - * @author Toon Keppens |
|
| 2007 | - * |
|
| 2008 | - * @param Integer $blog_id |
|
| 2009 | - * @param Integer $user_id |
|
| 2010 | - */ |
|
| 2011 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
| 2003 | + /** |
|
| 2004 | + * Unsubscribe a user from a given blog |
|
| 2005 | + * @author Toon Keppens |
|
| 2006 | + * |
|
| 2007 | + * @param Integer $blog_id |
|
| 2008 | + * @param Integer $user_id |
|
| 2009 | + */ |
|
| 2010 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
| 2012 | 2011 | { |
| 2013 | - // Init |
|
| 2012 | + // Init |
|
| 2014 | 2013 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
| 2015 | 2014 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
| 2016 | 2015 | |
| 2017 | - // Unsubscribe the user |
|
| 2018 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
| 2016 | + // Unsubscribe the user |
|
| 2017 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
| 2019 | 2018 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
| 2020 | - Database::query($sql); |
|
| 2019 | + Database::query($sql); |
|
| 2021 | 2020 | |
| 2022 | - // Remove this user's permissions. |
|
| 2023 | - $sql = "DELETE FROM $tbl_user_permissions |
|
| 2021 | + // Remove this user's permissions. |
|
| 2022 | + $sql = "DELETE FROM $tbl_user_permissions |
|
| 2024 | 2023 | WHERE user_id = '".(int)$user_id."'"; |
| 2025 | - Database::query($sql); |
|
| 2026 | - } |
|
| 2027 | - |
|
| 2028 | - /** |
|
| 2029 | - * Displays the form to register users in a blog (in a course) |
|
| 2030 | - * The listed users are users subcribed in the course. |
|
| 2031 | - * @author Toon Keppens |
|
| 2032 | - * |
|
| 2033 | - * @param Integer $blog_id |
|
| 2034 | - * |
|
| 2035 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
| 2036 | - */ |
|
| 2037 | - public static function display_form_user_subscribe($blog_id) |
|
| 2038 | - { |
|
| 2039 | - $_course = api_get_course_info(); |
|
| 2040 | - $is_western_name_order = api_is_western_name_order(); |
|
| 2041 | - $session_id = api_get_session_id(); |
|
| 2042 | - $course_id = $_course['real_id']; |
|
| 2043 | - |
|
| 2044 | - $currentCourse = $_course['code']; |
|
| 2045 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2046 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2047 | - |
|
| 2048 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
| 2049 | - |
|
| 2050 | - $properties["width"] = "100%"; |
|
| 2051 | - |
|
| 2052 | - // Get blog members' id. |
|
| 2053 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
| 2024 | + Database::query($sql); |
|
| 2025 | + } |
|
| 2026 | + |
|
| 2027 | + /** |
|
| 2028 | + * Displays the form to register users in a blog (in a course) |
|
| 2029 | + * The listed users are users subcribed in the course. |
|
| 2030 | + * @author Toon Keppens |
|
| 2031 | + * |
|
| 2032 | + * @param Integer $blog_id |
|
| 2033 | + * |
|
| 2034 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
| 2035 | + */ |
|
| 2036 | + public static function display_form_user_subscribe($blog_id) |
|
| 2037 | + { |
|
| 2038 | + $_course = api_get_course_info(); |
|
| 2039 | + $is_western_name_order = api_is_western_name_order(); |
|
| 2040 | + $session_id = api_get_session_id(); |
|
| 2041 | + $course_id = $_course['real_id']; |
|
| 2042 | + |
|
| 2043 | + $currentCourse = $_course['code']; |
|
| 2044 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2045 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2046 | + |
|
| 2047 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
| 2048 | + |
|
| 2049 | + $properties["width"] = "100%"; |
|
| 2050 | + |
|
| 2051 | + // Get blog members' id. |
|
| 2052 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
| 2054 | 2053 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2055 | 2054 | ON user.user_id = blogs_rel_user.user_id |
| 2056 | 2055 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
| 2057 | - $result = Database::query($sql); |
|
| 2058 | - |
|
| 2059 | - $blog_member_ids = array(); |
|
| 2060 | - while($user = Database::fetch_array($result)) { |
|
| 2061 | - $blog_member_ids[] = $user['user_id']; |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - // Set table headers |
|
| 2065 | - $column_header[] = array ('', false, ''); |
|
| 2066 | - if ($is_western_name_order) { |
|
| 2067 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2068 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2069 | - } else { |
|
| 2070 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2071 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2072 | - } |
|
| 2073 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2074 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
| 2056 | + $result = Database::query($sql); |
|
| 2057 | + |
|
| 2058 | + $blog_member_ids = array(); |
|
| 2059 | + while($user = Database::fetch_array($result)) { |
|
| 2060 | + $blog_member_ids[] = $user['user_id']; |
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + // Set table headers |
|
| 2064 | + $column_header[] = array ('', false, ''); |
|
| 2065 | + if ($is_western_name_order) { |
|
| 2066 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2067 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2068 | + } else { |
|
| 2069 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2070 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2071 | + } |
|
| 2072 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2073 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
| 2075 | 2074 | |
| 2076 | 2075 | $student_list = CourseManager:: get_student_list_from_course_code( |
| 2077 | 2076 | $currentCourse, |
| 2078 | 2077 | false, |
| 2079 | 2078 | $session_id |
| 2080 | 2079 | ); |
| 2081 | - $user_data = array(); |
|
| 2082 | - |
|
| 2083 | - // Add users that are not in this blog to the list. |
|
| 2084 | - foreach ($student_list as $key=>$user) { |
|
| 2085 | - if(isset($user['id_user'])) { |
|
| 2086 | - $user['user_id'] = $user['id_user']; |
|
| 2087 | - } |
|
| 2088 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2089 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
| 2090 | - $row = array (); |
|
| 2091 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2092 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
| 2093 | - if ($is_western_name_order) { |
|
| 2094 | - $row[] = $a_infosUser["firstname"]; |
|
| 2095 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2096 | - } else { |
|
| 2097 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2098 | - $row[] = $a_infosUser["firstname"]; |
|
| 2099 | - } |
|
| 2100 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
| 2101 | - |
|
| 2102 | - //Link to register users |
|
| 2103 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2104 | - $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>"; |
|
| 2105 | - } else { |
|
| 2106 | - $row[] = ''; |
|
| 2107 | - } |
|
| 2108 | - $user_data[] = $row; |
|
| 2109 | - } |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - // Display |
|
| 2113 | - $query_vars['action'] = 'manage_members'; |
|
| 2114 | - $query_vars['blog_id'] = $blog_id; |
|
| 2115 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2116 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2117 | - $link = ''; |
|
| 2118 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2119 | - $link .= "blog_id=$blog_id&"; |
|
| 2120 | - |
|
| 2121 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2122 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2123 | - echo get_lang('WithSelected') . ' : '; |
|
| 2124 | - echo '<select name="action">'; |
|
| 2125 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2126 | - echo '</select>'; |
|
| 2127 | - echo '<input type="hidden" name="register" value="true" />'; |
|
| 2128 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2129 | - echo '</form>'; |
|
| 2130 | - } |
|
| 2131 | - |
|
| 2132 | - /** |
|
| 2133 | - * Displays the form to register users in a blog (in a course) |
|
| 2134 | - * The listed users are users subcribed in the course. |
|
| 2135 | - * @author Toon Keppens |
|
| 2136 | - * |
|
| 2137 | - * @param Integer $blog_id |
|
| 2138 | - * |
|
| 2139 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
| 2140 | - */ |
|
| 2141 | - public static function display_form_user_unsubscribe ($blog_id) |
|
| 2142 | - { |
|
| 2143 | - $_user = api_get_user_info(); |
|
| 2144 | - $is_western_name_order = api_is_western_name_order(); |
|
| 2145 | - |
|
| 2146 | - // Init |
|
| 2147 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2148 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2149 | - |
|
| 2150 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
| 2151 | - |
|
| 2152 | - $properties["width"] = "100%"; |
|
| 2153 | - //table column titles |
|
| 2154 | - $column_header[] = array ('', false, ''); |
|
| 2155 | - if ($is_western_name_order) { |
|
| 2156 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2157 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2158 | - } else { |
|
| 2159 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2160 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2161 | - } |
|
| 2162 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2163 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2164 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2165 | - |
|
| 2166 | - $course_id = api_get_course_int_id(); |
|
| 2167 | - |
|
| 2168 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
| 2080 | + $user_data = array(); |
|
| 2081 | + |
|
| 2082 | + // Add users that are not in this blog to the list. |
|
| 2083 | + foreach ($student_list as $key=>$user) { |
|
| 2084 | + if(isset($user['id_user'])) { |
|
| 2085 | + $user['user_id'] = $user['id_user']; |
|
| 2086 | + } |
|
| 2087 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2088 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
| 2089 | + $row = array (); |
|
| 2090 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2091 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
| 2092 | + if ($is_western_name_order) { |
|
| 2093 | + $row[] = $a_infosUser["firstname"]; |
|
| 2094 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2095 | + } else { |
|
| 2096 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2097 | + $row[] = $a_infosUser["firstname"]; |
|
| 2098 | + } |
|
| 2099 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
| 2100 | + |
|
| 2101 | + //Link to register users |
|
| 2102 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2103 | + $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>"; |
|
| 2104 | + } else { |
|
| 2105 | + $row[] = ''; |
|
| 2106 | + } |
|
| 2107 | + $user_data[] = $row; |
|
| 2108 | + } |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + // Display |
|
| 2112 | + $query_vars['action'] = 'manage_members'; |
|
| 2113 | + $query_vars['blog_id'] = $blog_id; |
|
| 2114 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2115 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2116 | + $link = ''; |
|
| 2117 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2118 | + $link .= "blog_id=$blog_id&"; |
|
| 2119 | + |
|
| 2120 | + echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2121 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2122 | + echo get_lang('WithSelected') . ' : '; |
|
| 2123 | + echo '<select name="action">'; |
|
| 2124 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2125 | + echo '</select>'; |
|
| 2126 | + echo '<input type="hidden" name="register" value="true" />'; |
|
| 2127 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2128 | + echo '</form>'; |
|
| 2129 | + } |
|
| 2130 | + |
|
| 2131 | + /** |
|
| 2132 | + * Displays the form to register users in a blog (in a course) |
|
| 2133 | + * The listed users are users subcribed in the course. |
|
| 2134 | + * @author Toon Keppens |
|
| 2135 | + * |
|
| 2136 | + * @param Integer $blog_id |
|
| 2137 | + * |
|
| 2138 | + * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
| 2139 | + */ |
|
| 2140 | + public static function display_form_user_unsubscribe ($blog_id) |
|
| 2141 | + { |
|
| 2142 | + $_user = api_get_user_info(); |
|
| 2143 | + $is_western_name_order = api_is_western_name_order(); |
|
| 2144 | + |
|
| 2145 | + // Init |
|
| 2146 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2147 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2148 | + |
|
| 2149 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
| 2150 | + |
|
| 2151 | + $properties["width"] = "100%"; |
|
| 2152 | + //table column titles |
|
| 2153 | + $column_header[] = array ('', false, ''); |
|
| 2154 | + if ($is_western_name_order) { |
|
| 2155 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2156 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2157 | + } else { |
|
| 2158 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2159 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2160 | + } |
|
| 2161 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2162 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2163 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2164 | + |
|
| 2165 | + $course_id = api_get_course_int_id(); |
|
| 2166 | + |
|
| 2167 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
| 2169 | 2168 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2170 | 2169 | ON user.user_id = blogs_rel_user.user_id |
| 2171 | 2170 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
| 2172 | 2171 | |
| 2173 | - if (!($sql_result = Database::query($sql))) { |
|
| 2174 | - return false; |
|
| 2175 | - } |
|
| 2176 | - |
|
| 2177 | - $user_data = array (); |
|
| 2178 | - |
|
| 2179 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
| 2180 | - $row = array (); |
|
| 2181 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2182 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
| 2183 | - if ($is_western_name_order) { |
|
| 2184 | - $row[] = $myrow["firstname"]; |
|
| 2185 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2186 | - } else { |
|
| 2187 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2188 | - $row[] = $myrow["firstname"]; |
|
| 2189 | - } |
|
| 2190 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
| 2191 | - |
|
| 2192 | - $sql = "SELECT bt.title task |
|
| 2172 | + if (!($sql_result = Database::query($sql))) { |
|
| 2173 | + return false; |
|
| 2174 | + } |
|
| 2175 | + |
|
| 2176 | + $user_data = array (); |
|
| 2177 | + |
|
| 2178 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
| 2179 | + $row = array (); |
|
| 2180 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2181 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
| 2182 | + if ($is_western_name_order) { |
|
| 2183 | + $row[] = $myrow["firstname"]; |
|
| 2184 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2185 | + } else { |
|
| 2186 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2187 | + $row[] = $myrow["firstname"]; |
|
| 2188 | + } |
|
| 2189 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
| 2190 | + |
|
| 2191 | + $sql = "SELECT bt.title task |
|
| 2193 | 2192 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
| 2194 | 2193 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
| 2195 | 2194 | ON btu.task_id = bt.task_id |
@@ -2197,158 +2196,158 @@ discard block |
||
| 2197 | 2196 | bt.c_id = $course_id AND |
| 2198 | 2197 | btu.blog_id = $blog_id AND |
| 2199 | 2198 | btu.user_id = " . $myrow['user_id']; |
| 2200 | - $sql_res = Database::query($sql); |
|
| 2201 | - |
|
| 2202 | - $task = ''; |
|
| 2203 | - |
|
| 2204 | - while($r = Database::fetch_array($sql_res)) { |
|
| 2205 | - $task .= stripslashes($r['task']) . ', '; |
|
| 2206 | - } |
|
| 2207 | - //echo $task; |
|
| 2208 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
| 2209 | - $row[] = $task; |
|
| 2210 | - //Link to register users |
|
| 2211 | - |
|
| 2212 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
| 2213 | - $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>"; |
|
| 2214 | - } else { |
|
| 2215 | - $row[] = ''; |
|
| 2216 | - } |
|
| 2217 | - |
|
| 2218 | - $user_data[] = $row; |
|
| 2219 | - } |
|
| 2220 | - |
|
| 2221 | - $query_vars['action'] = 'manage_members'; |
|
| 2222 | - $query_vars['blog_id'] = $blog_id; |
|
| 2223 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2224 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2225 | - $link = ''; |
|
| 2226 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2227 | - $link .= "blog_id=$blog_id&"; |
|
| 2228 | - |
|
| 2229 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2230 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2231 | - echo get_lang('WithSelected') . ' : '; |
|
| 2232 | - echo '<select name="action">'; |
|
| 2233 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2234 | - echo '</select>'; |
|
| 2235 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
| 2236 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2237 | - echo '</form>'; |
|
| 2238 | - } |
|
| 2239 | - |
|
| 2240 | - /** |
|
| 2241 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
| 2242 | - * The blog admin can thus select what a certain user can do in the current blog |
|
| 2243 | - * |
|
| 2244 | - * @param Integer $blog_id |
|
| 2245 | - */ |
|
| 2246 | - public static function display_form_user_rights ($blog_id) |
|
| 2199 | + $sql_res = Database::query($sql); |
|
| 2200 | + |
|
| 2201 | + $task = ''; |
|
| 2202 | + |
|
| 2203 | + while($r = Database::fetch_array($sql_res)) { |
|
| 2204 | + $task .= stripslashes($r['task']) . ', '; |
|
| 2205 | + } |
|
| 2206 | + //echo $task; |
|
| 2207 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
| 2208 | + $row[] = $task; |
|
| 2209 | + //Link to register users |
|
| 2210 | + |
|
| 2211 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
| 2212 | + $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>"; |
|
| 2213 | + } else { |
|
| 2214 | + $row[] = ''; |
|
| 2215 | + } |
|
| 2216 | + |
|
| 2217 | + $user_data[] = $row; |
|
| 2218 | + } |
|
| 2219 | + |
|
| 2220 | + $query_vars['action'] = 'manage_members'; |
|
| 2221 | + $query_vars['blog_id'] = $blog_id; |
|
| 2222 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2223 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2224 | + $link = ''; |
|
| 2225 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2226 | + $link .= "blog_id=$blog_id&"; |
|
| 2227 | + |
|
| 2228 | + echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2229 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2230 | + echo get_lang('WithSelected') . ' : '; |
|
| 2231 | + echo '<select name="action">'; |
|
| 2232 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2233 | + echo '</select>'; |
|
| 2234 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
| 2235 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2236 | + echo '</form>'; |
|
| 2237 | + } |
|
| 2238 | + |
|
| 2239 | + /** |
|
| 2240 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
| 2241 | + * The blog admin can thus select what a certain user can do in the current blog |
|
| 2242 | + * |
|
| 2243 | + * @param Integer $blog_id |
|
| 2244 | + */ |
|
| 2245 | + public static function display_form_user_rights ($blog_id) |
|
| 2246 | + { |
|
| 2247 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
| 2248 | + echo '<br />'; |
|
| 2249 | + |
|
| 2250 | + // Integration of patricks permissions system. |
|
| 2251 | + require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
| 2252 | + } |
|
| 2253 | + |
|
| 2254 | + /** |
|
| 2255 | + * Displays the form to create a new post |
|
| 2256 | + * @author Toon Keppens |
|
| 2257 | + * |
|
| 2258 | + * @param Integer $blog_id |
|
| 2259 | + */ |
|
| 2260 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
| 2247 | 2261 | { |
| 2248 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
| 2249 | - echo '<br />'; |
|
| 2250 | - |
|
| 2251 | - // Integration of patricks permissions system. |
|
| 2252 | - require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
| 2253 | - } |
|
| 2254 | - |
|
| 2255 | - /** |
|
| 2256 | - * Displays the form to create a new post |
|
| 2257 | - * @author Toon Keppens |
|
| 2258 | - * |
|
| 2259 | - * @param Integer $blog_id |
|
| 2260 | - */ |
|
| 2261 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
| 2262 | - { |
|
| 2263 | - $form = new FormValidator( |
|
| 2264 | - 'add_post', |
|
| 2265 | - 'post', |
|
| 2266 | - 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(), |
|
| 2267 | - null, |
|
| 2268 | - array('enctype' => 'multipart/form-data') |
|
| 2269 | - ); |
|
| 2270 | - |
|
| 2271 | - $header = get_lang('AddNewComment'); |
|
| 2272 | - if (isset($_GET['task_id'])) { |
|
| 2273 | - $header = get_lang('ExecuteThisTask'); |
|
| 2274 | - } |
|
| 2275 | - $form->addHeader($header); |
|
| 2276 | - $form->addText('title', get_lang('Title')); |
|
| 2277 | - |
|
| 2278 | - $config = array(); |
|
| 2279 | - if (!api_is_allowed_to_edit()) { |
|
| 2280 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
| 2281 | - } else { |
|
| 2282 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
| 2283 | - } |
|
| 2284 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
| 2285 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 2286 | - |
|
| 2287 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 2288 | - |
|
| 2289 | - $form->addHidden('action', null); |
|
| 2290 | - $form->addHidden('comment_parent_id', 0); |
|
| 2291 | - |
|
| 2292 | - if (isset($_GET['task_id'])) { |
|
| 2293 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
| 2294 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
| 2295 | - } else { |
|
| 2296 | - $form->addHidden('new_comment_submit', 'true'); |
|
| 2297 | - } |
|
| 2298 | - $form->addButton('save', get_lang('Save')); |
|
| 2299 | - $form->display(); |
|
| 2300 | - } |
|
| 2301 | - |
|
| 2302 | - |
|
| 2303 | - /** |
|
| 2304 | - * show the calender of the given month |
|
| 2305 | - * @author Patrick Cool |
|
| 2306 | - * @author Toon Keppens |
|
| 2307 | - * |
|
| 2308 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
| 2309 | - * @param Integer $month: the integer value of the month we are viewing |
|
| 2310 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
| 2311 | - * @param String $monthName: the language variable for the mont name |
|
| 2312 | - * |
|
| 2313 | - * @return html code |
|
| 2314 | - */ |
|
| 2315 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
| 2316 | - { |
|
| 2317 | - // Init |
|
| 2318 | - $_user = api_get_user_info(); |
|
| 2319 | - global $DaysShort; |
|
| 2320 | - global $MonthsLong; |
|
| 2321 | - |
|
| 2322 | - $posts = array(); |
|
| 2323 | - $tasks = array(); |
|
| 2324 | - |
|
| 2325 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2326 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2327 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 2328 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 2329 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2330 | - |
|
| 2331 | - $course_id = api_get_course_int_id(); |
|
| 2332 | - |
|
| 2333 | - //Handle leap year |
|
| 2334 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2335 | - |
|
| 2336 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2337 | - $numberofdays[2] = 29; |
|
| 2338 | - |
|
| 2339 | - //Get the first day of the month |
|
| 2340 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
| 2341 | - $monthName = $MonthsLong[$month-1]; |
|
| 2342 | - |
|
| 2343 | - //Start the week on monday |
|
| 2344 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
| 2345 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
| 2346 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
| 2347 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2348 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2349 | - |
|
| 2350 | - // Get posts for this month |
|
| 2351 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
| 2262 | + $form = new FormValidator( |
|
| 2263 | + 'add_post', |
|
| 2264 | + 'post', |
|
| 2265 | + 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(), |
|
| 2266 | + null, |
|
| 2267 | + array('enctype' => 'multipart/form-data') |
|
| 2268 | + ); |
|
| 2269 | + |
|
| 2270 | + $header = get_lang('AddNewComment'); |
|
| 2271 | + if (isset($_GET['task_id'])) { |
|
| 2272 | + $header = get_lang('ExecuteThisTask'); |
|
| 2273 | + } |
|
| 2274 | + $form->addHeader($header); |
|
| 2275 | + $form->addText('title', get_lang('Title')); |
|
| 2276 | + |
|
| 2277 | + $config = array(); |
|
| 2278 | + if (!api_is_allowed_to_edit()) { |
|
| 2279 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
| 2280 | + } else { |
|
| 2281 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
| 2282 | + } |
|
| 2283 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
| 2284 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 2285 | + |
|
| 2286 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 2287 | + |
|
| 2288 | + $form->addHidden('action', null); |
|
| 2289 | + $form->addHidden('comment_parent_id', 0); |
|
| 2290 | + |
|
| 2291 | + if (isset($_GET['task_id'])) { |
|
| 2292 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
| 2293 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
| 2294 | + } else { |
|
| 2295 | + $form->addHidden('new_comment_submit', 'true'); |
|
| 2296 | + } |
|
| 2297 | + $form->addButton('save', get_lang('Save')); |
|
| 2298 | + $form->display(); |
|
| 2299 | + } |
|
| 2300 | + |
|
| 2301 | + |
|
| 2302 | + /** |
|
| 2303 | + * show the calender of the given month |
|
| 2304 | + * @author Patrick Cool |
|
| 2305 | + * @author Toon Keppens |
|
| 2306 | + * |
|
| 2307 | + * @param Array $blogitems an array containing all the blog items for the given month |
|
| 2308 | + * @param Integer $month: the integer value of the month we are viewing |
|
| 2309 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
| 2310 | + * @param String $monthName: the language variable for the mont name |
|
| 2311 | + * |
|
| 2312 | + * @return html code |
|
| 2313 | + */ |
|
| 2314 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
| 2315 | + { |
|
| 2316 | + // Init |
|
| 2317 | + $_user = api_get_user_info(); |
|
| 2318 | + global $DaysShort; |
|
| 2319 | + global $MonthsLong; |
|
| 2320 | + |
|
| 2321 | + $posts = array(); |
|
| 2322 | + $tasks = array(); |
|
| 2323 | + |
|
| 2324 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2325 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2326 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 2327 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 2328 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2329 | + |
|
| 2330 | + $course_id = api_get_course_int_id(); |
|
| 2331 | + |
|
| 2332 | + //Handle leap year |
|
| 2333 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2334 | + |
|
| 2335 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2336 | + $numberofdays[2] = 29; |
|
| 2337 | + |
|
| 2338 | + //Get the first day of the month |
|
| 2339 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
| 2340 | + $monthName = $MonthsLong[$month-1]; |
|
| 2341 | + |
|
| 2342 | + //Start the week on monday |
|
| 2343 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
| 2344 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
| 2345 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
| 2346 | + $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2347 | + $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2348 | + |
|
| 2349 | + // Get posts for this month |
|
| 2350 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
| 2352 | 2351 | FROM $tbl_blogs_posts post |
| 2353 | 2352 | INNER JOIN $tbl_users user |
| 2354 | 2353 | ON post.author_id = user.user_id |
@@ -2358,20 +2357,20 @@ discard block |
||
| 2358 | 2357 | MONTH(date_creation) = '".(int)$month."' AND |
| 2359 | 2358 | YEAR(date_creation) = '".(int)$year."' |
| 2360 | 2359 | ORDER BY date_creation"; |
| 2361 | - $result = Database::query($sql); |
|
| 2362 | - |
|
| 2363 | - // We will create an array of days on which there are posts. |
|
| 2364 | - if( Database::num_rows($result) > 0) { |
|
| 2365 | - while($blog_post = Database::fetch_array($result)) { |
|
| 2366 | - // If the day of this post is not yet in the array, add it. |
|
| 2367 | - if (!in_array($blog_post['post_day'], $posts)) |
|
| 2368 | - $posts[] = $blog_post['post_day']; |
|
| 2369 | - } |
|
| 2370 | - } |
|
| 2371 | - |
|
| 2372 | - // Get tasks for this month |
|
| 2373 | - if ($_user['user_id']) { |
|
| 2374 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
| 2360 | + $result = Database::query($sql); |
|
| 2361 | + |
|
| 2362 | + // We will create an array of days on which there are posts. |
|
| 2363 | + if( Database::num_rows($result) > 0) { |
|
| 2364 | + while($blog_post = Database::fetch_array($result)) { |
|
| 2365 | + // If the day of this post is not yet in the array, add it. |
|
| 2366 | + if (!in_array($blog_post['post_day'], $posts)) |
|
| 2367 | + $posts[] = $blog_post['post_day']; |
|
| 2368 | + } |
|
| 2369 | + } |
|
| 2370 | + |
|
| 2371 | + // Get tasks for this month |
|
| 2372 | + if ($_user['user_id']) { |
|
| 2373 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
| 2375 | 2374 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 2376 | 2375 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
| 2377 | 2376 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2383,85 +2382,85 @@ discard block |
||
| 2383 | 2382 | MONTH(target_date) = '".(int)$month."' AND |
| 2384 | 2383 | YEAR(target_date) = '".(int)$year."' |
| 2385 | 2384 | ORDER BY target_date ASC"; |
| 2386 | - $result = Database::query($sql); |
|
| 2387 | - |
|
| 2388 | - if (Database::num_rows($result) > 0) { |
|
| 2389 | - while ($mytask = Database::fetch_array($result)) { |
|
| 2390 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
| 2391 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
| 2392 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
| 2393 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
| 2394 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
| 2395 | - } |
|
| 2396 | - } |
|
| 2397 | - } |
|
| 2398 | - |
|
| 2399 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
| 2400 | - "<tr id=\"title\">", |
|
| 2401 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
| 2402 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
| 2403 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
| 2404 | - |
|
| 2405 | - echo "<tr>"; |
|
| 2406 | - |
|
| 2407 | - for($ii = 1; $ii < 8; $ii ++) |
|
| 2408 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2409 | - |
|
| 2410 | - echo "</tr>"; |
|
| 2411 | - |
|
| 2412 | - $curday = -1; |
|
| 2413 | - $today = getdate(); |
|
| 2414 | - |
|
| 2415 | - while ($curday <= $numberofdays[$month]) { |
|
| 2416 | - echo "<tr>"; |
|
| 2417 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2418 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
| 2419 | - $curday = 1; |
|
| 2420 | - |
|
| 2421 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
| 2422 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2423 | - $dayheader = "$curday"; |
|
| 2424 | - |
|
| 2425 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2426 | - $dayheader = "$curday"; |
|
| 2427 | - $class = "class=\"days_today\""; |
|
| 2428 | - } |
|
| 2429 | - |
|
| 2430 | - echo "<td " . $class.">"; |
|
| 2431 | - |
|
| 2432 | - // If there are posts on this day, create a filter link. |
|
| 2433 | - if(in_array($curday, $posts)) |
|
| 2434 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2435 | - else |
|
| 2436 | - echo $dayheader; |
|
| 2437 | - |
|
| 2438 | - if (count($tasks) > 0) { |
|
| 2439 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
| 2440 | - // Add tasks to calendar |
|
| 2441 | - foreach ($tasks[$curday] as $task) { |
|
| 2442 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
| 2443 | - echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
| 2385 | + $result = Database::query($sql); |
|
| 2386 | + |
|
| 2387 | + if (Database::num_rows($result) > 0) { |
|
| 2388 | + while ($mytask = Database::fetch_array($result)) { |
|
| 2389 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
| 2390 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
| 2391 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
| 2392 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
| 2393 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
| 2394 | + } |
|
| 2395 | + } |
|
| 2396 | + } |
|
| 2397 | + |
|
| 2398 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
| 2399 | + "<tr id=\"title\">", |
|
| 2400 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
| 2401 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
| 2402 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
| 2403 | + |
|
| 2404 | + echo "<tr>"; |
|
| 2405 | + |
|
| 2406 | + for($ii = 1; $ii < 8; $ii ++) |
|
| 2407 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2408 | + |
|
| 2409 | + echo "</tr>"; |
|
| 2410 | + |
|
| 2411 | + $curday = -1; |
|
| 2412 | + $today = getdate(); |
|
| 2413 | + |
|
| 2414 | + while ($curday <= $numberofdays[$month]) { |
|
| 2415 | + echo "<tr>"; |
|
| 2416 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2417 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
| 2418 | + $curday = 1; |
|
| 2419 | + |
|
| 2420 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
| 2421 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2422 | + $dayheader = "$curday"; |
|
| 2423 | + |
|
| 2424 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2425 | + $dayheader = "$curday"; |
|
| 2426 | + $class = "class=\"days_today\""; |
|
| 2427 | + } |
|
| 2428 | + |
|
| 2429 | + echo "<td " . $class.">"; |
|
| 2430 | + |
|
| 2431 | + // If there are posts on this day, create a filter link. |
|
| 2432 | + if(in_array($curday, $posts)) |
|
| 2433 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2434 | + else |
|
| 2435 | + echo $dayheader; |
|
| 2436 | + |
|
| 2437 | + if (count($tasks) > 0) { |
|
| 2438 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
| 2439 | + // Add tasks to calendar |
|
| 2440 | + foreach ($tasks[$curday] as $task) { |
|
| 2441 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
| 2442 | + echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
| 2444 | 2443 | echo '</a>'; |
| 2445 | - } |
|
| 2446 | - } |
|
| 2447 | - } |
|
| 2448 | - |
|
| 2449 | - echo "</td>"; |
|
| 2450 | - $curday ++; |
|
| 2451 | - } else |
|
| 2452 | - echo "<td> </td>"; |
|
| 2453 | - } |
|
| 2454 | - echo "</tr>"; |
|
| 2455 | - } |
|
| 2456 | - echo "</table>"; |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - /** |
|
| 2460 | - * Blog admin | Display the form to add a new blog. |
|
| 2461 | - * |
|
| 2462 | - */ |
|
| 2463 | - public static function display_new_blog_form() |
|
| 2464 | - { |
|
| 2444 | + } |
|
| 2445 | + } |
|
| 2446 | + } |
|
| 2447 | + |
|
| 2448 | + echo "</td>"; |
|
| 2449 | + $curday ++; |
|
| 2450 | + } else |
|
| 2451 | + echo "<td> </td>"; |
|
| 2452 | + } |
|
| 2453 | + echo "</tr>"; |
|
| 2454 | + } |
|
| 2455 | + echo "</table>"; |
|
| 2456 | + } |
|
| 2457 | + |
|
| 2458 | + /** |
|
| 2459 | + * Blog admin | Display the form to add a new blog. |
|
| 2460 | + * |
|
| 2461 | + */ |
|
| 2462 | + public static function display_new_blog_form() |
|
| 2463 | + { |
|
| 2465 | 2464 | $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add'); |
| 2466 | 2465 | $form->addElement('header', get_lang('AddBlog')); |
| 2467 | 2466 | $form->addElement('text', 'blog_name', get_lang('Title')); |
@@ -2471,34 +2470,34 @@ discard block |
||
| 2471 | 2470 | $form->addButtonSave(get_lang('SaveProject')); |
| 2472 | 2471 | |
| 2473 | 2472 | $defaults = array( |
| 2474 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
| 2475 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
| 2476 | - ); |
|
| 2473 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
| 2474 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
| 2475 | + ); |
|
| 2477 | 2476 | $form->setDefaults($defaults); |
| 2478 | 2477 | $form->display(); |
| 2479 | - } |
|
| 2480 | - |
|
| 2481 | - /** |
|
| 2482 | - * Blog admin | Display the form to edit a blog. |
|
| 2483 | - * |
|
| 2484 | - */ |
|
| 2485 | - public static function display_edit_blog_form($blog_id) |
|
| 2486 | - { |
|
| 2487 | - $course_id = api_get_course_int_id(); |
|
| 2488 | - $blog_id= intval($blog_id); |
|
| 2489 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2490 | - |
|
| 2491 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
| 2478 | + } |
|
| 2479 | + |
|
| 2480 | + /** |
|
| 2481 | + * Blog admin | Display the form to edit a blog. |
|
| 2482 | + * |
|
| 2483 | + */ |
|
| 2484 | + public static function display_edit_blog_form($blog_id) |
|
| 2485 | + { |
|
| 2486 | + $course_id = api_get_course_int_id(); |
|
| 2487 | + $blog_id= intval($blog_id); |
|
| 2488 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2489 | + |
|
| 2490 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
| 2492 | 2491 | FROM $tbl_blogs |
| 2493 | 2492 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
| 2494 | - $result = Database::query($sql); |
|
| 2495 | - $blog = Database::fetch_array($result); |
|
| 2493 | + $result = Database::query($sql); |
|
| 2494 | + $blog = Database::fetch_array($result); |
|
| 2496 | 2495 | |
| 2497 | - // the form contained errors but we do not want to lose the changes the user already did |
|
| 2498 | - if ($_POST) { |
|
| 2499 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
| 2500 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
| 2501 | - } |
|
| 2496 | + // the form contained errors but we do not want to lose the changes the user already did |
|
| 2497 | + if ($_POST) { |
|
| 2498 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
| 2499 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
| 2500 | + } |
|
| 2502 | 2501 | |
| 2503 | 2502 | $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
| 2504 | 2503 | $form->addElement('header', get_lang('EditBlog')); |
@@ -2514,76 +2513,76 @@ discard block |
||
| 2514 | 2513 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
| 2515 | 2514 | $form->setDefaults($defaults); |
| 2516 | 2515 | $form->display(); |
| 2517 | - } |
|
| 2516 | + } |
|
| 2518 | 2517 | |
| 2519 | - /** |
|
| 2520 | - * Blog admin | Returns table with blogs in this course |
|
| 2521 | - */ |
|
| 2522 | - public static function display_blog_list() |
|
| 2518 | + /** |
|
| 2519 | + * Blog admin | Returns table with blogs in this course |
|
| 2520 | + */ |
|
| 2521 | + public static function display_blog_list() |
|
| 2523 | 2522 | { |
| 2524 | - global $charset; |
|
| 2525 | - $_user = api_get_user_info(); |
|
| 2523 | + global $charset; |
|
| 2524 | + $_user = api_get_user_info(); |
|
| 2526 | 2525 | $course_id = api_get_course_int_id(); |
| 2527 | 2526 | |
| 2528 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2527 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2529 | 2528 | |
| 2530 | - //condition for the session |
|
| 2531 | - $session_id = api_get_session_id(); |
|
| 2529 | + //condition for the session |
|
| 2530 | + $session_id = api_get_session_id(); |
|
| 2532 | 2531 | |
| 2533 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
| 2532 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
| 2534 | 2533 | FROM $tbl_blogs WHERE c_id = $course_id |
| 2535 | 2534 | ORDER BY date_creation DESC"; |
| 2536 | - $result = Database::query($sql); |
|
| 2537 | - $list_info = array(); |
|
| 2538 | - if (Database::num_rows($result)) { |
|
| 2539 | - while ($row_project=Database::fetch_row($result)) { |
|
| 2540 | - $list_info[]=$row_project; |
|
| 2541 | - } |
|
| 2542 | - } |
|
| 2543 | - |
|
| 2544 | - $list_content_blog = array(); |
|
| 2545 | - $list_body_blog = array(); |
|
| 2546 | - |
|
| 2547 | - if (is_array($list_info)) { |
|
| 2548 | - foreach ($list_info as $key => $info_log) { |
|
| 2549 | - // Validation when belongs to a session |
|
| 2550 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
| 2551 | - |
|
| 2552 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2553 | - $title = $info_log[0]; |
|
| 2535 | + $result = Database::query($sql); |
|
| 2536 | + $list_info = array(); |
|
| 2537 | + if (Database::num_rows($result)) { |
|
| 2538 | + while ($row_project=Database::fetch_row($result)) { |
|
| 2539 | + $list_info[]=$row_project; |
|
| 2540 | + } |
|
| 2541 | + } |
|
| 2542 | + |
|
| 2543 | + $list_content_blog = array(); |
|
| 2544 | + $list_body_blog = array(); |
|
| 2545 | + |
|
| 2546 | + if (is_array($list_info)) { |
|
| 2547 | + foreach ($list_info as $key => $info_log) { |
|
| 2548 | + // Validation when belongs to a session |
|
| 2549 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
| 2550 | + |
|
| 2551 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2552 | + $title = $info_log[0]; |
|
| 2554 | 2553 | $image = Display::return_icon('blog.png', $title); |
| 2555 | - $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; |
|
| 2554 | + $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; |
|
| 2556 | 2555 | |
| 2557 | - $list_body_blog[] = $list_name; |
|
| 2558 | - $list_body_blog[] = $info_log[1]; |
|
| 2556 | + $list_body_blog[] = $list_name; |
|
| 2557 | + $list_body_blog[] = $info_log[1]; |
|
| 2559 | 2558 | |
| 2560 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2561 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2562 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2559 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2560 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2561 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2563 | 2562 | $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
| 2564 | 2563 | |
| 2565 | - $my_image.= "</a>"; |
|
| 2566 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2567 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2564 | + $my_image.= "</a>"; |
|
| 2565 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2566 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2568 | 2567 | $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
| 2569 | 2568 | |
| 2570 | - $my_image.= "</a>"; |
|
| 2571 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2569 | + $my_image.= "</a>"; |
|
| 2570 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2572 | 2571 | $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
| 2573 | 2572 | |
| 2574 | - $my_image.= "</a>"; |
|
| 2575 | - $list_body_blog[]=$my_image; |
|
| 2576 | - $list_content_blog[]=$list_body_blog; |
|
| 2577 | - $list_body_blog = array(); |
|
| 2578 | - } |
|
| 2579 | - |
|
| 2580 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2581 | - $table->set_header(0, get_lang('Title')); |
|
| 2582 | - $table->set_header(1, get_lang('SubTitle')); |
|
| 2583 | - $table->set_header(2, get_lang('Modify')); |
|
| 2584 | - $table->display(); |
|
| 2585 | - } |
|
| 2586 | - } |
|
| 2573 | + $my_image.= "</a>"; |
|
| 2574 | + $list_body_blog[]=$my_image; |
|
| 2575 | + $list_content_blog[]=$list_body_blog; |
|
| 2576 | + $list_body_blog = array(); |
|
| 2577 | + } |
|
| 2578 | + |
|
| 2579 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2580 | + $table->set_header(0, get_lang('Title')); |
|
| 2581 | + $table->set_header(1, get_lang('SubTitle')); |
|
| 2582 | + $table->set_header(2, get_lang('Modify')); |
|
| 2583 | + $table->display(); |
|
| 2584 | + } |
|
| 2585 | + } |
|
| 2587 | 2586 | } |
| 2588 | 2587 | |
| 2589 | 2588 | /** |
@@ -2603,34 +2602,34 @@ discard block |
||
| 2603 | 2602 | */ |
| 2604 | 2603 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
| 2605 | 2604 | { |
| 2606 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2607 | - |
|
| 2608 | - $blog_id = intval($blog_id); |
|
| 2609 | - $comment_id = intval($comment_id); |
|
| 2610 | - $post_id = intval($post_id); |
|
| 2611 | - $row=array(); |
|
| 2612 | - $where=''; |
|
| 2613 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
| 2614 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2615 | - } |
|
| 2616 | - |
|
| 2617 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
| 2618 | - if (!empty ($post_id)) { |
|
| 2619 | - $where.= ' AND '; |
|
| 2620 | - } |
|
| 2621 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2622 | - } |
|
| 2605 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2606 | + |
|
| 2607 | + $blog_id = intval($blog_id); |
|
| 2608 | + $comment_id = intval($comment_id); |
|
| 2609 | + $post_id = intval($post_id); |
|
| 2610 | + $row=array(); |
|
| 2611 | + $where=''; |
|
| 2612 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
| 2613 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2614 | + } |
|
| 2615 | + |
|
| 2616 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
| 2617 | + if (!empty ($post_id)) { |
|
| 2618 | + $where.= ' AND '; |
|
| 2619 | + } |
|
| 2620 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2621 | + } |
|
| 2623 | 2622 | |
| 2624 | 2623 | $course_id = api_get_course_int_id(); |
| 2625 | 2624 | |
| 2626 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2625 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2627 | 2626 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2628 | 2627 | |
| 2629 | - $result=Database::query($sql); |
|
| 2630 | - if (Database::num_rows($result)!=0) { |
|
| 2631 | - $row=Database::fetch_array($result); |
|
| 2632 | - } |
|
| 2633 | - return $row; |
|
| 2628 | + $result=Database::query($sql); |
|
| 2629 | + if (Database::num_rows($result)!=0) { |
|
| 2630 | + $row=Database::fetch_array($result); |
|
| 2631 | + } |
|
| 2632 | + return $row; |
|
| 2634 | 2633 | } |
| 2635 | 2634 | |
| 2636 | 2635 | /** |
@@ -2644,16 +2643,16 @@ discard block |
||
| 2644 | 2643 | |
| 2645 | 2644 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
| 2646 | 2645 | { |
| 2647 | - $_course = api_get_course_info(); |
|
| 2648 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2649 | - $blog_id = intval($blog_id); |
|
| 2650 | - $comment_id = intval($comment_id); |
|
| 2651 | - $post_id = intval($post_id); |
|
| 2646 | + $_course = api_get_course_info(); |
|
| 2647 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2648 | + $blog_id = intval($blog_id); |
|
| 2649 | + $comment_id = intval($comment_id); |
|
| 2650 | + $post_id = intval($post_id); |
|
| 2652 | 2651 | |
| 2653 | 2652 | $course_id = api_get_course_int_id(); |
| 2654 | - $where = null; |
|
| 2653 | + $where = null; |
|
| 2655 | 2654 | |
| 2656 | - // delete files in DB |
|
| 2655 | + // delete files in DB |
|
| 2657 | 2656 | if (!empty ($post_id) && is_numeric($post_id)) { |
| 2658 | 2657 | $where .= ' AND post_id ="'.$post_id.'" '; |
| 2659 | 2658 | } |
@@ -2665,25 +2664,25 @@ discard block |
||
| 2665 | 2664 | $where .= ' comment_id ="'.$comment_id.'" '; |
| 2666 | 2665 | } |
| 2667 | 2666 | |
| 2668 | - // delete all files in directory |
|
| 2669 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 2670 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 2671 | - $updir = $sys_course_path.$courseDir; |
|
| 2667 | + // delete all files in directory |
|
| 2668 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 2669 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 2670 | + $updir = $sys_course_path.$courseDir; |
|
| 2672 | 2671 | |
| 2673 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
| 2672 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
| 2674 | 2673 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2675 | - $result=Database::query($sql); |
|
| 2676 | - |
|
| 2677 | - while ($row=Database::fetch_row($result)) { |
|
| 2678 | - $file=$updir.'/'.$row[0]; |
|
| 2679 | - if (Security::check_abs_path($file,$updir) ) |
|
| 2680 | - { |
|
| 2681 | - @ unlink($file); |
|
| 2682 | - } |
|
| 2683 | - } |
|
| 2684 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2674 | + $result=Database::query($sql); |
|
| 2675 | + |
|
| 2676 | + while ($row=Database::fetch_row($result)) { |
|
| 2677 | + $file=$updir.'/'.$row[0]; |
|
| 2678 | + if (Security::check_abs_path($file,$updir) ) |
|
| 2679 | + { |
|
| 2680 | + @ unlink($file); |
|
| 2681 | + } |
|
| 2682 | + } |
|
| 2683 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2685 | 2684 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2686 | - Database::query($sql); |
|
| 2685 | + Database::query($sql); |
|
| 2687 | 2686 | } |
| 2688 | 2687 | |
| 2689 | 2688 | /** |
@@ -2693,12 +2692,12 @@ discard block |
||
| 2693 | 2692 | */ |
| 2694 | 2693 | function get_blog_post_from_user($course_code, $user_id) |
| 2695 | 2694 | { |
| 2696 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2697 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2698 | - $course_info = api_get_course_info($course_code); |
|
| 2699 | - $course_id = $course_info['real_id']; |
|
| 2695 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2696 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2697 | + $course_info = api_get_course_info($course_code); |
|
| 2698 | + $course_id = $course_info['real_id']; |
|
| 2700 | 2699 | |
| 2701 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
| 2700 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
| 2702 | 2701 | FROM $tbl_blogs blog |
| 2703 | 2702 | INNER JOIN $tbl_blog_post post |
| 2704 | 2703 | ON (blog.blog_id = post.blog_id) |
@@ -2707,19 +2706,19 @@ discard block |
||
| 2707 | 2706 | post.c_id = $course_id AND |
| 2708 | 2707 | author_id = $user_id AND visibility = 1 |
| 2709 | 2708 | ORDER BY post.date_creation DESC "; |
| 2710 | - $result = Database::query($sql); |
|
| 2711 | - $return_data = ''; |
|
| 2712 | - |
|
| 2713 | - if (Database::num_rows($result)!=0) { |
|
| 2714 | - while ($row=Database::fetch_array($result)) { |
|
| 2715 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2716 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2717 | - $return_data.= '<br / >'; |
|
| 2718 | - $return_data.= $row['full_text']; |
|
| 2719 | - $return_data.= '<br /><br />'; |
|
| 2720 | - } |
|
| 2721 | - } |
|
| 2722 | - return $return_data; |
|
| 2709 | + $result = Database::query($sql); |
|
| 2710 | + $return_data = ''; |
|
| 2711 | + |
|
| 2712 | + if (Database::num_rows($result)!=0) { |
|
| 2713 | + while ($row=Database::fetch_array($result)) { |
|
| 2714 | + $return_data.= '<div class="clear"></div><br />'; |
|
| 2715 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2716 | + $return_data.= '<br / >'; |
|
| 2717 | + $return_data.= $row['full_text']; |
|
| 2718 | + $return_data.= '<br /><br />'; |
|
| 2719 | + } |
|
| 2720 | + } |
|
| 2721 | + return $return_data; |
|
| 2723 | 2722 | } |
| 2724 | 2723 | |
| 2725 | 2724 | /** |
@@ -2736,7 +2735,7 @@ discard block |
||
| 2736 | 2735 | $course_info = api_get_course_info($course_code); |
| 2737 | 2736 | $course_id = $course_info['real_id']; |
| 2738 | 2737 | |
| 2739 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
| 2738 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
| 2740 | 2739 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
| 2741 | 2740 | ON (blog.blog_id = comment.blog_id) |
| 2742 | 2741 | WHERE blog.c_id = $course_id AND |
@@ -2744,18 +2743,18 @@ discard block |
||
| 2744 | 2743 | author_id = $user_id AND |
| 2745 | 2744 | visibility = 1 |
| 2746 | 2745 | ORDER BY blog_name"; |
| 2747 | - $result = Database::query($sql); |
|
| 2748 | - $return_data = ''; |
|
| 2749 | - if (Database::num_rows($result)!=0) { |
|
| 2750 | - while ($row=Database::fetch_array($result)) { |
|
| 2751 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2752 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2753 | - $return_data.= '<br / >'; |
|
| 2754 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
| 2755 | - $return_data.= $row['comment']; |
|
| 2756 | - $return_data.= '<br />'; |
|
| 2757 | - } |
|
| 2758 | - } |
|
| 2759 | - return $return_data; |
|
| 2746 | + $result = Database::query($sql); |
|
| 2747 | + $return_data = ''; |
|
| 2748 | + if (Database::num_rows($result)!=0) { |
|
| 2749 | + while ($row=Database::fetch_array($result)) { |
|
| 2750 | + $return_data.= '<div class="clear"></div><br />'; |
|
| 2751 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2752 | + $return_data.= '<br / >'; |
|
| 2753 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
| 2754 | + $return_data.= $row['comment']; |
|
| 2755 | + $return_data.= '<br />'; |
|
| 2756 | + } |
|
| 2757 | + } |
|
| 2758 | + return $return_data; |
|
| 2760 | 2759 | } |
| 2761 | 2760 | |
@@ -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 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 30 | 30 | |
| 31 | 31 | $sql = "SELECT blog_name |
| 32 | - FROM " . $tbl_blogs . " |
|
| 33 | - WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
|
| 32 | + FROM " . $tbl_blogs." |
|
| 33 | + WHERE c_id = $course_id AND blog_id = ".intval($blog_id); |
|
| 34 | 34 | |
| 35 | 35 | $result = Database::query($sql); |
| 36 | 36 | $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); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'blog_name' => $title, |
| 130 | 130 | 'blog_subtitle' => $subtitle, |
| 131 | 131 | 'date_creation' => $current_date, |
| 132 | - 'visibility' => 1 , |
|
| 132 | + 'visibility' => 1, |
|
| 133 | 133 | 'session_id' => $session_id, |
| 134 | 134 | ]; |
| 135 | 135 | $this_blog_id = Database::insert($tbl_blogs, $params); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // Put it on course homepage |
| 170 | 170 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
| 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')"; |
|
| 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')"; |
|
| 172 | 172 | Database::query($sql); |
| 173 | 173 | |
| 174 | 174 | $toolId = Database::insert_id(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | blog_subtitle = '".Database::escape_string($subtitle)."' |
| 204 | 204 | WHERE |
| 205 | 205 | c_id = $course_id AND |
| 206 | - blog_id ='".Database::escape_string((int)$blog_id)."' |
|
| 206 | + blog_id ='".Database::escape_string((int) $blog_id)."' |
|
| 207 | 207 | LIMIT 1"; |
| 208 | 208 | Database::query($sql); |
| 209 | 209 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | // Update course homepage link |
| 220 | 220 | $sql = "UPDATE $tbl_tool SET |
| 221 | 221 | name = '".Database::escape_string($title)."' |
| 222 | - WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
|
| 222 | + WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int) $blog_id."' LIMIT 1"; |
|
| 223 | 223 | Database::query($sql); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | Database::query($sql); |
| 262 | 262 | |
| 263 | 263 | // Delete blog |
| 264 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 264 | + $sql = "DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 265 | 265 | Database::query($sql); |
| 266 | 266 | |
| 267 | 267 | // Delete from course homepage |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | $course_id = $_course['real_id']; |
| 293 | 293 | |
| 294 | 294 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 295 | - $upload_ok=true; |
|
| 296 | - $has_attachment=false; |
|
| 295 | + $upload_ok = true; |
|
| 296 | + $has_attachment = false; |
|
| 297 | 297 | $current_date = api_get_utc_datetime(); |
| 298 | 298 | |
| 299 | 299 | if (!empty($_FILES['user_upload']['name'])) { |
| 300 | 300 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
| 301 | - $has_attachment=true; |
|
| 301 | + $has_attachment = true; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if ($upload_ok) { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | // Create the post |
| 309 | 309 | $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
| 310 | - VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
|
| 310 | + VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int) $blog_id."', '".(int) $_user['user_id']."');"; |
|
| 311 | 311 | |
| 312 | 312 | Database::query($sql); |
| 313 | 313 | $last_post_id = Database::insert_id(); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if ($has_attachment) { |
| 321 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 321 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 322 | 322 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 323 | 323 | $updir = $sys_course_path.$courseDir; |
| 324 | 324 | |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | // Create the post |
| 371 | 371 | $sql = "UPDATE $tbl_blogs_posts SET |
| 372 | - title = '" . Database::escape_string($title)."', |
|
| 372 | + title = '".Database::escape_string($title)."', |
|
| 373 | 373 | full_text = '" . Database::escape_string($full_text)."' |
| 374 | - WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
|
| 374 | + WHERE c_id = $course_id AND post_id ='".(int) $post_id."' AND blog_id ='".(int) $blog_id."' |
|
| 375 | 375 | LIMIT 1 "; |
| 376 | 376 | Database::query($sql); |
| 377 | 377 | } |
@@ -392,21 +392,21 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | // Delete ratings on this comment |
| 394 | 394 | $sql = "DELETE FROM $tbl_blogs_rating |
| 395 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
|
| 395 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND item_id = '".(int) $post_id."' AND rating_type = 'post'"; |
|
| 396 | 396 | Database::query($sql); |
| 397 | 397 | |
| 398 | 398 | // Delete the post |
| 399 | 399 | $sql = "DELETE FROM $tbl_blogs_posts |
| 400 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
|
| 400 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."'"; |
|
| 401 | 401 | Database::query($sql); |
| 402 | 402 | |
| 403 | 403 | // Delete the comments |
| 404 | 404 | $sql = "DELETE FROM $tbl_blogs_comments |
| 405 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
|
| 405 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."' AND blog_id = '".(int) $blog_id."'"; |
|
| 406 | 406 | Database::query($sql); |
| 407 | 407 | |
| 408 | 408 | // Delete posts and attachments |
| 409 | - delete_all_blog_attachment($blog_id,$post_id); |
|
| 409 | + delete_all_blog_attachment($blog_id, $post_id); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | { |
| 423 | 423 | $_user = api_get_user_info(); |
| 424 | 424 | $_course = api_get_course_info(); |
| 425 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 425 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 426 | 426 | |
| 427 | 427 | $upload_ok = true; |
| 428 | 428 | $has_attachment = false; |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | if (!empty($_FILES['user_upload']['name'])) { |
| 433 | 433 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
| 434 | - $has_attachment=true; |
|
| 434 | + $has_attachment = true; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | if ($upload_ok) { |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | // Create the comment |
| 442 | 442 | $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
| 443 | - 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."')"; |
|
| 443 | + 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."')"; |
|
| 444 | 444 | Database::query($sql); |
| 445 | 445 | |
| 446 | 446 | // Empty post values, or they are shown on the page again |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | if ($has_attachment) { |
| 455 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 455 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 456 | 456 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 457 | 457 | $updir = $sys_course_path.$courseDir; |
| 458 | 458 | |
@@ -463,19 +463,19 @@ discard block |
||
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | 465 | // user's file name |
| 466 | - $file_name =$_FILES['user_upload']['name']; |
|
| 466 | + $file_name = $_FILES['user_upload']['name']; |
|
| 467 | 467 | |
| 468 | 468 | if (!filter_extension($new_file_name)) { |
| 469 | 469 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 470 | 470 | } else { |
| 471 | 471 | $new_file_name = uniqid(''); |
| 472 | - $new_path=$updir.'/'.$new_file_name; |
|
| 473 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 472 | + $new_path = $updir.'/'.$new_file_name; |
|
| 473 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 474 | 474 | $comment = Database::escape_string($file_comment); |
| 475 | 475 | |
| 476 | 476 | // Storing the attachments if any |
| 477 | 477 | if ($result) { |
| 478 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 478 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 479 | 479 | "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."' )"; |
| 480 | 480 | Database::query($sql); |
| 481 | 481 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | // Delete them recursively |
| 526 | 526 | while ($comment = Database::fetch_array($result)) { |
| 527 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 527 | + Blog::delete_comment($blog_id, $post_id, $comment['comment_id']); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | // Finally, delete the selected comment to |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | // Create the task |
| 552 | 552 | $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
| 553 | - VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
|
| 553 | + VALUES ($course_id , '".(int) $blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');"; |
|
| 554 | 554 | Database::query($sql); |
| 555 | 555 | |
| 556 | 556 | $task_id = Database::insert_id(); |
@@ -560,13 +560,13 @@ discard block |
||
| 560 | 560 | Database::query($sql); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - $tool = 'BLOG_' . $blog_id; |
|
| 563 | + $tool = 'BLOG_'.$blog_id; |
|
| 564 | 564 | |
| 565 | 565 | if ($articleDelete == 'on') { |
| 566 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 567 | - '" . (int)$course_id . "', |
|
| 568 | - '" . (int)$task_id . "', |
|
| 569 | - '" . Database::escape_string($tool) . "', |
|
| 566 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
| 567 | + '" . (int) $course_id."', |
|
| 568 | + '" . (int) $task_id."', |
|
| 569 | + '" . Database::escape_string($tool)."', |
|
| 570 | 570 | 'article_delete' |
| 571 | 571 | )"; |
| 572 | 572 | Database::query($sql); |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | if ($articleEdit == 'on') { |
| 583 | 583 | $sql = " |
| 584 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
| 585 | - '" . (int)$course_id . "', |
|
| 586 | - '" . (int)$task_id . "', |
|
| 587 | - '" . Database::escape_string($tool) . "', |
|
| 584 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
| 585 | + '" . (int) $course_id."', |
|
| 586 | + '" . (int) $task_id."', |
|
| 587 | + '" . Database::escape_string($tool)."', |
|
| 588 | 588 | 'article_edit' |
| 589 | 589 | )"; |
| 590 | 590 | Database::query($sql); |
@@ -598,10 +598,10 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | if ($commentsDelete == 'on') { |
| 600 | 600 | $sql = " |
| 601 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
| 602 | - '" . (int)$course_id . "', |
|
| 603 | - '" . (int)$task_id . "', |
|
| 604 | - '" . Database::escape_string($tool) . "', |
|
| 601 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
| 602 | + '" . (int) $course_id."', |
|
| 603 | + '" . (int) $task_id."', |
|
| 604 | + '" . Database::escape_string($tool)."', |
|
| 605 | 605 | 'article_comments_delete' |
| 606 | 606 | )"; |
| 607 | 607 | Database::query($sql); |
@@ -634,20 +634,20 @@ discard block |
||
| 634 | 634 | title = '".Database::escape_string($title)."', |
| 635 | 635 | description = '".Database::escape_string($description)."', |
| 636 | 636 | color = '".Database::escape_string($color)."' |
| 637 | - WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
|
| 637 | + WHERE c_id = $course_id AND task_id ='".(int) $task_id."' LIMIT 1"; |
|
| 638 | 638 | Database::query($sql); |
| 639 | 639 | |
| 640 | - $tool = 'BLOG_' . $blog_id; |
|
| 640 | + $tool = 'BLOG_'.$blog_id; |
|
| 641 | 641 | |
| 642 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 643 | - WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
|
| 642 | + $sql = "DELETE FROM ".$tbl_tasks_permissions." |
|
| 643 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 644 | 644 | Database::query($sql); |
| 645 | 645 | |
| 646 | 646 | if ($articleDelete == 'on') { |
| 647 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 648 | - '" . (int)$course_id . "', |
|
| 649 | - '" . (int)$task_id . "', |
|
| 650 | - '" . Database::escape_string($tool) . "', |
|
| 647 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
| 648 | + '" . (int) $course_id."', |
|
| 649 | + '" . (int) $task_id."', |
|
| 650 | + '" . Database::escape_string($tool)."', |
|
| 651 | 651 | 'article_delete' |
| 652 | 652 | )"; |
| 653 | 653 | Database::query($sql); |
@@ -660,10 +660,10 @@ discard block |
||
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | if ($articleEdit == 'on') { |
| 663 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 664 | - '" . (int)$course_id . "', |
|
| 665 | - '" . (int)$task_id . "', |
|
| 666 | - '" . Database::escape_string($tool) . "', |
|
| 663 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
| 664 | + '" . (int) $course_id."', |
|
| 665 | + '" . (int) $task_id."', |
|
| 666 | + '" . Database::escape_string($tool)."', |
|
| 667 | 667 | 'article_edit' |
| 668 | 668 | )"; |
| 669 | 669 | Database::query($sql); |
@@ -676,10 +676,10 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | if ($commentsDelete == 'on') { |
| 679 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 680 | - '" . (int)$course_id . "', |
|
| 681 | - '" . (int)$task_id . "', |
|
| 682 | - '" . Database::escape_string($tool) . "', |
|
| 679 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
| 680 | + '" . (int) $course_id."', |
|
| 681 | + '" . (int) $task_id."', |
|
| 682 | + '" . Database::escape_string($tool)."', |
|
| 683 | 683 | 'article_comments_delete' |
| 684 | 684 | )"; |
| 685 | 685 | Database::query($sql); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | // Delete posts |
| 706 | 706 | $sql = "DELETE FROM $tbl_blogs_tasks |
| 707 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
|
| 707 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND task_id = '".(int) $task_id."'"; |
|
| 708 | 708 | Database::query($sql); |
| 709 | 709 | } |
| 710 | 710 | |
@@ -722,9 +722,9 @@ discard block |
||
| 722 | 722 | $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
| 723 | 723 | WHERE |
| 724 | 724 | c_id = $course_id AND |
| 725 | - blog_id = '".(int)$blog_id."' AND |
|
| 726 | - task_id = '".(int)$task_id."' AND |
|
| 727 | - user_id = '".(int)$user_id."'"; |
|
| 725 | + blog_id = '".(int) $blog_id."' AND |
|
| 726 | + task_id = '".(int) $task_id."' AND |
|
| 727 | + user_id = '".(int) $user_id."'"; |
|
| 728 | 728 | Database::query($sql); |
| 729 | 729 | } |
| 730 | 730 | |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $_user = api_get_user_info(); |
| 739 | 739 | |
| 740 | 740 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 741 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 741 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 742 | 742 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 743 | 743 | |
| 744 | 744 | $course_id = api_get_course_int_id(); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | task.c_id = $course_id AND |
| 756 | 756 | blog.c_id = $course_id AND |
| 757 | 757 | task_rel_user.c_id = $course_id AND |
| 758 | - task_rel_user.user_id = ".(int)$_user['user_id']." |
|
| 758 | + task_rel_user.user_id = ".(int) $_user['user_id']." |
|
| 759 | 759 | ORDER BY target_date ASC"; |
| 760 | 760 | |
| 761 | 761 | $result = Database::query($sql); |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | if (Database::num_rows($result) > 0) { |
| 764 | 764 | echo '<ul>'; |
| 765 | 765 | while ($mytask = Database::fetch_array($result)) { |
| 766 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 766 | + echo '<li><a href="blog.php?action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes($mytask['task_id']).'" title="[Blog: '.stripslashes($mytask['blog_name']).'] '.get_lang('ExecuteThisTask').'">'.stripslashes($mytask['title']).'</a></li>'; |
|
| 767 | 767 | } |
| 768 | 768 | echo '<ul>'; |
| 769 | 769 | } else { |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | // Get blog properties |
| 789 | 789 | $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
| 790 | - WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
|
| 790 | + WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'"; |
|
| 791 | 791 | $result = Database::query($sql); |
| 792 | 792 | $blog = Database::fetch_array($result); |
| 793 | 793 | $visibility = $blog['visibility']; |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | if ($visibility == 1) { |
| 797 | 797 | // Change visibility state, remove from course home. |
| 798 | 798 | $sql = "UPDATE $tbl_blogs SET visibility = '0' |
| 799 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
| 799 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
| 800 | 800 | Database::query($sql); |
| 801 | 801 | |
| 802 | 802 | $sql = "DELETE FROM $tbl_tool |
@@ -805,11 +805,11 @@ discard block |
||
| 805 | 805 | } else { |
| 806 | 806 | // Change visibility state, add to course home. |
| 807 | 807 | $sql = "UPDATE $tbl_blogs SET visibility = '1' |
| 808 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
| 808 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
| 809 | 809 | Database::query($sql); |
| 810 | 810 | |
| 811 | 811 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
| 812 | - VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
| 812 | + VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
| 813 | 813 | Database::query($sql); |
| 814 | 814 | $id = Database::insert_id(); |
| 815 | 815 | |
@@ -840,14 +840,14 @@ discard block |
||
| 840 | 840 | FROM $tbl_blogs_posts post |
| 841 | 841 | INNER JOIN $tbl_users user |
| 842 | 842 | ON post.author_id = user.user_id |
| 843 | - WHERE post.blog_id = '".(int)$blog_id."' AND |
|
| 843 | + WHERE post.blog_id = '".(int) $blog_id."' AND |
|
| 844 | 844 | post.c_id = $course_id AND |
| 845 | 845 | $filter |
| 846 | - ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
|
| 846 | + ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts; |
|
| 847 | 847 | $result = Database::query($sql); |
| 848 | 848 | |
| 849 | 849 | // Display |
| 850 | - if(Database::num_rows($result) > 0) { |
|
| 850 | + if (Database::num_rows($result) > 0) { |
|
| 851 | 851 | $limit = 200; |
| 852 | 852 | while ($blog_post = Database::fetch_array($result)) { |
| 853 | 853 | // Get number of comments |
@@ -855,8 +855,8 @@ discard block |
||
| 855 | 855 | FROM $tbl_blogs_comments |
| 856 | 856 | WHERE |
| 857 | 857 | c_id = $course_id AND |
| 858 | - blog_id = '".(int)$blog_id."' AND |
|
| 859 | - post_id = '" . (int)$blog_post['post_id']."'"; |
|
| 858 | + blog_id = '".(int) $blog_id."' AND |
|
| 859 | + post_id = '" . (int) $blog_post['post_id']."'"; |
|
| 860 | 860 | $tmp = Database::query($sql); |
| 861 | 861 | $blog_post_comments = Database::fetch_array($tmp); |
| 862 | 862 | |
@@ -867,11 +867,11 @@ discard block |
||
| 867 | 867 | |
| 868 | 868 | // Create an introduction text (but keep FULL sentences) |
| 869 | 869 | $words = 0; |
| 870 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 870 | + $blog_post_text_cut = cut($blog_post_text, $limit); |
|
| 871 | 871 | $words = strlen($blog_post_text); |
| 872 | 872 | |
| 873 | 873 | if ($words >= $limit) { |
| 874 | - $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>'; |
|
| 874 | + $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>'; |
|
| 875 | 875 | $introduction_text = $blog_post_text_cut; |
| 876 | 876 | } else { |
| 877 | 877 | $introduction_text = $blog_post_text; |
@@ -881,27 +881,27 @@ discard block |
||
| 881 | 881 | $introduction_text = stripslashes($introduction_text); |
| 882 | 882 | |
| 883 | 883 | echo '<div class="blogpost">'; |
| 884 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 885 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 886 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 887 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 884 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
| 885 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.$blog_post_date.'</a></span>'; |
|
| 886 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>'; |
|
| 887 | + echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>'; |
|
| 888 | 888 | |
| 889 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 889 | + $file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0); |
|
| 890 | 890 | |
| 891 | 891 | if (!empty($file_name_array)) { |
| 892 | 892 | echo '<br /><br />'; |
| 893 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 893 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 894 | 894 | echo '<a href="download.php?file='; |
| 895 | 895 | echo $file_name_array['path']; |
| 896 | 896 | echo ' "> '.$file_name_array['filename'].' </a><br />'; |
| 897 | 897 | echo '</span>'; |
| 898 | 898 | } |
| 899 | 899 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 900 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 900 | + echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - <a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].'</a></span>'; |
|
| 901 | 901 | echo '</div>'; |
| 902 | 902 | } |
| 903 | 903 | } else { |
| 904 | - if($filter == '1=1') { |
|
| 904 | + if ($filter == '1=1') { |
|
| 905 | 905 | echo get_lang('NoArticles'); |
| 906 | 906 | } else { |
| 907 | 907 | echo get_lang('NoArticleMatches'); |
@@ -915,19 +915,19 @@ discard block |
||
| 915 | 915 | * @param Integer $blog_id |
| 916 | 916 | * @param String $query_string |
| 917 | 917 | */ |
| 918 | - public static function display_search_results ($blog_id, $query_string) |
|
| 918 | + public static function display_search_results($blog_id, $query_string) |
|
| 919 | 919 | { |
| 920 | 920 | // Init |
| 921 | 921 | $query_string = Database::escape_string($query_string); |
| 922 | - $query_string_parts = explode(' ',$query_string); |
|
| 922 | + $query_string_parts = explode(' ', $query_string); |
|
| 923 | 923 | $query_string = array(); |
| 924 | 924 | foreach ($query_string_parts as $query_part) { |
| 925 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 925 | + $query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' "; |
|
| 926 | 926 | } |
| 927 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 927 | + $query_string = '('.implode('OR', $query_string).')'; |
|
| 928 | 928 | |
| 929 | 929 | // Display the posts |
| 930 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 930 | + echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>'; |
|
| 931 | 931 | Blog::display_blog_posts($blog_id, $query_string); |
| 932 | 932 | } |
| 933 | 933 | |
@@ -940,14 +940,14 @@ discard block |
||
| 940 | 940 | public static function display_day_results($blog_id, $query_string) |
| 941 | 941 | { |
| 942 | 942 | $date_output = $query_string; |
| 943 | - $date = explode('-',$query_string); |
|
| 944 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 943 | + $date = explode('-', $query_string); |
|
| 944 | + $query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]); |
|
| 945 | 945 | |
| 946 | 946 | // Put date in correct output format |
| 947 | 947 | $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
| 948 | 948 | |
| 949 | 949 | // Display the posts |
| 950 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 950 | + echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>'; |
|
| 951 | 951 | Blog::display_blog_posts($blog_id, $query_string); |
| 952 | 952 | } |
| 953 | 953 | |
@@ -974,8 +974,8 @@ discard block |
||
| 974 | 974 | ON post.author_id = user.user_id |
| 975 | 975 | WHERE |
| 976 | 976 | post.c_id = $course_id AND |
| 977 | - post.blog_id = '".(int)$blog_id."' AND |
|
| 978 | - post.post_id = '".(int)$post_id."' |
|
| 977 | + post.blog_id = '".(int) $blog_id."' AND |
|
| 978 | + post.post_id = '".(int) $post_id."' |
|
| 979 | 979 | ORDER BY post_id DESC"; |
| 980 | 980 | $result = Database::query($sql); |
| 981 | 981 | $blog_post = Database::fetch_array($result); |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | // Get number of comments |
| 984 | 984 | $sql = "SELECT COUNT(1) as number_of_comments |
| 985 | 985 | FROM $tbl_blogs_comments |
| 986 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
|
| 986 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'"; |
|
| 987 | 987 | $result = Database::query($sql); |
| 988 | 988 | $blog_post_comments = Database::fetch_array($result); |
| 989 | 989 | |
@@ -994,34 +994,34 @@ discard block |
||
| 994 | 994 | |
| 995 | 995 | $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
| 996 | 996 | |
| 997 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 998 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 999 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 997 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) { |
|
| 998 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('EditThisPost').'">'; |
|
| 999 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1000 | 1000 | $blog_post_actions .= '</a>'; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1004 | - $blog_post_actions .= '<a href="blog.php?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('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1003 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) { |
|
| 1004 | + $blog_post_actions .= '<a href="blog.php?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('DeleteThisArticle').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;">'; |
|
| 1005 | 1005 | $blog_post_actions .= Display::return_icon('delete.png'); |
| 1006 | 1006 | $blog_post_actions .= '</a>'; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1010 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1009 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) |
|
| 1010 | + $rating_select = Blog::display_rating_form('post', $blog_id, $post_id); |
|
| 1011 | 1011 | |
| 1012 | - $blog_post_text=stripslashes($blog_post_text); |
|
| 1012 | + $blog_post_text = stripslashes($blog_post_text); |
|
| 1013 | 1013 | |
| 1014 | 1014 | // Display post |
| 1015 | 1015 | echo '<div class="blogpost">'; |
| 1016 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1017 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1018 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1016 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
| 1017 | + echo '<span class="blogpost_date">'.$blog_post_date.'</span>'; |
|
| 1018 | + echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />'; |
|
| 1019 | 1019 | |
| 1020 | 1020 | $file_name_array = get_blog_attachment($blog_id, $post_id); |
| 1021 | 1021 | |
| 1022 | 1022 | if (!empty($file_name_array)) { |
| 1023 | 1023 | echo ' <br />'; |
| 1024 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1024 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1025 | 1025 | echo '<a href="download.php?file='; |
| 1026 | 1026 | echo $file_name_array['path']; |
| 1027 | 1027 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1032,20 +1032,20 @@ discard block |
||
| 1032 | 1032 | echo '<br />'; |
| 1033 | 1033 | } |
| 1034 | 1034 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1035 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1036 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1035 | + echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post', $blog_id, $post_id).$rating_select.'</span>'; |
|
| 1036 | + echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>'; |
|
| 1037 | 1037 | echo '</div>'; |
| 1038 | 1038 | |
| 1039 | 1039 | // Display comments if there are any |
| 1040 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1040 | + if ($blog_post_comments['number_of_comments'] > 0) { |
|
| 1041 | 1041 | echo '<div class="comments">'; |
| 1042 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1042 | + echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />'; |
|
| 1043 | 1043 | Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
| 1044 | 1044 | echo '</div>'; |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | // Display comment form |
| 1048 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1048 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { |
|
| 1049 | 1049 | Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
| 1050 | 1050 | } |
| 1051 | 1051 | } |
@@ -1073,16 +1073,16 @@ discard block |
||
| 1073 | 1073 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1074 | 1074 | WHERE |
| 1075 | 1075 | c_id = $course_id AND |
| 1076 | - blog_id = '".(int)$blog_id."' AND |
|
| 1077 | - item_id = '".(int)$item_id."' AND |
|
| 1076 | + blog_id = '".(int) $blog_id."' AND |
|
| 1077 | + item_id = '".(int) $item_id."' AND |
|
| 1078 | 1078 | rating_type = '".Database::escape_string($type)."' AND |
| 1079 | - user_id = '".(int)$_user['user_id']."'"; |
|
| 1079 | + user_id = '".(int) $_user['user_id']."'"; |
|
| 1080 | 1080 | $result = Database::query($sql); |
| 1081 | 1081 | |
| 1082 | 1082 | // Add rating |
| 1083 | 1083 | if (Database::num_rows($result) == 0) { |
| 1084 | 1084 | $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
| 1085 | - VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
| 1085 | + VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
| 1086 | 1086 | Database::query($sql); |
| 1087 | 1087 | |
| 1088 | 1088 | $id = Database::insert_id(); |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
| 1116 | 1116 | WHERE |
| 1117 | 1117 | c_id = $course_id AND |
| 1118 | - blog_id = '".(int)$blog_id."' AND |
|
| 1119 | - item_id = '".(int)$item_id."' AND |
|
| 1118 | + blog_id = '".(int) $blog_id."' AND |
|
| 1119 | + item_id = '".(int) $item_id."' AND |
|
| 1120 | 1120 | rating_type = '".Database::escape_string($type)."' "; |
| 1121 | 1121 | $result = Database::query($sql); |
| 1122 | 1122 | $result = Database::fetch_array($result); |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | * |
| 1134 | 1134 | *@return String |
| 1135 | 1135 | */ |
| 1136 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1136 | + public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1137 | 1137 | { |
| 1138 | 1138 | $_user = api_get_user_info(); |
| 1139 | 1139 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
@@ -1143,14 +1143,14 @@ discard block |
||
| 1143 | 1143 | // Check if the user has already rated this post |
| 1144 | 1144 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1145 | 1145 | WHERE c_id = $course_id AND |
| 1146 | - blog_id = '".(int)$blog_id."' |
|
| 1147 | - AND item_id = '".(int)$post_id."' |
|
| 1146 | + blog_id = '".(int) $blog_id."' |
|
| 1147 | + AND item_id = '".(int) $post_id."' |
|
| 1148 | 1148 | AND rating_type = '".Database::escape_string($type)."' |
| 1149 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
| 1149 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
| 1150 | 1150 | $result = Database::query($sql); |
| 1151 | 1151 | // Add rating |
| 1152 | 1152 | if (Database::num_rows($result) == 0) { |
| 1153 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1153 | + return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" 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>'; |
|
| 1154 | 1154 | } else { |
| 1155 | 1155 | return ''; |
| 1156 | 1156 | } |
@@ -1159,14 +1159,14 @@ discard block |
||
| 1159 | 1159 | if ($type = 'comment') { |
| 1160 | 1160 | // Check if the user has already rated this comment |
| 1161 | 1161 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1162 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
|
| 1163 | - AND item_id = '".(int)$comment_id."' |
|
| 1162 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' |
|
| 1163 | + AND item_id = '".(int) $comment_id."' |
|
| 1164 | 1164 | AND rating_type = '".Database::escape_string($type)."' |
| 1165 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
| 1165 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
| 1166 | 1166 | $result = Database::query($sql); |
| 1167 | 1167 | |
| 1168 | 1168 | if (Database::num_rows($result) == 0) { |
| 1169 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" 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>'; |
|
| 1169 | + return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" 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>'; |
|
| 1170 | 1170 | } else { |
| 1171 | 1171 | return ''; |
| 1172 | 1172 | } |
@@ -1201,11 +1201,11 @@ discard block |
||
| 1201 | 1201 | WHERE |
| 1202 | 1202 | comments.c_id = $course_id AND |
| 1203 | 1203 | parent_comment_id = $current AND |
| 1204 | - comments.blog_id = '".(int)$blog_id."' AND |
|
| 1205 | - comments.post_id = '".(int)$post_id."'"; |
|
| 1204 | + comments.blog_id = '".(int) $blog_id."' AND |
|
| 1205 | + comments.post_id = '".(int) $post_id."'"; |
|
| 1206 | 1206 | $result = Database::query($sql); |
| 1207 | 1207 | |
| 1208 | - while($comment = Database::fetch_array($result)) { |
|
| 1208 | + while ($comment = Database::fetch_array($result)) { |
|
| 1209 | 1209 | // Select the children recursivly |
| 1210 | 1210 | $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
| 1211 | 1211 | FROM $tbl_blogs_comments comments |
@@ -1214,8 +1214,8 @@ discard block |
||
| 1214 | 1214 | WHERE |
| 1215 | 1215 | comments.c_id = $course_id AND |
| 1216 | 1216 | comment_id = $current |
| 1217 | - AND blog_id = '".(int)$blog_id."' |
|
| 1218 | - AND post_id = '".(int)$post_id."'"; |
|
| 1217 | + AND blog_id = '".(int) $blog_id."' |
|
| 1218 | + AND post_id = '".(int) $post_id."'"; |
|
| 1219 | 1219 | $tmp = Database::query($tmp); |
| 1220 | 1220 | $tmp = Database::fetch_array($tmp); |
| 1221 | 1221 | $parent_cat = $tmp['parent_comment_id']; |
@@ -1240,22 +1240,22 @@ discard block |
||
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | if (!is_null($comment['task_id'])) { |
| 1243 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1243 | + $border_color = ' border-left: 3px solid #'.$comment['color']; |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | $comment_text = stripslashes($comment_text); |
| 1247 | 1247 | |
| 1248 | 1248 | // Output... |
| 1249 | 1249 | $margin = $current_level * 30; |
| 1250 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1251 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1252 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1253 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1250 | + echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">'; |
|
| 1251 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']).'\'" title="'.get_lang('ReplyToThisComment').'" >'.stripslashes($comment['title']).'</a></span>'; |
|
| 1252 | + echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>'; |
|
| 1253 | + echo '<span class="blogpost_text">'.$comment_text.'</span>'; |
|
| 1254 | 1254 | |
| 1255 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1255 | + $file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']); |
|
| 1256 | 1256 | if (!empty($file_name_array)) { |
| 1257 | 1257 | echo '<br /><br />'; |
| 1258 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1258 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1259 | 1259 | echo '<a href="download.php?file='; |
| 1260 | 1260 | echo $file_name_array['path']; |
| 1261 | 1261 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | } |
| 1266 | 1266 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
| 1267 | 1267 | 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>'; |
| 1268 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1268 | + echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>'; |
|
| 1269 | 1269 | echo '</div>'; |
| 1270 | 1270 | |
| 1271 | 1271 | // Go further down the tree. |
@@ -1281,11 +1281,11 @@ discard block |
||
| 1281 | 1281 | */ |
| 1282 | 1282 | public static function display_form_new_post($blog_id) |
| 1283 | 1283 | { |
| 1284 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1284 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
| 1285 | 1285 | $form = new FormValidator( |
| 1286 | 1286 | 'add_post', |
| 1287 | 1287 | 'post', |
| 1288 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1288 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(), |
|
| 1289 | 1289 | null, |
| 1290 | 1290 | array('enctype' => 'multipart/form-data') |
| 1291 | 1291 | ); |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1330 | 1330 | WHERE |
| 1331 | 1331 | post.c_id = $course_id AND |
| 1332 | - post.blog_id = '".(int)$blog_id ."' |
|
| 1333 | - AND post.post_id = '".(int)$post_id."' |
|
| 1332 | + post.blog_id = '".(int) $blog_id."' |
|
| 1333 | + AND post.post_id = '".(int) $post_id."' |
|
| 1334 | 1334 | ORDER BY post_id DESC"; |
| 1335 | 1335 | $result = Database::query($sql); |
| 1336 | 1336 | $blog_post = Database::fetch_array($result); |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | $form = new FormValidator( |
| 1340 | 1340 | 'edit_post', |
| 1341 | 1341 | 'post', |
| 1342 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1342 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id='.intval($_GET['post_id']).'&blog_id='.intval($blog_id).'&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1343 | 1343 | ); |
| 1344 | 1344 | |
| 1345 | 1345 | $form->addHeader(get_lang('EditPost')); |
@@ -1371,31 +1371,31 @@ discard block |
||
| 1371 | 1371 | global $charset; |
| 1372 | 1372 | $course_id = api_get_course_int_id(); |
| 1373 | 1373 | |
| 1374 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1374 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
| 1375 | 1375 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1376 | 1376 | $counter = 0; |
| 1377 | 1377 | global $color2; |
| 1378 | 1378 | |
| 1379 | 1379 | echo '<div class="actions">'; |
| 1380 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1380 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=add">'; |
|
| 1381 | 1381 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
| 1382 | - echo get_lang('AddTasks') . '</a> '; |
|
| 1383 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1382 | + echo get_lang('AddTasks').'</a> '; |
|
| 1383 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=assign">'; |
|
| 1384 | 1384 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
| 1385 | - echo get_lang('AssignTasks') . '</a>'; |
|
| 1385 | + echo get_lang('AssignTasks').'</a>'; |
|
| 1386 | 1386 | ?> |
| 1387 | 1387 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
| 1388 | - <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
|
| 1388 | + <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a> |
|
| 1389 | 1389 | <?php |
| 1390 | 1390 | echo '</div>'; |
| 1391 | 1391 | |
| 1392 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1392 | + echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />'; |
|
| 1393 | 1393 | echo "<table class=\"data_table\">"; |
| 1394 | 1394 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
| 1395 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
| 1396 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1397 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
| 1398 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1395 | + "<th width='240'><b>", get_lang('Title'), "</b></th>", |
|
| 1396 | + "<th><b>", get_lang('Description'), "</b></th>", |
|
| 1397 | + "<th><b>", get_lang('Color'), "</b></th>", |
|
| 1398 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>", |
|
| 1399 | 1399 | "</tr>"; |
| 1400 | 1400 | |
| 1401 | 1401 | |
@@ -1407,8 +1407,8 @@ discard block |
||
| 1407 | 1407 | description, |
| 1408 | 1408 | color, |
| 1409 | 1409 | system_task |
| 1410 | - FROM " . $tbl_blogs_tasks . " |
|
| 1411 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
| 1410 | + FROM " . $tbl_blogs_tasks." |
|
| 1411 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
| 1412 | 1412 | ORDER BY system_task, title"; |
| 1413 | 1413 | $result = Database::query($sql); |
| 1414 | 1414 | |
@@ -1417,10 +1417,10 @@ discard block |
||
| 1417 | 1417 | $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
| 1418 | 1418 | $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
| 1419 | 1419 | $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
| 1420 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1421 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1420 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id']; |
|
| 1421 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1422 | 1422 | |
| 1423 | - echo '<tr class="' . $css_class . '" valign="top">'; |
|
| 1423 | + echo '<tr class="'.$css_class.'" valign="top">'; |
|
| 1424 | 1424 | echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>'; |
| 1425 | 1425 | echo '<td>'.Security::remove_XSS($task['description']).'</td>'; |
| 1426 | 1426 | echo '<td><span style="background-color: #'.$task['color'].'"> </span></td>'; |
@@ -1446,23 +1446,23 @@ discard block |
||
| 1446 | 1446 | * |
| 1447 | 1447 | * @param Integer $blog_id |
| 1448 | 1448 | */ |
| 1449 | - public static function display_assigned_task_list ($blog_id) |
|
| 1449 | + public static function display_assigned_task_list($blog_id) |
|
| 1450 | 1450 | { |
| 1451 | 1451 | // Init |
| 1452 | 1452 | $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
| 1453 | 1453 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1454 | 1454 | $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
| 1455 | 1455 | $counter = 0; |
| 1456 | - global $charset,$color2; |
|
| 1456 | + global $charset, $color2; |
|
| 1457 | 1457 | |
| 1458 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1458 | + echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />'; |
|
| 1459 | 1459 | echo "<table class=\"data_table\">"; |
| 1460 | 1460 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
| 1461 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
| 1462 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
| 1463 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
| 1464 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
| 1465 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
| 1461 | + "<th width='240'><b>", get_lang('Member'), "</b></th>", |
|
| 1462 | + "<th><b>", get_lang('Task'), "</b></th>", |
|
| 1463 | + "<th><b>", get_lang('Description'), "</b></th>", |
|
| 1464 | + "<th><b>", get_lang('TargetDate'), "</b></th>", |
|
| 1465 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>", |
|
| 1466 | 1466 | "</tr>"; |
| 1467 | 1467 | |
| 1468 | 1468 | $course_id = api_get_course_int_id(); |
@@ -1474,17 +1474,17 @@ discard block |
||
| 1474 | 1474 | WHERE |
| 1475 | 1475 | task_rel_user.c_id = $course_id AND |
| 1476 | 1476 | task.c_id = $course_id AND |
| 1477 | - task_rel_user.blog_id = '".(int)$blog_id."' |
|
| 1477 | + task_rel_user.blog_id = '".(int) $blog_id."' |
|
| 1478 | 1478 | ORDER BY target_date ASC"; |
| 1479 | 1479 | $result = Database::query($sql); |
| 1480 | 1480 | |
| 1481 | 1481 | while ($assignment = Database::fetch_array($result)) { |
| 1482 | 1482 | $counter++; |
| 1483 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1483 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1484 | 1484 | $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
| 1485 | 1485 | $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
| 1486 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1487 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1486 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id']; |
|
| 1487 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1488 | 1488 | |
| 1489 | 1489 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
| 1490 | 1490 | |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | * @author Toon Keppens |
| 1517 | 1517 | * |
| 1518 | 1518 | */ |
| 1519 | - public static function display_new_task_form ($blog_id) |
|
| 1519 | + public static function display_new_task_form($blog_id) |
|
| 1520 | 1520 | { |
| 1521 | 1521 | // Init |
| 1522 | 1522 | $colors = array( |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | ); |
| 1539 | 1539 | |
| 1540 | 1540 | // form |
| 1541 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1541 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">'; |
|
| 1542 | 1542 | |
| 1543 | 1543 | // form title |
| 1544 | 1544 | echo '<legend>'.get_lang('AddTask').'</legend>'; |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | // task title |
| 1547 | 1547 | echo ' <div class="control-group"> |
| 1548 | 1548 | <label class="control-label"> |
| 1549 | - <span class="form_required">*</span>' . get_lang('Title') . ' |
|
| 1549 | + <span class="form_required">*</span>' . get_lang('Title').' |
|
| 1550 | 1550 | </label> |
| 1551 | 1551 | <div class="controls"> |
| 1552 | 1552 | <input name="task_name" type="text" size="70" /> |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | // task comment |
| 1557 | 1557 | echo ' <div class="control-group"> |
| 1558 | 1558 | <label class="control-label"> |
| 1559 | - ' . get_lang('Description') . ' |
|
| 1559 | + ' . get_lang('Description').' |
|
| 1560 | 1560 | </label> |
| 1561 | 1561 | <div class="controls"> |
| 1562 | 1562 | <textarea name="task_description" cols="45"></textarea> |
@@ -1566,18 +1566,18 @@ discard block |
||
| 1566 | 1566 | // task management |
| 1567 | 1567 | echo ' <div class="control-group"> |
| 1568 | 1568 | <label class="control-label"> |
| 1569 | - ' . get_lang('TaskManager') . ' |
|
| 1569 | + ' . get_lang('TaskManager').' |
|
| 1570 | 1570 | </label> |
| 1571 | 1571 | <div class="controls">'; |
| 1572 | 1572 | echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
| 1573 | 1573 | echo '<tr>'; |
| 1574 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1575 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1574 | + echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>'; |
|
| 1575 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
| 1576 | 1576 | echo '</tr>'; |
| 1577 | 1577 | echo '<tr>'; |
| 1578 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1579 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1580 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1578 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1579 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>'; |
|
| 1580 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1581 | 1581 | echo '</tr>'; |
| 1582 | 1582 | echo '<tr>'; |
| 1583 | 1583 | echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
@@ -1592,13 +1592,13 @@ discard block |
||
| 1592 | 1592 | // task color |
| 1593 | 1593 | echo ' <div class="control-group"> |
| 1594 | 1594 | <label class="control-label"> |
| 1595 | - ' . get_lang('Color') . ' |
|
| 1595 | + ' . get_lang('Color').' |
|
| 1596 | 1596 | </label> |
| 1597 | 1597 | <div class="controls">'; |
| 1598 | 1598 | 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">'; |
| 1599 | 1599 | foreach ($colors as $color) { |
| 1600 | - $style = 'style="background-color: #' . $color . '"'; |
|
| 1601 | - echo '<option value="' . $color . '" ' . $style . '> </option>'; |
|
| 1600 | + $style = 'style="background-color: #'.$color.'"'; |
|
| 1601 | + echo '<option value="'.$color.'" '.$style.'> </option>'; |
|
| 1602 | 1602 | } |
| 1603 | 1603 | echo '</select>'; |
| 1604 | 1604 | echo ' </div> |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | <div class="controls"> |
| 1610 | 1610 | <input type="hidden" name="action" value="" /> |
| 1611 | 1611 | <input type="hidden" name="new_task_submit" value="true" /> |
| 1612 | - <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
|
| 1612 | + <button class="save" type="submit" name="Submit">' . get_lang('Save').'</button> |
|
| 1613 | 1613 | </div> |
| 1614 | 1614 | </div>'; |
| 1615 | 1615 | echo '</form>'; |
@@ -1623,34 +1623,34 @@ discard block |
||
| 1623 | 1623 | * @author Toon Keppens |
| 1624 | 1624 | * |
| 1625 | 1625 | */ |
| 1626 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1626 | + public static function display_edit_task_form($blog_id, $task_id) { |
|
| 1627 | 1627 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1628 | 1628 | $course_id = api_get_course_int_id(); |
| 1629 | 1629 | |
| 1630 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1630 | + $colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000'); |
|
| 1631 | 1631 | |
| 1632 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1632 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 1633 | 1633 | $result = Database::query($sql); |
| 1634 | 1634 | $task = Database::fetch_array($result); |
| 1635 | 1635 | |
| 1636 | 1636 | // Display |
| 1637 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1638 | - <legend>' . get_lang('EditTask') . '</legend> |
|
| 1637 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'"> |
|
| 1638 | + <legend>' . get_lang('EditTask').'</legend> |
|
| 1639 | 1639 | <table width="100%" border="0" cellspacing="2"> |
| 1640 | 1640 | <tr> |
| 1641 | - <td align="right">' . get_lang('Title') . ': </td> |
|
| 1642 | - <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']) . '" /></td> |
|
| 1641 | + <td align="right">' . get_lang('Title').': </td> |
|
| 1642 | + <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']).'" /></td> |
|
| 1643 | 1643 | </tr> |
| 1644 | 1644 | <tr> |
| 1645 | - <td align="right">' . get_lang('Description') . ': </td> |
|
| 1645 | + <td align="right">' . get_lang('Description').': </td> |
|
| 1646 | 1646 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
| 1647 | 1647 | </tr>'; |
| 1648 | 1648 | |
| 1649 | 1649 | /* edit by Kevin Van Den Haute ([email protected]) */ |
| 1650 | 1650 | $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
| 1651 | 1651 | |
| 1652 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1653 | - WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
|
| 1652 | + $sql = " SELECT id, action FROM ".$tbl_tasks_permissions." |
|
| 1653 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 1654 | 1654 | $result = Database::query($sql); |
| 1655 | 1655 | |
| 1656 | 1656 | $arrPermissions = array(); |
@@ -1659,22 +1659,22 @@ discard block |
||
| 1659 | 1659 | $arrPermissions[] = $row['action']; |
| 1660 | 1660 | |
| 1661 | 1661 | echo '<tr>'; |
| 1662 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1662 | + echo '<td style="text-align:right; vertical-align:top;">'.get_lang('TaskManager').': </td>'; |
|
| 1663 | 1663 | echo '<td>'; |
| 1664 | 1664 | echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
| 1665 | 1665 | echo '<tr>'; |
| 1666 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1667 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1666 | + echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>'; |
|
| 1667 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
| 1668 | 1668 | echo '</tr>'; |
| 1669 | 1669 | echo '<tr>'; |
| 1670 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1671 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1672 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1670 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1671 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>'; |
|
| 1672 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1673 | 1673 | echo '</tr>'; |
| 1674 | 1674 | echo '<tr>'; |
| 1675 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1676 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1677 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1675 | + echo '<td style="text-align:center;"><input '.((in_array('article_delete', $arrPermissions)) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1676 | + echo '<td style="text-align:center;"><input '.((in_array('article_edit', $arrPermissions)) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1677 | + echo '<td style="text-align:center;"><input '.((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1678 | 1678 | echo '</tr>'; |
| 1679 | 1679 | echo '</table>'; |
| 1680 | 1680 | echo '</td>'; |
@@ -1682,13 +1682,13 @@ discard block |
||
| 1682 | 1682 | /* end of edit */ |
| 1683 | 1683 | |
| 1684 | 1684 | echo '<tr> |
| 1685 | - <td align="right">' . get_lang('Color') . ': </td> |
|
| 1685 | + <td align="right">' . get_lang('Color').': </td> |
|
| 1686 | 1686 | <td> |
| 1687 | - <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">'; |
|
| 1687 | + <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">'; |
|
| 1688 | 1688 | foreach ($colors as $color) { |
| 1689 | 1689 | $selected = ($color == $task['color']) ? ' selected' : ''; |
| 1690 | - $style = 'style="background-color: #' . $color . '"'; |
|
| 1691 | - echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
|
| 1690 | + $style = 'style="background-color: #'.$color.'"'; |
|
| 1691 | + echo '<option value="'.$color.'" '.$style.' '.$selected.' > </option>'; |
|
| 1692 | 1692 | } |
| 1693 | 1693 | echo ' </select> |
| 1694 | 1694 | </td> |
@@ -1697,9 +1697,9 @@ discard block |
||
| 1697 | 1697 | <td align="right"> </td> |
| 1698 | 1698 | <td><br /><input type="hidden" name="action" value="" /> |
| 1699 | 1699 | <input type="hidden" name="edit_task_submit" value="true" /> |
| 1700 | - <input type="hidden" name="task_id" value="' . $task['task_id'] . '" /> |
|
| 1701 | - <input type="hidden" name="blog_id" value="' . $task['blog_id'] . '" /> |
|
| 1702 | - <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button></td> |
|
| 1700 | + <input type="hidden" name="task_id" value="' . $task['task_id'].'" /> |
|
| 1701 | + <input type="hidden" name="blog_id" value="' . $task['blog_id'].'" /> |
|
| 1702 | + <button class="save" type="submit" name="Submit">' . get_lang('Save').'</button></td> |
|
| 1703 | 1703 | </tr> |
| 1704 | 1704 | </table> |
| 1705 | 1705 | </form>'; |
@@ -1721,7 +1721,7 @@ discard block |
||
| 1721 | 1721 | FROM $tbl_users user |
| 1722 | 1722 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 1723 | 1723 | ON user.user_id = blogs_rel_user.user_id |
| 1724 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
| 1724 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
| 1725 | 1725 | $result = Database::query($sql); |
| 1726 | 1726 | |
| 1727 | 1727 | $options = array(); |
@@ -1740,7 +1740,7 @@ discard block |
||
| 1740 | 1740 | color, |
| 1741 | 1741 | system_task |
| 1742 | 1742 | FROM $tbl_blogs_tasks |
| 1743 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
| 1743 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
| 1744 | 1744 | ORDER BY system_task, title"; |
| 1745 | 1745 | $result = Database::query($sql); |
| 1746 | 1746 | |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | */ |
| 1789 | 1789 | public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
| 1790 | 1790 | { |
| 1791 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1791 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1792 | 1792 | |
| 1793 | 1793 | $course_id = api_get_course_int_id(); |
| 1794 | 1794 | |
@@ -1797,9 +1797,9 @@ discard block |
||
| 1797 | 1797 | SELECT target_date |
| 1798 | 1798 | FROM $tbl_blogs_tasks_rel_user |
| 1799 | 1799 | WHERE c_id = $course_id AND |
| 1800 | - blog_id = '".(int)$blog_id."' AND |
|
| 1801 | - user_id = '".(int)$user_id."' AND |
|
| 1802 | - task_id = '".(int)$task_id."'"; |
|
| 1800 | + blog_id = '".(int) $blog_id."' AND |
|
| 1801 | + user_id = '".(int) $user_id."' AND |
|
| 1802 | + task_id = '".(int) $task_id."'"; |
|
| 1803 | 1803 | $result = Database::query($sql); |
| 1804 | 1804 | $row = Database::fetch_assoc($result); |
| 1805 | 1805 | |
@@ -1834,11 +1834,11 @@ discard block |
||
| 1834 | 1834 | |
| 1835 | 1835 | $sql = " |
| 1836 | 1836 | SELECT COUNT(*) as 'number' |
| 1837 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
| 1837 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
| 1838 | 1838 | WHERE c_id = $course_id AND |
| 1839 | - blog_id = " . (int)$blog_id . " |
|
| 1840 | - AND user_id = " . (int)$user_id . " |
|
| 1841 | - AND task_id = " . (int)$task_id . " |
|
| 1839 | + blog_id = ".(int) $blog_id." |
|
| 1840 | + AND user_id = " . (int) $user_id." |
|
| 1841 | + AND task_id = " . (int) $task_id." |
|
| 1842 | 1842 | "; |
| 1843 | 1843 | |
| 1844 | 1844 | $result = Database::query($sql); |
@@ -1846,18 +1846,18 @@ discard block |
||
| 1846 | 1846 | |
| 1847 | 1847 | if ($row['number'] == 0) { |
| 1848 | 1848 | $sql = " |
| 1849 | - INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
|
| 1849 | + INSERT INTO " . $tbl_blogs_tasks_rel_user." ( |
|
| 1850 | 1850 | c_id, |
| 1851 | 1851 | blog_id, |
| 1852 | 1852 | user_id, |
| 1853 | 1853 | task_id, |
| 1854 | 1854 | target_date |
| 1855 | 1855 | ) VALUES ( |
| 1856 | - '" . (int)$course_id . "', |
|
| 1857 | - '" . (int)$blog_id . "', |
|
| 1858 | - '" . (int)$user_id . "', |
|
| 1859 | - '" . (int)$task_id . "', |
|
| 1860 | - '" . Database::escape_string($target_date) . "' |
|
| 1856 | + '" . (int) $course_id."', |
|
| 1857 | + '" . (int) $blog_id."', |
|
| 1858 | + '" . (int) $user_id."', |
|
| 1859 | + '" . (int) $task_id."', |
|
| 1860 | + '" . Database::escape_string($target_date)."' |
|
| 1861 | 1861 | )"; |
| 1862 | 1862 | |
| 1863 | 1863 | Database::query($sql); |
@@ -1887,12 +1887,12 @@ discard block |
||
| 1887 | 1887 | $course_id = api_get_course_int_id(); |
| 1888 | 1888 | |
| 1889 | 1889 | $sql = "SELECT COUNT(*) as 'number' |
| 1890 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
| 1890 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
| 1891 | 1891 | WHERE |
| 1892 | 1892 | c_id = $course_id AND |
| 1893 | - blog_id = " . (int)$blog_id . " AND |
|
| 1894 | - user_id = " . (int)$user_id . " AND |
|
| 1895 | - task_id = " . (int)$task_id . " |
|
| 1893 | + blog_id = ".(int) $blog_id." AND |
|
| 1894 | + user_id = " . (int) $user_id." AND |
|
| 1895 | + task_id = " . (int) $task_id." |
|
| 1896 | 1896 | "; |
| 1897 | 1897 | |
| 1898 | 1898 | $result = Database::query($sql); |
@@ -1900,17 +1900,17 @@ discard block |
||
| 1900 | 1900 | |
| 1901 | 1901 | if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
| 1902 | 1902 | $sql = " |
| 1903 | - UPDATE " . $tbl_blogs_tasks_rel_user . " |
|
| 1903 | + UPDATE " . $tbl_blogs_tasks_rel_user." |
|
| 1904 | 1904 | SET |
| 1905 | - user_id = " . (int)$user_id . ", |
|
| 1906 | - task_id = " . (int)$task_id . ", |
|
| 1907 | - target_date = '" . Database::escape_string($target_date) . "' |
|
| 1905 | + user_id = " . (int) $user_id.", |
|
| 1906 | + task_id = " . (int) $task_id.", |
|
| 1907 | + target_date = '" . Database::escape_string($target_date)."' |
|
| 1908 | 1908 | WHERE |
| 1909 | 1909 | c_id = $course_id AND |
| 1910 | - blog_id = " . (int)$blog_id . " AND |
|
| 1911 | - user_id = " . (int)$old_user_id . " AND |
|
| 1912 | - task_id = " . (int)$old_task_id . " AND |
|
| 1913 | - target_date = '" . Database::escape_string($old_target_date) . "' |
|
| 1910 | + blog_id = ".(int) $blog_id." AND |
|
| 1911 | + user_id = " . (int) $old_user_id." AND |
|
| 1912 | + task_id = " . (int) $old_task_id." AND |
|
| 1913 | + target_date = '" . Database::escape_string($old_target_date)."' |
|
| 1914 | 1914 | "; |
| 1915 | 1915 | Database::query($sql); |
| 1916 | 1916 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | |
| 1932 | 1932 | |
| 1933 | 1933 | $sql = "SELECT title, description FROM $tbl_blogs_tasks |
| 1934 | - WHERE task_id = '".(int)$task_id."' |
|
| 1934 | + WHERE task_id = '".(int) $task_id."' |
|
| 1935 | 1935 | AND c_id = $course_id"; |
| 1936 | 1936 | $result = Database::query($sql); |
| 1937 | 1937 | $row = Database::fetch_assoc($result); |
@@ -1939,19 +1939,19 @@ discard block |
||
| 1939 | 1939 | $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
| 1940 | 1940 | FROM $tbl_blogs_posts post |
| 1941 | 1941 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1942 | - WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
|
| 1942 | + WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id |
|
| 1943 | 1943 | ORDER BY post_id DESC |
| 1944 | 1944 | LIMIT 0, 100"; |
| 1945 | 1945 | $result = Database::query($sql); |
| 1946 | 1946 | |
| 1947 | 1947 | // Display |
| 1948 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1949 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1948 | + echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>'; |
|
| 1949 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>'; |
|
| 1950 | 1950 | |
| 1951 | 1951 | if (Database::num_rows($result) > 0) { |
| 1952 | - while($blog_post = Database::fetch_array($result)) { |
|
| 1952 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 1953 | 1953 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1954 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1954 | + echo '<a href="blog.php?action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.stripslashes($blog_post['title']).'</a>, '.get_lang('WrittenBy').' '.stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))).'<br />'; |
|
| 1955 | 1955 | } |
| 1956 | 1956 | } else { |
| 1957 | 1957 | echo get_lang('NoArticles'); |
@@ -1975,12 +1975,12 @@ discard block |
||
| 1975 | 1975 | |
| 1976 | 1976 | // Subscribe the user |
| 1977 | 1977 | $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
| 1978 | - VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
|
| 1978 | + VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');"; |
|
| 1979 | 1979 | Database::query($sql); |
| 1980 | 1980 | |
| 1981 | 1981 | // Give this user basic rights |
| 1982 | 1982 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
| 1983 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
|
| 1983 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')"; |
|
| 1984 | 1984 | Database::query($sql); |
| 1985 | 1985 | |
| 1986 | 1986 | $id = Database::insert_id(); |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | 1992 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
| 1993 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
|
| 1993 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')"; |
|
| 1994 | 1994 | Database::query($sql); |
| 1995 | 1995 | |
| 1996 | 1996 | $id = Database::insert_id(); |
@@ -2016,12 +2016,12 @@ discard block |
||
| 2016 | 2016 | |
| 2017 | 2017 | // Unsubscribe the user |
| 2018 | 2018 | $sql = "DELETE FROM $tbl_blogs_rel_user |
| 2019 | - WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
|
| 2019 | + WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'"; |
|
| 2020 | 2020 | Database::query($sql); |
| 2021 | 2021 | |
| 2022 | 2022 | // Remove this user's permissions. |
| 2023 | 2023 | $sql = "DELETE FROM $tbl_user_permissions |
| 2024 | - WHERE user_id = '".(int)$user_id."'"; |
|
| 2024 | + WHERE user_id = '".(int) $user_id."'"; |
|
| 2025 | 2025 | Database::query($sql); |
| 2026 | 2026 | } |
| 2027 | 2027 | |
@@ -2042,7 +2042,7 @@ discard block |
||
| 2042 | 2042 | $course_id = $_course['real_id']; |
| 2043 | 2043 | |
| 2044 | 2044 | $currentCourse = $_course['code']; |
| 2045 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2045 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2046 | 2046 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
| 2047 | 2047 | |
| 2048 | 2048 | echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
@@ -2057,12 +2057,12 @@ discard block |
||
| 2057 | 2057 | $result = Database::query($sql); |
| 2058 | 2058 | |
| 2059 | 2059 | $blog_member_ids = array(); |
| 2060 | - while($user = Database::fetch_array($result)) { |
|
| 2060 | + while ($user = Database::fetch_array($result)) { |
|
| 2061 | 2061 | $blog_member_ids[] = $user['user_id']; |
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | 2064 | // Set table headers |
| 2065 | - $column_header[] = array ('', false, ''); |
|
| 2065 | + $column_header[] = array('', false, ''); |
|
| 2066 | 2066 | if ($is_western_name_order) { |
| 2067 | 2067 | $column_header[] = array(get_lang('FirstName'), true, ''); |
| 2068 | 2068 | $column_header[] = array(get_lang('LastName'), true, ''); |
@@ -2082,13 +2082,13 @@ discard block |
||
| 2082 | 2082 | |
| 2083 | 2083 | // Add users that are not in this blog to the list. |
| 2084 | 2084 | foreach ($student_list as $key=>$user) { |
| 2085 | - if(isset($user['id_user'])) { |
|
| 2085 | + if (isset($user['id_user'])) { |
|
| 2086 | 2086 | $user['user_id'] = $user['id_user']; |
| 2087 | 2087 | } |
| 2088 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2088 | + if (!in_array($user['user_id'], $blog_member_ids)) { |
|
| 2089 | 2089 | $a_infosUser = api_get_user_info($user['user_id']); |
| 2090 | - $row = array (); |
|
| 2091 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2090 | + $row = array(); |
|
| 2091 | + $row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>'; |
|
| 2092 | 2092 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
| 2093 | 2093 | if ($is_western_name_order) { |
| 2094 | 2094 | $row[] = $a_infosUser["firstname"]; |
@@ -2100,8 +2100,8 @@ discard block |
||
| 2100 | 2100 | $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
| 2101 | 2101 | |
| 2102 | 2102 | //Link to register users |
| 2103 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2104 | - $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>"; |
|
| 2103 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) { |
|
| 2104 | + $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>"; |
|
| 2105 | 2105 | } else { |
| 2106 | 2106 | $row[] = ''; |
| 2107 | 2107 | } |
@@ -2112,20 +2112,20 @@ discard block |
||
| 2112 | 2112 | // Display |
| 2113 | 2113 | $query_vars['action'] = 'manage_members'; |
| 2114 | 2114 | $query_vars['blog_id'] = $blog_id; |
| 2115 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2116 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2115 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">'; |
|
| 2116 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
| 2117 | 2117 | $link = ''; |
| 2118 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2118 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
| 2119 | 2119 | $link .= "blog_id=$blog_id&"; |
| 2120 | 2120 | |
| 2121 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2122 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2123 | - echo get_lang('WithSelected') . ' : '; |
|
| 2121 | + echo '<a href="blog.php?'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - '; |
|
| 2122 | + echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> '; |
|
| 2123 | + echo get_lang('WithSelected').' : '; |
|
| 2124 | 2124 | echo '<select name="action">'; |
| 2125 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2125 | + echo '<option value="select_subscribe">'.get_lang('Register').'</option>'; |
|
| 2126 | 2126 | echo '</select>'; |
| 2127 | 2127 | echo '<input type="hidden" name="register" value="true" />'; |
| 2128 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2128 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
| 2129 | 2129 | echo '</form>'; |
| 2130 | 2130 | } |
| 2131 | 2131 | |
@@ -2138,7 +2138,7 @@ discard block |
||
| 2138 | 2138 | * |
| 2139 | 2139 | * @return Html Form with sortable table with users to unsubcribe from a blog. |
| 2140 | 2140 | */ |
| 2141 | - public static function display_form_user_unsubscribe ($blog_id) |
|
| 2141 | + public static function display_form_user_unsubscribe($blog_id) |
|
| 2142 | 2142 | { |
| 2143 | 2143 | $_user = api_get_user_info(); |
| 2144 | 2144 | $is_western_name_order = api_is_western_name_order(); |
@@ -2151,34 +2151,34 @@ discard block |
||
| 2151 | 2151 | |
| 2152 | 2152 | $properties["width"] = "100%"; |
| 2153 | 2153 | //table column titles |
| 2154 | - $column_header[] = array ('', false, ''); |
|
| 2154 | + $column_header[] = array('', false, ''); |
|
| 2155 | 2155 | if ($is_western_name_order) { |
| 2156 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2157 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2156 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2157 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2158 | 2158 | } else { |
| 2159 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2160 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2159 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2160 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2161 | 2161 | } |
| 2162 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2163 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2164 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2162 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2163 | + $column_header[] = array(get_lang('TaskManager'), true, ''); |
|
| 2164 | + $column_header[] = array(get_lang('UnRegister'), false, ''); |
|
| 2165 | 2165 | |
| 2166 | 2166 | $course_id = api_get_course_int_id(); |
| 2167 | 2167 | |
| 2168 | 2168 | $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
| 2169 | 2169 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2170 | 2170 | ON user.user_id = blogs_rel_user.user_id |
| 2171 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
| 2171 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
| 2172 | 2172 | |
| 2173 | 2173 | if (!($sql_result = Database::query($sql))) { |
| 2174 | 2174 | return false; |
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | - $user_data = array (); |
|
| 2177 | + $user_data = array(); |
|
| 2178 | 2178 | |
| 2179 | 2179 | while ($myrow = Database::fetch_array($sql_result)) { |
| 2180 | - $row = array (); |
|
| 2181 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2180 | + $row = array(); |
|
| 2181 | + $row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>'; |
|
| 2182 | 2182 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
| 2183 | 2183 | if ($is_western_name_order) { |
| 2184 | 2184 | $row[] = $myrow["firstname"]; |
@@ -2190,19 +2190,19 @@ discard block |
||
| 2190 | 2190 | $row[] = Display::icon_mailto_link($myrow["email"]); |
| 2191 | 2191 | |
| 2192 | 2192 | $sql = "SELECT bt.title task |
| 2193 | - FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
|
| 2194 | - INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
|
| 2193 | + FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu |
|
| 2194 | + INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt |
|
| 2195 | 2195 | ON btu.task_id = bt.task_id |
| 2196 | 2196 | WHERE btu.c_id = $course_id AND |
| 2197 | 2197 | bt.c_id = $course_id AND |
| 2198 | 2198 | btu.blog_id = $blog_id AND |
| 2199 | - btu.user_id = " . $myrow['user_id']; |
|
| 2199 | + btu.user_id = ".$myrow['user_id']; |
|
| 2200 | 2200 | $sql_res = Database::query($sql); |
| 2201 | 2201 | |
| 2202 | 2202 | $task = ''; |
| 2203 | 2203 | |
| 2204 | - while($r = Database::fetch_array($sql_res)) { |
|
| 2205 | - $task .= stripslashes($r['task']) . ', '; |
|
| 2204 | + while ($r = Database::fetch_array($sql_res)) { |
|
| 2205 | + $task .= stripslashes($r['task']).', '; |
|
| 2206 | 2206 | } |
| 2207 | 2207 | //echo $task; |
| 2208 | 2208 | $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
@@ -2210,7 +2210,7 @@ discard block |
||
| 2210 | 2210 | //Link to register users |
| 2211 | 2211 | |
| 2212 | 2212 | if ($myrow["user_id"] != $_user['user_id']) { |
| 2213 | - $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>"; |
|
| 2213 | + $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>"; |
|
| 2214 | 2214 | } else { |
| 2215 | 2215 | $row[] = ''; |
| 2216 | 2216 | } |
@@ -2220,20 +2220,20 @@ discard block |
||
| 2220 | 2220 | |
| 2221 | 2221 | $query_vars['action'] = 'manage_members'; |
| 2222 | 2222 | $query_vars['blog_id'] = $blog_id; |
| 2223 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2224 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2223 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">'; |
|
| 2224 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
| 2225 | 2225 | $link = ''; |
| 2226 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2226 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
| 2227 | 2227 | $link .= "blog_id=$blog_id&"; |
| 2228 | 2228 | |
| 2229 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2230 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2231 | - echo get_lang('WithSelected') . ' : '; |
|
| 2229 | + echo '<a href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - '; |
|
| 2230 | + echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> '; |
|
| 2231 | + echo get_lang('WithSelected').' : '; |
|
| 2232 | 2232 | echo '<select name="action">'; |
| 2233 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2233 | + echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>'; |
|
| 2234 | 2234 | echo '</select>'; |
| 2235 | 2235 | echo '<input type="hidden" name="unregister" value="true" />'; |
| 2236 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2236 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
| 2237 | 2237 | echo '</form>'; |
| 2238 | 2238 | } |
| 2239 | 2239 | |
@@ -2243,7 +2243,7 @@ discard block |
||
| 2243 | 2243 | * |
| 2244 | 2244 | * @param Integer $blog_id |
| 2245 | 2245 | */ |
| 2246 | - public static function display_form_user_rights ($blog_id) |
|
| 2246 | + public static function display_form_user_rights($blog_id) |
|
| 2247 | 2247 | { |
| 2248 | 2248 | echo '<legend>'.get_lang('RightsManager').'</legend>'; |
| 2249 | 2249 | echo '<br />'; |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | $form = new FormValidator( |
| 2264 | 2264 | 'add_post', |
| 2265 | 2265 | 'post', |
| 2266 | - 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(), |
|
| 2266 | + 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(), |
|
| 2267 | 2267 | null, |
| 2268 | 2268 | array('enctype' => 'multipart/form-data') |
| 2269 | 2269 | ); |
@@ -2331,21 +2331,21 @@ discard block |
||
| 2331 | 2331 | $course_id = api_get_course_int_id(); |
| 2332 | 2332 | |
| 2333 | 2333 | //Handle leap year |
| 2334 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2334 | + $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2335 | 2335 | |
| 2336 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2336 | + if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2337 | 2337 | $numberofdays[2] = 29; |
| 2338 | 2338 | |
| 2339 | 2339 | //Get the first day of the month |
| 2340 | 2340 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
| 2341 | - $monthName = $MonthsLong[$month-1]; |
|
| 2341 | + $monthName = $MonthsLong[$month - 1]; |
|
| 2342 | 2342 | |
| 2343 | 2343 | //Start the week on monday |
| 2344 | 2344 | $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
| 2345 | 2345 | $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
| 2346 | 2346 | $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
| 2347 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2348 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2347 | + $backwardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year); |
|
| 2348 | + $forewardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year); |
|
| 2349 | 2349 | |
| 2350 | 2350 | // Get posts for this month |
| 2351 | 2351 | $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
@@ -2354,15 +2354,15 @@ discard block |
||
| 2354 | 2354 | ON post.author_id = user.user_id |
| 2355 | 2355 | WHERE |
| 2356 | 2356 | post.c_id = $course_id AND |
| 2357 | - post.blog_id = '".(int)$blog_id."' AND |
|
| 2358 | - MONTH(date_creation) = '".(int)$month."' AND |
|
| 2359 | - YEAR(date_creation) = '".(int)$year."' |
|
| 2357 | + post.blog_id = '".(int) $blog_id."' AND |
|
| 2358 | + MONTH(date_creation) = '".(int) $month."' AND |
|
| 2359 | + YEAR(date_creation) = '".(int) $year."' |
|
| 2360 | 2360 | ORDER BY date_creation"; |
| 2361 | 2361 | $result = Database::query($sql); |
| 2362 | 2362 | |
| 2363 | 2363 | // We will create an array of days on which there are posts. |
| 2364 | - if( Database::num_rows($result) > 0) { |
|
| 2365 | - while($blog_post = Database::fetch_array($result)) { |
|
| 2364 | + if (Database::num_rows($result) > 0) { |
|
| 2365 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 2366 | 2366 | // If the day of this post is not yet in the array, add it. |
| 2367 | 2367 | if (!in_array($blog_post['post_day'], $posts)) |
| 2368 | 2368 | $posts[] = $blog_post['post_day']; |
@@ -2379,9 +2379,9 @@ discard block |
||
| 2379 | 2379 | task_rel_user.c_id = $course_id AND |
| 2380 | 2380 | task.c_id = $course_id AND |
| 2381 | 2381 | blog.c_id = $course_id AND |
| 2382 | - task_rel_user.user_id = '".(int)$_user['user_id']."' AND |
|
| 2383 | - MONTH(target_date) = '".(int)$month."' AND |
|
| 2384 | - YEAR(target_date) = '".(int)$year."' |
|
| 2382 | + task_rel_user.user_id = '".(int) $_user['user_id']."' AND |
|
| 2383 | + MONTH(target_date) = '".(int) $month."' AND |
|
| 2384 | + YEAR(target_date) = '".(int) $year."' |
|
| 2385 | 2385 | ORDER BY target_date ASC"; |
| 2386 | 2386 | $result = Database::query($sql); |
| 2387 | 2387 | |
@@ -2404,7 +2404,7 @@ discard block |
||
| 2404 | 2404 | |
| 2405 | 2405 | echo "<tr>"; |
| 2406 | 2406 | |
| 2407 | - for($ii = 1; $ii < 8; $ii ++) |
|
| 2407 | + for ($ii = 1; $ii < 8; $ii++) |
|
| 2408 | 2408 | echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
| 2409 | 2409 | |
| 2410 | 2410 | echo "</tr>"; |
@@ -2414,24 +2414,24 @@ discard block |
||
| 2414 | 2414 | |
| 2415 | 2415 | while ($curday <= $numberofdays[$month]) { |
| 2416 | 2416 | echo "<tr>"; |
| 2417 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2417 | + for ($ii = 0; $ii < 7; $ii++) { |
|
| 2418 | 2418 | if (($curday == -1) && ($ii == $startdayofweek)) |
| 2419 | 2419 | $curday = 1; |
| 2420 | 2420 | |
| 2421 | 2421 | if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
| 2422 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2422 | + $bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\""; |
|
| 2423 | 2423 | $dayheader = "$curday"; |
| 2424 | 2424 | |
| 2425 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2425 | + if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2426 | 2426 | $dayheader = "$curday"; |
| 2427 | 2427 | $class = "class=\"days_today\""; |
| 2428 | 2428 | } |
| 2429 | 2429 | |
| 2430 | - echo "<td " . $class.">"; |
|
| 2430 | + echo "<td ".$class.">"; |
|
| 2431 | 2431 | |
| 2432 | 2432 | // If there are posts on this day, create a filter link. |
| 2433 | - if(in_array($curday, $posts)) |
|
| 2434 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2433 | + if (in_array($curday, $posts)) |
|
| 2434 | + echo '<a href="blog.php?blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang('ViewPostsOfThisDay').'">'.$curday.'</a>'; |
|
| 2435 | 2435 | else |
| 2436 | 2436 | echo $dayheader; |
| 2437 | 2437 | |
@@ -2439,7 +2439,7 @@ discard block |
||
| 2439 | 2439 | if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
| 2440 | 2440 | // Add tasks to calendar |
| 2441 | 2441 | foreach ($tasks[$curday] as $task) { |
| 2442 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
| 2442 | + echo '<a href="blog.php?action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes($task['task_id']).'" title="'.$task['title'].' : '.get_lang('InBlog').' : '.$task['blog_name'].' - '.get_lang('ExecuteThisTask').'">'; |
|
| 2443 | 2443 | echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
| 2444 | 2444 | echo '</a>'; |
| 2445 | 2445 | } |
@@ -2447,7 +2447,7 @@ discard block |
||
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | echo "</td>"; |
| 2450 | - $curday ++; |
|
| 2450 | + $curday++; |
|
| 2451 | 2451 | } else |
| 2452 | 2452 | echo "<td> </td>"; |
| 2453 | 2453 | } |
@@ -2485,7 +2485,7 @@ discard block |
||
| 2485 | 2485 | public static function display_edit_blog_form($blog_id) |
| 2486 | 2486 | { |
| 2487 | 2487 | $course_id = api_get_course_int_id(); |
| 2488 | - $blog_id= intval($blog_id); |
|
| 2488 | + $blog_id = intval($blog_id); |
|
| 2489 | 2489 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 2490 | 2490 | |
| 2491 | 2491 | $sql = "SELECT blog_id, blog_name, blog_subtitle |
@@ -2500,7 +2500,7 @@ discard block |
||
| 2500 | 2500 | $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | - $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
|
| 2503 | + $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
|
| 2504 | 2504 | $form->addElement('header', get_lang('EditBlog')); |
| 2505 | 2505 | $form->addElement('text', 'blog_name', get_lang('Title')); |
| 2506 | 2506 | $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle')); |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | $result = Database::query($sql); |
| 2537 | 2537 | $list_info = array(); |
| 2538 | 2538 | if (Database::num_rows($result)) { |
| 2539 | - while ($row_project=Database::fetch_row($result)) { |
|
| 2540 | - $list_info[]=$row_project; |
|
| 2539 | + while ($row_project = Database::fetch_row($result)) { |
|
| 2540 | + $list_info[] = $row_project; |
|
| 2541 | 2541 | } |
| 2542 | 2542 | } |
| 2543 | 2543 | |
@@ -2549,35 +2549,35 @@ discard block |
||
| 2549 | 2549 | // Validation when belongs to a session |
| 2550 | 2550 | $session_img = api_get_session_image($info_log[4], $_user['status']); |
| 2551 | 2551 | |
| 2552 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2552 | + $url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq(); |
|
| 2553 | 2553 | $title = $info_log[0]; |
| 2554 | 2554 | $image = Display::return_icon('blog.png', $title); |
| 2555 | - $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; |
|
| 2555 | + $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; |
|
| 2556 | 2556 | |
| 2557 | 2557 | $list_body_blog[] = $list_name; |
| 2558 | 2558 | $list_body_blog[] = $info_log[1]; |
| 2559 | 2559 | |
| 2560 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2561 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2562 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2563 | - $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
|
| 2560 | + $visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible'; |
|
| 2561 | + $visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible'; |
|
| 2562 | + $my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">'; |
|
| 2563 | + $my_image .= Display::return_icon('edit.png', get_lang('EditBlog')); |
|
| 2564 | 2564 | |
| 2565 | - $my_image.= "</a>"; |
|
| 2566 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2567 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2568 | - $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
|
| 2565 | + $my_image .= "</a>"; |
|
| 2566 | + $my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" '; |
|
| 2567 | + $my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >'; |
|
| 2568 | + $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
|
| 2569 | 2569 | |
| 2570 | - $my_image.= "</a>"; |
|
| 2571 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2572 | - $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
|
| 2570 | + $my_image .= "</a>"; |
|
| 2571 | + $my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">'; |
|
| 2572 | + $my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info)); |
|
| 2573 | 2573 | |
| 2574 | - $my_image.= "</a>"; |
|
| 2575 | - $list_body_blog[]=$my_image; |
|
| 2576 | - $list_content_blog[]=$list_body_blog; |
|
| 2574 | + $my_image .= "</a>"; |
|
| 2575 | + $list_body_blog[] = $my_image; |
|
| 2576 | + $list_content_blog[] = $list_body_blog; |
|
| 2577 | 2577 | $list_body_blog = array(); |
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2580 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project'); |
|
| 2581 | 2581 | $table->set_header(0, get_lang('Title')); |
| 2582 | 2582 | $table->set_header(1, get_lang('SubTitle')); |
| 2583 | 2583 | $table->set_header(2, get_lang('Modify')); |
@@ -2601,34 +2601,34 @@ discard block |
||
| 2601 | 2601 | * @author Julio Montoya Dokeos |
| 2602 | 2602 | * @version avril 2008, dokeos 1.8.5 |
| 2603 | 2603 | */ |
| 2604 | -function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
|
| 2604 | +function get_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
| 2605 | 2605 | { |
| 2606 | 2606 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 2607 | 2607 | |
| 2608 | 2608 | $blog_id = intval($blog_id); |
| 2609 | 2609 | $comment_id = intval($comment_id); |
| 2610 | 2610 | $post_id = intval($post_id); |
| 2611 | - $row=array(); |
|
| 2612 | - $where=''; |
|
| 2611 | + $row = array(); |
|
| 2612 | + $where = ''; |
|
| 2613 | 2613 | if (!empty ($post_id) && is_numeric($post_id)) { |
| 2614 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2614 | + $where .= ' AND post_id ="'.$post_id.'" '; |
|
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | if (!empty ($comment_id) && is_numeric($comment_id)) { |
| 2618 | 2618 | if (!empty ($post_id)) { |
| 2619 | - $where.= ' AND '; |
|
| 2619 | + $where .= ' AND '; |
|
| 2620 | 2620 | } |
| 2621 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2621 | + $where .= ' comment_id ="'.$comment_id.'" '; |
|
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | 2624 | $course_id = api_get_course_int_id(); |
| 2625 | 2625 | |
| 2626 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2626 | + $sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.' |
|
| 2627 | 2627 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2628 | 2628 | |
| 2629 | - $result=Database::query($sql); |
|
| 2630 | - if (Database::num_rows($result)!=0) { |
|
| 2631 | - $row=Database::fetch_array($result); |
|
| 2629 | + $result = Database::query($sql); |
|
| 2630 | + if (Database::num_rows($result) != 0) { |
|
| 2631 | + $row = Database::fetch_array($result); |
|
| 2632 | 2632 | } |
| 2633 | 2633 | return $row; |
| 2634 | 2634 | } |
@@ -2642,7 +2642,7 @@ discard block |
||
| 2642 | 2642 | * @version avril 2008, dokeos 1.8.5 |
| 2643 | 2643 | */ |
| 2644 | 2644 | |
| 2645 | -function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
|
| 2645 | +function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
| 2646 | 2646 | { |
| 2647 | 2647 | $_course = api_get_course_info(); |
| 2648 | 2648 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
@@ -2666,22 +2666,22 @@ discard block |
||
| 2666 | 2666 | } |
| 2667 | 2667 | |
| 2668 | 2668 | // delete all files in directory |
| 2669 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 2669 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 2670 | 2670 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 2671 | 2671 | $updir = $sys_course_path.$courseDir; |
| 2672 | 2672 | |
| 2673 | 2673 | $sql = 'SELECT path FROM '.$blog_table_attachment.' |
| 2674 | 2674 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2675 | - $result=Database::query($sql); |
|
| 2675 | + $result = Database::query($sql); |
|
| 2676 | 2676 | |
| 2677 | - while ($row=Database::fetch_row($result)) { |
|
| 2678 | - $file=$updir.'/'.$row[0]; |
|
| 2679 | - if (Security::check_abs_path($file,$updir) ) |
|
| 2677 | + while ($row = Database::fetch_row($result)) { |
|
| 2678 | + $file = $updir.'/'.$row[0]; |
|
| 2679 | + if (Security::check_abs_path($file, $updir)) |
|
| 2680 | 2680 | { |
| 2681 | 2681 | @ unlink($file); |
| 2682 | 2682 | } |
| 2683 | 2683 | } |
| 2684 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2684 | + $sql = 'DELETE FROM '.$blog_table_attachment.' |
|
| 2685 | 2685 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2686 | 2686 | Database::query($sql); |
| 2687 | 2687 | } |
@@ -2694,8 +2694,8 @@ discard block |
||
| 2694 | 2694 | function get_blog_post_from_user($course_code, $user_id) |
| 2695 | 2695 | { |
| 2696 | 2696 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 2697 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2698 | - $course_info = api_get_course_info($course_code); |
|
| 2697 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2698 | + $course_info = api_get_course_info($course_code); |
|
| 2699 | 2699 | $course_id = $course_info['real_id']; |
| 2700 | 2700 | |
| 2701 | 2701 | $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
@@ -2710,13 +2710,13 @@ discard block |
||
| 2710 | 2710 | $result = Database::query($sql); |
| 2711 | 2711 | $return_data = ''; |
| 2712 | 2712 | |
| 2713 | - if (Database::num_rows($result)!=0) { |
|
| 2714 | - while ($row=Database::fetch_array($result)) { |
|
| 2715 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2716 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2717 | - $return_data.= '<br / >'; |
|
| 2718 | - $return_data.= $row['full_text']; |
|
| 2719 | - $return_data.= '<br /><br />'; |
|
| 2713 | + if (Database::num_rows($result) != 0) { |
|
| 2714 | + while ($row = Database::fetch_array($result)) { |
|
| 2715 | + $return_data .= '<div class="clear"></div><br />'; |
|
| 2716 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png', get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2717 | + $return_data .= '<br / >'; |
|
| 2718 | + $return_data .= $row['full_text']; |
|
| 2719 | + $return_data .= '<br /><br />'; |
|
| 2720 | 2720 | } |
| 2721 | 2721 | } |
| 2722 | 2722 | return $return_data; |
@@ -2746,14 +2746,14 @@ discard block |
||
| 2746 | 2746 | ORDER BY blog_name"; |
| 2747 | 2747 | $result = Database::query($sql); |
| 2748 | 2748 | $return_data = ''; |
| 2749 | - if (Database::num_rows($result)!=0) { |
|
| 2750 | - while ($row=Database::fetch_array($result)) { |
|
| 2751 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2752 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2753 | - $return_data.= '<br / >'; |
|
| 2749 | + if (Database::num_rows($result) != 0) { |
|
| 2750 | + while ($row = Database::fetch_array($result)) { |
|
| 2751 | + $return_data .= '<div class="clear"></div><br />'; |
|
| 2752 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2753 | + $return_data .= '<br / >'; |
|
| 2754 | 2754 | //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
| 2755 | - $return_data.= $row['comment']; |
|
| 2756 | - $return_data.= '<br />'; |
|
| 2755 | + $return_data .= $row['comment']; |
|
| 2756 | + $return_data .= '<br />'; |
|
| 2757 | 2757 | } |
| 2758 | 2758 | } |
| 2759 | 2759 | return $return_data; |