Completed
Push — 1.11.x ( 6904fa...6a92e6 )
by José
525:44 queued 484:20
created
src/Chamilo/CourseBundle/Component/CourseCopy/Course.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
     }
327 327
 
328 328
     /**
329
-    * Serialize the course with the best serializer available
330
-    * @return string
331
-    */
329
+     * Serialize the course with the best serializer available
330
+     * @return string
331
+     */
332 332
     public static function serialize($course)
333 333
     {
334 334
         if (extension_loaded('igbinary')) {
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
     }
340 340
 
341 341
     /**
342
-    * Unserialize the course with the best serializer available
343
-    * @param string $course
344
-    */
342
+     * Unserialize the course with the best serializer available
343
+     * @param string $course
344
+     */
345 345
     public static function unserialize($course)
346 346
     {
347 347
         if (extension_loaded('igbinary')) {
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CalendarEvent.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,19 +66,19 @@
 block discarded – undo
66 66
         $attachment_comment = null,
67 67
         $all_day = 0
68 68
     ) {
69
-		parent::__construct($id, RESOURCE_EVENT);
69
+        parent::__construct($id, RESOURCE_EVENT);
70 70
 
71
-		$this->title = $title;
72
-		$this->content = $content;
73
-		$this->start_date = $start_date;
74
-		$this->end_date = $end_date;
75
-		$this->all_day = $all_day;
71
+        $this->title = $title;
72
+        $this->content = $content;
73
+        $this->start_date = $start_date;
74
+        $this->end_date = $end_date;
75
+        $this->all_day = $all_day;
76 76
 
77
-		$this->attachment_path = $attachment_path;
78
-		$this->attachment_filename = $attachment_filename;
79
-		$this->attachment_size = $attachment_size;
80
-		$this->attachment_comment = $attachment_comment;
81
-	}
77
+        $this->attachment_path = $attachment_path;
78
+        $this->attachment_filename = $attachment_filename;
79
+        $this->attachment_size = $attachment_size;
80
+        $this->attachment_comment = $attachment_comment;
81
+    }
82 82
 
83 83
     /**
84 84
      * Show this Event
Please login to merge, or discard this patch.
Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyLearnpath.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -84,120 +84,120 @@
 block discarded – undo
84 84
      */
85 85
     public $author;
86 86
 
87
-	/**
88
-	 * Author's image
89
-	 */
90
-	public $preview_image;
87
+    /**
88
+     * Author's image
89
+     */
90
+    public $preview_image;
91 91
 
92
-	/**
93
-	 * Create a new learnpath
94
-	 * @param integer ID
95
-	 * @param integer Type (1,2,3,...)
96
-	 * @param string $name
97
-	 * @param string $path
98
-	 * @param string $ref
99
-	 * @param string $description
100
-	 * @param string $content_local
101
-	 * @param string $default_encoding
102
-	 * @param string $default_view_mode
103
-	 * @param bool   $prevent_reinit
104
-	 * @param bool   $force_commit
105
-	 * @param string $content_maker
106
-	 * @param integer $display_order
107
-	 * @param string $js_lib
108
-	 * @param string $content_license
109
-	 * @param integer $debug
110
-	 * @param string $visibility
111
-	 * @param array  $items
112
-	 */
113
-	public function __construct(
114
-		$id,
115
-		$type,
116
-		$name,
117
-		$path,
118
-		$ref,
119
-		$description,
120
-		$content_local,
121
-		$default_encoding,
122
-		$default_view_mode,
123
-		$prevent_reinit,
124
-		$force_commit,
125
-		$content_maker,
126
-		$display_order,
127
-		$js_lib,
128
-		$content_license,
129
-		$debug,
130
-		$visibility,
131
-		$author,
132
-		$preview_image,
133
-		$use_max_score,
134
-		$autolaunch,
135
-		$created_on,
136
-		$modified_on,
137
-		$publicated_on,
138
-		$expired_on,
139
-		$session_id,
140
-		$items
141
-	) {
142
-		parent::__construct($id, RESOURCE_LEARNPATH);
143
-		$this->lp_type = $type;
144
-		$this->name = $name;
145
-		$this->path = $path;
146
-		$this->ref = $ref;
147
-		$this->description = $description;
148
-		$this->content_local = $content_local;
149
-		$this->default_encoding = $default_encoding;
150
-		$this->default_view_mod = $default_view_mode;
151
-		$this->prevent_reinit = $prevent_reinit;
152
-		$this->force_commit = $force_commit;
153
-		$this->content_maker = $content_maker;
154
-		$this->display_order = $display_order;
155
-		$this->js_lib = $js_lib;
156
-		$this->content_license = $content_license;
157
-		$this->debug = $debug;
158
-		$this->visibility=$visibility;
92
+    /**
93
+     * Create a new learnpath
94
+     * @param integer ID
95
+     * @param integer Type (1,2,3,...)
96
+     * @param string $name
97
+     * @param string $path
98
+     * @param string $ref
99
+     * @param string $description
100
+     * @param string $content_local
101
+     * @param string $default_encoding
102
+     * @param string $default_view_mode
103
+     * @param bool   $prevent_reinit
104
+     * @param bool   $force_commit
105
+     * @param string $content_maker
106
+     * @param integer $display_order
107
+     * @param string $js_lib
108
+     * @param string $content_license
109
+     * @param integer $debug
110
+     * @param string $visibility
111
+     * @param array  $items
112
+     */
113
+    public function __construct(
114
+        $id,
115
+        $type,
116
+        $name,
117
+        $path,
118
+        $ref,
119
+        $description,
120
+        $content_local,
121
+        $default_encoding,
122
+        $default_view_mode,
123
+        $prevent_reinit,
124
+        $force_commit,
125
+        $content_maker,
126
+        $display_order,
127
+        $js_lib,
128
+        $content_license,
129
+        $debug,
130
+        $visibility,
131
+        $author,
132
+        $preview_image,
133
+        $use_max_score,
134
+        $autolaunch,
135
+        $created_on,
136
+        $modified_on,
137
+        $publicated_on,
138
+        $expired_on,
139
+        $session_id,
140
+        $items
141
+    ) {
142
+        parent::__construct($id, RESOURCE_LEARNPATH);
143
+        $this->lp_type = $type;
144
+        $this->name = $name;
145
+        $this->path = $path;
146
+        $this->ref = $ref;
147
+        $this->description = $description;
148
+        $this->content_local = $content_local;
149
+        $this->default_encoding = $default_encoding;
150
+        $this->default_view_mod = $default_view_mode;
151
+        $this->prevent_reinit = $prevent_reinit;
152
+        $this->force_commit = $force_commit;
153
+        $this->content_maker = $content_maker;
154
+        $this->display_order = $display_order;
155
+        $this->js_lib = $js_lib;
156
+        $this->content_license = $content_license;
157
+        $this->debug = $debug;
158
+        $this->visibility=$visibility;
159 159
 
160
-		$this->use_max_score=$use_max_score;
161
-		$this->autolaunch=$autolaunch;
162
-		$this->created_on=$created_on;
163
-		$this->modified_on=$modified_on;
164
-		$this->publicated_on=$publicated_on;
165
-		$this->expired_on=$expired_on;
166
-		$this->session_id=$session_id;
160
+        $this->use_max_score=$use_max_score;
161
+        $this->autolaunch=$autolaunch;
162
+        $this->created_on=$created_on;
163
+        $this->modified_on=$modified_on;
164
+        $this->publicated_on=$publicated_on;
165
+        $this->expired_on=$expired_on;
166
+        $this->session_id=$session_id;
167 167
 
168
-		$this->author= $author;
169
-		$this->preview_image= $preview_image;
168
+        $this->author= $author;
169
+        $this->preview_image= $preview_image;
170 170
 
171
-		$this->items = $items;
172
-	}
173
-	/**
174
-	 * Get the items
175
-	 */
176
-	function get_items()
177
-	{
178
-		return $this->items;
179
-	}
171
+        $this->items = $items;
172
+    }
173
+    /**
174
+     * Get the items
175
+     */
176
+    function get_items()
177
+    {
178
+        return $this->items;
179
+    }
180 180
 
181
-	/**
182
-	 * Check if a given resource is used as an item in this chapter
183
-	 */
184
-	function has_item($resource)
185
-	{
186
-		foreach ($this->items as $item) {
187
-			if ($item['id'] == $resource->get_id() &&
188
-				isset($item['type']) && $item['type'] == $resource->get_type()
189
-			) {
190
-				return true;
191
-			}
192
-		}
193
-		return false;
194
-	}
181
+    /**
182
+     * Check if a given resource is used as an item in this chapter
183
+     */
184
+    function has_item($resource)
185
+    {
186
+        foreach ($this->items as $item) {
187
+            if ($item['id'] == $resource->get_id() &&
188
+                isset($item['type']) && $item['type'] == $resource->get_type()
189
+            ) {
190
+                return true;
191
+            }
192
+        }
193
+        return false;
194
+    }
195 195
 
196
-	/**
197
-	 * Show this learnpath
198
-	 */
199
-	function show() {
200
-		parent::show();
201
-		echo $this->name;
202
-	}
196
+    /**
197
+     * Show this learnpath
198
+     */
199
+    function show() {
200
+        parent::show();
201
+        echo $this->name;
202
+    }
203 203
 }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Thematic.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
 {
12 12
     public $params = array();
13 13
     public $thematic_advance_list = array();
14
-	public $thematic_plan_list = array();
14
+    public $thematic_plan_list = array();
15 15
 
16 16
     /**
17
-    * Create a new Thematic
18
-    *
19
-    * @param array $params
20
-    */
17
+     * Create a new Thematic
18
+     *
19
+     * @param array $params
20
+     */
21 21
     public function __construct($params)
22 22
     {
23 23
         parent::__construct($params['id'], RESOURCE_THEMATIC);
Please login to merge, or discard this patch.
Chamilo/CourseBundle/Component/CourseCopy/Resources/DummyCourseCreator.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -291,16 +291,16 @@
 block discarded – undo
291 291
         Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.';
292 292
         switch($type)
293 293
         {
294
-         case 'description':
294
+            case 'description':
295 295
             $descriptions = explode(".",$dummy_text);
296 296
             return $descriptions[rand(0,count($descriptions)-1)];
297 297
             break;
298
-         case 'title':
298
+            case 'title':
299 299
             $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text);
300 300
             $titles = explode(" ",$dummy_text);
301 301
             return trim($titles[rand(0,count($titles)-1)]);
302 302
             break;
303
-         case 'text':
303
+            case 'text':
304 304
             $texts = explode("\n",$dummy_text);
305 305
             return $texts[rand(0,count($texts)-1)];
306 306
             break;
Please login to merge, or discard this patch.
main/inc/lib/extra_field.lib.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         'changeable',
20 20
         'filter',
21 21
         'extra_field_type',
22
-         /* Enable this when field_loggeable is introduced as a table field (2.0)
22
+            /* Enable this when field_loggeable is introduced as a table field (2.0)
23 23
         'field_loggeable',
24 24
          */
25 25
         'created_at'
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      * France:Paris;Bretagne;Marseille;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura;
557 557
      * into
558 558
      * array(
559
- *      'France' =>
559
+     *      'France' =>
560 560
      *      array('Paris', 'Bregtane', 'Marseille'),
561 561
      *  'Belgique' =>
562 562
      *      array('Namur', 'Liège')
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
                 foreach ($orderFields as $order) {
762 762
                     foreach ($extra as $field_details) {
763 763
                         if ($order == $field_details['variable']) {
764
-                           $newOrder[] = $field_details;
764
+                            $newOrder[] = $field_details;
765 765
                         }
766 766
                     }
767 767
                 }
Please login to merge, or discard this patch.
main/inc/lib/blog.lib.php 1 patch
Indentation   +1821 added lines, -1822 removed lines patch added patch discarded remove patch
@@ -6,112 +6,111 @@  discard block
 block discarded – undo
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 string $title
100
-	 */
101
-	public static function create_blog($title, $subtitle)
102
-	{
103
-		$_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 string $title
99
+     */
100
+    public static function create_blog($title, $subtitle)
101
+    {
102
+        $_user = api_get_user_info();
104 103
         $course_id = api_get_course_int_id();
105 104
 
106
-		$current_date=date('Y-m-d H:i:s',time());
107
-		$session_id = api_get_session_id();
108
-		// Tabel definitions
105
+        $current_date=date('Y-m-d H:i:s',time());
106
+        $session_id = api_get_session_id();
107
+        // Tabel definitions
109 108
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
110 109
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
111 110
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
112 111
 
113
-		//verified if exist blog
114
-		$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
112
+        //verified if exist blog
113
+        $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
115 114
 			  	WHERE
116 115
 			  	    c_id = '.$course_id.' AND
117 116
 			  	    blog_name="'.Database::escape_string($title).'" AND
@@ -120,9 +119,9 @@  discard block
 block discarded – undo
120 119
         $info_count = Database::result($res, 0, 0);
121 120
 
122 121
         if ($info_count == 0) {
123
-			// Create the blog
122
+            // Create the blog
124 123
             $params = [
125
-				'blog_id' => 0,
124
+                'blog_id' => 0,
126 125
                 'c_id' => $course_id,
127 126
                 'blog_name' => $title,
128 127
                 'blog_subtitle' =>  $subtitle,
@@ -130,14 +129,14 @@  discard block
 block discarded – undo
130 129
                 'visibility' => 1 ,
131 130
                 'session_id' => $session_id,
132 131
             ];
133
-			$this_blog_id = Database::insert($tbl_blogs, $params);
132
+            $this_blog_id = Database::insert($tbl_blogs, $params);
134 133
 
135
-			if ($this_blog_id > 0) {
134
+            if ($this_blog_id > 0) {
136 135
 
137 136
                 $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id";
138 137
                 Database::query($sql);
139 138
 
140
-				// insert into item_property
139
+                // insert into item_property
141 140
                 api_item_property_update(
142 141
                     api_get_course_info(),
143 142
                     TOOL_BLOGS,
@@ -145,12 +144,12 @@  discard block
 block discarded – undo
145 144
                     'BlogAdded',
146 145
                     api_get_user_id()
147 146
                 );
148
-			}
147
+            }
149 148
 
150
-			// Make first post. :)
149
+            // Make first post. :)
151 150
 
152 151
             $params = [
153
-				'post_id' => 0,
152
+                'post_id' => 0,
154 153
                 'c_id' => $course_id,
155 154
                 'title' => get_lang("Welcome"),
156 155
                 'full_text' => get_lang('FirstPostText'),
@@ -164,10 +163,10 @@  discard block
 block discarded – undo
164 163
                 Database::query($sql);
165 164
             }
166 165
 
167
-			// Put it on course homepage
168
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target)
166
+            // Put it on course homepage
167
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target)
169 168
 					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', '')";
170
-			Database::query($sql);
169
+            Database::query($sql);
171 170
 
172 171
             $toolId = Database::insert_id();
173 172
             if ($toolId) {
@@ -175,35 +174,35 @@  discard block
 block discarded – undo
175 174
                 Database::query($sql);
176 175
             }
177 176
 
178
-			// Subscribe the teacher to this blog
179
-			Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
180
-		}
181
-	}
182
-
183
-	/**
184
-	 * Update title and subtitle of a blog in the given course
185
-	 * @author Toon Keppens
186
-	 * @param string $title
187
-	 */
188
-	public static function edit_blog($blog_id, $title, $subtitle)
189
-	{
190
-		// Table definitions
191
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
192
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
177
+            // Subscribe the teacher to this blog
178
+            Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
179
+        }
180
+    }
181
+
182
+    /**
183
+     * Update title and subtitle of a blog in the given course
184
+     * @author Toon Keppens
185
+     * @param string $title
186
+     */
187
+    public static function edit_blog($blog_id, $title, $subtitle)
188
+    {
189
+        // Table definitions
190
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
191
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
193 192
 
194 193
         $course_id = api_get_course_int_id();
195 194
 
196
-		// Update the blog
197
-		$sql = "UPDATE $tbl_blogs SET
195
+        // Update the blog
196
+        $sql = "UPDATE $tbl_blogs SET
198 197
 		        blog_name = '".Database::escape_string($title)."',
199 198
 		        blog_subtitle = '".Database::escape_string($subtitle)."'
200 199
 		        WHERE
201 200
 		            c_id = $course_id AND
202 201
 		            blog_id ='".Database::escape_string((int)$blog_id)."'
203 202
                 LIMIT 1";
204
-		Database::query($sql);
203
+        Database::query($sql);
205 204
 
206
-		//update item_property (update)
205
+        //update item_property (update)
207 206
         api_item_property_update(
208 207
             api_get_course_info(),
209 208
             TOOL_BLOGS,
@@ -212,21 +211,21 @@  discard block
 block discarded – undo
212 211
             api_get_user_id()
213 212
         );
214 213
 
215
-		// Update course homepage link
216
-		$sql = "UPDATE $tbl_tool SET
214
+        // Update course homepage link
215
+        $sql = "UPDATE $tbl_tool SET
217 216
 		        name = '".Database::escape_string($title)."'
218 217
 		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
219
-		Database::query($sql);
220
-	}
221
-
222
-	/**
223
-	 * Deletes a blog and it's posts from the course database
224
-	 * @author Toon Keppens
225
-	 * @param Integer $blog_id
226
-	 */
227
-	public static function delete_blog($blog_id)
228
-	{
229
-		// Init
218
+        Database::query($sql);
219
+    }
220
+
221
+    /**
222
+     * Deletes a blog and it's posts from the course database
223
+     * @author Toon Keppens
224
+     * @param Integer $blog_id
225
+     */
226
+    public static function delete_blog($blog_id)
227
+    {
228
+        // Init
230 229
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
231 230
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
232 231
         $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS);
@@ -237,34 +236,34 @@  discard block
 block discarded – undo
237 236
         $course_id = api_get_course_int_id();
238 237
         $blog_id = intval($blog_id);
239 238
 
240
-		// Delete posts from DB and the attachments
241
-		delete_all_blog_attachment($blog_id);
239
+        // Delete posts from DB and the attachments
240
+        delete_all_blog_attachment($blog_id);
242 241
 
243
-		//Delete comments
244
-		$sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
245
-   		Database::query($sql);
242
+        //Delete comments
243
+        $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
244
+            Database::query($sql);
246 245
 
247
-		// Delete posts
248
-   		$sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
249
-   		Database::query($sql);
246
+        // Delete posts
247
+            $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
248
+            Database::query($sql);
250 249
 
251
-		// Delete tasks
252
-		$sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
253
-		Database::query($sql);
250
+        // Delete tasks
251
+        $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
252
+        Database::query($sql);
254 253
 
255
-		// Delete ratings
256
-		$sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
257
-		Database::query($sql);
254
+        // Delete ratings
255
+        $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
256
+        Database::query($sql);
258 257
 
259
-		// Delete blog
260
-		$sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
261
-		Database::query($sql);
258
+        // Delete blog
259
+        $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
260
+        Database::query($sql);
262 261
 
263
-		// Delete from course homepage
264
-		$sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
265
-		Database::query($sql);
262
+        // Delete from course homepage
263
+        $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
264
+        Database::query($sql);
266 265
 
267
-		//update item_property (delete)
266
+        //update item_property (delete)
268 267
         api_item_property_update(
269 268
             api_get_course_info(),
270 269
             TOOL_BLOGS,
@@ -272,152 +271,152 @@  discard block
 block discarded – undo
272 271
             'delete',
273 272
             api_get_user_id()
274 273
         );
275
-	}
276
-
277
-	/**
278
-	 * Creates a new post in a given blog
279
-	 * @author Toon Keppens
280
-	 * @param String $title
281
-	 * @param String $full_text
282
-	 * @param Integer $blog_id
283
-	 */
284
-	public static function create_post($title, $full_text, $file_comment, $blog_id)
285
-	{
286
-		$_user = api_get_user_info();
287
-		$_course = api_get_course_info();
288
-		$course_id = $_course['real_id'];
289
-
290
-		$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
291
-		$upload_ok=true;
292
-		$has_attachment=false;
293
-		$current_date = api_get_utc_datetime();
294
-
295
-		if (!empty($_FILES['user_upload']['name'])) {
296
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
297
-			$has_attachment=true;
298
-		}
299
-
300
-		if ($upload_ok) {
301
-			// Table Definitions
302
-			$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
303
-
304
-			// Create the post
305
-			$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
274
+    }
275
+
276
+    /**
277
+     * Creates a new post in a given blog
278
+     * @author Toon Keppens
279
+     * @param String $title
280
+     * @param String $full_text
281
+     * @param Integer $blog_id
282
+     */
283
+    public static function create_post($title, $full_text, $file_comment, $blog_id)
284
+    {
285
+        $_user = api_get_user_info();
286
+        $_course = api_get_course_info();
287
+        $course_id = $_course['real_id'];
288
+
289
+        $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
290
+        $upload_ok=true;
291
+        $has_attachment=false;
292
+        $current_date = api_get_utc_datetime();
293
+
294
+        if (!empty($_FILES['user_upload']['name'])) {
295
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
296
+            $has_attachment=true;
297
+        }
298
+
299
+        if ($upload_ok) {
300
+            // Table Definitions
301
+            $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
302
+
303
+            // Create the post
304
+            $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
306 305
 					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
307 306
 
308
-			Database::query($sql);
309
-			$last_post_id = Database::insert_id();
307
+            Database::query($sql);
308
+            $last_post_id = Database::insert_id();
310 309
 
311 310
             if ($last_post_id) {
312 311
                 $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id";
313 312
                 Database::query($sql);
314 313
             }
315 314
 
316
-			if ($has_attachment) {
317
-				$courseDir   = $_course['path'].'/upload/blog';
318
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
319
-				$updir = $sys_course_path.$courseDir;
320
-
321
-				// Try to add an extension to the file if it hasn't one
322
-				$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
323
-
324
-				// user's file name
325
-				$file_name = $_FILES['user_upload']['name'];
326
-
327
-				if (!filter_extension($new_file_name)) {
328
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
329
-				} else {
330
-					$new_file_name = uniqid('');
331
-					$new_path = $updir.'/'.$new_file_name;
332
-					$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
333
-					$comment = Database::escape_string($file_comment);
334
-
335
-					// Storing the attachments if any
336
-					if ($result) {
337
-						$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
338
-							   "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' )";
339
-						Database::query($sql);
315
+            if ($has_attachment) {
316
+                $courseDir   = $_course['path'].'/upload/blog';
317
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
318
+                $updir = $sys_course_path.$courseDir;
319
+
320
+                // Try to add an extension to the file if it hasn't one
321
+                $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
322
+
323
+                // user's file name
324
+                $file_name = $_FILES['user_upload']['name'];
325
+
326
+                if (!filter_extension($new_file_name)) {
327
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
328
+                } else {
329
+                    $new_file_name = uniqid('');
330
+                    $new_path = $updir.'/'.$new_file_name;
331
+                    $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
332
+                    $comment = Database::escape_string($file_comment);
333
+
334
+                    // Storing the attachments if any
335
+                    if ($result) {
336
+                        $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
337
+                                "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' )";
338
+                        Database::query($sql);
340 339
                         $id = Database::insert_id();
341 340
                         if ($id) {
342 341
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
343 342
                             Database::query($sql);
344 343
                         }
345
-					}
346
-				}
347
-			}
348
-		} else {
349
-			Display::display_error_message(get_lang('UplNoFileUploaded'));
350
-		}
351
-	}
352
-
353
-	/**
354
-	 * Edits a post in a given blog
355
-	 * @author Toon Keppens
356
-	 * @param Integer $blog_id
357
-	 * @param String $title
358
-	 * @param String $full_text
359
-	 * @param Integer $blog_id
360
-	 */
361
-	public static function edit_post($post_id, $title, $full_text, $blog_id)
362
-	{
363
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
344
+                    }
345
+                }
346
+            }
347
+        } else {
348
+            Display::display_error_message(get_lang('UplNoFileUploaded'));
349
+        }
350
+    }
351
+
352
+    /**
353
+     * Edits a post in a given blog
354
+     * @author Toon Keppens
355
+     * @param Integer $blog_id
356
+     * @param String $title
357
+     * @param String $full_text
358
+     * @param Integer $blog_id
359
+     */
360
+    public static function edit_post($post_id, $title, $full_text, $blog_id)
361
+    {
362
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
364 363
         $course_id = api_get_course_int_id();
365 364
 
366
-		// Create the post
367
-		$sql = "UPDATE $tbl_blogs_posts SET
365
+        // Create the post
366
+        $sql = "UPDATE $tbl_blogs_posts SET
368 367
 		        title = '" . Database::escape_string($title)."',
369 368
 		        full_text = '" . Database::escape_string($full_text)."'
370 369
 		        WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."'
371 370
 		        LIMIT 1 ";
372
-		Database::query($sql);
373
-	}
374
-
375
-	/**
376
-	 * Deletes an article and it's comments
377
-	 * @author Toon Keppens
378
-	 * @param int $blog_id
379
-	 * @param int $post_id
380
-	 */
381
-	public static function delete_post($blog_id, $post_id)
382
-	{
383
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
384
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
385
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
371
+        Database::query($sql);
372
+    }
373
+
374
+    /**
375
+     * Deletes an article and it's comments
376
+     * @author Toon Keppens
377
+     * @param int $blog_id
378
+     * @param int $post_id
379
+     */
380
+    public static function delete_post($blog_id, $post_id)
381
+    {
382
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
383
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
384
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
386 385
 
387 386
         $course_id = api_get_course_int_id();
388 387
 
389
-		// Delete ratings on this comment
390
-		$sql = "DELETE FROM $tbl_blogs_rating
388
+        // Delete ratings on this comment
389
+        $sql = "DELETE FROM $tbl_blogs_rating
391 390
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'";
392
-		Database::query($sql);
391
+        Database::query($sql);
393 392
 
394
-		// Delete the post
395
-		$sql = "DELETE FROM $tbl_blogs_posts
393
+        // Delete the post
394
+        $sql = "DELETE FROM $tbl_blogs_posts
396 395
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."'";
397
-		Database::query($sql);
396
+        Database::query($sql);
398 397
 
399
-		// Delete the comments
400
-		$sql = "DELETE FROM $tbl_blogs_comments
398
+        // Delete the comments
399
+        $sql = "DELETE FROM $tbl_blogs_comments
401 400
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'";
402
-		Database::query($sql);
403
-
404
-		// Delete posts and attachments
405
-		delete_all_blog_attachment($blog_id,$post_id);
406
-	}
407
-
408
-	/**
409
-	 * Creates a comment on a post in a given blog
410
-	 * @author Toon Keppens
411
-	 * @param String $title
412
-	 * @param String $full_text
413
-	 * @param Integer $blog_id
414
-	 * @param Integer $post_id
415
-	 * @param Integer $parent_id
416
-	 */
417
-	public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
418
-	{
419
-		$_user = api_get_user_info();
420
-		$_course = api_get_course_info();
401
+        Database::query($sql);
402
+
403
+        // Delete posts and attachments
404
+        delete_all_blog_attachment($blog_id,$post_id);
405
+    }
406
+
407
+    /**
408
+     * Creates a comment on a post in a given blog
409
+     * @author Toon Keppens
410
+     * @param String $title
411
+     * @param String $full_text
412
+     * @param Integer $blog_id
413
+     * @param Integer $post_id
414
+     * @param Integer $parent_id
415
+     */
416
+    public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
417
+    {
418
+        $_user = api_get_user_info();
419
+        $_course = api_get_course_info();
421 420
         $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
422 421
 
423 422
         $upload_ok = true;
@@ -425,55 +424,55 @@  discard block
 block discarded – undo
425 424
         $current_date = api_get_utc_datetime();
426 425
         $course_id = api_get_course_int_id();
427 426
 
428
-		if (!empty($_FILES['user_upload']['name'])) {
429
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
430
-			$has_attachment=true;
431
-		}
427
+        if (!empty($_FILES['user_upload']['name'])) {
428
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
429
+            $has_attachment=true;
430
+        }
432 431
 
433
-		if ($upload_ok) {
434
-			// Table Definition
435
-			$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
432
+        if ($upload_ok) {
433
+            // Table Definition
434
+            $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
436 435
 
437
-			// Create the comment
438
-			$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
436
+            // Create the comment
437
+            $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
439 438
 					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."')";
440
-			Database::query($sql);
439
+            Database::query($sql);
441 440
 
442
-			// Empty post values, or they are shown on the page again
443
-			$last_id = Database::insert_id();
441
+            // Empty post values, or they are shown on the page again
442
+            $last_id = Database::insert_id();
444 443
 
445 444
             if ($last_id) {
446 445
                 $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id";
447 446
                 Database::query($sql);
448 447
             }
449 448
 
450
-			if ($has_attachment) {
451
-				$courseDir   = $_course['path'].'/upload/blog';
452
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
453
-				$updir = $sys_course_path.$courseDir;
454
-
455
-				// Try to add an extension to the file if it hasn't one
456
-				$new_file_name = add_ext_on_mime(
457
-					stripslashes($_FILES['user_upload']['name']),
458
-					$_FILES['user_upload']['type']
459
-				);
460
-
461
-				// user's file name
462
-				$file_name =$_FILES['user_upload']['name'];
463
-
464
-				if (!filter_extension($new_file_name)) {
465
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
466
-				} else {
467
-					$new_file_name = uniqid('');
468
-					$new_path=$updir.'/'.$new_file_name;
469
-					$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
470
-					$comment = Database::escape_string($file_comment);
471
-
472
-					// Storing the attachments if any
473
-					if ($result) {
474
-						$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
475
-							 "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."'  )";
476
-						Database::query($sql);
449
+            if ($has_attachment) {
450
+                $courseDir   = $_course['path'].'/upload/blog';
451
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
452
+                $updir = $sys_course_path.$courseDir;
453
+
454
+                // Try to add an extension to the file if it hasn't one
455
+                $new_file_name = add_ext_on_mime(
456
+                    stripslashes($_FILES['user_upload']['name']),
457
+                    $_FILES['user_upload']['type']
458
+                );
459
+
460
+                // user's file name
461
+                $file_name =$_FILES['user_upload']['name'];
462
+
463
+                if (!filter_extension($new_file_name)) {
464
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
465
+                } else {
466
+                    $new_file_name = uniqid('');
467
+                    $new_path=$updir.'/'.$new_file_name;
468
+                    $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
469
+                    $comment = Database::escape_string($file_comment);
470
+
471
+                    // Storing the attachments if any
472
+                    if ($result) {
473
+                        $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
474
+                                "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."'  )";
475
+                        Database::query($sql);
477 476
 
478 477
                         $id = Database::insert_id();
479 478
 
@@ -481,91 +480,91 @@  discard block
 block discarded – undo
481 480
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
482 481
                             Database::query($sql);
483 482
                         }
484
-					}
485
-				}
486
-			}
487
-		}
488
-	}
489
-
490
-	/**
491
-	 * Deletes a comment from a blogpost
492
-	 * @author Toon Keppens
493
-	 * @param int $blog_id
494
-	 * @param int $comment_id
495
-	 */
496
-	public static function delete_comment($blog_id, $post_id, $comment_id)
497
-	{
498
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
499
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
500
-		$blog_id = intval($blog_id);
501
-		$post_id = intval($post_id);
502
-		$comment_id = intval($comment_id);
483
+                    }
484
+                }
485
+            }
486
+        }
487
+    }
488
+
489
+    /**
490
+     * Deletes a comment from a blogpost
491
+     * @author Toon Keppens
492
+     * @param int $blog_id
493
+     * @param int $comment_id
494
+     */
495
+    public static function delete_comment($blog_id, $post_id, $comment_id)
496
+    {
497
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
498
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
499
+        $blog_id = intval($blog_id);
500
+        $post_id = intval($post_id);
501
+        $comment_id = intval($comment_id);
503 502
         $course_id = api_get_course_int_id();
504 503
 
505
-		delete_all_blog_attachment($blog_id, $post_id, $comment_id);
504
+        delete_all_blog_attachment($blog_id, $post_id, $comment_id);
506 505
 
507
-		// Delete ratings on this comment
508
-		$sql = "DELETE FROM $tbl_blogs_rating
506
+        // Delete ratings on this comment
507
+        $sql = "DELETE FROM $tbl_blogs_rating
509 508
 				WHERE
510 509
 				    c_id = $course_id AND
511 510
 				    blog_id = '".$blog_id."' AND
512 511
 				    item_id = '".$comment_id."' AND
513 512
 				    rating_type = 'comment'";
514
-		Database::query($sql);
513
+        Database::query($sql);
515 514
 
516
-		// select comments that have the selected comment as their parent
517
-		$sql = "SELECT comment_id FROM $tbl_blogs_comments
515
+        // select comments that have the selected comment as their parent
516
+        $sql = "SELECT comment_id FROM $tbl_blogs_comments
518 517
 				WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'";
519
-		$result = Database::query($sql);
518
+        $result = Database::query($sql);
520 519
 
521
-		// Delete them recursively
522
-		while ($comment = Database::fetch_array($result)) {
523
-			Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
524
-		}
520
+        // Delete them recursively
521
+        while ($comment = Database::fetch_array($result)) {
522
+            Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
523
+        }
525 524
 
526
-		// Finally, delete the selected comment to
527
-		$sql = "DELETE FROM $tbl_blogs_comments
525
+        // Finally, delete the selected comment to
526
+        $sql = "DELETE FROM $tbl_blogs_comments
528 527
 				WHERE c_id = $course_id AND comment_id = '".$comment_id."'";
529
-		Database::query($sql);
530
-	}
531
-
532
-	/**
533
-	 * Creates a new task in a blog
534
-	 * @author Toon Keppens
535
-	 * @param Integer $blog_id
536
-	 * @param String $title
537
-	 * @param String $description
538
-	 * @param String $color
539
-	 */
540
-	public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
541
-	{
542
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
543
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
544
-
545
-		$course_id = api_get_course_int_id();
546
-
547
-		// Create the task
548
-		$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
528
+        Database::query($sql);
529
+    }
530
+
531
+    /**
532
+     * Creates a new task in a blog
533
+     * @author Toon Keppens
534
+     * @param Integer $blog_id
535
+     * @param String $title
536
+     * @param String $description
537
+     * @param String $color
538
+     */
539
+    public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
540
+    {
541
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
542
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
543
+
544
+        $course_id = api_get_course_int_id();
545
+
546
+        // Create the task
547
+        $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
549 548
 				VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
550
-		Database::query($sql);
549
+        Database::query($sql);
551 550
 
552
-		$task_id = Database::insert_id();
551
+        $task_id = Database::insert_id();
553 552
 
554 553
         if ($task_id) {
555 554
             $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id";
556 555
             Database::query($sql);
557 556
         }
558 557
 
559
-		$tool = 'BLOG_' . $blog_id;
558
+        $tool = 'BLOG_' . $blog_id;
560 559
 
561
-		if ($articleDelete == 'on') {
562
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
560
+        if ($articleDelete == 'on') {
561
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
563 562
 					'" . (int)$course_id . "',
564 563
 					'" . (int)$task_id . "',
565 564
 					'" . Database::escape_string($tool) . "',
566 565
 					'article_delete'
567 566
 				)";
568
-			Database::query($sql);
567
+            Database::query($sql);
569 568
 
570 569
             $id = Database::insert_id();
571 570
 
@@ -575,171 +574,171 @@  discard block
 block discarded – undo
575 574
             }
576 575
         }
