lib.php 21.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
 * This program is part of Mahara
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 * @package    mahara
 * @subpackage artefact-blog
 * @author     Alastair Pharo <alastair@catalyst.net.nz>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

defined('INTERNAL') || die();

/** 
 * Users can create blogs and blog posts using this plugin.
 */
class PluginArtefactBlog extends PluginArtefact {

    public static function get_artefact_types() {
        return array(
            'blog',
            'blogpost',
        );
    }
40
41
42
43
    
    public static function get_block_types() {
        return array();
    }
44
45
46
47
48
49
50

    public static function get_plugin_name() {
        return 'blog';
    }

    public static function menu_items() {
        return array(
Martyn Smith's avatar
Martyn Smith committed
51
            array(
52
53
54
55
56
                'path'   => 'myportfolio/blogs',
                'url'    => 'artefact/blog/',
                'title'  => get_string('blogs', 'artefact.blog'),
                'weight' => 30,
            ),
57
58
        );
    }
59

60
61
62
63
    public static function get_cron() {
        return array(
            (object)array(
                'callfunction' => 'clean_post_files',
Richard Mansfield's avatar
Richard Mansfield committed
64
65
                'hour'         => '4',
                'minute'       => '40'
66
67
68
69
70
71
72
73
74
            )
        );
    }

    /**
     * This function cleans out any files that have been uploaded, but which
     * are not associated with a blog, because of an aborted blog creation.
     */
    public static function clean_post_files() {
75

Richard Mansfield's avatar
Richard Mansfield committed
76
77
78
79
80
81
82
83
84
85
86
87
        $bloguploadbase = get_config('dataroot') . ArtefactTypeBlogPost::$blogattachmentroot;
        if (!$basedir = opendir($bloguploadbase)) {
            throw new Exception('Unable to read blog upload directory '.$bloguploadbase);
        }

        $currenttime = time();

        // Read through all the upload session directories
        while (false !== ($sessionupload = readdir($basedir))) {
            if ($sessionupload != "." && $sessionupload != "..") {
                $sessionupload = $bloguploadbase . $sessionupload;
                $subdir = opendir($sessionupload);
88

Richard Mansfield's avatar
Richard Mansfield committed
89
90
91
92
93
94
95
96
97
98
99
100
101
                // Remove all files older than the session timeout plus two hours.
                while (false !== ($uploadfile = readdir($subdir))) {
                    if ($uploadfile != "." && $uploadfile != "..") {
                        $uploadfile = $sessionupload . '/' . $uploadfile;
                        if ($currenttime - filemtime($uploadfile) > get_config('session_timeout') + 7200) {
                            unlink($uploadfile);
                        }
                    }
                }

                closedir($subdir);
                rmdir($sessionupload);
            }
102
        }
Richard Mansfield's avatar
Richard Mansfield committed
103
104

        closedir($basedir);
105
    }
106
107
108
109
110
111
112
}

/**
 * A Blog artefact is a collection of BlogPost artefacts.
 */
class ArtefactTypeBlog extends ArtefactType {

Alastair Pharo's avatar
Alastair Pharo committed
113
114
115
116
117
    /**
     * This constant gives the per-page pagination for listing blogs.
     */
    const pagination = 10;
    
118
119
120
    
    /** 
     * Whether comments are allowed on this blog or not.
Alastair Pharo's avatar
Alastair Pharo committed
121
122
     *
     * @var boolean
123
124
125
126
127
     */
    protected $commentsallowed = false;

    /** 
     * Whether the blog owner will be notified of comments or not.
Alastair Pharo's avatar
Alastair Pharo committed
128
129
     *
     * @var boolean
130
131
132
     */
    protected $commentsnotify = false;

133
134
135
136
137
138
139
140
141
    /**
     * We override the constructor to fetch the extra data.
     *
     * @param integer
     * @param object
     */
    public function __construct($id = 0, $data = null) {
        parent::__construct($id, $data);

142
        if (!$data) {
143
144
145
146
147
148
            if ($this->id) {
                if ($blogdata = get_record('artefact_blog_blog', 'blog', $this->id)) {
                    foreach($blogdata as $name => $value) {
                        if (property_exists($this, $name)) {
                            $this->$name = $value;
                        }
149
                    }
150
                }
151
152
153
154
                else {
                    // This should never happen unless the user is playing around with blog IDs in the location bar or similar
                    throw new ArtefactNotFoundException(get_string('blogdoesnotexist', 'artefact.blog'));
                }
155
            }
156
        }
157
158
159
160
161
162
163
164

        if (empty($this->id)) {
            $this->container = 1;
        }
    }

