index.php 3.58 KB
Newer Older
Alastair Pharo's avatar
Alastair Pharo committed
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
40
41
42
43
44
45
46
47
<?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-internal
 * @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
 *
 */

define('INTERNAL', 1);
define('MENUITEM', 'myblogs');

require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php');
safe_require('artefact', 'blog');

$form = pieform(array(
    'name' => 'newblog',
    'method' => 'post',
    'action' => '',
    'elements' => array(
        'title' => array(
            'type'        => 'text',
            'title'       => get_string('blogtitle', 'artefact.blog'),
            'description' => get_string('blogtitledesc', 'artefact.blog'),
            'rules' => array(
                'required'    => true
            )
        ),
        'description' => array(
Alastair Pharo's avatar
Alastair Pharo committed
48
            'type'        => 'wysiwyg',
Alastair Pharo's avatar
Alastair Pharo committed
49
            'rows'        => 10,
50
            'cols'        => 70,
Alastair Pharo's avatar
Alastair Pharo committed
51
52
53
            'title'       => get_string('blogdesc', 'artefact.blog'),
            'description' => get_string('blogdescdesc', 'artefact.blog'),
            'rules' => array(
Alastair Pharo's avatar
Alastair Pharo committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
                'required'    => false
            )
        ),
        'commentsallowed' => array(
            'type'        => 'radio',
            'title'       => get_string('commentsallowed', 'artefact.blog'),
            'description' => get_string('commentsalloweddesc', 'artefact.blog'),
            'options'     => array(
                0 => get_string('commentsallowedno', 'artefact.blog'),
                1 => get_string('commentsallowedyes', 'artefact.blog')
            )
        ),
        'commentsnotify' => array(
            'type'        => 'radio',
            'title'       => get_string('commentsnotify', 'artefact.blog'),
            'description' => get_string('commentsnotifydesc', 'artefact.blog'),
            'options'     => array(
                0 => get_string('commentsnotifyno', 'artefact.blog'),
                1 => get_string('commentsnotifyyes', 'artefact.blog')
Alastair Pharo's avatar
Alastair Pharo committed
73
74
75
            )
        ),
        'submit' => array(
Alastair Pharo's avatar
Alastair Pharo committed
76
77
78
79
80
            'type'  => 'submitcancel',
            'value' => array(
                get_string('createblog', 'artefact.blog'),
                get_string('cancel', 'artefact.blog')
            )
Alastair Pharo's avatar
Alastair Pharo committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        )
    )
));

$smarty =& smarty();
$smarty->assign_by_ref('newblogform', $form);
$smarty->display('artefact:blog:new.tpl');
exit;

/**
 * This function gets called to submit the new blog.
 *
 * @param array
 */
95
function newblog_submit(Pieform $form, $values) {
Alastair Pharo's avatar
Alastair Pharo committed
96
97
98
    global $USER;

    ArtefactTypeBlog::new_blog($USER, $values);
Alastair Pharo's avatar
Alastair Pharo committed
99
100
101
102
103
104
105
106
    redirect(get_config('wwwroot') . 'artefact/blog/list/');
}

/**
 * This function gets called to cancel a submission.
 */
function newblog_cancel_submit() {
    redirect(get_config('wwwroot') . 'artefact/blog/list/');
Alastair Pharo's avatar
Alastair Pharo committed
107
108
109
}

?>