577 576
 
578
-		if ($articleEdit == 'on') {
579
-			$sql = "
577
+        if ($articleEdit == 'on') {
578
+            $sql = "
580 579
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
581 580
 					'" . (int)$course_id . "',
582 581
 					'" . (int)$task_id . "',
583 582
 					'" . Database::escape_string($tool) . "',
584 583
 					'article_edit'
585 584
 				)";
586
-			Database::query($sql);
585
+            Database::query($sql);
587 586
             $id = Database::insert_id();
588 587
 
589 588
             if ($id) {
590 589
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
591 590
                 Database::query($sql);
592 591
             }
593
-		}
592
+        }
594 593
 
595
-		if ($commentsDelete == 'on') {
596
-			$sql = "
594
+        if ($commentsDelete == 'on') {
595
+            $sql = "
597 596
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
598 597
 					'" . (int)$course_id . "',
599 598
 					'" . (int)$task_id . "',
600 599
 					'" . Database::escape_string($tool) . "',
601 600
 					'article_comments_delete'
602 601
 				)";
603
-			Database::query($sql);
602
+            Database::query($sql);
604 603
             $id = Database::insert_id();
605 604
 
606 605
             if ($id) {
607 606
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
608 607
                 Database::query($sql);
609 608
             }
610
-		}
611
-	}
612
-
613
-	/**
614
-	 * Edit a task in a blog
615
-	 * @author Toon Keppens
616
-	 * @param Integer $task_id
617
-	 * @param String $title
618
-	 * @param String $description
619
-	 * @param String $color
620
-	 */
621
-	public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
622
-	{
623
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
624
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
609
+        }
610
+    }
611
+
612
+    /**
613
+     * Edit a task in a blog
614
+     * @author Toon Keppens
615
+     * @param Integer $task_id
616
+     * @param String $title
617
+     * @param String $description
618
+     * @param String $color
619
+     */
620
+    public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
621
+    {
622
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
623
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
625 624
 
626 625
         $course_id = api_get_course_int_id();
627 626
 
628
-		// Create the task
629
-		$sql = "UPDATE $tbl_blogs_tasks SET
627
+        // Create the task
628
+        $sql = "UPDATE $tbl_blogs_tasks SET
630 629
 					title = '".Database::escape_string($title)."',
631 630
 					description = '".Database::escape_string($description)."',
632 631
 					color = '".Database::escape_string($color)."'
633 632
 				WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1";
634
-		Database::query($sql);
633
+        Database::query($sql);
635 634
 
636
-		$tool = 'BLOG_' . $blog_id;
635
+        $tool = 'BLOG_' . $blog_id;
637 636
 
638
-		$sql = "DELETE FROM " . $tbl_tasks_permissions . "
637
+        $sql = "DELETE FROM " . $tbl_tasks_permissions . "
639 638
 				WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
640
-		Database::query($sql);
639
+        Database::query($sql);
641 640
 
642
-		if ($articleDelete == 'on') {
643
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
641
+        if ($articleDelete == 'on') {
642
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
644 643
 					'" . (int)$course_id . "',
645 644
 					'" . (int)$task_id . "',
646 645
 					'" . Database::escape_string($tool) . "',
647 646
 					'article_delete'
648 647
 				)";
649
-			Database::query($sql);
648
+            Database::query($sql);
650 649
             $id = Database::insert_id();
651 650
 
652 651
             if ($id) {
653 652
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
654 653
                 Database::query($sql);
655 654
             }
656
-		}
655
+        }
657 656
 
