/** * Edit a role * * @return void */ public function editTask($row = null) { if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } Request::setVar('hidemainmenu', 1); if (!is_object($row)) { // Incoming (expecting an array) $id = Request::getVar('id', array(0)); if (is_array($id)) { $id = !empty($id) ? $id[0] : 0; } $row = Role::oneOrNew($id); } if ($row->isNew()) { $row->set('created_by', User::get('id')); $row->set('created', Date::toSql()); } $types = Type::getMajorTypes(); // Set any errors foreach ($this->getErrors() as $error) { Notify::error($error); } // Output the HTML $this->view->set('row', $row)->set('types', $types)->setLayout('edit')->display(); }
/** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $vars = array(); if (empty($segments[0])) { return $vars; } if (is_numeric($segments[0])) { $vars['id'] = $segments[0]; } elseif (in_array($segments[0], array('browse', 'license', 'sourcecode', 'plugin'))) { $vars['task'] = $segments[0]; } elseif (in_array($segments[0], array('new', 'draft', 'start', 'retract', 'delete', 'discard', 'remove', 'reorder', 'access'))) { $vars['task'] = $segments[0]; $vars['controller'] = 'create'; if (isset($segments[1])) { $vars['id'] = $segments[1]; } } else { include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'type.php'; $types = Type::getMajorTypes(); // Normalize the title // This is so we can determine the type of resource to display from the URL // For example, /resources/teachingmaterials => Teaching Materials foreach ($types as $type) { if (trim($segments[0]) == $type->alias) { $vars['type'] = $segments[0]; $vars['task'] = 'browsetags'; break; } } if ($segments[0] == 'license') { $vars['task'] = $segments[0]; } else { if (!isset($vars['type'])) { $vars['alias'] = $segments[0]; } } } if (!empty($segments[1])) { switch ($segments[1]) { case 'download': $vars['task'] = 'download'; if (isset($segments[2])) { $vars['file'] = $segments[2]; } break; case 'play': $vars['task'] = 'play'; break; case 'watch': $vars['task'] = 'watch'; break; case 'video': $vars['task'] = 'video'; break; //case 'license': $vars['task'] = 'license'; break; //case 'license': $vars['task'] = 'license'; break; case 'citation': $vars['task'] = 'citation'; break; case 'feed.rss': $vars['task'] = 'feed'; break; case 'feed': $vars['task'] = 'feed'; break; case 'license': case 'sourcecode': $vars['tool'] = $segments[1]; break; default: if ($segments[0] == 'browse') { $vars['type'] = $segments[1]; } else { $vars['active'] = $segments[1]; } break; } } return $vars; }
/** * Display a list of contributable resource types and let the user pick * * @return void */ public function step_type() { $step = $this->step; $step++; // Get available resource types $types = Type::getMajorTypes(); $this->view->set('group', Request::getVar('group', ''))->set('step', $step)->set('types', $types)->setErrors($this->getErrors())->display(); }