*
 */
define('INTERNAL', 1);
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'view');
define('SECTION_PAGE', 'editaccess');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
require_once 'pieforms/pieform/elements/calendar.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'collection.php';
require_once get_config('libroot') . 'group.php';
$collection = null;
if ($collectionid = param_integer('collection', null)) {
    $collection = new Collection($collectionid);
    $views = $collection->views();
    if (empty($views)) {
        $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');