658
-		if ($articleEdit == 'on') {
659
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
657
+        if ($articleEdit == 'on') {
658
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
660 659
 					'" . (int)$course_id . "',
661 660
 					'" . (int)$task_id . "',
662 661
 					'" . Database::escape_string($tool) . "',
663 662
 					'article_edit'
664 663
 				)";
665
-			Database::query($sql);
664
+            Database::query($sql);
666 665
             $id = Database::insert_id();
667 666
 
668 667
             if ($id) {
669 668
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
670 669
                 Database::query($sql);
671 670
             }
672
-		}
671
+        }
673 672
 
674
-		if ($commentsDelete == 'on') {
675
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
673
+        if ($commentsDelete == 'on') {
674
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
676 675
 					'" . (int)$course_id . "',
677 676
 					'" . (int)$task_id . "',
678 677
 					'" . Database::escape_string($tool) . "',
679 678
 					'article_comments_delete'
680 679
 				)";
681
-			Database::query($sql);
680
+            Database::query($sql);
682 681
             $id = Database::insert_id();
683 682
 
684 683
             if ($id) {
685 684
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
686 685
                 Database::query($sql);
687 686
             }
688
-		}
689
-	}
690
-
691
-	/**
692
-	 * Deletes a task from a blog
693
-	 * @param Integer $blog_id
694
-	 * @param Integer $task_id
695
-	 */
696
-	public static function delete_task($blog_id, $task_id)
697
-	{
698
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
699
-		$course_id = api_get_course_int_id();
700
-
701
-		// Delete posts
702
-		$sql = "DELETE FROM $tbl_blogs_tasks
687
+        }
688
+    }
689
+
690
+    /**
691
+     * Deletes a task from a blog
692
+     * @param Integer $blog_id
693
+     * @param Integer $task_id
694
+     */
695
+    public static function delete_task($blog_id, $task_id)
696
+    {
697
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
698
+        $course_id = api_get_course_int_id();
699
+
700
+        // Delete posts
701
+        $sql = "DELETE FROM $tbl_blogs_tasks
703 702
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
704
-		Database::query($sql);
705
-	}
706
-
707
-	/**
708
-	 * Deletes an assigned task from a blog
709
-	 * @param Integer $blog_id
710
-	 */
711
-	public static function delete_assigned_task($blog_id, $task_id, $user_id)
712
-	{
713
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
703
+        Database::query($sql);
704
+    }
705
+
706
+    /**
707
+     * Deletes an assigned task from a blog
708
+     * @param Integer $blog_id
709
+     */
710
+    public static function delete_assigned_task($blog_id, $task_id, $user_id)
711
+    {
712
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
714 713
         $course_id = api_get_course_int_id();
715 714
 
716
-		// Delete posts
717
-		$sql = "DELETE FROM $tbl_blogs_tasks_rel_user
715
+        // Delete posts
716
+        $sql = "DELETE FROM $tbl_blogs_tasks_rel_user
718 717
 				WHERE
719 718
 				    c_id = $course_id AND
720 719
 				    blog_id = '".(int)$blog_id."' AND
721 720
 				    task_id = '".(int)$task_id."' AND
722 721
 				    user_id = '".(int)$user_id."'";
723
-		Database::query($sql);
724
-	}
725
-
726
-	/**
727
-	 * Get personal task list
728
-	 * @author Toon Keppens
729
-	 * @return Returns an unsorted list (<ul></ul>) with the users' tasks
730
-	 */
731
-	public static function get_personal_task_list()
732
-	{
733
-		$_user = api_get_user_info();
734
-
735
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
736
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
737
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
738
-
739
-		$course_id = api_get_course_int_id();
740
-
741
-		if ($_user['user_id']) {
742
-			$sql = "SELECT task_rel_user.*, task.title, blog.blog_name
722
+        Database::query($sql);
723
+    }
724
+
725
+    /**
726
+     * Get personal task list
727
+     * @author Toon Keppens
728
+     * @return Returns an unsorted list (<ul></ul>) with the users' tasks
729
+     */
730
+    public static function get_personal_task_list()
731
+    {
732
+        $_user = api_get_user_info();
733
+
734
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
735
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
736
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
737
+
738
+        $course_id = api_get_course_int_id();
739
+
740
+        if ($_user['user_id']) {
741
+            $sql = "SELECT task_rel_user.*, task.title, blog.blog_name
743 742
                     FROM $tbl_blogs_tasks_rel_user task_rel_user
744 743
                     INNER JOIN $tbl_blogs_tasks task
745 744
                     ON task_rel_user.task_id = task.task_id
@@ -753,85 +752,85 @@  discard block
 block discarded – undo
753 752
                         task_rel_user.user_id = ".(int)$_user['user_id']."
754 753
                     ORDER BY target_date ASC";
755 754
 
756
-			$result = Database::query($sql);
757
-
758
-			if (Database::num_rows($result) > 0) {
759
-				echo '<ul>';
760
-				while ($mytask = Database::fetch_array($result)) {
761
-					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>';
762
-				}
763
-				echo '<ul>';
764
-			} else {
765
-				echo get_lang('NoTasks');
766
-			}
767
-		} else {
768
-			echo get_lang('NoTasks');
769
-		}
770
-	}
771
-
772
-	/**
773
-	 * Changes the visibility of a blog
774
-	 * @author Toon Keppens
775
-	 * @param Integer $blog_id
776
-	 */
777
-	public static function change_blog_visibility($blog_id)
778
-	{
779
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
780
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
781
-		$course_id = api_get_course_int_id();
782
-
783
-		// Get blog properties
784
-		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
755
+            $result = Database::query($sql);
756
+
757
+            if (Database::num_rows($result) > 0) {
758
+                echo '<ul>';
759
+                while ($mytask = Database::fetch_array($result)) {
760
+                    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>';
761
+                }
762
+                echo '<ul>';
763
+            } else {
764
+                echo get_lang('NoTasks');
765
+            }
766
+        } else {
767
+            echo get_lang('NoTasks');
768
+        }
769
+    }
770
+
771
+    /**
772
+     * Changes the visibility of a blog
773
+     * @author Toon Keppens
774
+     * @param Integer $blog_id
775
+     */
776
+    public static function change_blog_visibility($blog_id)
777
+    {
778
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
779
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
780
+        $course_id = api_get_course_int_id();
781
+
782
+        // Get blog properties
783
+        $sql = "SELECT blog_name, visibility FROM $tbl_blogs
785 784
 				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
786
-		$result = Database::query($sql);
787
-		$blog = Database::fetch_array($result);
788
-		$visibility = $blog['visibility'];
789
-		$title = $blog['blog_name'];
790
-
791
-		if ($visibility == 1) {
792
-			// Change visibility state, remove from course home.
793
-			$sql = "UPDATE $tbl_blogs SET visibility = '0'
785
+        $result = Database::query($sql);
786
+        $blog = Database::fetch_array($result);
787
+        $visibility = $blog['visibility'];
788
+        $title = $blog['blog_name'];
789
+
790
+        if ($visibility == 1) {
791
+            // Change visibility state, remove from course home.
792
+            $sql = "UPDATE $tbl_blogs SET visibility = '0'
794 793
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
795
-			Database::query($sql);
794
+            Database::query($sql);
796 795
 
797
-			$sql = "DELETE FROM $tbl_tool
796
+            $sql = "DELETE FROM $tbl_tool
798 797
 					WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1";
799
-			Database::query($sql);
800
-		} else {
801
-			// Change visibility state, add to course home.
802
-			$sql = "UPDATE $tbl_blogs SET visibility = '1'
798
+            Database::query($sql);
799
+        } else {
800
+            // Change visibility state, add to course home.
801
+            $sql = "UPDATE $tbl_blogs SET visibility = '1'
803 802
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
804
-			Database::query($sql);
803
+            Database::query($sql);
805 804
 
806
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
805
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
807 806
 					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
808
-			Database::query($sql);
807
+            Database::query($sql);
809 808
             $id = Database::insert_id();
810 809
 
811 810
             if ($id) {
812 811
                 $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id";
813 812
                 Database::query($sql);
814 813
             }
815
-		}
816
-	}
817
-
818
-	/**
819
-	 * Shows the posts of a blog
820
-	 * @author Toon Keppens
821
-	 *
822
-	 * @param Integer $blog_id
823
-	 */
824
-	public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
814
+        }
815
+    }
816
+
817
+    /**
818
+     * Shows the posts of a blog
819
+     * @author Toon Keppens
820
+     *
821
+     * @param Integer $blog_id
822
+     */
823
+    public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
825 824
     {
826
-		// Init
827
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
828
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
829
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
825
+        // Init
826
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
827
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
828
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
830 829
 
831
-		$course_id = api_get_course_int_id();
830
+        $course_id = api_get_course_int_id();
832 831
 
833
-		// Get posts and authors
834
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
832
+        // Get posts and authors
833
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
835 834
 		        FROM $tbl_blogs_posts post
836 835
                 INNER JOIN $tbl_users user
837 836
                 ON post.author_id = user.user_id
@@ -839,131 +838,131 @@  discard block
 block discarded – undo
839 838
 						post.c_id = $course_id AND
840 839
 						$filter
841 840
 				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
842
-		$result = Database::query($sql);
843
-
844
-		// Display
845
-		if(Database::num_rows($result) > 0) {
846
-		    $limit = 200;
847
-			while ($blog_post = Database::fetch_array($result)) {
848
-				// Get number of comments
849
-				$sql = "SELECT COUNT(1) as number_of_comments
841
+        $result = Database::query($sql);
842
+
843
+        // Display
844
+        if(Database::num_rows($result) > 0) {
845
+            $limit = 200;
846
+            while ($blog_post = Database::fetch_array($result)) {
847
+                // Get number of comments
848
+                $sql = "SELECT COUNT(1) as number_of_comments
850 849
 						FROM $tbl_blogs_comments
851 850
 						WHERE
852 851
 						    c_id = $course_id AND
853 852
 						    blog_id = '".(int)$blog_id."' AND
854 853
 						    post_id = '" . (int)$blog_post['post_id']."'";
855
-				$tmp = Database::query($sql);
856
-				$blog_post_comments = Database::fetch_array($tmp);
857
-
858
-				// Prepare data
859
-				$blog_post_id = $blog_post['post_id'];
860
-				$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
861
-				$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
862
-
863
-				// Create an introduction text (but keep FULL sentences)
864
-				$words = 0;
865
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
866
-				$words = strlen($blog_post_text);
867
-
868
-				if ($words >= $limit) {
869
-					$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>';
870
-					$introduction_text = $blog_post_text_cut;
871
-				} else {
872
-				    $introduction_text = $blog_post_text;
873
-					$readMoreLink = '';
874
-				}
875
-
876
-				$introduction_text = stripslashes($introduction_text);
877
-
878
-				echo '<div class="blogpost">';
879
-				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>';
880
-				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>';
881
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
882
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
883
-
884
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
885
-
886
-				if (!empty($file_name_array)) {
887
-					echo '<br /><br />';
888
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
889
-					echo '<a href="download.php?file=';
890
-					echo $file_name_array['path'];
891
-					echo ' "> '.$file_name_array['filename'].' </a><br />';
892
-					echo '</span>';
893
-				}
894
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
895
-				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>';
896
-				echo '</div>';
897
-			}
898
-		} else {
899
-			if($filter == '1=1') {
900
-				echo get_lang('NoArticles');
901
-			} else {
902
-				echo get_lang('NoArticleMatches');
903
-			}
904
-		}
854
+                $tmp = Database::query($sql);
855
+                $blog_post_comments = Database::fetch_array($tmp);
856
+
857
+                // Prepare data
858
+                $blog_post_id = $blog_post['post_id'];
859
+                $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
860
+                $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
861
+
862
+                // Create an introduction text (but keep FULL sentences)
863
+                $words = 0;
864
+                $blog_post_text_cut = cut($blog_post_text, $limit) ;
865
+                $words = strlen($blog_post_text);
866
+
867
+                if ($words >= $limit) {
868
+                    $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>';
869
+                    $introduction_text = $blog_post_text_cut;
870
+                } else {
871
+                    $introduction_text = $blog_post_text;
872
+                    $readMoreLink = '';
873
+                }
874
+
875
+                $introduction_text = stripslashes($introduction_text);
876
+
877
+                echo '<div class="blogpost">';
878
+                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>';
879
+                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>';
880
+                echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
881
+                echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
882
+
883
+                $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
884
+
885
+                if (!empty($file_name_array)) {
886
+                    echo '<br /><br />';
887
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
888
+                    echo '<a href="download.php?file=';
889
+                    echo $file_name_array['path'];
890
+                    echo ' "> '.$file_name_array['filename'].' </a><br />';
891
+                    echo '</span>';
892
+                }
893
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
894
+                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>';
895
+                echo '</div>';
896
+            }
897
+        } else {
898
+            if($filter == '1=1') {
899
+                echo get_lang('NoArticles');
900
+            } else {
901
+                echo get_lang('NoArticleMatches');
902
+            }
903
+        }
905 904
 }
906 905
 
907
-	/**
908
-	 * Display the search results
909
-	 *
910
-	 * @param Integer $blog_id
911
-	 * @param String $query_string
912
-	 */
913
-	public static function display_search_results ($blog_id, $query_string)
914
-	{
915
-		// Init
916
-		$query_string = Database::escape_string($query_string);
917
-		$query_string_parts = explode(' ',$query_string);
918
-		$query_string = array();
919
-		foreach ($query_string_parts as $query_part) {
920
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
921
-		}
922
-		$query_string = '('.implode('OR',$query_string) . ')';
923
-
924
-		// Display the posts
925
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
926
-		Blog::display_blog_posts($blog_id, $query_string);
927
-	}
928
-
929
-	/**
930
-	 * Display posts from a certain date
931
-	 *
932
-	 * @param Integer $blog_id
933
-	 * @param String $query_string
934
-	 */
935
-	public static function display_day_results($blog_id, $query_string)
936
-	{
937
-		$date_output = $query_string;
938
-		$date = explode('-',$query_string);
939
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
940
-
941
-		// Put date in correct output format
942
-		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
943
-
944
-		// Display the posts
945
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
946
-		Blog::display_blog_posts($blog_id, $query_string);
947
-	}
948
-
949
-	/**
950
-	 * Displays a post and his comments
951
-	 *
952
-	 * @param Integer $blog_id
953
-	 * @param Integer $post_id
954
-	 */
955
-	public static function display_post($blog_id, $post_id)
956
-	{
957
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
958
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
959
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
960
-
961
-		global $charset, $dateFormatLong;
962
-
963
-		$course_id = api_get_course_int_id();
964
-
965
-		// Get posts and author
966
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
906
+    /**
907
+     * Display the search results
908
+     *
909
+     * @param Integer $blog_id
910
+     * @param String $query_string
911
+     */
912
+    public static function display_search_results ($blog_id, $query_string)
913
+    {
914
+        // Init
915
+        $query_string = Database::escape_string($query_string);
916
+        $query_string_parts = explode(' ',$query_string);
917
+        $query_string = array();
918
+        foreach ($query_string_parts as $query_part) {
919
+            $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
920
+        }
921
+        $query_string = '('.implode('OR',$query_string) . ')';
922
+
923
+        // Display the posts
924
+        echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
925
+        Blog::display_blog_posts($blog_id, $query_string);
926
+    }
927
+
928
+    /**
929
+     * Display posts from a certain date
930
+     *
931
+     * @param Integer $blog_id
932
+     * @param String $query_string
933
+     */
934
+    public static function display_day_results($blog_id, $query_string)
935
+    {
936
+        $date_output = $query_string;
937
+        $date = explode('-',$query_string);
938
+        $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
939
+
940
+        // Put date in correct output format
941
+        $date_output = api_format_date($date_output, DATE_FORMAT_LONG);
942
+
943
+        // Display the posts
944
+        echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
945
+        Blog::display_blog_posts($blog_id, $query_string);
946
+    }
947
+
948
+    /**
949
+     * Displays a post and his comments
950
+     *
951
+     * @param Integer $blog_id
952
+     * @param Integer $post_id
953
+     */
954
+    public static function display_post($blog_id, $post_id)
955
+    {
956
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
957
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
958
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
959
+
960
+        global $charset, $dateFormatLong;
961
+
962
+        $course_id = api_get_course_int_id();
963
+
964
+        // Get posts and author
965
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
967 966
 		        FROM $tbl_blogs_posts post
968 967
 					INNER JOIN $tbl_users user
969 968
 					ON post.author_id = user.user_id
@@ -972,113 +971,113 @@  discard block
 block discarded – undo
972 971
                     post.blog_id = '".(int)$blog_id."' AND
973 972
                     post.post_id = '".(int)$post_id."'
974 973
                 ORDER BY post_id DESC";
975
-		$result = Database::query($sql);
976
-		$blog_post = Database::fetch_array($result);
974
+        $result = Database::query($sql);
975
+        $blog_post = Database::fetch_array($result);
977 976
 
978
-		// Get number of comments
979
-		$sql = "SELECT COUNT(1) as number_of_comments
977
+        // Get number of comments
978
+        $sql = "SELECT COUNT(1) as number_of_comments
980 979
 		        FROM $tbl_blogs_comments
981 980
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
982
-		$result = Database::query($sql);
983
-		$blog_post_comments = Database::fetch_array($result);
981
+        $result = Database::query($sql);
982
+        $blog_post_comments = Database::fetch_array($result);
984 983
 
985
-		// Prepare data
986
-		$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
987
-		$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
988
-		$blog_post_actions = "";
984
+        // Prepare data
985
+        $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
986
+        $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
987
+        $blog_post_actions = "";
989 988
 
990
-		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
989
+        $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
991 990
 
992
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
993
-			$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') . '">';
994
-			$blog_post_actions .=  Display::return_icon('edit.png');
995
-			$blog_post_actions .= '</a>';
991
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) {
992
+            $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') . '">';
993
+            $blog_post_actions .=  Display::return_icon('edit.png');
994
+            $blog_post_actions .= '</a>';
996 995
         }
997 996
 
998
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
999
-			$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;">';
997
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
998
+            $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;">';
1000 999
             $blog_post_actions .= Display::return_icon('delete.png');
1001 1000
             $blog_post_actions .= '</a>';
1002 1001
         }
1003 1002
 
1004
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1005
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1003
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1004
+            $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1006 1005
 
