Beispiel #1
0
            }
        }
    }
}
$elements = array('firstname' => array('type' => 'text', 'title' => get_string('firstname'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'lastname' => array('type' => 'text', 'title' => get_string('lastname'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'email' => array('type' => 'text', 'title' => get_string('email'), 'rules' => array('required' => true), 'class' => 'form-control text'), 'leap2afile' => array('type' => 'file', 'class' => 'leap2aupload', 'title' => ''), 'username' => array('type' => 'text', 'title' => get_string('username'), 'rules' => array('required' => true, 'maxlength' => 236)), 'password' => array('type' => 'password', 'title' => get_string('password'), 'rules' => array('required' => true)), 'staff' => array('type' => 'switchbox', 'title' => get_string('sitestaff', 'admin'), 'ignore' => !$USER->get('admin')), 'admin' => array('type' => 'switchbox', 'title' => get_string('siteadmin', 'admin'), 'ignore' => !$USER->get('admin')), 'quota' => array('type' => 'bytes', 'title' => get_string('filequota1', 'admin'), 'rules' => array('integer' => true, 'minvalue' => 0), 'defaultvalue' => get_config_plugin('artefact', 'file', 'defaultquota')), 'authinstance' => array('type' => 'select', 'title' => get_string('institution'), 'options' => $options, 'defaultvalue' => 1, 'rules' => array('required' => true), 'ignore' => !$authinstancecount), 'institutionadmin' => array('type' => 'switchbox', 'class' => 'last', 'title' => get_string('institutionadministrator', 'admin'), 'ignore' => !$authinstancecount), 'submit' => array('type' => 'submit', 'value' => get_string('createuser', 'admin'), 'class' => 'btn-success btn-lg btn-block mtm'));
if (!$USER->get('admin')) {
    unset($elements['authinstance']['defaultvalue']);
}
if (!($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride'))) {
    $elements['quota'] = array('type' => 'text', 'disabled' => true, 'title' => get_string('filequota1', 'admin'), 'description' => get_string('filequotadescription', 'admin'), 'value' => display_size(get_config_plugin('artefact', 'file', 'defaultquota')));
}
// Add general account options
$prefs = (object) expected_account_preferences();
$elements = array_merge($elements, general_account_prefs_form_elements($prefs));
unset($prefs);
$form = pieform(array('name' => 'adduser', 'class' => 'panel panel-default panel-body pts', 'autofocus' => false, 'template' => 'adduser.php', 'templatedir' => pieform_template_dir('adduser.php'), 'plugintype' => 'core', 'pluginname' => 'admin', 'class' => 'form-condensed', 'elements' => $elements));
function adduser_validate(Pieform $form, $values)
{
    global $USER, $TRANSPORTER;
    $authobj = AuthFactory::create($values['authinstance']);
    $institution = $authobj->institution;
    // Institutional admins can only set their own institutions' authinstances
    if (!$USER->get('admin') && !$USER->is_institutional_admin($authobj->institution)) {
        $form->set_error('authinstance', get_string('notadminforinstitution', 'admin'));
        return;
    }
    $institution = new Institution($authobj->institution);
    // Don't exceed max user accounts for the institution
    if ($institution->isFull()) {
        $institution->send_admin_institution_is_full_message();
        $form->set_error('authinstance', get_string('institutionmaxusersexceeded', 'admin'));
        }
    }
    //END OVERWRITE 1
}
$elements = array('firstname' => array('type' => 'text', 'title' => get_string('firstname'), 'rules' => array('required' => true)), 'lastname' => array('type' => 'text', 'title' => get_string('lastname'), 'rules' => array('required' => true)), 'email' => array('type' => 'text', 'title' => get_string('email'), 'rules' => array('required' => true)), 'leap2afile' => array('type' => 'file', 'title' => ''), 'username' => array('type' => 'text', 'title' => get_string('username'), 'rules' => array('required' => true, 'maxlength' => 236)), 'password' => array('type' => 'password', 'title' => get_string('password'), 'rules' => array('required' => true)), 'staff' => array('type' => 'checkbox', 'title' => get_string('sitestaff', 'admin'), 'ignore' => !$USER->get('admin')), 'admin' => array('type' => 'checkbox', 'title' => get_string('siteadmin', 'admin'), 'ignore' => !$USER->get('admin')), 'quota' => array('type' => 'bytes', 'title' => get_string('filequota1', 'admin'), 'rules' => array('integer' => true, 'minvalue' => 0), 'defaultvalue' => get_config_plugin('artefact', 'file', 'defaultquota')), 'authinstance' => array('type' => 'select', 'title' => get_string('institution'), 'options' => $options, 'defaultvalue' => $mhr_auth_instance->id, 'rules' => array('required' => true), 'ignore' => !$authinstancecount), 'institutionadmin' => array('type' => 'checkbox', 'title' => get_string('institutionadministrator', 'admin'), 'ignore' => !$authinstancecount), 'submit' => array('type' => 'submit', 'value' => get_string('createuser', 'admin')));
if (!$USER->get('admin')) {
    unset($elements['authinstance']['defaultvalue']);
}
if (!($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride'))) {
    $elements['quota'] = array('type' => 'text', 'disabled' => true, 'title' => get_string('filequota1', 'admin'), 'description' => get_string('filequotadescription', 'admin'), 'value' => display_size(get_config_plugin('artefact', 'file', 'defaultquota')));
}
// Add general account options
$prefs = (object) expected_account_preferences();
$elements = array_merge($elements, general_account_prefs_form_elements($prefs));
unset($prefs);
$form = pieform(array('name' => 'adduser', 'autofocus' => false, 'template' => 'adduser.php', 'templatedir' => pieform_template_dir('adduser.php'), 'plugintype' => 'core', 'pluginname' => 'admin', 'elements' => $elements));
function adduser_validate(Pieform $form, $values)
{
    global $USER, $TRANSPORTER;
    $authobj = AuthFactory::create($values['authinstance']);
    $institution = $authobj->institution;
    // Institutional admins can only set their own institutions' authinstances
    if (!$USER->get('admin') && !$USER->is_institutional_admin($authobj->institution)) {
        $form->set_error('authinstance', get_string('notadminforinstitution', 'admin'));
        return;
    }
    // OVERWRITE 3: insert
    if ($authobj->authname != 'internal') {
        $form->set_error('authinstance', 'Must be internal');
        return;
    }
 public function wallpost_form(BlockInstance $instance, $replyto = '', $replyuser = '')
 {
     if ($replyuser) {
         $walltoreplyto = self::get_wall_id_for_user($replyuser);
     } else {
         $walltoreplyto = $instance->get('id');
     }
     require_once 'pieforms/pieform.php';
     return pieform(array('name' => 'wallpost_' . $instance->get('id'), 'renderer' => 'maharatable', 'autofocus' => false, 'jsform' => true, 'template' => 'wallpost.php', 'templatedir' => pieform_template_dir('wallpost.php', 'blocktype/wall'), 'successcallback' => array('PluginBlocktypeWall', 'wallpost_submit'), 'jssuccesscallback' => 'wallpost_success', 'elements' => array('text' => array('type' => 'textarea', 'description' => bbcode_format_post_message(), 'rows' => 3, 'cols' => 50, 'defaultvalue' => '', 'width' => '100%', 'rules' => array('required' => true, 'maxlength' => get_config_plugin('blocktype', 'wall', 'defaultpostsizelimit'))), 'postsizelimit' => array('type' => 'html', 'value' => get_string('maxcharacters', 'blocktype.wall', get_config_plugin('blocktype', 'wall', 'defaultpostsizelimit'))), 'private' => array('type' => 'checkbox', 'title' => get_string('makeyourpostprivate', 'blocktype.wall')), 'instance' => array('type' => 'hidden', 'value' => $walltoreplyto), 'replyto' => array('type' => 'hidden', 'value' => $replyto), 'submit' => array('type' => 'submit', 'value' => get_string('Post', 'blocktype.wall')))));
     // TODO if replying here, add select element for replyto other wall or own wall
     // depending on if the user we're replying to has a wall
 }
function get_max_custom_rows() {
    return {$maxlayoutrows};
}

addLoadEvent(function () {
    formchangemanager.add("viewlayout");
});

JAVASCRIPT;
$elements = array('viewid' => array('type' => 'hidden', 'value' => $view->get('id')));
$elements['customlayoutnumrows'] = array('type' => 'hidden', 'value' => 1);
$elements['layoutselect'] = array('type' => 'hidden', 'value' => $currentlayout, 'sesskey' => $USER->get('sesskey'));
$elements['layoutfallback'] = array('type' => 'hidden', 'value' => $defaultlayout->id);
$elements['submit'] = array('type' => 'submit', 'value' => get_string('save'));
$templatedata = array('id' => $id, 'basiclayoutoptions' => $basiclayoutoptions, 'layoutoptions' => $layoutoptions, 'currentlayout' => $currentlayout, 'clnumcolumnsoptions' => $clnumcolumnsoptions, 'clnumcolumnsdefault' => $clnumcolumnsdefault, 'columnlayoutoptions' => $columnlayoutoptions, 'customlayout' => $defaultlayout->id, 'clwidths' => $clwidths, 'maxrows' => $maxrows);
$layoutform = array('name' => 'viewlayout', 'template' => 'viewlayout.php', 'templatedir' => pieform_template_dir('viewlayout.php'), 'autofocus' => false, 'templatedata' => $templatedata, 'elements' => $elements);
$layoutform = pieform($layoutform);
$javascript = array('jquery', 'js/jquery/jquery-ui/js/jquery-ui-1.10.2.min.js', 'js/customlayout.js', 'js/jquery/modernizr.custom.js');
$stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/ui-lightness/jquery-ui-1.10.2.min.css') . '">';
$smarty = smarty($javascript, $stylesheets, array('view' => array('Row', 'removethisrow', 'rownr', 'nrrows', 'generatingpreview')), array('sidebars' => false));
$smarty->assign('INLINEJAVASCRIPT', $inlinejavascript);
$smarty->assign('form', $layoutform);
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewtype', $view->get('type'));
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('edittitle', $view->can_edit_title());
$smarty->assign('displaylink', $view->get_url());
$smarty->assign('new', $new);
if (get_config('viewmicroheaders')) {
    $smarty->assign('maharalogofilename', 'images/site-logo-small.png');
    $smarty->assign('microheaders', true);
Beispiel #5
0
        FROM {collection} c JOIN {collection_view} cv ON c.id = cv.collection
        WHERE c.owner = ?
        GROUP BY c.id, c.name, c.description
        HAVING COUNT(cv.view) > 0', array($USER->get('id')));
    if ($collections) {
        $elements['what']['options']['collections'] = get_string('justsomecollections', 'export');
        foreach ($collections as $collection) {
            $elements['collection_' . $collection->id] = array('type' => 'checkbox', 'class' => 'checkbox', 'title' => $collection->name, 'description' => $collection->description);
        }
    }
} else {
    $elements['what']['disabled'] = true;
    $jsfiles = array();
}
$elements['submit'] = array('type' => 'submit', 'class' => 'btn-primary', 'value' => get_string('generateexport', 'export'));
$form = pieform(array('name' => 'export', 'class' => 'portfolio-export', 'checkdirtychange' => false, 'template' => 'export.php', 'templatedir' => pieform_template_dir('export.php'), 'autofocus' => false, 'elements' => $elements));
function export_validate(Pieform $form, $values)
{
    global $SESSION;
    if ($values['what'] == 'views') {
        $viewchosen = false;
        foreach ($values as $key => $value) {
            if (substr($key, 0, 5) == 'view_' && $value) {
                $viewchosen = true;
            }
        }
        if (!$viewchosen) {
            $form->set_error('what', '');
            $SESSION->add_error_msg(get_string('youmustselectatleastoneviewtoexport', 'export'));
        }
    } else {
        FROM {collection} c JOIN {collection_view} cv ON c.id = cv.collection
        WHERE c.owner = ?
        GROUP BY c.id, c.name, c.description
        HAVING COUNT(cv.view) > 0', array($USER->get('id')));
    if ($collections) {
        $elements['what']['options']['collections'] = get_string('justsomecollections', 'export');
        foreach ($collections as $collection) {
            $elements['collection_' . $collection->id] = array('type' => 'checkbox', 'title' => $collection->name, 'description' => $collection->description);
        }
    }
} else {
    $elements['what']['disabled'] = true;
    $jsfiles = array();
}
$elements['submit'] = array('type' => 'submit', 'value' => get_string('generateexport', 'export'));
$form = pieform(array('name' => 'export', 'template' => 'export.php', 'templatedir' => pieform_template_dir('export.php'), 'autofocus' => false, 'elements' => $elements));
function export_validate(Pieform $form, $values)
{
    global $SESSION;
    if ($values['what'] == 'views') {
        $viewchosen = false;
        foreach ($values as $key => $value) {
            if (substr($key, 0, 5) == 'view_' && $value) {
                $viewchosen = true;
            }
        }
        if (!$viewchosen) {
            $form->set_error('what', '');
            $SESSION->add_error_msg(get_string('youmustselectatleastoneviewtoexport', 'export'));
        }
    } else {