    public function is_container() {
        return true;
165
    }
Alastair Pharo's avatar
Alastair Pharo committed
166
167

    /**
168
169
170
     * This function updates or inserts the artefact.  This involves putting
     * some data in the artefact table (handled by parent::commit()), and then
     * some data in the artefact_blog_blog table.
Alastair Pharo's avatar
Alastair Pharo committed
171
     */
172
    public function commit() {
173
174
175
176
177
178
179
180
181
182
183
184
185
186
        // Just forget the whole thing when we're clean.
        if (empty($this->dirty)) {
            return;
        }
      
        // We need to keep track of newness before and after.
        $new = empty($this->id);
        
        // Commit to the artefact table.
        parent::commit();

        // Reset dirtyness for the time being.
        $this->dirty = true;

Alastair Pharo's avatar
Alastair Pharo committed
187
        $data = (object)array(
188
189
190
191
192
193
194
195
196
197
198
199
200
            'blog'            => $this->get('id'),
            'commentsallowed' => ($this->get('commentsallowed') ? 1 : 0),
            'commentsnotify'  => ($this->get('commentsnotify') ? 1 : 0)
        );

        if ($new) {
            insert_record('artefact_blog_blog', $data);
        }
        else {
            update_record('artefact_blog_blog', $data, 'blog');
        }

        $this->dirty = false;
201
202
    }

Alastair Pharo's avatar
Alastair Pharo committed
203
    /**
204
205
     * This function extends ArtefactType::delete() by deleting blog-specific
     * data.
Alastair Pharo's avatar
Alastair Pharo committed
206
     */
207
    public function delete() {
208
209
210
211
212
213
214
215
216
        if (empty($this->id)) {
            return;
        }

        // Delete the blog-specific data.
        delete_records('artefact_blog_blog', 'blog', $this->id);

        // Delete the artefact and all children.
        parent::delete();
217
218
    }

219
220
221
222
223
224
225
226
227
228
229
230
231
    /**
     * Checks that the person viewing this blog is the owner. If not, throws an 
     * AccessDeniedException. Used in the blog section to ensure only the 
     * owners of the blogs can view or change them there. Other people see 
     * blogs when they are placed in views.
     */
    public function check_permission() {
        global $USER;
        if ($USER->get('id') != $this->owner) {
            throw new AccessDeniedException(get_string('youarenottheownerofthisblog', 'artefact.blog'));
        }
    }

232

233
234
    public function describe_size() {
        return $this->count_children() . ' ' . get_string('posts', 'artefact.blog');
235
236
    }

237
                
238
    public static function get_icon($options=null) {
239
240
    }

Nigel McNie's avatar
Nigel McNie committed
241
    public static function is_singular() {
Penny Leach's avatar
Penny Leach committed
242
243
244
        return false;
    }

Alastair Pharo's avatar
Alastair Pharo committed
245
    public static function collapse_config() {
246
247
    }

Alastair Pharo's avatar
Alastair Pharo committed
248
249
250
251
252
253
254
255
256
    /**
     * This function returns a list of the given user's blogs.
     *
     * @param User
     * @return array (count: integer, data: array)
     */
    public static function get_blog_list(User $user, $limit = self::pagination, $offset = 0) {
        ($result = get_records_sql_array("
         SELECT id, title, description
257
         FROM {artefact}
Alastair Pharo's avatar
Alastair Pharo committed
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
         WHERE owner = ?
          AND artefacttype = 'blog'
         ORDER BY title
         LIMIT ? OFFSET ?", array($user->get('id'), $limit, $offset)))
            || ($result = array());

        $count = (int)get_field('artefact', 'COUNT(*)', 'owner', $user->get('id'), 'artefacttype', 'blog');

        return array($count, $result);
    }

    /**
     * This function creates a new blog.
     *
     * @param User
     * @param array
     */
Alastair Pharo's avatar
Alastair Pharo committed
275
    public static function new_blog(User $user, array $values) {
Alastair Pharo's avatar
Alastair Pharo committed
276
277
278
279
        $artefact = new ArtefactTypeBlog();
        $artefact->set('title', $values['title']);
        $artefact->set('description', $values['description']);
        $artefact->set('owner', $user->get('id'));
280
281
        $artefact->set('commentsallowed', $values['commentsallowed'] ? true : false);
        $artefact->set('commentsnotify', $values['commentsnotify'] ? true : false);
282
        $artefact->set('tags', $values['tags']);
Alastair Pharo's avatar
Alastair Pharo committed
283
        $artefact->commit();
284
    }
Alastair Pharo's avatar
Alastair Pharo committed
285
286
287
288
289
290
291
292
293
294
295
296
297

    /**
     * This function updates an existing blog.
     *
     * @param User
     * @param array
     */
    public static function edit_blog(User $user, array $values) {
        if (empty($values['id']) || !is_numeric($values['id'])) {
            return;
        }

        $artefact = new ArtefactTypeBlog($values['id']);
298
299
300
301
        if ($user->get('id') != $artefact->get('owner')) {
            return;
        }
        
Alastair Pharo's avatar
Alastair Pharo committed
302
303
304
305
        $artefact->set('title', $values['title']);
        $artefact->set('description', $values['description']);
        $artefact->set('commentsallowed', $values['commentsallowed'] ? true : false);
        $artefact->set('commentsnotify', $values['commentsnotify'] ? true : false);
306
        $artefact->set('tags', $values['tags']);
Alastair Pharo's avatar
Alastair Pharo committed
307
308
        $artefact->commit();
    }
309
310
311
312

    public function public_feedback_allowed() {
        return $this->get('commentsallowed');
    }
313
314
315
316
317
318


    public function feedback_notify_owner() {
        return $this->get('commentsnotify');
    }

Martyn Smith's avatar
Martyn Smith committed
319
320
    public static function get_links($id) {
        $wwwroot = get_config('wwwroot');
321

Martyn Smith's avatar
Martyn Smith committed
322
323
324
325
326
        return array(
            '_default'                                  => $wwwroot . 'artefact/blog/view/?id=' . $id,
            get_string('blogsettings', 'artefact.blog') => $wwwroot . 'artefact/blog/settings/?id=' . $id,
        );
    }
327
328
329
330
331
332
333
}

/**
 * BlogPost artefacts occur within Blog artefacts
 */
class ArtefactTypeBlogPost extends ArtefactType {

Alastair Pharo's avatar
Alastair Pharo committed
334
335
336
337
338
    /**
     * This gives the number of blog posts to display at a time.
     */
    const pagination = 10;

339
    /**
Alastair Pharo's avatar
Alastair Pharo committed
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
     * This defines whether the blogpost is published or not.
     *
     * @var boolean
     */
    protected $published = false;

    /**
     * We override the constructor to fetch the extra data.
     *
     * @param integer
     * @param object
     */
    public function __construct($id = 0, $data = null) {
        parent::__construct($id, $data);

355
        if (!$data) {
356
357
358
359
360
361
            if ($this->id) {
                if ($bpdata = get_record('artefact_blog_blogpost', 'blogpost', $this->id)) {
                    foreach($bpdata as $name => $value) {
                        if (property_exists($this, $name)) {
                            $this->$name = $value;
                        }
362
                    }
Alastair Pharo's avatar
Alastair Pharo committed
363
                }
364
365
366
367
                else {
                    // This should never happen unless the user is playing around with blog post IDs in the location bar or similar
                    throw new ArtefactNotFoundException(get_string('blogpostdoesnotexist', 'artefact.blog'));
                }
368
369
            }
        }
Alastair Pharo's avatar
Alastair Pharo committed
370
371
372
373
374
    }

    /**
     * This function extends ArtefactType::commit() by adding additional data
     * into the artefact_blog_blogpost table.
375
     */
376
    public function commit() {
Alastair Pharo's avatar
Alastair Pharo committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
        if (empty($this->dirty)) {
            return;
        }

        $new = empty($this->id);
      
        parent::commit();

        $this->dirty = true;

        $data = (object)array(
            'blogpost'  => $this->get('id'),
            'published' => ($this->get('published') ? 1 : 0)
        );

        if ($new) {
            insert_record('artefact_blog_blogpost', $data);
        }
        else {
            update_record('artefact_blog_blogpost', $data, 'blogpost');
        }

        $this->dirty = false;
400
401
    }

402
    /**
Alastair Pharo's avatar
Alastair Pharo committed
403
404
     * This function extends ArtefactType::delete() by also deleting anything
     * that's in blogpost.
405
     */
406
    public function delete() {
Alastair Pharo's avatar
Alastair Pharo committed
407
408
409
        if (empty($this->id)) {
            return;
        }
410

Martyn Smith's avatar
Martyn Smith committed
411
        delete_records('artefact_blog_blogpost_file', 'blogpost', $this->id);
Alastair Pharo's avatar
Alastair Pharo committed
412
413
414
415
        delete_records('artefact_blog_blogpost', 'blogpost', $this->id);
      
        parent::delete();
    }
416
417
418
419
420
421
422
423
424
425
426
427
428

    /**
     * Checks that the person viewing this blog is the owner. If not, throws an 
     * AccessDeniedException. Used in the blog section to ensure only the 
     * owners of the blogs can view or change them there. Other people see 
     * blogs when they are placed in views.
     */
    public function check_permission() {
        global $USER;
        if ($USER->get('id') != $this->owner) {
            throw new AccessDeniedException(get_string('youarenottheownerofthisblogpost', 'artefact.blog'));
        }
    }
429
  
430
431
    public function describe_size() {
        return $this->count_attachments() . ' ' . get_string('attachments', 'artefact.blog');
432
433
    }

434
435
436
437
438
439
440
441
442
443
444
445
    public function attachment_id_list() {
        if (!$list = get_column('artefact_blog_blogpost_file', 'file', 'blogpost', $this->get('id'))) {
            $list = array();
        }
        return $list;
    }

    public function attach_file($artefactid) {
        $data = new StdClass;
        $data->blogpost = $this->get('id');
        $data->file = $artefactid;
        insert_record('artefact_blog_blogpost_file', $data);
446
447
448
449
450

        $data->artefact = $data->file;
        $data->parent = $data->blogpost;
        $data->dirty = true;
        insert_record('artefact_parent_cache', $data);
451
452
453
454
    }

    public function detach_file($artefactid) {
        delete_records('artefact_blog_blogpost_file', 'blogpost', $this->get('id'), 'file', $artefactid);
455
        delete_records('artefact_parent_cache', 'parent', $this->get('id'), 'artefact', $artefactid);
456
457
    }

Richard Mansfield's avatar
Richard Mansfield committed
458
459
460
461
462
463

    protected function count_attachments() {
        return count_records('artefact_blog_blogpost_file', 'blogpost', $this->get('id'));
    }


464
    public static function get_icon($options=null) {
465
466
    }

Nigel McNie's avatar
Nigel McNie committed
467
    public static function is_singular() {
Penny Leach's avatar
Penny Leach committed
468
469
470
        return false;
    }

Alastair Pharo's avatar
Alastair Pharo committed
471
    public static function collapse_config() {
472
473
    }

Alastair Pharo's avatar
Alastair Pharo committed
474
475
476
477
478
479
480
481
482
    /**
     * This function returns a list of the current user's blog posts, for the
     * given blog.
     *
     * @param User
     * @param integer
     * @param integer
     */
    public static function get_posts(User $user, $id, $limit = self::pagination, $offset = 0) {
483
        ($result = get_records_sql_assoc("
Alastair Pharo's avatar
Alastair Pharo committed
484
         SELECT a.id, a.title, a.description, a.ctime, a.mtime, bp.published
485
486
         FROM {artefact} a
          LEFT OUTER JOIN {artefact_blog_blogpost} bp
Alastair Pharo's avatar
Alastair Pharo committed
487
488
489
490
           ON a.id = bp.blogpost
         WHERE a.parent = ?
          AND a.artefacttype = 'blogpost'
          AND a.owner = ?
491
         ORDER BY bp.published ASC, a.ctime DESC
Alastair Pharo's avatar
Alastair Pharo committed
492
493
494
495
496
497
498
499
         LIMIT ? OFFSET ?;", array(
            $id,
            $user->get('id'),
            $limit,
            $offset
        )))
            || ($result = array());

500
501
502
503
        $count = (int)get_field('artefact', 'COUNT(*)', 'owner', $user->get('id'), 
                                'artefacttype', 'blogpost', 'parent', $id);

        // Get the attached files.
504
        if (count($result) > 0) {
505
506
507
508
            $idlist = implode(', ', array_map(create_function('$a', 'return $a->id;'), $result));
            $files = get_records_sql_array('
               SELECT
                  bf.blogpost, bf.file, a.artefacttype, a.title, a.description
509
510
               FROM {artefact_blog_blogpost_file} bf
                  INNER JOIN {artefact} a ON bf.file = a.id
511
512
513
514
515
516
517
               WHERE bf.blogpost IN (' . $idlist . ')', '');
            if ($files) {
                foreach ($files as $file) {
                    $result[$file->blogpost]->files[] = $file;
                }
            }
        }
Alastair Pharo's avatar
Alastair Pharo committed
518

519
        return array($count, array_values($result));
Alastair Pharo's avatar
Alastair Pharo committed
520
521
    }

522
    /** 
Alastair Pharo's avatar
Alastair Pharo committed
523
524
525
526
527
528
529
530
531
532
    /**
     * This function creates a new blog post.
     *
     * @param User
     * @param array
     */
    public static function new_post(User $user, array $values) {
        $artefact = new ArtefactTypeBlogPost();
        $artefact->set('title', $values['title']);
        $artefact->set('description', $values['description']);
Alastair Pharo's avatar
Alastair Pharo committed
533
        $artefact->set('published', $values['published']);
Alastair Pharo's avatar
Alastair Pharo committed
534
        $artefact->set('owner', $user->get('id'));
535
        $artefact->set('parent', $values['parent']);
Alastair Pharo's avatar
Alastair Pharo committed
536
        $artefact->commit();
537
        return true;
538
    }
Alastair Pharo's avatar
Alastair Pharo committed
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554

    /** 
     * This function updates an existing blog post.
     *
     * @param User
     * @param array
     */
    public static function edit_post(User $user, array $values) {
        $artefact = new ArtefactTypeBlogPost($values['id']);
        if ($user->get('id') != $artefact->get('owner')) {
            return false;
        }

        $artefact->set('title', $values['title']);
        $artefact->set('description', $values['description']);
        $artefact->set('published', $values['published']);
555
        $artefact->set('tags', $values['tags']);
Alastair Pharo's avatar
Alastair Pharo committed
556
557
558
559
        $artefact->commit();
        return true;
    }

560
561
562
    // Where to store temporary blog post files under dataroot
    static $blogattachmentroot = 'artefact/blog/uploads/';

563
564
565
566
567
568
569

    public static function get_temp_file_path($createid, $uploadnumber) {
        return get_config('dataroot') . self::$blogattachmentroot 
            . session_id() . $createid . '/' . $uploadnumber;
    }


570
571
572
573
574
575
576
577
    /**
     * Returns the size of a temporary attachment
     */
    public static function temp_attachment_size($createid, $uploadnumber) {
        return filesize(self::get_temp_file_path($createid, $uploadnumber));
    }


578
579
580
581
    /** 
     * This function saves an uploaded file to a temporary directory in dataroot
     *
     */
582
    public static function save_attachment_temporary($inputname, $dirname, $filename) {
583
584
        require_once('uploadmanager.php');
        $um = new upload_manager($inputname);
585
586
587
        $result = new StdClass;
        $tempdir = self::$blogattachmentroot . $dirname;
        $result->error = $um->process_file_upload($tempdir, $filename);
588
        $result->oldextension = $um->original_filename_extension();
589
590
591
592
        $tempfile = $tempdir . '/' . $filename;
        safe_require('artefact', 'file');
        $result->type = ArtefactTypeFile::detect_artefact_type($tempfile);
        return $result;
593
594
595
    }


596
597
598
    /**
     * Save a temporary uploaded file to the myfiles area.
     */
599
    public function save_attachment($directory, $filename, $title, $description, $oldextension, $tags) {
600
601
602
603
604
605
606

        // Create the blogfiles folder if it doesn't exist yet.
        $blogfilesid = self::blogfiles_folder_id();
        if (!$blogfilesid) {
            return false;
        }

607
608
609
610
611
612
613
        global $USER;

        safe_require('artefact', 'file');

        $data = new StdClass;
        $data->title = $title;
        $data->description = $description;
614
        $data->tags = $tags;
Richard Mansfield's avatar
Richard Mansfield committed
615
616
        $data->owner = $USER->get('id');
        $data->adminfiles = 0; // No admin blogs yet...
617
        $data->parent = $blogfilesid;
618
        $data->oldextension = $oldextension;
Richard Mansfield's avatar
Richard Mansfield committed
619
620
        
        $path = self::$blogattachmentroot . $directory . '/' . $filename;
621

Richard Mansfield's avatar
Richard Mansfield committed
622
        if (!$fileid = ArtefactTypeFile::save_file($path, $data)) {
623
624
            return false;
        }
625
626

        $this->attach_file($fileid);
627
        return $fileid;
628
629
630
631
632
633
634
635
636
    }

    public static function blogfiles_folder_id() {
        $name = get_string('blogfilesdirname', 'artefact.blog');
        $description = get_string('blogfilesdirdescription', 'artefact.blog');
        safe_require('artefact', 'file');
        return ArtefactTypeFolder::get_folder_id($name, $description);
    }

Alastair Pharo's avatar
Alastair Pharo committed
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
    /**
     * This function publishes the blog post.
     *
     * @return boolean
     */
    public function publish() {
        if (!$this->id) {
            return false;
        }
        
        $data = (object)array(
            'blogpost'  => $this->id,
            'published' => 1
        );

        if (get_field('artefact_blog_blogpost', 'COUNT(*)', 'blogpost', $this->id)) {
            update_record('artefact_blog_blogpost', $data, 'blogpost');
        }
        else {
            insert_record('artefact_blog_blogpost', $data);
        }
        return true;
    }
660
661
662
663
664
665
666
667

    /**
     * This function returns a list of files attached to a post to use
     * when displaying or editing a blog post
     *
     * @return array
     */
    public function get_attached_files() {
668
        $list = get_records_sql_array('SELECT a.id, a.artefacttype, a.title, a.description 
669
670
            FROM {artefact_blog_blogpost_file} f
            INNER JOIN {artefact} a ON a.id = f.file
671
            WHERE f.blogpost = ' . $this->id, '');
672
673

        // load tags
Martyn Smith's avatar
Martyn Smith committed
674
675
676
677
        if ($list) {
            foreach ( $list as &$attachment ) {
                $attachment->tags = join(', ', get_column('artefact_tag', 'tag', 'artefact', $attachment->id));
            }
678
679
        }
        return $list;
680
    }
681

682
    public function public_feedback_allowed() {
683
684
685
686
        // Comments are not allowed on posts when the blog has
        // commentsallowed set to 0;
        $parent = get_field('artefact', 'parent', 'id', $this->get('id'));
        return get_field('artefact_blog_blog', 'commentsallowed', 'blog', $parent);
687
    }
688
    
689
    
690
691
692
693
694
695
696
    public function feedback_notify_owner() {
        // Notify owner of comments on posts when the blog has
        // commentsnotify set to 1;
        $parent = get_field('artefact', 'parent', 'id', $this->get('id'));
        return get_field('artefact_blog_blog', 'commentsnotify', 'blog', $parent);
    }
    
Martyn Smith's avatar
Martyn Smith committed
697
698
699
700
701
702
703
    public static function get_links($id) {
        $wwwroot = get_config('wwwroot');

        return array(
            '_default'                                  => $wwwroot . 'artefact/blog/post.php?blogpost=' . $id,
        );
    }
704
}
705
706

?>