1007
-		$blog_post_text=stripslashes($blog_post_text);
1006
+        $blog_post_text=stripslashes($blog_post_text);
1008 1007
 
1009
-		// Display post
1010
-		echo '<div class="blogpost">';
1011
-		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>';
1012
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1013
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1008
+        // Display post
1009
+        echo '<div class="blogpost">';
1010
+        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>';
1011
+        echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1012
+        echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1014 1013
 
1015
-		$file_name_array = get_blog_attachment($blog_id, $post_id);
1014
+        $file_name_array = get_blog_attachment($blog_id, $post_id);
1016 1015
 
1017 1016
         if (!empty($file_name_array)) {
1018
-			echo ' <br />';
1019
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1020
-			echo '<a href="download.php?file=';
1021
-			echo $file_name_array['path'];
1022
-			echo ' "> '.$file_name_array['filename'].' </a>';
1023
-			echo '</span>';
1024
-			echo '<span class="attachment_comment">';
1025
-			echo $file_name_array['comment'];
1026
-			echo '</span>';
1027
-			echo '<br />';
1028
-		}
1017
+            echo ' <br />';
1018
+            echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1019
+            echo '<a href="download.php?file=';
1020
+            echo $file_name_array['path'];
1021
+            echo ' "> '.$file_name_array['filename'].' </a>';
1022
+            echo '</span>';
1023
+            echo '<span class="attachment_comment">';
1024
+            echo $file_name_array['comment'];
1025
+            echo '</span>';
1026
+            echo '<br />';
1027
+        }
1029 1028
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1030
-		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>';
1031
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1032
-		echo '</div>';
1033
-
1034
-		// Display comments if there are any
1035
-		if($blog_post_comments['number_of_comments'] > 0) {
1036
-			echo '<div class="comments">';
1037
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1038
-				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1039
-			echo '</div>';
1040
-		}
1041
-
1042
-		// Display comment form
1043
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1044
-			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1045
-		}
1046
-	}
1047
-
1048
-	/**
1049
-	 * Adds rating to a certain post or comment
1050
-	 * @author Toon Keppens
1051
-	 *
1052
-	 * @param String $type
1053
-	 * @param Integer $blog_id
1054
-	 * @param Integer $item_id
1055
-	 * @param Integer $rating
1056
-	 *
1057
-	 * @return Boolean success
1058
-	 */
1059
-	public static function add_rating($type, $blog_id, $item_id, $rating)
1060
-	{
1061
-		$_user = api_get_user_info();
1062
-
1063
-		// Init
1064
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1065
-		$course_id = api_get_course_int_id();
1066
-
1067
-		// Check if the user has already rated this post/comment
1068
-		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1029
+        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>';
1030
+        echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1031
+        echo '</div>';
1032
+
1033
+        // Display comments if there are any
1034
+        if($blog_post_comments['number_of_comments'] > 0) {
1035
+            echo '<div class="comments">';
1036
+                echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1037
+                Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1038
+            echo '</div>';
1039
+        }
1040
+
1041
+        // Display comment form
1042
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1043
+            Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1044
+        }
1045
+    }
1046
+
1047
+    /**
1048
+     * Adds rating to a certain post or comment
1049
+     * @author Toon Keppens
1050
+     *
1051
+     * @param String $type
1052
+     * @param Integer $blog_id
1053
+     * @param Integer $item_id
1054
+     * @param Integer $rating
1055
+     *
1056
+     * @return Boolean success
1057
+     */
1058
+    public static function add_rating($type, $blog_id, $item_id, $rating)
1059
+    {
1060
+        $_user = api_get_user_info();
1061
+
1062
+        // Init
1063
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1064
+        $course_id = api_get_course_int_id();
1065
+
1066
+        // Check if the user has already rated this post/comment
1067
+        $sql = "SELECT rating_id FROM $tbl_blogs_rating
1069 1068
                 WHERE
1070 1069
                     c_id = $course_id AND
1071 1070
                     blog_id = '".(int)$blog_id."' AND
1072 1071
                     item_id = '".(int)$item_id."' AND
1073 1072
                     rating_type = '".Database::escape_string($type)."' AND
1074 1073
                     user_id = '".(int)$_user['user_id']."'";
1075
-		$result = Database::query($sql);
1074
+        $result = Database::query($sql);
1076 1075
 
1077 1076
         // Add rating
1078
-		if (Database::num_rows($result) == 0) {
1079
-			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1077
+        if (Database::num_rows($result) == 0) {
1078
+            $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1080 1079
 					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1081
-			Database::query($sql);
1080
+            Database::query($sql);
1082 1081
 
1083 1082
             $id = Database::insert_id();
1084 1083
             if ($id) {
@@ -1086,103 +1085,103 @@  discard block
 block discarded – undo
1086 1085
                 Database::query($sql);
1087 1086
             }
1088 1087
 
1089
-			return true;
1088
+            return true;
1090 1089
         } else {
1091
-			return false;
1092
-		}
1093
-	}
1094
-
1095
-	/**
1096
-	 * Shows the rating of user
1097
-	 * @param String $type
1098
-	 * @param Integer $blog_id
1099
-	 * @param Integer $item_id
1100
-	 * @return array
1101
-	 */
1102
-	public static function display_rating($type, $blog_id, $item_id)
1103
-	{
1104
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1105
-		$course_id = api_get_course_int_id();
1106
-
1107
-		// Calculate rating
1108
-		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1090
+            return false;
1091
+        }
1092
+    }
1093
+
1094
+    /**
1095
+     * Shows the rating of user
1096
+     * @param String $type
1097
+     * @param Integer $blog_id
1098
+     * @param Integer $item_id
1099
+     * @return array
1100
+     */
1101
+    public static function display_rating($type, $blog_id, $item_id)
1102
+    {
1103
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1104
+        $course_id = api_get_course_int_id();
1105
+
1106
+        // Calculate rating
1107
+        $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1109 1108
 				WHERE
1110 1109
 				    c_id = $course_id AND
1111 1110
 				    blog_id = '".(int)$blog_id."' AND
1112 1111
 				    item_id = '".(int)$item_id."' AND
1113 1112
 				    rating_type = '".Database::escape_string($type)."' ";
1114
-		$result = Database::query($sql);
1115
-		$result = Database::fetch_array($result);
1116
-		return round($result['rating'], 2);
1117
-	}
1118
-
1119
-	/**
1120
-	 * Shows the rating form if not already rated by that user
1121
-	 * @author Toon Keppens
1122
-	 *
1123
-	 * @param String $type
1124
-	 * @param Integer $blog_id
1125
-	 * @param integer $post_id
1126
-	 */
1127
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1128
-	{
1129
-		$_user = api_get_user_info();
1130
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1113
+        $result = Database::query($sql);
1114
+        $result = Database::fetch_array($result);
1115
+        return round($result['rating'], 2);
1116
+    }
1117
+
1118
+    /**
1119
+     * Shows the rating form if not already rated by that user
1120
+     * @author Toon Keppens
1121
+     *
1122
+     * @param String $type
1123
+     * @param Integer $blog_id
1124
+     * @param integer $post_id
1125
+     */
1126
+    public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1127
+    {
1128
+        $_user = api_get_user_info();
1129
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1131 1130
         $course_id = api_get_course_int_id();
1132 1131
 
1133 1132
         if ($type == 'post') {
1134
-			// Check if the user has already rated this post
1135
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1133
+            // Check if the user has already rated this post
1134
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1136 1135
 					WHERE c_id = $course_id AND
1137 1136
 					blog_id = '".(int)$blog_id."'
1138 1137
 					AND item_id = '".(int)$post_id."'
1139 1138
 					AND rating_type = '".Database::escape_string($type)."'
1140 1139
 					AND user_id = '".(int)$_user['user_id']."'";
1141
-			$result = Database::query($sql);
1140
+            $result = Database::query($sql);
1142 1141
             // Add rating
1143 1142
             if (Database::num_rows($result) == 0) {
1144
-				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>';
1143
+                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>';
1145 1144
             } else {
1146
-				return '';
1147
-			}
1148
-		}
1145
+                return '';
1146
+            }
1147
+        }
1149 1148
 
