/** * Generates a form which will submit a view or collection to one of * the owner's groups. * * @param mixed $view The view to be submitted. Either a View object, * or (for compatibility with previous versions of * this function) an integer view id. * @param array $tutorgroupdata An array of StdClass objects with id * and name properties representing groups. * @param string $returnto A URL - where to go after leaving the * submit page. * * @return string */ function view_group_submission_form($view, $tutorgroupdata, $returnto = null) { if (is_numeric($view)) { $view = new View($view); } $viewid = $view->get('id'); $options = array(); foreach ($tutorgroupdata as $group) { $options[$group->id] = $group->name; } // This form sucks from a language string point of view. It should // use pieforms' form template feature $form = array('name' => 'view_group_submission_form_' . $viewid, 'method' => 'post', 'renderer' => 'div', 'class' => 'form-inline', 'autofocus' => false, 'successcallback' => 'view_group_submission_form_submit', 'elements' => array('text1' => array('type' => 'html', 'class' => 'text-inline', 'value' => ''), 'inputgroup' => array('type' => 'fieldset', 'class' => 'input-group', 'elements' => array('options' => array('type' => 'select', 'collapseifoneoption' => false, 'options' => $options), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-primary input-group-btn', 'value' => get_string('submit')))), 'returnto' => array('type' => 'hidden', 'value' => $returnto))); if ($view->get_collection()) { $form['elements']['collection'] = array('type' => 'hidden', 'value' => $view->get_collection()->get('id')); $form['elements']['text1']['value'] = get_string('submitthiscollectionto1', 'view') . ' '; } else { $form['elements']['view'] = array('type' => 'hidden', 'value' => $viewid); $form['elements']['text1']['value'] = get_string('submitthisviewto1', 'view') . ' '; } return pieform($form); }
/** * @param array $data Parameters: * - view (int) * - oldusers (array of user IDs) */ public function __construct($data, $cron = false) { parent::__construct($data, $cron); if (!($viewinfo = new View($this->view))) { if (!empty($this->cron)) { // probably deleted already return; } throw new ViewNotFoundException(get_string('viewnotfound', 'error', $this->view)); } $this->url = $viewinfo->get_url(false); $this->users = array_diff_key(activity_get_viewaccess_users($this->view), $this->oldusers); if ($viewinfo->get_collection()) { $this->incollection = true; $this->title = $viewinfo->get_collection()->get('name'); $this->add_urltext(array('key' => 'Collection', 'section' => 'collection')); } else { $this->title = $viewinfo->get('title'); $this->add_urltext(array('key' => 'View', 'section' => 'view')); } $this->ownername = $viewinfo->formatted_owner(); }
$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'); $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