/** * Edit form for a resource * * @param integer $isnew Flag for editing (0) or creating new (1) * @return void */ public function editTask($isnew = 0) { Request::setVar('hidemainmenu', 1); $this->view->isnew = $isnew; // Get the resource component config $this->view->rconfig = $this->config; // Push some needed styles to the tmeplate $this->css('resources.css'); // Incoming resource ID $id = Request::getVar('id', array(0)); if (is_array($id)) { $id = !empty($id) ? $id[0] : 0; } // Incoming parent ID - this determines if the resource is standalone or not $this->view->pid = Request::getInt('pid', 0); // Grab some filters for returning to place after editing $this->view->return = array(); $this->view->return['type'] = Request::getVar('type', ''); $this->view->return['sort'] = Request::getVar('sort', ''); $this->view->return['status'] = Request::getVar('status', ''); // Instantiate our resource object $this->view->row = new Resource($this->database); $this->view->row->load($id); // Fail if checked out not by 'me' if ($this->view->row->checked_out && $this->view->row->checked_out != User::get('id')) { $task = ''; if ($this->view->pid) { $task = '&task=children&pid=' . $this->view->pid; } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . $task, false), Lang::txt('COM_RESOURCES_WARNING_CHECKED_OUT'), 'notice'); return; } // Is this a new resource? if (!$id) { $this->view->row->created = Date::toSql(); $this->view->row->created_by = User::get('id'); $this->view->row->modified = $this->database->getNullDate(); $this->view->row->modified_by = 0; $this->view->row->publish_up = Date::toSql(); $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER'); if ($this->view->pid) { $this->view->row->published = 1; $this->view->row->standalone = 0; } else { $this->view->row->published = 3; // default to "new" status $this->view->row->standalone = 1; } $this->view->row->access = 0; } // Editing existing $this->view->row->checkout(User::get('id')); if (trim($this->view->row->publish_down) == '0000-00-00 00:00:00') { $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER'); } // Get name of resource creator $creator = User::getInstance($this->view->row->created_by); $this->view->row->created_by_name = $creator->get('name'); $this->view->row->created_by_name = $this->view->row->created_by_name ? $this->view->row->created_by_name : Lang::txt('Unknown'); // Get name of last person to modify resource if ($this->view->row->modified_by) { $modifier = User::getInstance($this->view->row->modified_by); $this->view->row->modified_by_name = $modifier->get('name'); $this->view->row->modified_by_name = $this->view->row->modified_by_name ? $this->view->row->modified_by_name : Lang::txt('Unknown'); } else { $this->view->row->modified_by_name = ''; } // Get params definitions $this->view->params = new \Hubzero\Html\Parameter($this->view->row->params, dirname(dirname(__DIR__)) . DS . 'resources.xml'); $this->view->attribs = new \Hubzero\Config\Registry($this->view->row->attribs); // Build selects of various types $rt = new Type($this->database); if ($this->view->row->standalone != 1) { $this->view->lists['type'] = Html::selectType($rt->getTypes(30), 'type', $this->view->row->type, '', '', '', ''); $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(28), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', ''); $this->view->lists['sub_type'] = Html::selectType($rt->getTypes(30), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', ''); } else { $this->view->lists['type'] = Html::selectType($rt->getTypes(27), 'type', $this->view->row->type, '', '', '', ''); $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(21), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', ''); } // Build the <select> of admin users $this->view->lists['created_by'] = $this->userSelect('created_by', 0, 1); // Build the <select> for the group access $this->view->lists['access'] = Html::selectAccess($this->view->rconfig->get('accesses'), $this->view->row->access); // Is this a standalone resource? if ($this->view->row->standalone == 1) { $this->view->lists['tags'] = ''; // Get groups $filters = array('authorized' => 'admin', 'fields' => array('cn', 'description', 'published', 'gidNumber', 'type'), 'type' => array(1, 3), 'sortby' => 'description'); $groups = \Hubzero\User\Group::find($filters); // Build <select> of groups $this->view->lists['groups'] = Html::selectGroup($groups, $this->view->row->group_owner); include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'profile.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'association.php'; // Get all contributors $mp = new \Components\Members\Tables\Profile($this->database); $members = null; //$mp->getRecords(array('sortby'=>'surname DESC','limit'=>'all','search'=>'','show'=>''), true); // Get all contributors linked to this resource $authnames = array(); if ($this->view->row->id) { $ma = new \Components\Members\Tables\Association($this->database); $sql = "SELECT n.uidNumber AS id, a.authorid, a.name, n.givenName, n.middleName, n.surname, a.role, a.organization\n\t\t\t\t\t\tFROM " . $ma->getTableName() . " AS a\n\t\t\t\t\t\tLEFT JOIN " . $mp->getTableName() . " AS n ON n.uidNumber=a.authorid\n\t\t\t\t\t\tWHERE a.subtable='resources'\n\t\t\t\t\t\tAND a.subid=" . $this->view->row->id . "\n\t\t\t\t\t\tORDER BY a.ordering"; $this->database->setQuery($sql); $authnames = $this->database->loadObjectList(); // Get the tags on this item $tagger = new Tags($this->view->row->id); $this->view->lists['tags'] = $tagger->render('string'); } // Build <select> of contributors $authorslist = new \Hubzero\Component\View(array('name' => $this->_controller, 'layout' => 'authors')); $authorslist->authnames = $authnames; $authorslist->attribs = $this->view->attribs; $authorslist->option = $this->_option; $authorslist->roles = $rt->getRolesForType($this->view->row->type); $this->view->lists['authors'] = $authorslist->loadTemplate(); } // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->setLayout('edit')->display(); }
<span class="hint"><?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_ACCESS_HINT'); ?> </span> </div> <div class="input-wrap" data-hint="<?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP_HINT'); ?> "> <label for="import-group"> <?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP'); ?> </label> <?php echo \Components\Resources\Helpers\Html::selectGroup($this->groups, $this->params->get('group', ''), 'params[group]', 'import-group'); ?> <span class="hint"><?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_GROUP_HINT'); ?> </span> </div> <div class="input-wrap" data-hint="<?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_MATCHTITLE_HINT'); ?> "> <label for="param-titlematch"> <?php echo Lang::txt('COM_RESOURCES_IMPORT_EDIT_FIELD_MATCHTITLE'); ?> </label>