1150 1149
         if ($type = 'comment') {
1151
-			// Check if the user has already rated this comment
1152
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1150
+            // Check if the user has already rated this comment
1151
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1153 1152
 					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1154 1153
 					AND item_id = '".(int)$comment_id."'
1155 1154
 					AND rating_type = '".Database::escape_string($type)."'
1156 1155
 					AND user_id = '".(int)$_user['user_id']."'";
1157
-			$result = Database::query($sql);
1156
+            $result = Database::query($sql);
1158 1157
 
1159 1158
             if (Database::num_rows($result) == 0) {
1160
-				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>';
1159
+                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>';
1161 1160
             } else {
1162
-				return '';
1163
-			}
1164
-		}
1165
-	}
1166
-
1167
-	/**
1168
-	 * This functions gets all replys to a post, threaded.
1169
-	 *
1170
-	 * @param Integer $current
1171
-	 * @param Integer $current_level
1172
-	 * @param Integer $blog_id
1173
-	 * @param Integer $post_id
1174
-	 */
1175
-	public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1176
-	{
1177
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1178
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1179
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1180
-		global $charset;
1181
-
1182
-		$course_id = api_get_course_int_id();
1183
-
1184
-		// Select top level comments
1185
-		$next_level = $current_level + 1;
1161
+                return '';
1162
+            }
1163
+        }
1164
+    }
1165
+
1166
+    /**
1167
+     * This functions gets all replys to a post, threaded.
1168
+     *
1169
+     * @param Integer $current
1170
+     * @param Integer $current_level
1171
+     * @param Integer $blog_id
1172
+     * @param Integer $post_id
1173
+     */
1174
+    public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1175
+    {
1176
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1177
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1178
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1179
+        global $charset;
1180
+
1181
+        $course_id = api_get_course_int_id();
1182
+
1183
+        // Select top level comments
1184
+        $next_level = $current_level + 1;
1186 1185
         $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color
1187 1186
                 FROM $tbl_blogs_comments comments
1188 1187
                 INNER JOIN $tbl_users user
@@ -1194,11 +1193,11 @@  discard block
 block discarded – undo
1194 1193
                     parent_comment_id = $current AND
1195 1194
                     comments.blog_id = '".(int)$blog_id."' AND
1196 1195
                     comments.post_id = '".(int)$post_id."'";
1197
-		$result = Database::query($sql);
1196
+        $result = Database::query($sql);
1198 1197
 
1199
-		while($comment = Database::fetch_array($result)) {
1200
-			// Select the children recursivly
1201
-			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1198
+        while($comment = Database::fetch_array($result)) {
1199
+            // Select the children recursivly
1200
+            $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1202 1201
 			        FROM $tbl_blogs_comments comments
1203 1202
 					INNER JOIN $tbl_users user
1204 1203
 					ON comments.author_id = user.user_id
@@ -1207,15 +1206,15 @@  discard block
 block discarded – undo
1207 1206
 						comment_id = $current
1208 1207
 						AND blog_id = '".(int)$blog_id."'
1209 1208
 						AND post_id = '".(int)$post_id."'";
1210
-			$tmp = Database::query($tmp);
1211
-			$tmp = Database::fetch_array($tmp);
1212
-			$parent_cat = $tmp['parent_comment_id'];
1213
-			$border_color = '';
1214
-
1215
-			// Prepare data
1216
-			$comment_text = make_clickable(stripslashes($comment['comment']));
1217
-			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1218
-			$blog_comment_actions = "";
1209
+            $tmp = Database::query($tmp);
1210
+            $tmp = Database::fetch_array($tmp);
1211
+            $parent_cat = $tmp['parent_comment_id'];
1212
+            $border_color = '';
1213
+
1214
+            // Prepare data
1215
+            $comment_text = make_clickable(stripslashes($comment['comment']));
1216
+            $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1217
+            $blog_comment_actions = "";
1219 1218
             if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) {
1220 1219
                 $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(
1221 1220
                         'DeleteThisComment'
@@ -1230,167 +1229,167 @@  discard block
 block discarded – undo
1230 1229
                 $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']);
1231 1230
             }
1232 1231
 
1233
-			if (!is_null($comment['task_id'])) {
1234
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1235
-			}
1236
-
1237
-			$comment_text = stripslashes($comment_text);
1238
-
1239
-			// Output...
1240
-			$margin = $current_level * 30;
1241
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1242
-				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>';
1243
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1244
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1245
-
1246
-				$file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1247
-				if (!empty($file_name_array)) {
1248
-					echo '<br /><br />';
1249
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1250
-					echo '<a href="download.php?file=';
1251
-					echo $file_name_array['path'];
1252
-					echo ' "> '.$file_name_array['filename'].' </a>';
1253
-					echo '<span class="attachment_comment">';
1254
-					echo $file_name_array['comment'];
1255
-					echo '</span><br />';
1256
-				}
1257
-                $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1258
-				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>';
1259
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1260
-			echo '</div>';
1261
-
1262
-			// Go further down the tree.
1263
-			Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1264
-		}
1265
-	}
1266
-
1267
-	/**
1268
-	 * Displays the form to create a new post
1269
-	 * @author Toon Keppens
1270
-	 *
1271
-	 * @param Integer $blog_id
1272
-	 */
1273
-	public static function display_form_new_post($blog_id)
1274
-	{
1275
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1276
-			$form = new FormValidator(
1277
-				'add_post',
1278
-				'post',
1279
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1280
-				null,
1281
-				array('enctype' => 'multipart/form-data')
1282
-			);
1283
-			$form->addHidden('post_title_edited', 'false');
1284
-			$form->addHeader(get_lang('NewPost'));
1285
-			$form->addText('title', get_lang('Title'));
1286
-			$config = array();
1287
-			if (!api_is_allowed_to_edit()) {
1288
-				$config['ToolbarSet'] = 'ProjectStudent';
1289
-			} else {
1290
-				$config['ToolbarSet'] = 'Project';
1291
-			}
1292
-			$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1293
-			$form->addFile('user_upload', get_lang('AddAnAttachment'));
1294
-			$form->addTextarea('post_file_comment', get_lang('FileComment'));
1295
-			$form->addHidden('new_post_submit', 'true');
1296
-			$form->addButton('save', get_lang('Save'));
1297
-
1298
-			$form->display();
1299
-		} else {
1300
-			api_not_allowed();
1301
-		}
1302
-	}
1303
-
1304
-	/**
1305
-	 * Displays the form to edit a post
1306
-	 * @author Toon Keppens
1307
-	 *
1308
-	 * @param Integer $blog_id
1309
-	 */
1310
-	public static function display_form_edit_post($blog_id, $post_id)
1311
-	{
1312
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1313
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1314
-
1315
-		$course_id = api_get_course_int_id();
1316
-
1317
-		// Get posts and author
1318
-		$sql = "SELECT post.*, user.lastname, user.firstname
1319
-				FROM $tbl_blogs_posts post
1320
-				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1321
-				WHERE
1322
-				post.c_id 			= $course_id AND
1323
-				post.blog_id 		= '".(int)$blog_id ."'
1324
-				AND post.post_id	= '".(int)$post_id."'
1325
-				ORDER BY post_id DESC";
1326
-		$result = Database::query($sql);
1327
-		$blog_post = Database::fetch_array($result);
1328
-
1329
-		// Form
1330
-		$form = new FormValidator(
1331
-			'edit_post',
1332
-			'post',
1333
-			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'])
1334
-		);
1335
-
1336
-		$form->addHeader(get_lang('EditPost'));
1337
-		$form->addText('title', get_lang('Title'));
1338
-
1339
-		if (!api_is_allowed_to_edit()) {
1340
-			$config['ToolbarSet'] = 'ProjectStudent';
1341
-		} else {
1342
-			$config['ToolbarSet'] = 'Project';
1343
-		}
1344
-		$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1345
-
1346
-		$form->addHidden('action', '');
1347
-		$form->addHidden('edit_post_submit', 'true');
1348
-		$form->addHidden('post_id', intval($_GET['post_id']));
1349
-		$form->addButton('save', get_lang('Save'));
1350
-		$form->setDefaults($blog_post);
1351
-		$form->display();
1352
-	}
1353
-
1354
-	/**
1355
-	 * Displays a list of tasks in this blog
1356
-	 * @author Toon Keppens
1357
-	 *
1358
-	 * @param Integer $blog_id
1359
-	 */
1360
-	public static function display_task_list($blog_id)
1232
+            if (!is_null($comment['task_id'])) {
1233
+                $border_color = ' border-left: 3px solid #' . $comment['color'];
1234
+            }
1235
+
1236
+            $comment_text = stripslashes($comment_text);
1237
+
1238
+            // Output...
1239
+            $margin = $current_level * 30;
1240
+            echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1241
+                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>';
1242
+                echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1243
+                echo '<span class="blogpost_text">' . $comment_text . '</span>';
1244
+
1245
+                $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1246
+                if (!empty($file_name_array)) {
1247
+                    echo '<br /><br />';
1248
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1249
+                    echo '<a href="download.php?file=';
1250
+                    echo $file_name_array['path'];
1251
+                    echo ' "> '.$file_name_array['filename'].' </a>';
1252
+                    echo '<span class="attachment_comment">';
1253
+                    echo $file_name_array['comment'];
1254
+                    echo '</span><br />';
1255
+                }
1256
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1257
+                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>';
1258
+                echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1259
+            echo '</div>';
1260
+
1261
+            // Go further down the tree.
1262
+            Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1263
+        }
1264
+    }
1265
+
1266
+    /**
1267
+     * Displays the form to create a new post
1268
+     * @author Toon Keppens
1269
+     *
1270
+     * @param Integer $blog_id
1271
+     */
1272
+    public static function display_form_new_post($blog_id)
1273
+    {
1274
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1275
+            $form = new FormValidator(
1276
+                'add_post',
1277
+                'post',
1278
+                api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1279
+                null,
1280
+                array('enctype' => 'multipart/form-data')
1281
+            );
1282
+            $form->addHidden('post_title_edited', 'false');
1283
+            $form->addHeader(get_lang('NewPost'));
1284
+            $form->addText('title', get_lang('Title'));
1285
+            $config = array();
1286
+            if (!api_is_allowed_to_edit()) {
1287
+                $config['ToolbarSet'] = 'ProjectStudent';
1288
+            } else {
1289
+                $config['ToolbarSet'] = 'Project';
1290
+            }
1291
+            $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1292
+            $form->addFile('user_upload', get_lang('AddAnAttachment'));
1293
+            $form->addTextarea('post_file_comment', get_lang('FileComment'));
1294
+            $form->addHidden('new_post_submit', 'true');
1295
+            $form->addButton('save', get_lang('Save'));
1296
+
1297
+            $form->display();
1298
+        } else {
1299
+            api_not_allowed();
1300
+        }
1301
+    }
1302
+
1303
+    /**
1304
+     * Displays the form to edit a post
1305
+     * @author Toon Keppens
1306
+     *
1307
+     * @param Integer $blog_id
1308
+     */
1309
+    public static function display_form_edit_post($blog_id, $post_id)
1310
+    {
1311
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1312
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1313
+
1314
+        $course_id = api_get_course_int_id();
1315
+
1316
+        // Get posts and author
1317
+        $sql = "SELECT post.*, user.lastname, user.firstname
1318
+				FROM $tbl_blogs_posts post
1319
+				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1320
+				WHERE
1321
+				post.c_id 			= $course_id AND
1322
+				post.blog_id 		= '".(int)$blog_id ."'
1323
+				AND post.post_id	= '".(int)$post_id."'
1324
+				ORDER BY post_id DESC";
1325
+        $result = Database::query($sql);
1326
+        $blog_post = Database::fetch_array($result);
1327
+
1328
+        // Form
1329
+        $form = new FormValidator(
1330
+            'edit_post',
1331
+            'post',
1332
+            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'])
1333
+        );
1334
+
1335
+        $form->addHeader(get_lang('EditPost'));
1336
+        $form->addText('title', get_lang('Title'));
1337
+
1338
+        if (!api_is_allowed_to_edit()) {
1339
+            $config['ToolbarSet'] = 'ProjectStudent';
1340
+        } else {
1341
+            $config['ToolbarSet'] = 'Project';
1342
+        }
1343
+        $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1344
+
1345
+        $form->addHidden('action', '');
1346
+        $form->addHidden('edit_post_submit', 'true');
1347
+        $form->addHidden('post_id', intval($_GET['post_id']));
1348
+        $form->addButton('save', get_lang('Save'));
1349
+        $form->setDefaults($blog_post);
1350
+        $form->display();
1351
+    }
1352
+
1353
+    /**
1354
+     * Displays a list of tasks in this blog
1355
+     * @author Toon Keppens
1356
+     *
1357
+     * @param Integer $blog_id
1358
+     */
1359
+    public static function display_task_list($blog_id)
1361 1360
     {
1362
-		global $charset;
1361
+        global $charset;
1363 1362
         $course_id = api_get_course_int_id();
1364 1363
 
1365
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1366
-			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1367
-			$counter = 0;
1368
-			global $color2;
1364
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1365
+            $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1366
+            $counter = 0;
1367
+            global $color2;
1369 1368
 
1370
-			echo '<div class="actions">';
1371
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">';
1369
+            echo '<div class="actions">';
1370
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">';
1372 1371
             echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks'));
1373 1372
             echo get_lang('AddTasks') . '</a> ';
1374
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">';
1373
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">';
1375 1374
             echo Display::return_icon('blog_task.gif', get_lang('AssignTasks'));
1376 1375
             echo get_lang('AssignTasks') . '</a>';
1377
-			?>
1376
+            ?>
1378 1377
 				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>">
1379 1378
                     <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1380 1379
 			<?php
1381
-			echo '</div>';
1380
+            echo '</div>';
1382 1381
 
1383
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1384
-			echo "<table class=\"data_table\">";
1385
-			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1386
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>",
1387
-					 "<th><b>",get_lang('Description'),"</b></th>",
1388
-					 "<th><b>",get_lang('Color'),"</b></th>",
1389
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>",
1390
-				"</tr>";
1382
+            echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1383
+            echo "<table class=\"data_table\">";
1384
+            echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1385
+                        "<th width='240'><b>",get_lang('Title'),"</b></th>",
1386
+                        "<th><b>",get_lang('Description'),"</b></th>",
1387
+                        "<th><b>",get_lang('Color'),"</b></th>",
1388
+                        "<th width='50'><b>",get_lang('Modify'),"</b></th>",
1389
+                "</tr>";
1391 1390
 
1392 1391
 
1393
-			$sql = " SELECT
1392
+            $sql = " SELECT
1394 1393
                         blog_id,
1395 1394
                         task_id,
1396 1395
                         blog_id,
@@ -1401,64 +1400,64 @@  discard block
 block discarded – undo
1401 1400
                     FROM " . $tbl_blogs_tasks . "
1402 1401
                     WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1403 1402
                     ORDER BY system_task, title";
1404
-			$result = Database::query($sql);
1403
+            $result = Database::query($sql);
1405 1404
 
1406
-			while ($task = Database::fetch_array($result)) {
1407
-				$counter++;
1408
-				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1409
-				$delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png";
1410
-				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1411
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1412
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1405
+            while ($task = Database::fetch_array($result)) {
1406
+                $counter++;
1407
+                $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1408
+                $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png";
1409
+                $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1410
+                $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1411
+                $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1413 1412
 
1414
-				echo '<tr class="' . $css_class . '" valign="top">';
1413
+                echo '<tr class="' . $css_class . '" valign="top">';
1415 1414
                 echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>';
1416 1415
                 echo '<td>'.Security::remove_XSS($task['description']).'</td>';
1417 1416
                 echo '<td><span style="background-color: #'.$task['color'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>';
1418 1417
                 echo '<td width="50">';
1419 1418
                 echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">';
1420 1419
                 echo Display::return_icon('edit.png', get_lang('EditTask'));
1421
-                      echo "</a>";
1422
-                      echo '<a href="'.$delete_link.'"';
1423
-                      echo $delete_confirm;
1424
-                       echo '>';
1420
+                        echo "</a>";
1421
+                        echo '<a href="'.$delete_link.'"';
1422
+                        echo $delete_confirm;
1423
+                        echo '>';
1425 1424
                         echo Display::return_icon($delete_icon, $delete_title);
1426
-                       echo "</a>";
1427
-                     echo '</td>';
1428
-                   echo '</tr>';
1429
-			}
1430
-			echo "</table>";
1431
-		}
1432
-	}
1433
-
1434
-	/**
1435
-	 * Displays a list of tasks assigned to a user in this blog
1436
-	 * @author Toon Keppens
1437
-	 *
1438
-	 * @param Integer $blog_id
1439
-	 */
1440
-	public static function display_assigned_task_list ($blog_id)
1425
+                        echo "</a>";
1426
+                        echo '</td>';
1427
+                    echo '</tr>';
1428
+            }
1429
+            echo "</table>";
1430
+        }
1431
+    }
1432
+
1433
+    /**
1434
+     * Displays a list of tasks assigned to a user in this blog
1435
+     * @author Toon Keppens
1436
+     *
1437
+     * @param Integer $blog_id
1438
+     */
1439
+    public static function display_assigned_task_list ($blog_id)
1441 1440
     {
1442
-		// Init
1443
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1444
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1445
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1446
-		$counter = 0;
1447
-		global $charset,$color2;
1448
-
1449
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1450
-		echo "<table class=\"data_table\">";
1451
-		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1452
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>",
1453
-				 "<th><b>",get_lang('Task'),"</b></th>",
1454
-				 "<th><b>",get_lang('Description'),"</b></th>",
1455
-				 "<th><b>",get_lang('TargetDate'),"</b></th>",
1456
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>",
1457
-			"</tr>";
1458
-
1459
-		$course_id = api_get_course_int_id();
1460
-
1461
-		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1441
+        // Init
1442
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1443
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1444
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1445
+        $counter = 0;
1446
+        global $charset,$color2;
1447
+
1448
+        echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1449
+        echo "<table class=\"data_table\">";
1450
+        echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1451
+                    "<th width='240'><b>",get_lang('Member'),"</b></th>",
1452
+                    "<th><b>",get_lang('Task'),"</b></th>",
1453
+                    "<th><b>",get_lang('Description'),"</b></th>",
1454
+                    "<th><b>",get_lang('TargetDate'),"</b></th>",
1455
+                    "<th width='50'><b>",get_lang('Modify'),"</b></th>",
1456
+            "</tr>";
1457
+
1458
+        $course_id = api_get_course_int_id();
1459
+
1460
+        $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1462 1461
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
1463 1462
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
1464 1463
 				INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
@@ -1467,15 +1466,15 @@  discard block
 block discarded – undo
1467 1466
 					task.c_id = $course_id AND
1468 1467
 					task_rel_user.blog_id = '".(int)$blog_id."'
1469 1468
 				ORDER BY target_date ASC";
1470
-		$result = Database::query($sql);
1469
+        $result = Database::query($sql);
1471 1470
 
1472
-		while ($assignment = Database::fetch_array($result)) {
1473
-			$counter++;
1474
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1475
-			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png";
1476
-			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1477
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1478
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1471
+        while ($assignment = Database::fetch_array($result)) {
1472
+            $counter++;
1473
+            $css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1474
+            $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png";
1475
+            $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1476
+            $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1477
+            $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1479 1478
 
1480 1479
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1481 1480
 
@@ -1490,26 +1489,26 @@  discard block
 block discarded – undo
1490 1489
             echo '<td>'.$assignment['target_date'].'</td>';
1491 1490
             echo '<td width="50">';
1492 1491
             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'].'">';
1493
-	            echo Display::return_icon('edit.png', get_lang('EditTask'));
1494
-				echo "</a>";
1495
-				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'].'" ';
1496
-				echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1492
+                echo Display::return_icon('edit.png', get_lang('EditTask'));
1493
+                echo "</a>";
1494
+                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'].'" ';
1495
+                echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1497 1496
                 echo Display::return_icon($delete_icon, $delete_title);
1498
-				echo "</a>";
1499
-				echo '</td>';
1500
-				echo '</tr>';
1501
-		}
1502
-		echo "</table>";
1503
-	}
1504
-
1505
-	/**
1506
-	 * Displays new task form
1507
-	 * @author Toon Keppens
1508
-	 *
1509
-	 */
1510
-	public static function display_new_task_form ($blog_id)
1511
-	{
1512
-		// Init
1497
+                echo "</a>";
1498
+                echo '</td>';
1499
+                echo '</tr>';
1500
+        }
1501
+        echo "</table>";
1502
+    }
1503
+
1504
+    /**
1505
+     * Displays new task form
1506
+     * @author Toon Keppens
1507
+     *
1508
+     */
1509
+    public static function display_new_task_form ($blog_id)
1510
+    {
1511
+        // Init
1513 1512
         $colors = array(
1514 1513
             'FFFFFF',
1515 1514
             'FFFF99',
@@ -1528,14 +1527,14 @@  discard block
 block discarded – undo
1528 1527
             '000000'
1529 1528
         );
1530 1529
 
1531
-		// form
1532
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1530
+        // form
1531
+        echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1533 1532
 
1534
-		// form title
1535
-		echo '<legend>'.get_lang('AddTask').'</legend>';
1533
+        // form title
1534
+        echo '<legend>'.get_lang('AddTask').'</legend>';
1536 1535
 
1537
-		// task title
1538
-		echo '	<div class="control-group">
1536
+        // task title
1537
+        echo '	<div class="control-group">
1539 1538
 					<label class="control-label">
1540 1539
 						<span class="form_required">*</span>' . get_lang('Title') . '
1541 1540
 					</label>
@@ -1544,8 +1543,8 @@  discard block
 block discarded – undo
1544 1543
 					</div>
1545 1544
 				</div>';
1546 1545
 
1547
-		// task comment
1548
-		echo '	<div class="control-group">
1546
+        // task comment
1547
+        echo '	<div class="control-group">
1549 1548
 					<label class="control-label">
1550 1549
 						' . get_lang('Description') . '
1551 1550
 					</label>
@@ -1554,8 +1553,8 @@  discard block
 block discarded – undo
1554 1553
 					</div>
1555 1554
 				</div>';
1556 1555
 
1557
-		// task management
1558
-		echo '	<div class="control-group">
1556
+        // task management
1557
+        echo '	<div class="control-group">
1559 1558
 					<label class="control-label">
1560 1559
 						' . get_lang('TaskManager') . '
1561 1560
 					</label>
@@ -1576,12 +1575,12 @@  discard block
 block discarded – undo
1576 1575
                         echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1577 1576
                     echo '</tr>';
1578 1577
                 echo '</table>';
1579
-		echo '		</div>
1578
+        echo '		</div>
1580 1579
 				</div>';
1581 1580
 
1582 1581
 
1583
-		// task color
1584
-		echo '	<div class="control-group">
1582
+        // task color
1583
+        echo '	<div class="control-group">
1585 1584
 					<label class="control-label">
1586 1585
 						' . get_lang('Color') . '
1587 1586
 					</label>
@@ -1592,40 +1591,40 @@  discard block
 block discarded – undo
1592 1591
                     echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1593 1592
                 }
1594 1593
         echo '</select>';
1595
-		echo '		</div>
1594
+        echo '		</div>
1596 1595
 				</div>';
1597 1596
 
1598
-		// submit
1599
-		echo '	<div class="control-group">
1597
+        // submit
1598
+        echo '	<div class="control-group">
1600 1599
 					<div class="controls">
1601 1600
 							<input type="hidden" name="action" value="" />
1602 1601
 							<input type="hidden" name="new_task_submit" value="true" />
1603 1602
 						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1604 1603
 					</div>
1605 1604
 				</div>';
1606
-		echo '</form>';
1605
+        echo '</form>';
1607 1606
 
1608
-		echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1609
-	}
1607
+        echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1608
+    }
1610 1609
 
1611 1610
 
