public static function instance_config_form($instance, $istemplate) { if ($istemplate) { // No configuration when this block is in a template return array(); } safe_require('artefact', 'blog'); $configdata = $instance->get('configdata'); return array(self::artefactchooser_element(isset($configdata['artefactids']) ? $configdata['artefactids'] : null, $istemplate), PluginArtefactBlog::block_advanced_options_element($configdata, 'blog')); }
public static function instance_config_form(BlockInstance $instance) { global $USER; safe_require('artefact', 'blog'); $configdata = $instance->get('configdata'); if (!empty($configdata['artefactid'])) { $blog = $instance->get_artefact_instance($configdata['artefactid']); } $elements = array(); // If the blog post in this block is owned by the owner of the View, // then the block can be configured. Otherwise, the blog post was // copied in from another View. We won't confuse users by asking them to // choose a blog post to put in this block, when the one that is // currently in it isn't choosable. // // Note: the owner check will have to change when we do group/site // blogs if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) { $publishedposts = get_column_sql(' SELECT a.id FROM {artefact} a INNER JOIN {artefact_blog_blogpost} p ON p.blogpost = a.id WHERE p.published = 1 AND a.owner= ?', array($USER->get('id'))); $elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $publishedposts); $elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blogpost'); } else { $elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blogpost', 'artefact.blog')) . '</div>'); } return $elements; }
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) {
$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) {
public static function instance_config_form(BlockInstance $instance) { global $USER; safe_require('artefact', 'blog'); $configdata = $instance->get('configdata'); require_once get_config('libroot') . 'view.php'; $view = new View($instance->get('view')); $institution = $view->get('institution'); $group = $view->get('group'); if (!empty($configdata['artefactid'])) { $blog = $instance->get_artefact_instance($configdata['artefactid']); } $elements = array(); // If the blog in this block is owned by the owner of the View, then // the block can be configured. Otherwise, the blog was copied in from // another View. We won't confuse users by asking them to choose a blog // to put in this block, when the one that is currently in it isn't // choosable. // // Note: the owner check will have to change when we do group/site // blogs if (empty($configdata['artefactid']) || ArtefactTypeBlog::can_edit_blog($blog, $institution, $group)) { $where = array('blog'); $sql = "SELECT a.id FROM {artefact} a\n WHERE a.artefacttype = ?"; if ($institution) { $sql .= " AND a.institution = ?"; $where[] = $institution; } else { if ($group) { $sql .= " AND a.group = ?"; $where[] = $group; } else { $sql .= " AND a.owner = ?"; $where[] = $USER->get('id'); } } $blogids = get_column_sql($sql, $where); $elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $blogids); $elements['count'] = array('type' => 'text', 'title' => get_string('postsperpage', 'blocktype.blog/blog'), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 5, 'size' => 3); $elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blog'); } else { $elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('Blog', 'artefact.blog')) . '</div>'); } return $elements; }
public static function instance_config_form($instance) { global $USER; safe_require('artefact', 'blog'); $configdata = $instance->get('configdata'); if (!empty($configdata['artefactid'])) { $blog = $instance->get_artefact_instance($configdata['artefactid']); } $elements = array(); // If the blog in this block is owned by the owner of the View, then // the block can be configured. Otherwise, the blog was copied in from // another View. We won't confuse users by asking them to choose a blog // to put in this block, when the one that is currently in it isn't // choosable. // // Note: the owner check will have to change when we do group/site // blogs if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) { $elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null); $elements['count'] = array('type' => 'text', 'title' => get_string('postsperpage', 'blocktype.blog/blog'), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 5, 'size' => 3); $elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blog'); } else { $elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="message">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blog', 'artefact.blog')) . '</div>'); } return $elements; }
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');
public static function instance_config_form(BlockInstance $instance) { global $USER; safe_require('artefact', 'blog'); $configdata = $instance->get('configdata'); if (!empty($configdata['artefactid'])) { $blog = $instance->get_artefact_instance($configdata['artefactid']); } $elements = array(); // If the blog post in this block is owned by the owner of the View, // then the block can be configured. Otherwise, the blog post was // copied in from another View. We won't confuse users by asking them to // choose a blog post to put in this block, when the one that is // currently in it isn't choosable. $institution = $instance->get('view_obj')->get('institution'); $group = $instance->get('view_obj')->get('group'); if (empty($configdata['artefactid']) || ArtefactTypeBlog::can_edit_blog($blog, $institution, $group)) { $sql = "SELECT a.id FROM {artefact} a\n INNER JOIN {artefact_blog_blogpost} p ON p.blogpost = a.id\n WHERE p.published = 1"; if ($institution) { $sql .= " AND a.institution = ?"; $where = array($institution); } else { if ($group) { $sql .= " AND a.group = ?"; $where = array($group); } else { $sql .= " AND a.owner = ?"; $where = array($USER->get('id')); } } $publishedposts = get_column_sql($sql, $where); $elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $publishedposts); $elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blogpost'); } else { $elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blogpost', 'artefact.blog')) . '</div>'); } return $elements; }
* @subpackage artefact-blog * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'content/blogs'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'blog'); define('SECTION_PAGE', 'view'); require dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php'; define('TITLE', get_string('viewblog', 'artefact.blog')); safe_require('artefact', 'blog'); require_once get_config('libroot') . 'pieforms/pieform.php'; if (!PluginArtefactBlog::is_active()) { throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('blog', 'artefact.blog'))); } if ($changepoststatus = param_integer('changepoststatus', null)) { ArtefactTypeBlogpost::changepoststatus_form($changepoststatus); } if ($delete = param_integer('delete', null)) { ArtefactTypeBlogpost::delete_form($delete); } $id = param_integer('id', null); if ($blogpost = param_integer('blogpost', null)) { $post = ArtefactTypeBlogPost::get_post_data($blogpost); $id = $post->blogid; $limit = 1; $setlimit = 1; $offset = $post->offset;