Exemplo n.º 1
0
function delete_blog_submit(Pieform $form, $values)
{
    global $SESSION;
    $blog = new ArtefactTypeBlog($values['delete']);
    $blog->check_permission();
    if ($blog->get('locked')) {
        $SESSION->add_error_msg(get_string('submittedforassessment', 'view'));
    } else {
        $blog->delete();
        $SESSION->add_ok_msg(get_string('blogdeleted', 'artefact.blog'));
    }
    redirect('/artefact/blog/index.php');
}
Exemplo n.º 2
0
function delete_blog_submit(Pieform $form, $values)
{
    global $SESSION;
    require_once 'embeddedimage.php';
    $blog = new ArtefactTypeBlog($values['delete']);
    $blog->check_permission();
    $institution = $blog->get('institution');
    if ($blog->get('locked')) {
        $SESSION->add_error_msg(get_string('submittedforassessment', 'view'));
    } else {
        $blog->delete();
        EmbeddedImage::delete_embedded_images('blog', $blog->get('id'));
        $SESSION->add_ok_msg(get_string('blogdeleted', 'artefact.blog'));
    }
    if ($institution) {
        redirect('/artefact/blog/index.php?institution=' . $institution);
    }
    redirect('/artefact/blog/index.php');
}
Exemplo n.º 3
0
    throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('Blog', 'artefact.blog')));
}
/*
 * For a new post, the 'blog' parameter will be set to the blog's
 * artefact id.  For an existing post, the 'blogpost' parameter will
 * be set to the blogpost's artefact id.
 */
$blogpost = param_integer('blogpost', param_integer('id', 0));
if (!$blogpost) {
    /*
     *  For a new post, a tag can be set from tagged blogpost block
     */
    $tagselect = param_variable('tagselect', '');
    $blog = param_integer('blog');
    $blogobj = new ArtefactTypeBlog($blog);
    $blogobj->check_permission(true);
    $title = '';
    $description = '';
    $tags = array($tagselect);
    $checked = '';
    $pagetitle = get_string('newblogpost', 'artefact.blog', get_field('artefact', 'title', 'id', $blog));
    $focuselement = 'title';
    $attachments = array();
    if ($blogobj->get('group')) {
        $group = get_record('group', 'id', $blogobj->get('group'), 'deleted', 0);
        $subsectionheading = $pagetitle;
        define('TITLE', $group->name);
    } else {
        define('TITLE', $pagetitle);
    }
} else {
Exemplo n.º 4
0
        }
    }
    if ($records) {
        if (count($records) > 1) {
            // no id supplied and more than one journal so go to journal list page
            redirect("/artefact/blog/index.php");
            exit;
        }
        $id = $records[0]->id;
        $blog = new ArtefactTypeBlog($id, $records[0]);
    }
} else {
    $blog = new ArtefactTypeBlog($id);
}
if (!empty($blog)) {
    $blog->check_permission();
}
if (!isset($limit)) {
    $limit = param_integer('limit', 5);
}
if (!isset($setlimit)) {
    $setlimit = 0;
}
if (!isset($offset)) {
    $offset = param_integer('offset', 0);
}
$posts = ArtefactTypeBlogPost::get_posts($id, $limit, $offset);
$template = 'artefact:blog:posts.tpl';
$pagination = array('baseurl' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $id, 'id' => 'blogpost_pagination', 'jsonscript' => 'artefact/blog/view/index.json.php', 'datatable' => 'postlist', 'setlimit' => $setlimit);
ArtefactTypeBlogPost::render_posts($posts, $template, array(), $pagination);
$strpublished = json_encode(get_string('published', 'artefact.blog'));
Exemplo n.º 5
0
if (!PluginArtefactBlog::is_active()) {
    throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('blog', 'artefact.blog')));
}
$id = param_integer('id');
$blog = new ArtefactTypeBlog($id);
$institution = $institutionname = $groupid = null;
if ($blog->get('institution')) {
    $institution = true;
    $institutionname = $blog->get('institution');
} else {
    if ($blog->get('group')) {
        $groupid = $blog->get('group');
    }
}
PluginArtefactBlog::set_blog_nav($institution, $institutionname, $groupid);
$blog->check_permission(true);
if ($blog->get('locked')) {
    throw new AccessDeniedException(get_string('submittedforassessment', 'view'));
}
$form = pieform(array('name' => 'editblog', 'method' => 'post', 'action' => '', 'plugintype' => 'artefact', 'pluginname' => 'blog', 'elements' => array('id' => array('type' => 'hidden', 'value' => $id), 'institution' => array('type' => 'hidden', 'value' => $institutionname ? $institutionname : 0), 'group' => array('type' => 'hidden', 'value' => $groupid ? $groupid : 0), 'title' => array('type' => 'text', 'title' => get_string('blogtitle', 'artefact.blog'), 'description' => get_string('blogtitledesc', 'artefact.blog'), 'rules' => array('required' => true), 'defaultvalue' => $blog->get('title')), 'description' => array('type' => 'wysiwyg', 'rows' => 10, 'cols' => 70, 'title' => get_string('blogdesc', 'artefact.blog'), 'description' => get_string('blogdescdesc', 'artefact.blog'), 'rules' => array('maxlength' => 65536, 'required' => false), 'defaultvalue' => $blog->get('description')), 'tags' => array('defaultvalue' => $blog->get('tags'), 'type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'help' => true), 'license' => license_form_el_basic($blog), 'licensing_advanced' => license_form_el_advanced($blog), 'submit' => array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('savesettings', 'artefact.blog'), get_string('cancel', 'artefact.blog'))))));
$smarty = smarty();
if (!$institutionname && !$groupid) {
    if (!$USER->get_account_preference('multipleblogs') && count_records('artefact', 'artefacttype', 'blog', 'owner', $USER->get('id')) == 1) {
        $smarty->assign('enablemultipleblogstext', 1);
    }
}
$smarty->assign_by_ref('editform', $form);
$smarty->assign_by_ref('blog', $blog);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->display('artefact:blog:settings.tpl');
exit;
Exemplo n.º 6
0
    throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('blog', 'artefact.blog')));
}
/*
 * For a new post, the 'blog' parameter will be set to the blog's
 * artefact id.  For an existing post, the 'blogpost' parameter will
 * be set to the blogpost's artefact id.
 */
$blogpost = param_integer('blogpost', param_integer('id', 0));
if (!$blogpost) {
    /*
     *  For a new post, a tag can be set from tagged blogpost block
     */
    $tagselect = param_variable('tagselect', '');
    $blog = param_integer('blog');
    $blogobj = new ArtefactTypeBlog($blog);
    $blogobj->check_permission();
    $title = '';
    $description = '';
    $tags = array($tagselect);
    $checked = '';
    $pagetitle = get_string('newblogpost', 'artefact.blog', get_field('artefact', 'title', 'id', $blog));
    $focuselement = 'title';
    $attachments = array();
    define('TITLE', $pagetitle);
} else {
    $blogpostobj = new ArtefactTypeBlogPost($blogpost);
    $blogpostobj->check_permission();
    if ($blogpostobj->get('locked')) {
        throw new AccessDeniedException(get_string('submittedforassessment', 'view'));
    }
    $blog = $blogpostobj->get('parent');