1612
-	/**
1613
-	 * Displays edit task form
1614
-	 * @author Toon Keppens
1615
-	 *
1616
-	 */
1617
-	public static function display_edit_task_form ($blog_id, $task_id) {
1618
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1611
+    /**
1612
+     * Displays edit task form
1613
+     * @author Toon Keppens
1614
+     *
1615
+     */
1616
+    public static function display_edit_task_form ($blog_id, $task_id) {
1617
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1619 1618
         $course_id = api_get_course_int_id();
1620 1619
 
1621
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1620
+        $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1622 1621
 
1623
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1624
-		$result = Database::query($sql);
1625
-		$task = Database::fetch_array($result);
1622
+        $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1623
+        $result = Database::query($sql);
1624
+        $task = Database::fetch_array($result);
1626 1625
 
1627
-		// Display
1628
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1626
+        // Display
1627
+        echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1629 1628
 					<legend>' . get_lang('EditTask') . '</legend>
1630 1629
 					<table width="100%" border="0" cellspacing="2">
1631 1630
 						<tr>
@@ -1637,42 +1636,42 @@  discard block
 block discarded – undo
1637 1636
 					   <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td>
1638 1637
 						</tr>';
1639 1638
 
1640
-						/* edit by Kevin Van Den Haute ([email protected]) */
1641
-						$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1639
+                        /* edit by Kevin Van Den Haute ([email protected]) */
1640
+                        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1642 1641
 
1643
-						$sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1642
+                        $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1644 1643
 							     WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
1645
-						$result = Database::query($sql);
1646
-
1647
-						$arrPermissions = array();
1648
-
1649
-						while ($row = Database::fetch_array($result))
1650
-							$arrPermissions[] = $row['action'];
1651
-
1652
-						    echo '<tr>';
1653
-							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1654
-							echo '<td>';
1655
-								echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1656
-									echo '<tr>';
1657
-										echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1658
-										echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1659
-									echo '</tr>';
1660
-									echo '<tr>';
1661
-										echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1662
-										echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1663
-										echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1664
-									echo '</tr>';
1665
-									echo '<tr>';
1666
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1667
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1668
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1669
-									echo '</tr>';
1670
-								echo '</table>';
1671
-							echo '</td>';
1672
-						echo '</tr>';
1673
-						/* end of edit */
1674
-
1675
-						echo '<tr>
1644
+                        $result = Database::query($sql);
1645
+
1646
+                        $arrPermissions = array();
1647
+
1648
+                        while ($row = Database::fetch_array($result))
1649
+                            $arrPermissions[] = $row['action'];
1650
+
1651
+                            echo '<tr>';
1652
+                            echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1653
+                            echo '<td>';
1654
+                                echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1655
+                                    echo '<tr>';
1656
+                                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1657
+                                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1658
+                                    echo '</tr>';
1659
+                                    echo '<tr>';
1660
+                                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1661
+                                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1662
+                                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1663
+                                    echo '</tr>';
1664
+                                    echo '<tr>';
1665
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1666
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1667
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1668
+                                    echo '</tr>';
1669
+                                echo '</table>';
1670
+                            echo '</td>';
1671
+                        echo '</tr>';
1672
+                        /* end of edit */
1673
+
1674
+                        echo '<tr>
1676 1675
 					   <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
1677 1676
 					   <td>
1678 1677
 					   	<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">';
@@ -1681,7 +1680,7 @@  discard block
 block discarded – undo
1681 1680
                                 $style = 'style="background-color: #' . $color . '"';
1682 1681
                                 echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1683 1682
                             }
1684
-		echo '			   </select>
1683
+        echo '			   </select>
1685 1684
 						  </td>
1686 1685
 						</tr>
1687 1686
 						<tr>
@@ -1694,34 +1693,34 @@  discard block
 block discarded – undo
1694 1693
 						</tr>
1695 1694
 					</table>
1696 1695
 				</form>';
1697
-	}
1698
-
1699
-	/**
1700
-	 * @param $blog_id
1701
-	 * @return FormValidator
1702
-	 */
1703
-	public static function getTaskForm($blog_id)
1704
-	{
1705
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1706
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1707
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1708
-		$course_id = api_get_course_int_id();
1709
-
1710
-		// Get users in this blog / make select list of it
1711
-		$sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1696
+    }
1697
+
1698
+    /**
1699
+     * @param $blog_id
1700
+     * @return FormValidator
1701
+     */
1702
+    public static function getTaskForm($blog_id)
1703
+    {
1704
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1705
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1706
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1707
+        $course_id = api_get_course_int_id();
1708
+
1709
+        // Get users in this blog / make select list of it
1710
+        $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1712 1711
 				FROM $tbl_users user
1713 1712
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1714 1713
 				ON user.user_id = blogs_rel_user.user_id
1715 1714
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1716
-		$result = Database::query($sql);
1715
+        $result = Database::query($sql);
1717 1716
 
1718
-		$options = array();
1719
-		while ($user = Database::fetch_array($result)) {
1720
-			$options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1721
-		}
1717
+        $options = array();
1718
+        while ($user = Database::fetch_array($result)) {
1719
+            $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1720
+        }
1722 1721
 
1723
-		// Get tasks in this blog / make select list of it
1724
-		$sql = "
1722
+        // Get tasks in this blog / make select list of it
1723
+        $sql = "
1725 1724
 			SELECT
1726 1725
 				blog_id,
1727 1726
 				task_id,
@@ -1733,97 +1732,97 @@  discard block
 block discarded – undo
1733 1732
 			FROM $tbl_blogs_tasks
1734 1733
 			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1735 1734
 			ORDER BY system_task, title";
1736
-		$result = Database::query($sql);
1737
-
1738
-		$taskOptions = array();
1739
-		while ($task = Database::fetch_array($result)) {
1740
-			$taskOptions[$task['task_id']] = stripslashes($task['title']);
1741
-		}
1742
-
1743
-		$form = new FormValidator(
1744
-			'assign_task',
1745
-			'post',
1746
-			api_get_path(
1747
-				WEB_CODE_PATH
1748
-			).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1749
-		);
1750
-
1751
-		$form->addHeader(get_lang('AssignTask'));
1752
-		$form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1753
-		$form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1754
-		$form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1755
-
1756
-		$form->addHidden('action', '');
1757
-		$form->addButtonSave(get_lang('Ok'));
1758
-
1759
-		return $form;
1760
-	}
1761
-
1762
-	/**
1763
-	 * Displays assign task form
1764
-	 * @author Toon Keppens
1765
-	 *
1766
-	 */
1767
-	public static function display_assign_task_form($blog_id)
1768
-	{
1769
-		$form = self::getTaskForm($blog_id);
1770
-		$form->addHidden('assign_task_submit', 'true');
1771
-		$form->display();
1772
-		echo '<div style="clear: both; margin-bottom:10px;"></div>';
1773
-	}
1774
-
1775
-	/**
1776
-	 * Displays assign task form
1777
-	 * @author Toon Keppens
1778
-	 *
1779
-	 */
1780
-	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1781
-	{
1782
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1783
-
1784
-		$course_id = api_get_course_int_id();
1785
-
1786
-		// Get assignd date;
1787
-		$sql = "
1735
+        $result = Database::query($sql);
1736
+
1737
+        $taskOptions = array();
1738
+        while ($task = Database::fetch_array($result)) {
1739
+            $taskOptions[$task['task_id']] = stripslashes($task['title']);
1740
+        }
1741
+
1742
+        $form = new FormValidator(
1743
+            'assign_task',
1744
+            'post',
1745
+            api_get_path(
1746
+                WEB_CODE_PATH
1747
+            ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1748
+        );
1749
+
1750
+        $form->addHeader(get_lang('AssignTask'));
1751
+        $form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1752
+        $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1753
+        $form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1754
+
1755
+        $form->addHidden('action', '');
1756
+        $form->addButtonSave(get_lang('Ok'));
1757
+
1758
+        return $form;
1759
+    }
1760
+
1761
+    /**
1762
+     * Displays assign task form
1763
+     * @author Toon Keppens
1764
+     *
1765
+     */
1766
+    public static function display_assign_task_form($blog_id)
1767
+    {
1768
+        $form = self::getTaskForm($blog_id);
1769
+        $form->addHidden('assign_task_submit', 'true');
1770
+        $form->display();
1771
+        echo '<div style="clear: both; margin-bottom:10px;"></div>';
1772
+    }
1773
+
1774
+    /**
1775
+     * Displays assign task form
1776
+     * @author Toon Keppens
1777
+     *
1778
+     */
1779
+    public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1780
+    {
1781
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1782
+
1783
+        $course_id = api_get_course_int_id();
1784
+
1785
+        // Get assignd date;
1786
+        $sql = "
1788 1787
 			SELECT target_date
1789 1788
 			FROM $tbl_blogs_tasks_rel_user
1790 1789
 			WHERE c_id = $course_id AND
1791 1790
 			      blog_id = '".(int)$blog_id."' AND
1792 1791
 			      user_id = '".(int)$user_id."' AND
1793 1792
 			      task_id = '".(int)$task_id."'";
1794
-		$result = Database::query($sql);
1795
-		$row = Database::fetch_assoc($result);
1796
-
1797
-		$date = $row['target_date'];
1798
-
1799
-		$defaults = [
1800
-			'task_user_id' => $user_id,
1801
-			'task_task_id' => $task_id,
1802
-			'task_day' => $date
1803
-		];
1804
-		$form = self::getTaskForm($blog_id);
1805
-		$form->addHidden('old_task_id', $task_id);
1806
-		$form->addHidden('old_user_id', $user_id);
1807
-		$form->addHidden('old_target_date', $date);
1808
-		$form->addHidden('assign_task_edit_submit', 'true');
1809
-		$form->setDefaults($defaults);
1810
-		$form->display();
1811
-	}
1812
-
1813
-	/**
1814
-	 * Assigns a task to a user in a blog
1815
-	 *
1816
-	 * @param Integer $blog_id
1817
-	 * @param Integer $user_id
1818
-	 * @param Integer $task_id
1819
-	 * @param Date $target_date
1820
-	 */
1821
-	public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1822
-	{
1823
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1824
-		$course_id = api_get_course_int_id();
1825
-
1826
-		$sql = "
1793
+        $result = Database::query($sql);
1794
+        $row = Database::fetch_assoc($result);
1795
+
1796
+        $date = $row['target_date'];
1797
+
1798
+        $defaults = [
1799
+            'task_user_id' => $user_id,
1800
+            'task_task_id' => $task_id,
1801
+            'task_day' => $date
1802
+        ];
1803
+        $form = self::getTaskForm($blog_id);
1804
+        $form->addHidden('old_task_id', $task_id);
1805
+        $form->addHidden('old_user_id', $user_id);
1806
+        $form->addHidden('old_target_date', $date);
1807
+        $form->addHidden('assign_task_edit_submit', 'true');
1808
+        $form->setDefaults($defaults);
1809
+        $form->display();
1810
+    }
1811
+
1812
+    /**
1813
+     * Assigns a task to a user in a blog
1814
+     *
1815
+     * @param Integer $blog_id
1816
+     * @param Integer $user_id
1817
+     * @param Integer $task_id
1818
+     * @param Date $target_date
1819
+     */
1820
+    public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1821
+    {
1822
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1823
+        $course_id = api_get_course_int_id();
1824
+
1825
+        $sql = "
1827 1826
 			SELECT COUNT(*) as 'number'
1828 1827
 			FROM " . $tbl_blogs_tasks_rel_user . "
1829 1828
 			WHERE c_id = $course_id AND
@@ -1832,11 +1831,11 @@  discard block
 block discarded – undo
1832 1831
 			AND	task_id = " . (int)$task_id . "
1833 1832
 		";
1834 1833
 
1835
-		$result = Database::query($sql);
1836
-		$row = Database::fetch_assoc($result);
1834
+        $result = Database::query($sql);
1835
+        $row = Database::fetch_assoc($result);
1837 1836
 
1838
-		if ($row['number'] == 0) {
1839
-			$sql = "
1837
+        if ($row['number'] == 0) {
1838
+            $sql = "
1840 1839
 				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1841 1840
 					c_id,
1842 1841
 					blog_id,
@@ -1851,9 +1850,9 @@  discard block
 block discarded – undo
1851 1850
 					'" . Database::escape_string($target_date) . "'
1852 1851
 				)";
1853 1852
 
1854
-			Database::query($sql);
1855
-		}
1856
-	}
1853
+            Database::query($sql);
1854
+        }
1855
+    }
1857 1856
 
1858 1857
     /**
1859 1858
      * @param $blog_id
@@ -1873,11 +1872,11 @@  discard block
 block discarded – undo
1873 1872
         $old_task_id,
1874 1873
         $old_target_date
1875 1874
     ) {
1876
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1875
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1877 1876
 
1878
-		$course_id = api_get_course_int_id();
1877
+        $course_id = api_get_course_int_id();
1879 1878
 
1880
-		$sql = "SELECT COUNT(*) as 'number'
1879
+        $sql = "SELECT COUNT(*) as 'number'
1881 1880
                 FROM " . $tbl_blogs_tasks_rel_user . "
1882 1881
                 WHERE
1883 1882
                     c_id = $course_id AND
@@ -1886,11 +1885,11 @@  discard block
 block discarded – undo
1886 1885
                     task_id = " . (int)$task_id . "
1887 1886
             ";
1888 1887
 
1889
-		$result = Database::query($sql);
1890
-		$row = Database::fetch_assoc($result);
1888
+        $result = Database::query($sql);
1889
+        $row = Database::fetch_assoc($result);
1891 1890
 
1892
-		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1893
-			$sql = "
1891
+        if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1892
+            $sql = "
1894 1893
 				UPDATE " . $tbl_blogs_tasks_rel_user . "
1895 1894
 				SET
1896 1895
 					user_id = " . (int)$user_id . ",
@@ -1903,76 +1902,76 @@  discard block
 block discarded – undo
1903 1902
 					task_id = " . (int)$old_task_id . " AND
1904 1903
 					target_date = '" . Database::escape_string($old_target_date) . "'
1905 1904
 			";
1906
-			Database::query($sql);
1907
-		}
1908
-	}
1909
-
1910
-	/**
1911
-	 * Displays a list with posts a user can select to execute his task.
1912
-	 *
1913
-	 * @param Integer $blog_id
1914
-	 * @param unknown_type $task_id
1915
-	 */
1916
-	public static function display_select_task_post($blog_id, $task_id)
1905
+            Database::query($sql);
1906
+        }
1907
+    }
1908
+
1909
+    /**
1910
+     * Displays a list with posts a user can select to execute his task.
1911
+     *
1912
+     * @param Integer $blog_id
1913
+     * @param unknown_type $task_id
1914
+     */
1915
+    public static function display_select_task_post($blog_id, $task_id)
1917 1916
     {
1918
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1919
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1920
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1921
-		$course_id = api_get_course_int_id();
1917
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1918
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1919
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1920
+        $course_id = api_get_course_int_id();
1922 1921
 
1923 1922
 
1924
-		$sql = "SELECT title, description FROM $tbl_blogs_tasks
1923
+        $sql = "SELECT title, description FROM $tbl_blogs_tasks
1925 1924
 				WHERE task_id = '".(int)$task_id."'
1926 1925
 				AND c_id = $course_id";
1927
-		$result = Database::query($sql);
1928
-		$row = Database::fetch_assoc($result);
1929
-		// Get posts and authors
1930
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
1926
+        $result = Database::query($sql);
1927
+        $row = Database::fetch_assoc($result);
1928
+        // Get posts and authors
1929
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
1931 1930
 				FROM $tbl_blogs_posts post
1932 1931
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1933 1932
 				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
1934 1933
 				ORDER BY post_id DESC
1935 1934
 				LIMIT 0, 100";
1936
-		$result = Database::query($sql);
1935
+        $result = Database::query($sql);
1937 1936
 
1938
-		// Display
1939
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1940
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1937
+        // Display
1938
+        echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1939
+        echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1941 1940
 
1942
-		if (Database::num_rows($result) > 0) {
1943
-			while($blog_post = Database::fetch_array($result)) {
1944
-			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1945
-				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 />';
1946
-			}
1941
+        if (Database::num_rows($result) > 0) {
1942
+            while($blog_post = Database::fetch_array($result)) {
1943
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1944
+                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 />';
1945
+            }
1947 1946
         } else {
1948 1947
             echo get_lang('NoArticles');
1949 1948
         }
1950
-	}
1951
-
1952
-	/**
1953
-	 * Subscribes a user to a given blog
1954
-	 * @author Toon Keppens
1955
-	 *
1956
-	 * @param Integer $blog_id
1957
-	 * @param Integer $user_id
1958
-	 */
1959
-	public static function set_user_subscribed($blog_id, $user_id)
1949
+    }
1950
+
1951
+    /**
1952
+     * Subscribes a user to a given blog
1953
+     * @author Toon Keppens
1954
+     *
1955
+     * @param Integer $blog_id
1956
+     * @param Integer $user_id
1957
+     */
1958
+    public static function set_user_subscribed($blog_id, $user_id)
1960 1959
     {
1961
-		// Init
1962
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1963
-		$tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1960
+        // Init
1961
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1962
+        $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1964 1963
 
1965
-		$course_id = api_get_course_int_id();
1964
+        $course_id = api_get_course_int_id();
1966 1965
 
1967
-		// Subscribe the user
1968
-		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1966
+        // Subscribe the user
1967
+        $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1969 1968
 		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
1970
-		Database::query($sql);
1969
+        Database::query($sql);
1971 1970
 
1972
-		// Give this user basic rights
1973
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1971
+        // Give this user basic rights
1972
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1974 1973
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
1975
-		Database::query($sql);
1974
+        Database::query($sql);
1976 1975
 
1977 1976
         $id = Database::insert_id();
1978 1977
         if ($id) {
@@ -1980,9 +1979,9 @@  discard block
 block discarded – undo
1980 1979
             Database::query($sql);
1981 1980
         }
1982 1981
 
1983
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1982
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1984 1983
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
1985
-		Database::query($sql);
1984
+        Database::query($sql);
1986 1985
 
1987 1986
         $id = Database::insert_id();
1988 1987
         if ($id) {
@@ -1990,197 +1989,197 @@  discard block
 block discarded – undo
1990 1989
             Database::query($sql);
1991 1990
         }
1992 1991
 
1993
-	}
1992
+    }
1994 1993
 
