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) { editpost_filebrowser.callback(form, data); }; EOF; $smarty = smarty(array(), array(), array(), array('tinymceconfig' => ' image_filebrowser: "editpost_filebrowser", ', 'sideblocks' => array(array('name' => 'quota', 'weight' => -10, 'data' => array())))); $smarty->assign('INLINEJAVASCRIPT', $javascript);
public static function instance_config_form(BlockInstance $instance) { global $USER; require_once 'license.php'; safe_require('artefact', 'file'); $instance->set('artefactplugin', 'internal'); $configdata = $instance->get('configdata'); if (!($height = get_config('blockeditorheight'))) { $cfheight = param_integer('cfheight', 0); $height = $cfheight ? $cfheight * 0.7 : 150; } $otherblockcount = 0; $readonly = false; $text = ''; $tags = ''; $view = $instance->get_view(); if (!empty($configdata['artefactid'])) { $artefactid = $configdata['artefactid']; try { $artefact = $instance->get_artefact_instance($artefactid); $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact); $text = $artefact->get('description'); $tags = $artefact->get('tags'); if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) { $blocks = array_unique($blocks); $otherblockcount = count($blocks) - 1; } } catch (ArtefactNotFoundException $e) { unset($artefactid); } } $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>'; $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg); $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php'; if ($group = $view->get('group')) { $manageurl .= '?group=' . $group; } else { if ($institution = $view->get('institution')) { $manageurl .= '?institution=' . $institution; } } // Update the attached files in block configdata as // it may change when attached files have been deleted $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false; if ($attachmentids !== false && isset($configdata['artefactids']) && $configdata['artefactids'] != $attachmentids) { $configdata['artefactids'] = $attachmentids; $instance->set('configdata', $configdata); $instance->commit(); } $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . $otherblocksmsg . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox') . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'value' => '<div id="instconf_textreadonly_display" class="well text-midtone">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'value' => '<a id="chooseartefactlink" href="#" class="btn btn-default">' . get_string('usecontentfromanothertextbox1', 'blocktype.internal/textbox') . '</a>'), 'managenotes' => array('type' => 'html', 'class' => 'hidden text-right', 'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right right"></span></a>'), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'license' => license_form_el_basic(isset($artefact) ? $artefact : null), 'license_advanced' => license_form_el_advanced(isset($artefact) ? $artefact : null), 'licensereadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('license'), 'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'), 'artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('attachments', 'artefact.blog'), 'class' => 'last with-formgroup', 'elements' => array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null)))); if ($readonly) { $elements['license']['class'] = 'hidden'; $elements['license_advanced']['class'] = 'hidden'; } return $elements; }
public static function add_comment_form($defaultprivate = false, $moderate = false) { global $USER; $form = array('name' => 'add_feedback_form', 'method' => 'post', 'class' => 'js-hidden', 'plugintype' => 'artefact', 'pluginname' => 'comment', 'jsform' => true, 'autofocus' => false, 'elements' => array(), 'jssuccesscallback' => 'addFeedbackSuccess'); if (!$USER->is_logged_in()) { $form['spam'] = array('secret' => get_config('formsecret'), 'mintime' => 1, 'hash' => array('authorname', 'message', 'ispublic', 'message', 'submit')); $form['elements']['authorname'] = array('type' => 'text', 'title' => get_string('name'), 'rules' => array('required' => true)); } $form['elements']['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'rows' => 5, 'cols' => 80, 'rules' => array('maxlength' => 8192)); if (get_config_plugin('artefact', 'comment', 'commentratings')) { $form['elements']['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star'); } $form['elements']['ispublic'] = array('type' => 'checkbox', 'title' => get_string('makepublic', 'artefact.comment'), 'defaultvalue' => !$defaultprivate); if (get_config('licensemetadata')) { $form['elements']['license'] = license_form_el_basic(null); $form['elements']['licensing_advanced'] = license_form_el_advanced(null); } if ($moderate) { $form['elements']['ispublic']['description'] = get_string('approvalrequired', 'artefact.comment'); $form['elements']['moderate'] = array('type' => 'hidden', 'value' => true); } if ($USER->is_logged_in()) { $form['elements']['attachments'] = array('type' => 'files', 'title' => get_string('attachfile', 'artefact.comment'), 'defaultvalue' => array(), 'maxfilesize' => get_max_upload_size(false)); } $form['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('placefeedback', 'artefact.comment'), get_string('cancel'))); return $form; }
} $lastcomment = ArtefactTypeComment::last_public_comment($viewid, $comment->get('onartefact')); if (!$comment->get('private') && $id != $lastcomment->id) { $SESSION->add_error_msg(get_string('cantedithasreplies', 'artefact.comment')); redirect($goto); } $elements = array(); $elements['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'rows' => 5, 'cols' => 80, 'defaultvalue' => $comment->get('description'), 'rules' => array('maxlength' => 8192)); if (get_config_plugin('artefact', 'comment', 'commentratings')) { $elements['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star', 'defaultvalue' => $comment->get('rating')); } else { $elements['rating'] = array('type' => 'hidden', 'value' => $comment->get('rating')); } $elements['ispublic'] = array('type' => 'checkbox', 'title' => get_string('makepublic', 'artefact.comment'), 'defaultvalue' => !$comment->get('private')); if (get_config('licensemetadata')) { $elements['license'] = license_form_el_basic($comment); $elements['licensing_advanced'] = license_form_el_advanced($comment); } $elements['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => $goto); $form = pieform(array('name' => 'edit_comment', 'method' => 'post', 'plugintype' => 'artefact', 'pluginname' => 'comment', 'elements' => $elements)); function edit_comment_validate(Pieform $form, $values) { require_once get_config('libroot.php') . 'antispam.php'; $result = probation_validate_content($values['message']); if ($result !== true) { $form->set_error('message', get_string('newuserscantpostlinksorimages')); } } function edit_comment_submit(Pieform $form, $values) { global $viewid, $comment, $SESSION, $goto, $USER;
function general_account_prefs_form_elements($prefs) { global $USER; require_once 'license.php'; $elements = array(); $elements['friendscontrol'] = array('type' => 'radio', 'defaultvalue' => $prefs->friendscontrol, 'title' => get_string('friendsdescr', 'account'), 'class' => 'mrs mls', 'options' => array('nobody' => get_string('friendsnobody', 'account'), 'auth' => get_string('friendsauth', 'account'), 'auto' => get_string('friendsauto', 'account')), 'help' => true); $elements['wysiwyg'] = array('type' => 'switchbox', 'defaultvalue' => get_config('wysiwyg') ? get_config('wysiwyg') == 'enable' : $prefs->wysiwyg, 'title' => get_string('wysiwygdescr', 'account'), 'help' => true, 'disabled' => get_config('wysiwyg')); if (get_config('licensemetadata')) { $elements['licensedefault'] = license_form_el_basic(null); $elements['licensedefault']['title'] = get_string('licensedefault', 'account'); if ($USER->get('institutions')) { $elements['licensedefault']['options'][LICENSE_INSTITUTION_DEFAULT] = get_string('licensedefaultinherit', 'account'); } $elements['licensedefault']['description'] = get_string('licensedefaultdescription', 'account'); if (isset($prefs->licensedefault)) { $elements['licensedefault']['defaultvalue'] = $prefs->licensedefault; } } $elements['maildisabled'] = array('type' => 'switchbox', 'defaultvalue' => $prefs->maildisabled, 'title' => get_string('disableemail', 'account'), 'help' => true); $elements['messages'] = array('type' => 'radio', 'defaultvalue' => $prefs->messages, 'title' => get_string('messagesdescr', 'account'), 'options' => array('nobody' => get_string('messagesnobody', 'account'), 'friends' => get_string('messagesfriends', 'account'), 'allow' => get_string('messagesallow', 'account')), 'help' => true); $languages = get_languages(); // Determine default language. $instlang = get_user_institution_language($USER->id, $instlanginstname); if (!empty($instlang) && $instlang != 'default') { $sitedefaultlabel = get_string('defaultlangforinstitution', 'admin', get_config_institution($instlanginstname, 'displayname')) . ' (' . $languages[$instlang] . ')'; } else { $sitedefaultlabel = get_string('sitedefault', 'admin') . ' (' . $languages[get_config('lang')] . ')'; } $elements['lang'] = array('type' => 'select', 'defaultvalue' => $prefs->lang, 'title' => get_string('language', 'account'), 'options' => array_merge(array('default' => $sitedefaultlabel), $languages), 'help' => true, 'ignore' => count($languages) < 2); $sitethemes = array(); // Get all available standard site themes if (get_config('sitethemeprefs') && !in_admin_section()) { // get_user_accessible_themes() returns 'sitedefault' to mean fall back to the site or // institution theme. This won't work for account prefs, where 'sitedefault' is just // a theme that doesn't exist. So change the 'sitedefault' key to '', and the empty // preference will be interpreted as "No theme selected". $sitethemes = array_reverse(get_user_accessible_themes()); unset($sitethemes['sitedefault']); $sitethemes = array_reverse($sitethemes); } // Get all user's institution themes $institutionthemes = array(); if ($institutions = $USER->get('institutions')) { $allthemes = get_all_theme_objects(); foreach ($institutions as $i) { if (empty($i->theme)) { $institutionthemes['sitedefault' . '/' . $i->institution] = $i->displayname . ' - ' . get_string('sitedefault', 'admin'); } else { $institutionthemes[$i->theme . '/' . $i->institution] = $i->displayname . ' - ' . $allthemes[$i->theme]->displayname; } } } $themes = array_merge($sitethemes, $institutionthemes); natcasesort($themes); $currenttheme = $USER->get_themedata(); if (!isset($currenttheme->basename)) { $defaulttheme = 'sitedefault'; } else { $defaulttheme = $currenttheme->basename; } if (isset($currenttheme->institutionname)) { $defaulttheme = $defaulttheme . '/' . $currenttheme->institutionname; } if (!array_key_exists($defaulttheme, $themes)) { reset($themes); $defaulttheme = key($themes); } $elements['theme'] = array('type' => 'select', 'defaultvalue' => $defaulttheme, 'title' => get_string('theme'), 'options' => $themes, 'ignore' => count($themes) < 2, 'help' => true); $elements['addremovecolumns'] = array('type' => 'switchbox', 'defaultvalue' => $prefs->addremovecolumns, 'title' => get_string('showviewcolumns', 'account'), 'help' => 'true'); // TODO: add a way for plugins (like blog!) to have account preferences $elements['multipleblogs'] = array('type' => 'switchbox', 'title' => get_string('enablemultipleblogs1', 'account'), 'description' => get_string('enablemultipleblogsdescription1', 'account'), 'defaultvalue' => $prefs->multipleblogs); if (get_config('showtagssideblock')) { $elements['tagssideblockmaxtags'] = array('type' => 'text', 'size' => 4, 'title' => get_string('tagssideblockmaxtags', 'account'), 'description' => get_string('tagssideblockmaxtagsdescription', 'account'), 'defaultvalue' => isset($prefs->tagssideblockmaxtags) ? $prefs->tagssideblockmaxtags : get_config('tagssideblockmaxtags'), 'rules' => array('integer' => true, 'minvalue' => 0, 'maxvalue' => 1000)); } $elements['groupsideblockmaxgroups'] = array('type' => 'text', 'size' => 4, 'title' => get_string('limitto1', 'blocktype.mygroups'), 'description' => get_string('limittodescsideblock1', 'blocktype.mygroups'), 'defaultvalue' => isset($prefs->groupsideblockmaxgroups) ? $prefs->groupsideblockmaxgroups : '', 'rules' => array('regex' => '/^[0-9]*$/', 'minvalue' => 0, 'maxvalue' => 1000)); $elements['groupsideblocksortby'] = array('type' => 'select', 'defaultvalue' => isset($prefs->groupsideblocksortby) ? $prefs->groupsideblocksortby : 'alphabetical', 'title' => get_string('sortgroups', 'blocktype.mygroups'), 'options' => array('latest' => get_string('latest', 'blocktype.mygroups'), 'earliest' => get_string('earliest', 'blocktype.mygroups'), 'alphabetical' => get_string('alphabetical', 'blocktype.mygroups'))); if (get_config('userscanhiderealnames')) { $elements['hiderealname'] = array('type' => 'switchbox', 'title' => get_string('hiderealname', 'account'), 'description' => get_string('hiderealnamedescription', 'account'), 'defaultvalue' => $prefs->hiderealname); } if (get_config('homepageinfo')) { $elements['showhomeinfo'] = array('type' => 'switchbox', 'defaultvalue' => $prefs->showhomeinfo, 'title' => get_string('showhomeinfo2', 'account'), 'description' => get_string('showhomeinfodescription1', 'account', hsc(get_config('sitename'))), 'help' => 'true'); } if (get_config('showprogressbar')) { $elements['showprogressbar'] = array('type' => 'switchbox', 'defaultvalue' => $prefs->showprogressbar, 'title' => get_string('showprogressbar', 'account'), 'description' => get_string('showprogressbardescription', 'account', hsc(get_config('sitename')))); } if (get_config('allowmobileuploads')) { $defaultvalue = array(); $mobileuploadtoken = isset($prefs->mobileuploadtoken) ? $prefs->mobileuploadtoken : get_config('mobileuploadtoken'); $defaultvalue = explode('|', trim($mobileuploadtoken, '|')); $elements['mobileuploadtoken'] = array('type' => 'multitext', 'title' => get_string('mobileuploadtoken', 'account'), 'defaultvalue' => $defaultvalue, 'help' => 'true'); } if (get_config_plugin('artefact', 'file', 'resizeonuploadenable')) { $elements['resizeonuploaduserdefault'] = array('type' => 'switchbox', 'title' => get_string('resizeonuploaduserdefault1', 'account'), 'description' => get_string('resizeonuploaduserdefaultdescription2', 'account'), 'defaultvalue' => $prefs->resizeonuploaduserdefault); } if (get_config('userscandisabledevicedetection')) { $elements['devicedetection'] = array('type' => 'switchbox', 'title' => get_string('devicedetection', 'account'), 'description' => get_string('devicedetectiondescription', 'account'), 'defaultvalue' => $prefs->devicedetection); } return $elements; }
* @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', 'new'); require dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php'; define('TITLE', get_string('newblog', 'artefact.blog') . ': ' . get_string('blogsettings', 'artefact.blog')); require_once 'license.php'; require_once 'pieforms/pieform.php'; safe_require('artefact', 'blog'); $form = pieform(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', 'value' => array(get_string('createblog', 'artefact.blog'), get_string('cancel', 'artefact.blog')))))); $smarty =& smarty(); $smarty->assign_by_ref('form', $form); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('form.tpl'); exit; /** * This function gets called to submit the new blog. * * @param array */ function newblog_submit(Pieform $form, $values) { global $USER; ArtefactTypeBlog::new_blog($USER, $values); redirect('/artefact/blog/index.php');
/** * Given an artefact object, return the form already rendered. * * @param object The artefact * @return string HTML containing <tr> tags at the top level. */ function license_form_files($prefix, $prefix2 = null) { if (!get_config('licensemetadata')) { return ''; } require_once 'pieforms/pieform.php'; if ($prefix2 !== null) { $prefix .= '_' . $prefix2; } $form = array('name' => $prefix, 'plugintype' => 'artefact', 'pluginname' => 'file', 'elements' => array($prefix . '_license' => license_form_el_basic(null), 'license_advanced' => license_form_el_advanced(null, $prefix . '_'))); $pie = new Pieform($form); $pie->build(); $rendered = $pie->get_property('elements'); if (empty($form['elements'][$prefix . '_license']['rules']['required'])) { $rowattr = ''; } else { $rowattr = 'class="required"'; } $html = ''; foreach (array($rendered[$prefix . '_license'], $rendered['license_advanced']['elements'][$prefix . '_licensor'], $rendered['license_advanced']['elements'][$prefix . '_licensorurl']) as $e) { $helphtml = preg_replace('/files_filebrowser_(edit_)?licens/', 'licens', $e['helphtml']); $html .= '<div class="form-group">' . $rowattr . '' . $e['labelhtml'] . '' . '' . $e['html'] . $helphtml . '</div>'; $rowattr = ''; } $html = str_replace('id="' . $prefix . '_' . $prefix . '_', 'id="' . $prefix . '_', $html); $html = str_replace('for="' . $prefix . '_' . $prefix . '_', 'for="' . $prefix . '_', $html); return $html; }
/** * Gets the new/edit fields for the tasks pieform * */ public static function get_taskform_elements($parent, $task = null) { $elements = array('title' => array('type' => 'text', 'defaultvalue' => null, 'title' => get_string('title', 'artefact.plans'), 'description' => get_string('titledesc', 'artefact.plans'), 'size' => 30, 'rules' => array('required' => true)), 'completiondate' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false, 'ifFormat' => '%Y/%m/%d', 'dateFormat' => 'yy/mm/dd'), 'defaultvalue' => null, 'title' => get_string('completiondate', 'artefact.plans'), 'description' => get_string('dateformatguide'), 'rules' => array('required' => true)), 'description' => array('type' => 'textarea', 'rows' => 10, 'cols' => 50, 'resizable' => false, 'defaultvalue' => null, 'title' => get_string('description', 'artefact.plans')), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile')), 'completed' => array('type' => 'checkbox', 'defaultvalue' => null, 'title' => get_string('completed', 'artefact.plans'), 'description' => get_string('completeddesc', 'artefact.plans'))); if (!empty($task)) { foreach ($elements as $k => $element) { $elements[$k]['defaultvalue'] = $task->get($k); } $elements['task'] = array('type' => 'hidden', 'value' => $task->id); } if (get_config('licensemetadata')) { $elements['license'] = license_form_el_basic($task); $elements['license_advanced'] = license_form_el_advanced($task); } $elements['parent'] = array('type' => 'hidden', 'value' => $parent); return $elements; }
public static function add_comment_form($defaultprivate = false, $moderate = false) { global $USER; $form = array('name' => 'add_feedback_form', 'method' => 'post', 'plugintype' => 'artefact', 'pluginname' => 'comment', 'jsform' => true, 'autofocus' => false, 'elements' => array(), 'jssuccesscallback' => 'addFeedbackSuccess', 'jserrorcallback' => 'addFeedbackError'); if (!$USER->is_logged_in()) { $form['spam'] = array('secret' => get_config('formsecret'), 'mintime' => 1, 'hash' => array('authorname', 'message', 'message', 'submit')); $form['elements']['authorname'] = array('type' => 'text', 'title' => get_string('name'), 'rules' => array('required' => true)); } $form['elements']['message'] = array('type' => 'wysiwyg', 'title' => get_string('message'), 'class' => 'hide-label', 'rows' => 5, 'cols' => 80, 'rules' => array('maxlength' => 8192)); if (get_config_plugin('artefact', 'comment', 'commentratings')) { $form['elements']['rating'] = array('type' => 'radio', 'title' => get_string('rating', 'artefact.comment'), 'options' => array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''), 'class' => 'star'); } $form['elements']['ispublic'] = array('type' => 'switchbox', 'title' => get_string('makepublic', 'artefact.comment'), 'defaultvalue' => !$defaultprivate); if (get_config('licensemetadata')) { $form['elements']['license'] = license_form_el_basic(null); $form['elements']['licensing_advanced'] = license_form_el_advanced(null); } if ($moderate) { $form['elements']['ispublic']['description'] = get_string('approvalrequired', 'artefact.comment'); $form['elements']['moderate'] = array('type' => 'hidden', 'value' => true); } if ($USER->is_logged_in()) { $form['elements']['attachments'] = array('type' => 'files', 'title' => get_string('attachfile', 'artefact.comment'), 'defaultvalue' => array(), 'maxfilesize' => get_max_upload_size(false)); } $form['elements']['submit'] = array('type' => 'submitcancel', 'class' => 'btn-default', 'value' => array(get_string('Comment', 'artefact.comment'), get_string('cancel'))); // This is a placeholder where we can display the parent comment's text // And also the strings we display when we are forcing a reply to be public or private $snippet = smarty_core(); $form['elements']['replytoview'] = array('type' => 'html', 'value' => $snippet->fetch('artefact:comment:replyplaceholder.tpl')); // This is a placeholder for the parent comment's ID. It'll be populated by Javascript if needed. $form['elements']['replyto'] = array('type' => 'hidden', 'dynamic' => 'true', 'value' => null); return $form; }
$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; /** * This function is called to update the blog details. */ function editblog_submit(Pieform $form, $values)
} else { if ($institution = $artefact->get('institution')) { define('INSTITUTIONALADMIN', 1); define('MENUITEM', 'manageinstitutions'); $goto .= '?institution=' . $institution; } else { define('MENUITEM', 'content/notes'); } } $folder = param_integer('folder', 0); $browse = (int) param_variable('browse', 0); $highlight = null; if ($file = param_integer('file', 0)) { $highlight = array($file); } $form = array('name' => 'editnote', 'method' => 'post', 'jsform' => true, 'newiframeonsubmit' => true, 'jssuccesscallback' => 'editnote_callback', 'jserrorcallback' => 'editnote_callback', 'plugintype' => 'artefact', 'pluginname' => 'internal', 'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'), 'elements' => array('title' => array('type' => 'text', 'title' => get_string('Title', 'artefact.internal'), 'defaultvalue' => $artefact->get('title')), 'description' => array('type' => 'wysiwyg', 'title' => get_string('Note', 'artefact.internal'), 'rows' => 10, 'cols' => 70, 'defaultvalue' => $artefact->get('description')), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $artefact->get('tags')), 'license' => license_form_el_basic($artefact), 'licensing_advanced' => license_form_el_advanced($artefact), 'filebrowser' => array('type' => 'filebrowser', 'title' => get_string('attachments', 'artefact.blog'), 'folder' => $folder, 'highlight' => $highlight, 'browse' => $browse, 'page' => get_config('wwwroot') . 'artefact/internal/editnote.php?id=' . $note . '&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' => $artefact->attachment_id_list(), 'selectlistcallback' => 'artefact_get_records_by_id', 'selectcallback' => 'add_note_attachment', 'unselectcallback' => 'delete_note_attachment'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => $artefact->get('allowcomments')), 'perms' => array('type' => 'rolepermissions', 'title' => get_string('Permissions'), 'defaultvalue' => $artefact->get('rolepermissions'), 'group' => $group, 'ignore' => !$group), 'submitnote' => array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => $goto))); if (!get_config('licensemetadata')) { unset($form['elements']['license']); unset($form['elements']['licensing_advanced']); } $form = pieform($form); /* * Javascript specific to this page. Creates the list of files * attached to the note. */ $wwwroot = get_config('wwwroot'); $noimagesmessage = json_encode(get_string('noimageshavebeenattachedtothispost', 'artefact.blog')); $javascript = <<<EOF function editnote_callback(form, data) { editnote_filebrowser.callback(form, data); };
} $elements['customthemefs']['elements']['resetcustom'] = array('type' => 'switchbox', 'class' => 'nojs-hidden-inline', 'title' => get_string('resetcolours', 'admin'), 'description' => get_string('resetcoloursdesc1', 'admin')); $elements['dropdownmenu'] = array('type' => 'switchbox', 'title' => get_string('dropdownmenu', 'admin'), 'description' => get_string('dropdownmenudescriptioninstitution1', 'admin'), 'defaultvalue' => $data->dropdownmenu, 'help' => true); } // The skins checkbox should be shown for the default institution if (get_config('skins')) { $elements['skins'] = array('type' => 'switchbox', 'title' => get_string('skins', 'admin'), 'description' => get_string('skinsinstitutiondescription1', 'admin'), 'defaultvalue' => $data->skins); } $elements['commentsortorder'] = array('type' => 'select', 'title' => get_string('commentsortorder', 'admin'), 'description' => get_string('commentsortorderdescription', 'admin'), 'defaultvalue' => $data->commentsortorder, 'options' => array('earliest' => get_string('earliest'), 'latest' => get_string('latest')), 'help' => true); $elements['commentthreaded'] = array('type' => 'switchbox', 'title' => get_string('commentthreaded', 'admin'), 'description' => get_string('commentthreadeddescription', 'admin'), 'defaultvalue' => $data->commentthreaded); // Some more fields that are hidden from the default institution if (empty($data->name) || $data->name != 'mahara') { $elements['showonlineusers'] = array('type' => 'select', 'disabled' => get_config('showonlineuserssideblock') ? '' : 'disabled', 'title' => get_string('showonlineusers', 'admin'), 'description' => get_string('showonlineusersdescription', 'admin'), 'defaultvalue' => $data->showonlineusers, 'collapseifoneoption' => true, 'options' => $showonlineusersoptions); if (get_config('licensemetadata')) { $elements['licensemandatory'] = array('type' => 'switchbox', 'title' => get_string('licensemandatory', 'admin'), 'description' => get_string('licensemandatorydescription', 'admin'), 'defaultvalue' => $data->licensemandatory); $elements['licensedefault'] = license_form_el_basic(null, true); $elements['licensedefault']['title'] = get_string('licensedefault', 'admin'); $elements['licensedefault']['description'] = get_string('licensedefaultdescription', 'admin'); if ($data->licensedefault) { $elements['licensedefault']['defaultvalue'] = $data->licensedefault; } } if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) { $elements['defaultquota'] = array('type' => 'bytes', 'title' => get_string('defaultquota', 'artefact.file'), 'description' => get_string('defaultinstitutionquotadescription', 'admin'), 'defaultvalue' => !empty($data->defaultquota) ? $data->defaultquota : get_config_plugin('artefact', 'file', 'defaultquota')); $elements['updateuserquotas'] = array('type' => 'switchbox', 'title' => get_string('updateuserquotas', 'artefact.file'), 'description' => get_string('updateinstitutionuserquotasdesc1', 'admin')); } else { $elements['defaultquota'] = array('type' => 'text', 'title' => get_string('defaultquota', 'artefact.file'), 'value' => display_size(!empty($data->defaultquota) ? $data->defaultquota : get_config_plugin('artefact', 'file', 'defaultquota')), 'disabled' => true); } $elements['allowinstitutionpublicviews'] = array('type' => 'switchbox', 'title' => get_string('allowinstitutionpublicviews', 'admin'), 'description' => get_string('allowinstitutionpublicviewsdescription1', 'admin'), 'defaultvalue' => get_config('allowpublicviews') && $data->allowinstitutionpublicviews, 'disabled' => get_config('allowpublicviews') == false, 'help' => true); if ($USER->get('admin')) { $elements['maxuseraccounts'] = array('type' => 'text', 'title' => get_string('maxuseraccounts', 'admin'), 'description' => get_string('maxuseraccountsdescription', 'admin'), 'defaultvalue' => empty($data->maxuseraccounts) ? '' : $data->maxuseraccounts, 'rules' => array('regex' => '/^\\d*$/', 'maxlength' => 8), 'size' => 5);
define('SECTION_PAGE', 'index'); define('RESUME_SUBPAGE', 'license'); require_once dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('resume', 'artefact.resume')); require_once 'pieforms/pieform.php'; require_once 'license.php'; safe_require('artefact', 'resume'); if (!get_config('licensemetadata')) { redirect('/artefact/resume'); } $personalinformation = null; try { $personalinformation = artefact_instance_from_type('personalinformation'); } catch (Exception $e) { } $form = array('name' => 'resumelicense', 'plugintype' => 'artefact', 'pluginname' => 'resume', 'elements' => array('license' => license_form_el_basic($personalinformation), 'license_advanced' => license_form_el_advanced($personalinformation), 'submit' => array('type' => 'submit', 'value' => get_string('save')))); $form = pieform($form); function resumelicense_submit(Pieform $form, $values) { global $personalinformation, $USER; $userid = $USER->get('id'); if (empty($personalinformation)) { $personalinformation = new ArtefactTypePersonalinformation(0, array('owner' => $userid, 'title' => get_string('personalinformation', 'artefact.resume'))); } if (get_config('licensemetadata')) { $personalinformation->set('license', $values['license']); $personalinformation->set('licensor', $values['licensor']); $personalinformation->set('licensorurl', $values['licensorurl']); } $personalinformation->commit(); $result = array('error' => false, 'message' => get_string('resumesaved', 'artefact.resume'), 'goto' => get_config('wwwroot') . 'artefact/resume/license.php');
/** * Gets the new/edit fields for the activities pieform * */ public static function get_activityform_elements($parent, $activity = null) { $elements = array('title' => array('type' => 'text', 'defaultvalue' => null, 'title' => get_string('activity', 'artefact.cpds'), 'description' => get_string('titledesc', 'artefact.cpds'), 'size' => 30, 'rules' => array('required' => true)), 'location' => array('type' => 'text', 'size' => 30, 'defaultvalue' => null, 'title' => get_string('location', 'artefact.cpds'), 'description' => get_string('locationdesc', 'artefact.cpds'), 'rules' => array('required' => true)), 'startdate' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false, 'ifFormat' => '%Y/%m/%d', 'dateFormat' => 'yy/mm/dd'), 'defaultvalue' => null, 'title' => get_string('startdate', 'artefact.cpds'), 'description' => get_string('dateformatguide'), 'rules' => array('required' => true)), 'enddate' => array('type' => 'calendar', 'caloptions' => array('showsTime' => false, 'ifFormat' => '%Y/%m/%d', 'dateFormat' => 'yy/mm/dd'), 'defaultvalue' => null, 'title' => get_string('enddate', 'artefact.cpds'), 'description' => get_string('dateformatguide'), 'rules' => array('required' => false)), 'description' => array('type' => 'wysiwyg', 'rows' => 10, 'cols' => 70, 'resizable' => false, 'defaultvalue' => null, 'title' => get_string('description', 'artefact.cpds'), 'rules' => array('maxlength' => 65536)), 'tags' => array('type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile')), 'hours' => array('type' => 'text', 'size' => 7, 'defaultvalue' => 0.0, 'title' => get_string('hours', 'artefact.cpds'), 'description' => get_string('hoursdesc', 'artefact.cpds'))); if (!empty($activity)) { foreach ($elements as $k => $element) { $elements[$k]['defaultvalue'] = $activity->get($k); } $elements['activity'] = array('type' => 'hidden', 'value' => $activity->id); } if (get_config('licensemetadata')) { $elements['license'] = license_form_el_basic($activity); $elements['license_advanced'] = license_form_el_advanced($activity); } $elements['parent'] = array('type' => 'hidden', 'value' => $parent); return $elements; }