Example #1
0
define('INTERNAL', 1);
require_once dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
require_once 'view.php';
require_once get_config('libroot') . 'group.php';
define('TITLE', get_string('changemyviewlayout', 'view'));
$id = param_integer('id');
$new = param_boolean('new');
$category = param_alpha('c', '');
$view = new View($id);
$numcolumns = $view->get('numcolumns');
$currentlayout = $view->get('layout');
$back = !$USER->get_account_preference('addremovecolumns');
$group = $view->get('group');
$institution = $view->get('institution');
View::set_nav($group, $institution);
if (!$USER->can_edit_view($view)) {
    throw new AccessDeniedException();
}
// if not set, use equal width layout for that number of columns
if (!$currentlayout) {
    $currentlayout = $numcolumns == 2 ? 1 : ($numcolumns == 3 ? 4 : 7);
}
if ($numcolumns > 1 && $numcolumns < 5) {
    $layouts = get_records_array('view_layout', 'columns', $numcolumns);
    $options = array();
    foreach ($layouts as $layout) {
        $options[$layout->id] = get_string($layout->widths, 'view');
    }
    $layoutform = new Pieform(array('name' => 'viewlayout', 'elements' => array('layout' => array('type' => 'radio', 'options' => $options, 'defaultvalue' => $currentlayout), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('submit'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'view/columns.php?id=' . $view->get('id') . '&c=' . $category . '&new=' . $new))));
} else {
        $SESSION->add_error_msg(get_string('emptycollectionnoeditaccess', 'collection'));
        redirect('/collection/views.php?id=' . $collectionid);
    }
    // Pick any old view, they all have the same access records.
    $viewid = $views['views'][0]->view;
} else {
    $viewid = param_integer('id');
}
$view = new View($viewid);
if (empty($collection)) {
    $collection = $view->get_collection();
}
define('TITLE', get_string('editaccess', 'view'));
$group = $view->get('group');
$institution = $view->get('institution');
View::set_nav($group, $institution, true);
if (!$USER->can_edit_view($view) || $view->get('owner') == "0") {
    throw new AccessDeniedException();
}
if ($group && !group_within_edit_window($group)) {
    throw new AccessDeniedException();
}
$form = array('name' => 'editaccess', 'renderer' => 'div', 'plugintype' => 'core', 'pluginname' => 'view', 'viewid' => $view->get('id'), 'userview' => (int) $view->get('owner'), 'elements' => array('id' => array('type' => 'hidden', 'value' => $view->get('id'))));
// Create checkboxes to allow the user to apply these access rules to
// any of their views/collections.
// For institution views, force edit access of one view at a time for now.  Editing multiple
// institution views requires doing some tricky stuff with the 'copy for new users/groups'
// options, and there's not much room for the 'Share' tab in the admin area anyway
if ($view->get('type') != 'profile') {
    list($collections, $views) = View::get_views_and_collections($view->get('owner'), $group, $institution, $view->get('accessconf'), false);
}
Example #3
0
 * @package    mahara
 * @subpackage core
 * @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);
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'group.php';
$owner = param_integer('owner', 0);
$groupid = param_integer('group', null);
$institution = param_alphanum('institution', null);
$searchcollection = param_integer('searchcollection', false);
View::set_nav($groupid, $institution, false, $searchcollection);
if ($usetemplate = param_integer('usetemplate', null)) {
    // If a form has been submitted, build it now and pieforms will
    // call the submit function straight away
    pieform(create_view_form($groupid, $institution, $usetemplate, param_integer('copycollection', null)));
}
if ($groupid && (!group_user_can_edit_views($groupid) || !group_within_edit_window($groupid)) || $institution && !$USER->can_edit_institution($institution)) {
    throw new AccessDeniedException();
}
if (!empty($groupid)) {
    $group = group_current_group();
    define('TITLE', $group->name);
} else {
    $owner = $USER->get('id');
    define('TITLE', get_string('copyvieworcollection', 'view'));
}
    }
    form_validate(param_variable('sesskey', null));
    $view->delete();
    $view->post_edit_redirect();
}
// If a block was configured & submitted, build the form now so it can
// be processed without having to render the other blocks.
if ($blockid = param_integer('blockconfig', 0)) {
    // However, if removing a newly placed block, let it fall through to process_changes
    if (!isset($_POST['cancel_action_configureblockinstance_id_' . $blockid]) || !param_integer('removeoncancel', 0) || param_integer('pieform_jssubmission', 0)) {
        require_once get_config('docroot') . 'blocktype/lib.php';
        $bi = new BlockInstance($blockid);
        $bi->build_configure_form();
    }
}
View::set_nav($group, $institution, $view->get('type') == 'profile');
if ($view->get('type') == 'profile') {
    $profile = true;
    $displaylink = get_config('wwwroot') . 'user/view.php';
    $title = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true));
    define('TITLE', $title . ': ' . get_string('editcontentandlayout', 'view'));
} else {
    if ($view->get('type') == 'dashboard') {
        $dashboard = true;
        $displaylink = get_config('wwwroot');
        $title = get_string('usersdashboard', 'mahara', display_name($view->get('owner'), null, true));
        define('TITLE', $title . ': ' . get_string('editcontentandlayout', 'view'));
    } else {
        if ($view->get('type') == 'grouphomepage') {
            $displaylink = get_config('wwwroot') . 'group/view.php?id=' . (int) $view->get('group');
            $title = get_string('grouphomepage', 'view');
} else {
    $viewid = param_integer('id');
    define('SECTION_PLUGINNAME', 'view');
}
$view = new View($viewid);
if (empty($collection)) {
    $collection = $view->get_collection();
}
if ($collection) {
    define('TITLE', $collection->get('name') . ': ' . get_string('editaccess', 'view'));
} else {
    define('TITLE', $view->get('title') . ': ' . get_string('editaccess', 'view'));
}
$group = $view->get('group');
$institution = $view->get('institution');
View::set_nav($group, $institution, false, $collection);
if (!$USER->can_edit_view($view)) {
    throw new AccessDeniedException();
}
$js = '';
if (empty($collection) && !count_records('block_instance', 'view', $view->get('id'))) {
    $confirmmessage = get_string('reallyaddaccesstoemptyview', 'view');
    $js .= <<<EOF
addLoadEvent(function() {
    connect('editaccess_submit', 'onclick', function () {
        var accesslistrows = getElementsByTagAndClassName('tr', null, 'accesslistitems');
        if (accesslistrows.length > 0 && !confirm('{$confirmmessage}')) {
            replaceChildNodes('accesslistitems', []);
        }
    });
});