1995
-	/**
1996
-	 * Unsubscribe a user from a given blog
1997
-	 * @author Toon Keppens
1998
-	 *
1999
-	 * @param Integer $blog_id
2000
-	 * @param Integer $user_id
2001
-	 */
2002
-	public static function set_user_unsubscribed($blog_id, $user_id)
1994
+    /**
1995
+     * Unsubscribe a user from a given blog
1996
+     * @author Toon Keppens
1997
+     *
1998
+     * @param Integer $blog_id
1999
+     * @param Integer $user_id
2000
+     */
2001
+    public static function set_user_unsubscribed($blog_id, $user_id)
2003 2002
     {
2004
-		// Init
2003
+        // Init
2005 2004
         $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2006 2005
         $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
2007 2006
 
2008
-		// Unsubscribe the user
2009
-		$sql = "DELETE FROM $tbl_blogs_rel_user
2007
+        // Unsubscribe the user
2008
+        $sql = "DELETE FROM $tbl_blogs_rel_user
2010 2009
 		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
2011
-		Database::query($sql);
2010
+        Database::query($sql);
2012 2011
 
2013
-		// Remove this user's permissions.
2014
-		$sql = "DELETE FROM $tbl_user_permissions
2012
+        // Remove this user's permissions.
2013
+        $sql = "DELETE FROM $tbl_user_permissions
2015 2014
 		        WHERE user_id = '".(int)$user_id."'";
2016
-		Database::query($sql);
2017
-	}
2018
-
2019
-	/**
2020
-	 * Displays the form to register users in a blog (in a course)
2021
-	 * The listed users are users subcribed in the course.
2022
-	 * @author Toon Keppens
2023
-	 *
2024
-	 * @param Integer $blog_id
2025
-	 *
2026
-	 * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2027
-	 */
2028
-	public static function display_form_user_subscribe($blog_id)
2029
-	{
2030
-		$_course = api_get_course_info();
2031
-		$is_western_name_order = api_is_western_name_order();
2032
-		$session_id = api_get_session_id();
2033
-		$course_id = $_course['real_id'];
2034
-
2035
-		$currentCourse = $_course['code'];
2036
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2037
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2038
-
2039
-		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2040
-
2041
-		$properties["width"] = "100%";
2042
-
2043
-		// Get blog members' id.
2044
-		$sql = "SELECT user.user_id FROM $tbl_users user
2015
+        Database::query($sql);
2016
+    }
2017
+
2018
+    /**
2019
+     * Displays the form to register users in a blog (in a course)
2020
+     * The listed users are users subcribed in the course.
2021
+     * @author Toon Keppens
2022
+     *
2023
+     * @param Integer $blog_id
2024
+     *
2025
+     * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2026
+     */
2027
+    public static function display_form_user_subscribe($blog_id)
2028
+    {
2029
+        $_course = api_get_course_info();
2030
+        $is_western_name_order = api_is_western_name_order();
2031
+        $session_id = api_get_session_id();
2032
+        $course_id = $_course['real_id'];
2033
+
2034
+        $currentCourse = $_course['code'];
2035
+        $tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2036
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2037
+
2038
+        echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2039
+
2040
+        $properties["width"] = "100%";
2041
+
2042
+        // Get blog members' id.
2043
+        $sql = "SELECT user.user_id FROM $tbl_users user
2045 2044
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2046 2045
 				ON user.user_id = blogs_rel_user.user_id
2047 2046
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'";
2048
-		$result = Database::query($sql);
2049
-
2050
-		$blog_member_ids = array();
2051
-		while($user = Database::fetch_array($result)) {
2052
-			$blog_member_ids[] = $user['user_id'];
2053
-		}
2054
-
2055
-		// Set table headers
2056
-		$column_header[] = array ('', false, '');
2057
-		if ($is_western_name_order) {
2058
-			$column_header[] = array(get_lang('FirstName'), true, '');
2059
-			$column_header[] = array(get_lang('LastName'), true, '');
2060
-		} else {
2061
-			$column_header[] = array(get_lang('LastName'), true, '');
2062
-			$column_header[] = array(get_lang('FirstName'), true, '');
2063
-		}
2064
-		$column_header[] = array(get_lang('Email'), false, '');
2065
-		$column_header[] = array(get_lang('Register'), false, '');
2047
+        $result = Database::query($sql);
2048
+
2049
+        $blog_member_ids = array();
2050
+        while($user = Database::fetch_array($result)) {
2051
+            $blog_member_ids[] = $user['user_id'];
2052
+        }
2053
+
2054
+        // Set table headers
2055
+        $column_header[] = array ('', false, '');
2056
+        if ($is_western_name_order) {
2057
+            $column_header[] = array(get_lang('FirstName'), true, '');
2058
+            $column_header[] = array(get_lang('LastName'), true, '');
2059
+        } else {
2060
+            $column_header[] = array(get_lang('LastName'), true, '');
2061
+            $column_header[] = array(get_lang('FirstName'), true, '');
2062
+        }
2063
+        $column_header[] = array(get_lang('Email'), false, '');
2064
+        $column_header[] = array(get_lang('Register'), false, '');
2066 2065
 
2067 2066
         $student_list = CourseManager:: get_student_list_from_course_code(
2068 2067
             $currentCourse,
2069 2068
             false,
2070 2069
             $session_id
2071 2070
         );
2072
-		$user_data = array();
2073
-
2074
-		// Add users that are not in this blog to the list.
2075
-		foreach ($student_list as $key=>$user) {
2076
-			if(isset($user['id_user'])) {
2077
-				$user['user_id'] = $user['id_user'];
2078
-			}
2079
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2080
-				$a_infosUser = api_get_user_info($user['user_id']);
2081
-				$row = array ();
2082
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2083
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2084
-				if ($is_western_name_order) {
2085
-					$row[] = $a_infosUser["firstname"];
2086
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2087
-				} else {
2088
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2089
-					$row[] = $a_infosUser["firstname"];
2090
-				}
2091
-				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2092
-
2093
-				//Link to register users
2094
-				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2095
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2096
-				} else {
2097
-					$row[] = '';
2098
-				}
2099
-				$user_data[] = $row;
2100
-			}
2101
-		}
2102
-
2103
-		// Display
2104
-		$query_vars['action'] = 'manage_members';
2105
-		$query_vars['blog_id'] = $blog_id;
2106
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2107
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2108
-			$link = '';
2109
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2110
-			$link .= "blog_id=$blog_id&";
2111
-
2112
-			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2113
-			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2114
-			echo get_lang('WithSelected') . ' : ';
2115
-			echo '<select name="action">';
2116
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2117
-			echo '</select>';
2118
-			echo '<input type="hidden" name="register" value="true" />';
2119
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2120
-		echo '</form>';
2121
-	}
2122
-
2123
-	/**
2124
-	 * Displays the form to register users in a blog (in a course)
2125
-	 * The listed users are users subcribed in the course.
2126
-	 * @author Toon Keppens
2127
-	 *
2128
-	 * @param Integer $blog_id
2129
-	 *
2130
-	 * @return false|null Form with sortable table with users to unsubcribe from a blog.
2131
-	 */
2132
-	public static function display_form_user_unsubscribe ($blog_id)
2133
-	{
2134
-		$_user = api_get_user_info();
2135
-		$is_western_name_order = api_is_western_name_order();
2136
-
2137
-		// Init
2138
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2139
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2140
-
2141
-		echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2142
-
2143
-		$properties["width"] = "100%";
2144
-		//table column titles
2145
-		$column_header[] = array ('', false, '');
2146
-		if ($is_western_name_order) {
2147
-			$column_header[] = array (get_lang('FirstName'), true, '');
2148
-			$column_header[] = array (get_lang('LastName'), true, '');
2149
-		} else {
2150
-			$column_header[] = array (get_lang('LastName'), true, '');
2151
-			$column_header[] = array (get_lang('FirstName'), true, '');
2152
-		}
2153
-		$column_header[] = array (get_lang('Email'), false, '');
2154
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2155
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2156
-
2157
-		$course_id = api_get_course_int_id();
2158
-
2159
-		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2071
+        $user_data = array();
2072
+
2073
+        // Add users that are not in this blog to the list.
2074
+        foreach ($student_list as $key=>$user) {
2075
+            if(isset($user['id_user'])) {
2076
+                $user['user_id'] = $user['id_user'];
2077
+            }
2078
+            if(!in_array($user['user_id'],$blog_member_ids)) {
2079
+                $a_infosUser = api_get_user_info($user['user_id']);
2080
+                $row = array ();
2081
+                $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2082
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2083
+                if ($is_western_name_order) {
2084
+                    $row[] = $a_infosUser["firstname"];
2085
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2086
+                } else {
2087
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2088
+                    $row[] = $a_infosUser["firstname"];
2089
+                }
2090
+                $row[] = Display::icon_mailto_link($a_infosUser["email"]);
2091
+
2092
+                //Link to register users
2093
+                if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2094
+                    $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2095
+                } else {
2096
+                    $row[] = '';
2097
+                }
2098
+                $user_data[] = $row;
2099
+            }
2100
+        }
2101
+
2102
+        // Display
2103
+        $query_vars['action'] = 'manage_members';
2104
+        $query_vars['blog_id'] = $blog_id;
2105
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2106
+            Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2107
+            $link = '';
2108
+            $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2109
+            $link .= "blog_id=$blog_id&";
2110
+
2111
+            echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2112
+            echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2113
+            echo get_lang('WithSelected') . ' : ';
2114
+            echo '<select name="action">';
2115
+            echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2116
+            echo '</select>';
2117
+            echo '<input type="hidden" name="register" value="true" />';
2118
+            echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2119
+        echo '</form>';
2120
+    }
2121
+
2122
+    /**
2123
+     * Displays the form to register users in a blog (in a course)
2124
+     * The listed users are users subcribed in the course.
2125
+     * @author Toon Keppens
2126
+     *
2127
+     * @param Integer $blog_id
2128
+     *
2129
+     * @return false|null Form with sortable table with users to unsubcribe from a blog.
2130
+     */
2131
+    public static function display_form_user_unsubscribe ($blog_id)
2132
+    {
2133
+        $_user = api_get_user_info();
2134
+        $is_western_name_order = api_is_western_name_order();
2135
+
2136
+        // Init
2137
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2138
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2139
+
2140
+        echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2141
+
2142
+        $properties["width"] = "100%";
2143
+        //table column titles
2144
+        $column_header[] = array ('', false, '');
2145
+        if ($is_western_name_order) {
2146
+            $column_header[] = array (get_lang('FirstName'), true, '');
2147
+            $column_header[] = array (get_lang('LastName'), true, '');
2148
+        } else {
2149
+            $column_header[] = array (get_lang('LastName'), true, '');
2150
+            $column_header[] = array (get_lang('FirstName'), true, '');
2151
+        }
2152
+        $column_header[] = array (get_lang('Email'), false, '');
2153
+        $column_header[] = array (get_lang('TaskManager'), true, '');
2154
+        $column_header[] = array (get_lang('UnRegister'), false, '');
2155
+
2156
+        $course_id = api_get_course_int_id();
2157
+
2158
+        $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2160 2159
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2161 2160
                 ON user.user_id = blogs_rel_user.user_id
2162 2161
                 WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2163 2162
 
2164
-		if (!($sql_result = Database::query($sql))) {
2165
-			return false;
2166
-		}
2167
-
2168
-		$user_data = array ();
2169
-
2170
-		while ($myrow = Database::fetch_array($sql_result)) {
2171
-			$row = array ();
2172
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2173
-			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2174
-			if ($is_western_name_order) {
2175
-				$row[] = $myrow["firstname"];
2176
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2177
-			} else {
2178
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2179
-				$row[] = $myrow["firstname"];
2180
-			}
2181
-			$row[] = Display::icon_mailto_link($myrow["email"]);
2182
-
2183
-			$sql = "SELECT bt.title task
2163
+        if (!($sql_result = Database::query($sql))) {
2164
+            return false;
2165
+        }
2166
+
2167
+        $user_data = array ();
2168
+
2169
+        while ($myrow = Database::fetch_array($sql_result)) {
2170
+            $row = array ();
2171
+            $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2172
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2173
+            if ($is_western_name_order) {
2174
+                $row[] = $myrow["firstname"];
2175
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2176
+            } else {
2177
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2178
+                $row[] = $myrow["firstname"];
2179
+            }
2180
+            $row[] = Display::icon_mailto_link($myrow["email"]);
2181
+
2182
+            $sql = "SELECT bt.title task
2184 2183
 					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2185 2184
 					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2186 2185
 					ON btu.task_id = bt.task_id
@@ -2188,157 +2187,157 @@  discard block
 block discarded – undo
2188 2187
 							bt.c_id 	= $course_id  AND
2189 2188
 							btu.blog_id = $blog_id AND
2190 2189
 							btu.user_id = " . $myrow['user_id'];
2191
-			$sql_res = Database::query($sql);
2192
-
2193
-			$task = '';
2194
-
2195
-			while($r = Database::fetch_array($sql_res)) {
2196
-				$task .= stripslashes($r['task']) . ', ';
2197
-			}
2198
-			//echo $task;
2199
-			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2200
-			$row[] = $task;
2201
-			//Link to register users
2202
-
2203
-			if ($myrow["user_id"] != $_user['user_id']) {
2204
-				$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>";
2205
-			} else {
2206
-				$row[] = '';
2207
-			}
2208
-
2209
-			$user_data[] = $row;
2210
-		}
2211
-
2212
-		$query_vars['action'] = 'manage_members';
2213
-		$query_vars['blog_id'] = $blog_id;
2214
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2215
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2216
-		$link = '';
2217
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2218
-		$link .= "blog_id=$blog_id&";
2219
-
2220
-		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2221
-		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2222
-		echo get_lang('WithSelected') . ' : ';
2223
-		echo '<select name="action">';
2224
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2225
-		echo '</select>';
2226
-		echo '<input type="hidden" name="unregister" value="true" />';
2227
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2228
-		echo '</form>';
2229
-	}
2230
-
2231
-	/**
2232
-	 * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2233
-	 * The blog admin can thus select what a certain user can do in the current blog
2234
-	 *
2235
-	 * @param Integer $blog_id
2236
-	 */
2237
-	public static function display_form_user_rights ($blog_id)
2190
+            $sql_res = Database::query($sql);
2191
+
2192
+            $task = '';
2193
+
2194
+            while($r = Database::fetch_array($sql_res)) {
2195
+                $task .= stripslashes($r['task']) . ', ';
2196
+            }
2197
+            //echo $task;
2198
+            $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2199
+            $row[] = $task;
2200
+            //Link to register users
2201
+
2202
+            if ($myrow["user_id"] != $_user['user_id']) {
2203
+                $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>";
2204
+            } else {
2205
+                $row[] = '';
2206
+            }
2207
+
2208
+            $user_data[] = $row;
2209
+        }
2210
+
2211
+        $query_vars['action'] = 'manage_members';
2212
+        $query_vars['blog_id'] = $blog_id;
2213
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2214
+        Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2215
+        $link = '';
2216
+        $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2217
+        $link .= "blog_id=$blog_id&";
2218
+
2219
+        echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2220
+        echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2221
+        echo get_lang('WithSelected') . ' : ';
2222
+        echo '<select name="action">';
2223
+        echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2224
+        echo '</select>';
2225
+        echo '<input type="hidden" name="unregister" value="true" />';
2226
+        echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2227
+        echo '</form>';
2228
+    }
2229
+
2230
+    /**
2231
+     * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2232
+     * The blog admin can thus select what a certain user can do in the current blog
2233
+     *
2234
+     * @param Integer $blog_id
2235
+     */
2236
+    public static function display_form_user_rights ($blog_id)
2237
+    {
2238
+        echo '<legend>'.get_lang('RightsManager').'</legend>';
2239
+        echo '<br />';
2240
+
2241
+        // Integration of patricks permissions system.
2242
+        require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2243
+    }
2244
+
2245
+    /**
2246
+     * Displays the form to create a new post
2247
+     * @author Toon Keppens
2248
+     *
2249
+     * @param Integer $blog_id
2250
+     * @param integer $post_id
2251
+     */
2252
+    public static function display_new_comment_form($blog_id, $post_id, $title)
2238 2253
     {
2239
-		echo '<legend>'.get_lang('RightsManager').'</legend>';
2240
-		echo '<br />';
2241
-
2242
-		// Integration of patricks permissions system.
2243
-		require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2244
-	}
2245
-
2246
-	/**
2247
-	 * Displays the form to create a new post
2248
-	 * @author Toon Keppens
2249
-	 *
2250
-	 * @param Integer $blog_id
2251
-	 * @param integer $post_id
2252
-	 */
2253
-	public static function display_new_comment_form($blog_id, $post_id, $title)
2254
-	{
2255
-		$form = new FormValidator(
2256
-			'add_post',
2257
-			'post',
2258
-			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(),
2259
-			null,
2260
-			array('enctype' => 'multipart/form-data')
2261
-		);
2262
-
2263
-		$header = get_lang('AddNewComment');
2264
-		if (isset($_GET['task_id'])) {
2265
-			$header = get_lang('ExecuteThisTask');
2266
-		}
2267
-		$form->addHeader($header);
2268
-		$form->addText('title', get_lang('Title'));
2269
-
2270
-		$config = array();
2271
-		if (!api_is_allowed_to_edit()) {
2272
-			$config['ToolbarSet'] = 'ProjectComment';
2273
-		} else {
2274
-			$config['ToolbarSet'] = 'ProjectCommentStudent';
2275
-		}
2276
-		$form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2277
-		$form->addFile('user_upload', get_lang('AddAnAttachment'));
2278
-
2279
-		$form->addTextarea('post_file_comment', get_lang('FileComment'));
2280
-
2281
-		$form->addHidden('action', null);
2282
-		$form->addHidden('comment_parent_id', 0);
2283
-
2284
-		if (isset($_GET['task_id'])) {
2285
-			$form->addHidden('new_task_execution_submit', 'true');
2286
-			$form->addHidden('task_id', intval($_GET['task_id']));
2287
-		} else {
2288
-			$form->addHidden('new_comment_submit', 'true');
2289
-		}
2290
-		$form->addButton('save', get_lang('Save'));
2291
-		$form->display();
2292
-	}
2293
-
2294
-
2295
-	/**
2296
-	 * show the calender of the given month
2297
-	 * @author Patrick Cool
2298
-	 * @author Toon Keppens
2299
-	 *
2300
-	 * @param Integer $month: the integer value of the month we are viewing
2301
-	 * @param Integer $year: the 4-digit year indication e.g. 2005
2302
-	 *
2303
-	 * @return html code
2304
-	*/
2305
-	public static function display_minimonthcalendar($month, $year, $blog_id)
2306
-	{
2307
-		// Init
2308
-		$_user = api_get_user_info();
2309
-		global $DaysShort;
2310
-		global $MonthsLong;
2311
-
2312
-		$posts = array();
2313
-		$tasks = array();
2314
-
2315
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2316
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2317
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2318
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2319
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2320
-
2321
-		$course_id = api_get_course_int_id();
2322
-
2323
-		//Handle leap year
2324
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2325
-
2326
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2327
-			$numberofdays[2] = 29;
2328
-
2329
-		//Get the first day of the month
2330
-		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2331
-		$monthName = $MonthsLong[$month-1];
2332
-
2333
-		//Start the week on monday
2334
-		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2335
-		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2336
-		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2337
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2338
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2339
-
2340
-		// Get posts for this month
2341
-		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2254
+        $form = new FormValidator(
2255
+            'add_post',
2256
+            'post',
2257
+            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(),
2258
+            null,
2259
+            array('enctype' => 'multipart/form-data')
2260
+        );
2261
+
2262
+        $header = get_lang('AddNewComment');
2263
+        if (isset($_GET['task_id'])) {
2264
+            $header = get_lang('ExecuteThisTask');
2265
+        }
2266
+        $form->addHeader($header);
2267
+        $form->addText('title', get_lang('Title'));
2268
+
2269
+        $config = array();
2270
+        if (!api_is_allowed_to_edit()) {
2271
+            $config['ToolbarSet'] = 'ProjectComment';
2272
+        } else {
2273
+            $config['ToolbarSet'] = 'ProjectCommentStudent';
2274
+        }
2275
+        $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2276
+        $form->addFile('user_upload', get_lang('AddAnAttachment'));
2277
+
2278
+        $form->addTextarea('post_file_comment', get_lang('FileComment'));
2279
+
2280
+        $form->addHidden('action', null);
2281
+        $form->addHidden('comment_parent_id', 0);
2282
+
2283
+        if (isset($_GET['task_id'])) {
2284
+            $form->addHidden('new_task_execution_submit', 'true');
2285
+            $form->addHidden('task_id', intval($_GET['task_id']));
2286
+        } else {
2287
+            $form->addHidden('new_comment_submit', 'true');
2288
+        }
2289
+        $form->addButton('save', get_lang('Save'));
2290
+        $form->display();
2291
+    }
2292
+
2293
+
2294
+    /**
2295
+     * show the calender of the given month
2296
+     * @author Patrick Cool
2297
+     * @author Toon Keppens
2298
+     *
2299
+     * @param Integer $month: the integer value of the month we are viewing
2300
+     * @param Integer $year: the 4-digit year indication e.g. 2005
2301
+     *
2302
+     * @return html code
2303
+     */
2304
+    public static function display_minimonthcalendar($month, $year, $blog_id)
2305
+    {
2306
+        // Init
2307
+        $_user = api_get_user_info();
2308
+        global $DaysShort;
2309
+        global $MonthsLong;
2310
+
2311
+        $posts = array();
2312
+        $tasks = array();
2313
+
2314
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2315
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2316
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2317
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2318
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2319
+
2320
+        $course_id = api_get_course_int_id();
2321
+
2322
+        //Handle leap year
2323
+        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2324
+
2325
+        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2326
+            $numberofdays[2] = 29;
2327
+
2328
+        //Get the first day of the month
2329
+        $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2330
+        $monthName = $MonthsLong[$month-1];
2331
+
2332
+        //Start the week on monday
2333
+        $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2334
+        $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2335
+        $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2336
+        $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2337
+        $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2338
+
2339
+        // Get posts for this month
2340
+        $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2342 2341
 				FROM $tbl_blogs_posts post
2343 2342
 				INNER JOIN $tbl_users user
2344 2343
 				ON post.author_id = user.user_id
@@ -2348,20 +2347,20 @@  discard block
 block discarded – undo
2348 2347
 					MONTH(date_creation) = '".(int)$month."' AND
2349 2348
 					YEAR(date_creation) = '".(int)$year."'
2350 2349
 				ORDER BY date_creation";
2351
-		$result = Database::query($sql);
2352
-
2353
-		// We will create an array of days on which there are posts.
2354
-		if( Database::num_rows($result) > 0) {
2355
-			while($blog_post = Database::fetch_array($result)) {
2356
-				// If the day of this post is not yet in the array, add it.
2357
-				if (!in_array($blog_post['post_day'], $posts))
2358
-					$posts[] = $blog_post['post_day'];
2359
-			}
2360
-		}
2361
-
2362
-		// Get tasks for this month
2363
-		if ($_user['user_id']) {
2364
-			$sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2350
+        $result = Database::query($sql);
2351
+
2352
+        // We will create an array of days on which there are posts.
2353
+        if( Database::num_rows($result) > 0) {
2354
+            while($blog_post = Database::fetch_array($result)) {
2355
+                // If the day of this post is not yet in the array, add it.
2356
+                if (!in_array($blog_post['post_day'], $posts))
2357
+                    $posts[] = $blog_post['post_day'];
2358
+            }
2359
+        }
2360
+
2361
+        // Get tasks for this month
2362
+        if ($_user['user_id']) {
2363
+            $sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2365 2364
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
2366 2365
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
2367 2366
 				INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
@@ -2373,85 +2372,85 @@  discard block
 block discarded – undo
2373 2372
 					MONTH(target_date) = '".(int)$month."' AND
2374 2373
 					YEAR(target_date) = '".(int)$year."'
2375 2374
 				ORDER BY target_date ASC";
2376
-			$result = Database::query($sql);
2377
-
2378
-			if (Database::num_rows($result) > 0) {
2379
-				while ($mytask = Database::fetch_array($result)) {
2380
-					$tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2381
-					$tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2382
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2383
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2384
-					$tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2385
-				}
2386
-			}
2387
-		}
2388
-
2389
-		echo 	'<table id="smallcalendar" class="table table-responsive">',
2390
-				"<tr id=\"title\">",
2391
-				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>",
2392
-				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>",
2393
-				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>", "</tr>";
2394
-
2395
-		echo "<tr>";
2396
-
2397
-		for($ii = 1; $ii < 8; $ii ++)
2398
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2399
-
2400
-		echo "</tr>";
2401
-
2402
-		$curday = -1;
2403
-		$today = getdate();
2404
-
2405
-		while ($curday <= $numberofdays[$month]) {
2406
-			echo "<tr>";
2407
-			for ($ii = 0; $ii < 7; $ii ++) {
2408
-				if (($curday == -1) && ($ii == $startdayofweek))
2409
-					$curday = 1;
2410
-
2411
-			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2412
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2413
-					$dayheader = "$curday";
2414
-
2415
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2416
-						$dayheader = "$curday";
2417
-						$class = "class=\"days_today\"";
2418
-					}
2419
-
2420
-					echo "<td " . $class.">";
2421
-
2422
-					// If there are posts on this day, create a filter link.
2423
-					if(in_array($curday, $posts))
2424
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2425
-					else
2426
-						echo $dayheader;
2427
-
2428
-					if (count($tasks) > 0) {
2429
-						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2430
-							// Add tasks to calendar
2431
-							foreach ($tasks[$curday] as $task) {
2432
-								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') . '">';
2433
-								echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask'));
2375
+            $result = Database::query($sql);
2376
+
2377
+            if (Database::num_rows($result) > 0) {
2378
+                while ($mytask = Database::fetch_array($result)) {
2379
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2380
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2381
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2382
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2383
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2384
+                }
2385
+            }
2386
+        }
2387
+
2388
+        echo 	'<table id="smallcalendar" class="table table-responsive">',
2389
+                "<tr id=\"title\">",
2390
+                "<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>",
2391
+                "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>",
2392
+                "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>", "</tr>";
2393
+
2394
+        echo "<tr>";
2395
+
2396
+        for($ii = 1; $ii < 8; $ii ++)
2397
+            echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2398
+
2399
+        echo "</tr>";
2400
+
2401
+        $curday = -1;
2402
+        $today = getdate();
2403
+
2404
+        while ($curday <= $numberofdays[$month]) {
2405
+            echo "<tr>";
2406
+            for ($ii = 0; $ii < 7; $ii ++) {
2407
+                if (($curday == -1) && ($ii == $startdayofweek))
2408
+                    $curday = 1;
2409
+
2410
+                    if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2411
+                    $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2412
+                    $dayheader = "$curday";
2413
+
2414
+                    if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2415
+                        $dayheader = "$curday";
2416
+                        $class = "class=\"days_today\"";
2417
+                    }
2418
+
2419
+                    echo "<td " . $class.">";
2420
+
2421
+                    // If there are posts on this day, create a filter link.
2422
+                    if(in_array($curday, $posts))
2423
+                        echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2424
+                    else
2425
+                        echo $dayheader;
2426
+
2427
+                    if (count($tasks) > 0) {
2428
+                        if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2429
+                            // Add tasks to calendar
2430
+                            foreach ($tasks[$curday] as $task) {
2431
+                                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') . '">';
2432
+                                echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask'));
2434 2433
                                 echo '</a>';
2435
-							}
2436
-						}
2437
-					}
2438
-
2439
-					echo "</td>";
2440
-					$curday ++;
2441
-				} else
2442
-					echo "<td>&nbsp;</td>";
2443
-			}
2444
-			echo "</tr>";
2445
-		}
2446
-		echo "</table>";
2447
-	}
2448
-
2449
-	/**
2450
-	 * Blog admin | Display the form to add a new blog.
2451
-	 *
2452
-	 */
2453
-	public static function display_new_blog_form()
2454
-	{
2434
+                            }
2435
+                        }
2436
+                    }
2437
+
2438
+                    echo "</td>";
2439
+                    $curday ++;
2440
+                } else
2441
+                    echo "<td>&nbsp;</td>";
2442
+            }
2443
+            echo "</tr>";
2444
+        }
2445
+        echo "</table>";
2446
+    }
2447
+
2448
+    /**
2449
+     * Blog admin | Display the form to add a new blog.
2450
+     *
2451
+     */
2452
+    public static function display_new_blog_form()
2453
+    {
2455 2454
         $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add');
2456 2455
         $form->addElement('header', get_lang('AddBlog'));
2457 2456
         $form->addElement('text', 'blog_name', get_lang('Title'));
@@ -2461,34 +2460,34 @@  discard block
 block discarded – undo
2461 2460
         $form->addButtonSave(get_lang('SaveProject'));
2462 2461
 
2463 2462
         $defaults = array(
2464
-			'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2465
-        	'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2466
-		);
2463
+            'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2464
+            'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2465
+        );
2467 2466
         $form->setDefaults($defaults);
