$institutionname = $s['institution']; if (!($USER->get('admin') || $USER->is_institutional_admin())) { throw new AccessDeniedException(); } $title = get_string('institutionblogs', 'artefact.blog'); } } else { if ($id) { $blogobj = new ArtefactTypeBlog($id); $institution = $institutionname = $blogobj->get('institution'); if ($institution != 'mahara') { $s = institution_selector_for_page($institution, get_config('wwwroot') . 'artefact/blog/view/index.php'); } } } PluginArtefactBlog::set_blog_nav($institution, $institutionname); if ($institutionname === false) { $smarty = smarty(); $smarty->display('admin/users/noinstitutions.tpl'); exit; } if ($changepoststatus = param_integer('changepoststatus', null)) { ArtefactTypeBlogpost::changepoststatus_form($changepoststatus); } if ($delete = param_integer('delete', null)) { ArtefactTypeBlogpost::delete_form($delete); } if (is_null($id)) { if ($institutionname) { $records = get_records_select_array('artefact', "artefacttype = 'blog' AND \"institution\" = ?", array($institutionname), 'id ASC'); if (!$records || count($records) > 1) {
define('TITLE', $group->name); } else { define('TITLE', $pagetitle); } } $institution = $institutionname = $groupid = null; $blogobj = new ArtefactTypeBlog($blog); if ($blogobj->get('institution')) { $institution = true; $institutionname = $blogobj->get('institution'); } else { if ($blogobj->get('group')) { $groupid = $blogobj->get('group'); } } PluginArtefactBlog::set_blog_nav($institution, $institutionname, $groupid); $folder = param_integer('folder', 0); $browse = (int) param_variable('browse', 0); $highlight = null; if ($file = param_integer('file', 0)) { $highlight = array($file); } $form = pieform(array('name' => 'editpost', 'method' => 'post', 'autofocus' => $focuselement, 'jsform' => true, 'newiframeonsubmit' => true, 'jssuccesscallback' => 'editpost_callback', 'jserrorcallback' => 'editpost_callback', 'plugintype' => 'artefact', 'pluginname' => 'blog', 'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'), 'elements' => array('blog' => array('type' => 'hidden', 'value' => $blog), 'blogpost' => array('type' => 'hidden', 'value' => $blogpost), 'title' => array('type' => 'text', 'title' => get_string('posttitle', 'artefact.blog'), 'rules' => array('required' => true), 'defaultvalue' => $title), 'description' => array('type' => 'wysiwyg', 'rows' => 20, 'cols' => 70, 'title' => get_string('postbody', 'artefact.blog'), 'description' => get_string('postbodydesc', 'artefact.blog'), 'rules' => array('maxlength' => 65536, 'required' => true), 'defaultvalue' => $description), 'tags' => array('defaultvalue' => $tags, 'type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdesc'), 'help' => true), 'license' => license_form_el_basic(isset($blogpostobj) ? $blogpostobj : null), 'licensing_advanced' => license_form_el_advanced(isset($blogpostobj) ? $blogpostobj : null), 'filebrowser' => array('type' => 'filebrowser', 'title' => get_string('attachments', 'artefact.blog'), 'folder' => $folder, 'highlight' => $highlight, 'institution' => $institutionname, 'group' => $groupid, 'browse' => $browse, 'page' => get_config('wwwroot') . 'artefact/blog/post.php?' . ($blogpost ? 'id=' . $blogpost : 'blog=' . $blog) . '&browse=1', 'browsehelp' => 'browsemyfiles', 'config' => array('upload' => true, 'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'), 'resizeonuploaduseroption' => get_config_plugin('artefact', 'file', 'resizeonuploaduseroption'), 'resizeonuploaduserdefault' => $USER->get_account_preference('resizeonuploaduserdefault'), 'createfolder' => false, 'edit' => false, 'select' => true), 'defaultvalue' => $attachments, 'selectlistcallback' => 'artefact_get_records_by_id', 'selectcallback' => 'add_attachment', 'unselectcallback' => 'delete_attachment'), 'draft' => array('type' => 'switchbox', 'title' => get_string('draft', 'artefact.blog'), 'description' => get_string('thisisdraftdesc', 'artefact.blog'), 'defaultvalue' => $checked, 'help' => true), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'description' => get_string('allowcommentsonpost', 'artefact.blog'), 'defaultvalue' => $blogpost ? $blogpostobj->get('allowcomments') : 1), 'submitpost' => array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('savepost', 'artefact.blog'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog)))); /* * Javascript specific to this page. Creates the list of files * attached to the blog post. */ $wwwroot = get_config('wwwroot'); $noimagesmessage = json_encode(get_string('noimageshavebeenattachedtothispost', 'artefact.blog')); $javascript = <<<EOF function editpost_callback(form, data) {
define('TITLE', get_string('newblog' . $section, 'artefact.blog', institution_display_name($institutionname)) . ': ' . get_string('blogsettings', 'artefact.blog')); PluginArtefactBlog::set_blog_nav(true, $institutionname); } else { if ($groupid = param_alphanum('group', null)) { require_once 'group.php'; $group = get_record('group', 'id', $groupid, 'deleted', 0); $USER->reset_grouproles(); if (!isset($USER->grouproles[$group->id])) { throw new AccessDeniedException(get_string('youarenotamemberof', 'artefact.blog', $group->name)); } if (!group_role_can_edit_views($groupid, $USER->grouproles[$group->id])) { throw new AccessDeniedException(get_string('youarenotaneditingmemberof', 'artefact.blog', $group->name)); } $subsectionheading = get_string('newblog', 'artefact.blog'); define('TITLE', $group->name); PluginArtefactBlog::set_blog_nav(false, null, $groupid); } else { define('TITLE', get_string('newblog', 'artefact.blog') . ': ' . get_string('blogsettings', 'artefact.blog')); } } $form = array('name' => 'newblog', 'method' => 'post', 'action' => '', 'plugintype' => 'artefact', 'pluginname' => 'blog', 'elements' => array('title' => array('type' => 'text', 'title' => get_string('blogtitle', 'artefact.blog'), 'description' => get_string('blogtitledesc', 'artefact.blog'), 'rules' => array('required' => true)), '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)), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'help' => true), 'license' => license_form_el_basic(null), 'licensing_advanced' => license_form_el_advanced(null), 'submit' => array('type' => 'submitcancel', 'class' => 'btn-success', 'value' => array(get_string('createblog', 'artefact.blog'), get_string('cancel', 'artefact.blog'))))); $form['elements']['institution'] = array('type' => 'hidden', 'value' => $institutionname ? $institutionname : 0); $form['elements']['group'] = array('type' => 'hidden', 'value' => $groupid ? $groupid : 0); $form = pieform($form); $smarty =& smarty(); $smarty->assign_by_ref('form', $form); if ($subsectionheading) { $smarty->assign('subsectionheading', $subsectionheading); } $smarty->assign('PAGEHEADING', TITLE); $smarty->display('form.tpl');