2468 2467
         $form->display();
2469
-	}
2470
-
2471
-	/**
2472
-	 * Blog admin | Display the form to edit a blog.
2473
-	 *
2474
-	 */
2475
-	public static function display_edit_blog_form($blog_id)
2476
-	{
2477
-	    $course_id = api_get_course_int_id();
2478
-		$blog_id= intval($blog_id);
2479
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2480
-
2481
-		$sql = "SELECT blog_id, blog_name, blog_subtitle
2468
+    }
2469
+
2470
+    /**
2471
+     * Blog admin | Display the form to edit a blog.
2472
+     *
2473
+     */
2474
+    public static function display_edit_blog_form($blog_id)
2475
+    {
2476
+        $course_id = api_get_course_int_id();
2477
+        $blog_id= intval($blog_id);
2478
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2479
+
2480
+        $sql = "SELECT blog_id, blog_name, blog_subtitle
2482 2481
 		        FROM $tbl_blogs
2483 2482
 		        WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
2484
-		$result = Database::query($sql);
2485
-		$blog = Database::fetch_array($result);
2483
+        $result = Database::query($sql);
2484
+        $blog = Database::fetch_array($result);
2486 2485
 
2487
-		// the form contained errors but we do not want to lose the changes the user already did
2488
-		if ($_POST) {
2489
-			$blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2490
-			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2491
-		}
2486
+        // the form contained errors but we do not want to lose the changes the user already did
2487
+        if ($_POST) {
2488
+            $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2489
+            $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2490
+        }
2492 2491
 
2493 2492
         $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2494 2493
         $form->addElement('header', get_lang('EditBlog'));
@@ -2504,76 +2503,76 @@  discard block
 block discarded – undo
2504 2503
         $defaults['blog_subtitle'] = $blog['blog_subtitle'];
2505 2504
         $form->setDefaults($defaults);
2506 2505
         $form->display();
2507
-	}
2506
+    }
2508 2507
 
2509
-	/**
2510
-	 * Blog admin | Returns table with blogs in this course
2511
-	 */
2512
-	public static function display_blog_list()
2508
+    /**
2509
+     * Blog admin | Returns table with blogs in this course
2510
+     */
2511
+    public static function display_blog_list()
2513 2512
     {
2514
-		global $charset;
2515
-		$_user = api_get_user_info();
2513
+        global $charset;
2514
+        $_user = api_get_user_info();
2516 2515
         $course_id = api_get_course_int_id();
2517 2516
 
2518
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2517
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2519 2518
 
2520
-		//condition for the session
2521
-		$session_id = api_get_session_id();
2519
+        //condition for the session
2520
+        $session_id = api_get_session_id();
2522 2521
 
2523
-		$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2522
+        $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2524 2523
 				FROM $tbl_blogs WHERE c_id = $course_id
2525 2524
 				ORDER BY date_creation DESC";
2526
-		$result = Database::query($sql);
2527
-		$list_info = array();
2528
-		if (Database::num_rows($result)) {
2529
-			while ($row_project=Database::fetch_row($result)) {
2530
-				$list_info[]=$row_project;
2531
-			}
2532
-		}
2533
-
2534
-		$list_content_blog = array();
2535
-		$list_body_blog = array();
2536
-
2537
-		if (is_array($list_info)) {
2538
-			foreach ($list_info as $key => $info_log) {
2539
-				// Validation when belongs to a session
2540
-				$session_img = api_get_session_image($info_log[4], $_user['status']);
2541
-
2542
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2543
-				$title = $info_log[0];
2525
+        $result = Database::query($sql);
2526
+        $list_info = array();
2527
+        if (Database::num_rows($result)) {
2528
+            while ($row_project=Database::fetch_row($result)) {
2529
+                $list_info[]=$row_project;
2530
+            }
2531
+        }
2532
+
2533
+        $list_content_blog = array();
2534
+        $list_body_blog = array();
2535
+
2536
+        if (is_array($list_info)) {
2537
+            foreach ($list_info as $key => $info_log) {
2538
+                // Validation when belongs to a session
2539
+                $session_img = api_get_session_image($info_log[4], $_user['status']);
2540
+
2541
+                $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2542
+                $title = $info_log[0];
2544 2543
                         $image = Display::return_icon('blog.png', $title);
2545
-    			$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;
2544
+                $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;
2546 2545
 
2547
-				$list_body_blog[] = $list_name;
2548
-				$list_body_blog[] = $info_log[1];
2546
+                $list_body_blog[] = $list_name;
2547
+                $list_body_blog[] = $info_log[1];
2549 2548
 
2550
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2551
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2552
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2549
+                $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2550
+                $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2551
+                    $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2553 2552
                                 $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2554 2553
 
2555
-				$my_image.= "</a>";
2556
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2557
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2554
+                $my_image.= "</a>";
2555
+                $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2556
+                $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2558 2557
                                 $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2559 2558
 
2560
-				$my_image.= "</a>";
2561
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2559
+                $my_image.= "</a>";
2560
+                $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2562 2561
                                 $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2563 2562
 
2564
-				$my_image.= "</a>";
2565
-				$list_body_blog[]=$my_image;
2566
-				$list_content_blog[]=$list_body_blog;
2567
-				$list_body_blog = array();
2568
-			}
2569
-
2570
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2571
-			$table->set_header(0, get_lang('Title'));
2572
-			$table->set_header(1, get_lang('SubTitle'));
2573
-			$table->set_header(2, get_lang('Modify'));
2574
-			$table->display();
2575
-		}
2576
-	}
2563
+                $my_image.= "</a>";
2564
+                $list_body_blog[]=$my_image;
2565
+                $list_content_blog[]=$list_body_blog;
2566
+                $list_body_blog = array();
2567
+            }
2568
+
2569
+            $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2570
+            $table->set_header(0, get_lang('Title'));
2571
+            $table->set_header(1, get_lang('SubTitle'));
2572
+            $table->set_header(2, get_lang('Modify'));
2573
+            $table->display();
2574
+        }
2575
+    }
2577 2576
 }
2578 2577
 
2579 2578
 /**
@@ -2594,34 +2593,34 @@  discard block
 block discarded – undo
2594 2593
  */
2595 2594
 function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2596 2595
 {
2597
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2598
-
2599
-	$blog_id = intval($blog_id);
2600
-	$comment_id = intval($comment_id);
2601
-	$post_id = intval($post_id);
2602
-	$row=array();
2603
-	$where='';
2604
-	if (!empty ($post_id) && is_numeric($post_id)) {
2605
-		$where.=' AND post_id ="'.$post_id.'" ';
2606
-	}
2607
-
2608
-	if (!empty ($comment_id) && is_numeric($comment_id)) {
2609
-		if (!empty ($post_id)) {
2610
-			$where.= ' AND ';
2611
-		}
2612
-		$where.=' comment_id ="'.$comment_id.'" ';
2613
-	}
2596
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2597
+
2598
+    $blog_id = intval($blog_id);
2599
+    $comment_id = intval($comment_id);
2600
+    $post_id = intval($post_id);
2601
+    $row=array();
2602
+    $where='';
2603
+    if (!empty ($post_id) && is_numeric($post_id)) {
2604
+        $where.=' AND post_id ="'.$post_id.'" ';
2605
+    }
2606
+
2607
+    if (!empty ($comment_id) && is_numeric($comment_id)) {
2608
+        if (!empty ($post_id)) {
2609
+            $where.= ' AND ';
2610
+        }
2611
+        $where.=' comment_id ="'.$comment_id.'" ';
2612
+    }
2614 2613
 
2615 2614
     $course_id = api_get_course_int_id();
2616 2615
 
2617
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2616
+    $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2618 2617
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2619 2618
 
2620
-	$result=Database::query($sql);
2621
-	if (Database::num_rows($result)!=0) {
2622
-		$row=Database::fetch_array($result);
2623
-	}
2624
-	return $row;
2619
+    $result=Database::query($sql);
2620
+    if (Database::num_rows($result)!=0) {
2621
+        $row=Database::fetch_array($result);
2622
+    }
2623
+    return $row;
2625 2624
 }
2626 2625
 
2627 2626
 /**
@@ -2638,16 +2637,16 @@  discard block
 block discarded – undo
2638 2637
 
2639 2638
 function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2640 2639
 {
2641
-	$_course = api_get_course_info();
2642
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2643
-	$blog_id = intval($blog_id);
2644
-	$comment_id = intval($comment_id);
2645
-	$post_id = intval($post_id);
2640
+    $_course = api_get_course_info();
2641
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2642
+    $blog_id = intval($blog_id);
2643
+    $comment_id = intval($comment_id);
2644
+    $post_id = intval($post_id);
2646 2645
 
2647 2646
     $course_id = api_get_course_int_id();
2648
-	$where = null;
2647
+    $where = null;
2649 2648
 
2650
-	// delete files in DB
2649
+    // delete files in DB
2651 2650
     if (!empty ($post_id) && is_numeric($post_id)) {
2652 2651
         $where .= ' AND post_id ="'.$post_id.'" ';
2653 2652
     }
@@ -2659,25 +2658,25 @@  discard block
 block discarded – undo
2659 2658
         $where .= ' comment_id ="'.$comment_id.'" ';
2660 2659
     }
2661 2660
 
2662
-	// delete all files in directory
2663
-	$courseDir   = $_course['path'].'/upload/blog';
2664
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2665
-	$updir = $sys_course_path.$courseDir;
2661
+    // delete all files in directory
2662
+    $courseDir   = $_course['path'].'/upload/blog';
2663
+    $sys_course_path = api_get_path(SYS_COURSE_PATH);
2664
+    $updir = $sys_course_path.$courseDir;
2666 2665
 
2667
-	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2666
+    $sql = 'SELECT path FROM '.$blog_table_attachment.'
2668 2667
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2669
-	$result=Database::query($sql);
2670
-
2671
-	while ($row=Database::fetch_row($result)) {
2672
-		$file=$updir.'/'.$row[0];
2673
-		if (Security::check_abs_path($file,$updir) )
2674
-		{
2675
-			@ unlink($file);
2676
-		}
2677
-	}
2678
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2668
+    $result=Database::query($sql);
2669
+
2670
+    while ($row=Database::fetch_row($result)) {
2671
+        $file=$updir.'/'.$row[0];
2672
+        if (Security::check_abs_path($file,$updir) )
2673
+        {
2674
+            @ unlink($file);
2675
+        }
2676
+    }
2677
+    $sql = 'DELETE FROM '. $blog_table_attachment.'
2679 2678
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2680
-	Database::query($sql);
2679
+    Database::query($sql);
2681 2680
 }
2682 2681
 
2683 2682
 /**
@@ -2687,12 +2686,12 @@  discard block
 block discarded – undo
2687 2686
  */
2688 2687
 function get_blog_post_from_user($course_code, $user_id)
2689 2688
 {
2690
-	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2691
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2692
-	$course_info 	= api_get_course_info($course_code);
2693
-	$course_id 		= $course_info['real_id'];
2689
+    $tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2690
+    $tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2691
+    $course_info 	= api_get_course_info($course_code);
2692
+    $course_id 		= $course_info['real_id'];
2694 2693
 
2695
-	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2694
+    $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2696 2695
 			FROM $tbl_blogs blog
2697 2696
 			INNER JOIN  $tbl_blog_post post
2698 2697
 			ON (blog.blog_id = post.blog_id)
@@ -2701,19 +2700,19 @@  discard block
 block discarded – undo
2701 2700
 				post.c_id = $course_id AND
2702 2701
 				author_id =  $user_id AND visibility = 1
2703 2702
 			ORDER BY post.date_creation DESC ";
2704
-	$result = Database::query($sql);
2705
-	$return_data = '';
2706
-
2707
-	if (Database::num_rows($result)!=0) {
2708
-		while ($row=Database::fetch_array($result)) {
2709
-			$return_data.=  '<div class="clear"></div><br />';
2710
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>';
2711
-			$return_data.=  '<br / >';
2712
-			$return_data.= $row['full_text'];
2713
-			$return_data.= '<br /><br />';
2714
-		}
2715
-	}
2716
-	return $return_data;
2703
+    $result = Database::query($sql);
2704
+    $return_data = '';
2705
+
2706
+    if (Database::num_rows($result)!=0) {
2707
+        while ($row=Database::fetch_array($result)) {
2708
+            $return_data.=  '<div class="clear"></div><br />';
2709
+            $return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>';
2710
+            $return_data.=  '<br / >';
2711
+            $return_data.= $row['full_text'];
2712
+            $return_data.= '<br /><br />';
2713
+        }
2714
+    }
2715
+    return $return_data;
2717 2716
 }
2718 2717
 
2719 2718
 /**
@@ -2730,7 +2729,7 @@  discard block
 block discarded – undo
2730 2729
     $course_info = api_get_course_info($course_code);
2731 2730
     $course_id = $course_info['real_id'];
2732 2731
 
2733
-	$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2732
+    $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2734 2733
 			FROM $tbl_blogs blog INNER JOIN  $tbl_blog_comment comment
2735 2734
 			ON (blog.blog_id = comment.blog_id)
2736 2735
 			WHERE 	blog.c_id = $course_id AND
@@ -2738,18 +2737,18 @@  discard block
 block discarded – undo
2738 2737
 					author_id =  $user_id AND
2739 2738
 					visibility = 1
2740 2739
 			ORDER BY blog_name";
2741
-	$result = Database::query($sql);
2742
-	$return_data = '';
2743
-	if (Database::num_rows($result)!=0) {
2744
-		while ($row=Database::fetch_array($result)) {
2745
-			$return_data.=  '<div class="clear"></div><br />';
2746
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>';
2747
-			$return_data.=  '<br / >';
2748
-			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2749
-			$return_data.=  $row['comment'];
2750
-			$return_data.=  '<br />';
2751
-		}
2752
-	}
2753
-	return $return_data;
2740
+    $result = Database::query($sql);
2741
+    $return_data = '';
2742
+    if (Database::num_rows($result)!=0) {
2743
+        while ($row=Database::fetch_array($result)) {
2744
+            $return_data.=  '<div class="clear"></div><br />';
2745
+            $return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>';
2746
+            $return_data.=  '<br / >';
2747
+            //$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2748
+            $return_data.=  $row['comment'];
2749
+            $return_data.=  '<br />';
2750
+        }
2751
+    }
2752
+    return $return_data;
2754 2753
 }
2755 2754
 
Please login to merge, or discard this patch.
custompages/language.inc.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
     krsort($langs, SORT_NUMERIC);
30 30
     // Choosing the best match
31 31
     foreach($langs as $weight => $codes) {
32
-		foreach ($codes as $code) {
33
-        	if (in_array($code, $available_langs)) {
34
-            	return $code;
35
-        	}
36
-		}
32
+        foreach ($codes as $code) {
33
+            if (in_array($code, $available_langs)) {
34
+                return $code;
35
+            }
36
+        }
37 37
     }
38 38
     // No match
39 39
     return null;
Please login to merge, or discard this patch.
custompages/language.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 $lang_match = $chamilo_langs[get_preferred_language($available_langs)];
25 25
 // recover previous value ...
26 26
 if (isset($_SESSION['user_language_choice']))
27
-	$lang_match = $_SESSION['user_language_choice'];
27
+    $lang_match = $_SESSION['user_language_choice'];
28 28
 
29 29
 // Chamilo parameter, on logout
30 30
 if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) {
31
-	$lang_match = $_REQUEST['language'];
31
+    $lang_match = $_REQUEST['language'];
32 32
 }
33 33
 // Incoming link parameter
34 34
 if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) {
35
-	$lang_match = $chamilo_langs[$_REQUEST['lang']];
35
+    $lang_match = $chamilo_langs[$_REQUEST['lang']];
36 36
 }
37 37
 
38 38
 $detect = api_get_setting('auto_detect_language_custom_pages');
Please login to merge, or discard this patch.