/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `element` IN ('com_users', 'com_members')"; $this->db->setQuery($query); $objs = $this->db->loadObjectList(); $users = null; $members = null; foreach ($objs as $obj) { if ($obj->element == 'com_users') { $users = new \Hubzero\Config\Registry($obj->params); } if ($obj->element == 'com_members') { $members = new \Hubzero\Config\Registry($obj->params); } } if ($users && $members) { $params = array('allowUserRegistration' => 1, 'new_usertype' => 2, 'guest_usergroup' => 1, 'sendpassword' => 1, 'useractivation' => 2, 'simple_registration' => 0, 'allow_duplicate_emails' => 0, 'mail_to_admin' => 1, 'captcha' => '', 'frontend_userparams' => 1, 'site_language' => 0, 'change_login_name' => 0, 'reset_count' => 10, 'reset_time' => 1, 'login_attempts_limit' => 10, 'login_attempts_timeframe' => 1); foreach ($params as $param => $dflt) { $members->set($param, $users->get('param', $dflt)); } $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($members->toString()) . " WHERE `element`='com_members'"; $this->db->setQuery($query); $this->db->query(); } } }
/** * Down **/ public function down() { $this->addPluginEntry('resources', 'abouttool'); if ($this->db->tableExists('#__resource_types')) { // Get all the "mine" queries $this->db->setQuery("SELECT id, params FROM `#__resource_types` WHERE `category`=27 AND `alias`='tools'"); if ($records = $this->db->loadObjectList()) { $path = PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; if (!file_exists($path)) { $path = PATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; } include_once $path; $tbl = '\\Components\\Resources\\Tables\\Type'; if (class_exists('ResourcesType')) { $tbl = 'ResourcesType'; } // Update the query foreach ($records as $record) { $row = new $tbl($this->db); $row->bind($record); $p = new \Hubzero\Config\Registry($row->params); $p->set('plg_about', 0); $p->set('plg_abouttool', 1); $row->params = $p->toString(); $row->store(); } } } }
/** * Up **/ public function up() { $query = "CREATE TABLE IF NOT EXISTS `#__announcements` (\n\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`scope` varchar(100) DEFAULT NULL,\n\t\t\t\t\t`scope_id` int(11) DEFAULT NULL,\n\t\t\t\t\t`content` text,\n\t\t\t\t\t`priority` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`created_by` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t`state` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`sticky` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; $this->db->setQuery($query); $this->db->query(); $params = array('plugin_access' => 'members', 'display_tab' => 1); $this->addPluginEntry('groups', 'announcements', 1, $params); // get citation params if ($this->db->tableExists('#__extensions')) { $sql = "SELECT `params` FROM `#__extensions` WHERE `type`='plugin' AND `element`='messages' AND `folder` = 'groups'"; } else { $sql = "SELECT `params` FROM `#__plugins` WHERE `element`='messages' AND `folder`='groups'"; } $this->db->setQuery($sql); $p = $this->db->loadResult(); // load params object $params = new \Hubzero\Config\Registry($p); // set param to hide messages tab $params->set('display_tab', 0); // save new params if ($this->db->tableExists('#__extensions')) { $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote(json_encode($params->toArray())) . " WHERE `element`='messages' AND `folder`='groups'"; } else { $query = "UPDATE `#__plugins` SET `params`='" . $params->toString() . "' WHERE `element`='messages' AND `folder`='groups'"; } $this->db->setQuery($query); $this->db->query(); }
/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='system' AND `element`='jquery' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('jquery', 1); $params->set('jqueryui', 1); $params->set('jqueryfb', 1); $params->set('activateAdmin', 0); $params->set('noconflictAdmin', 0); $params->set('activateSite', 1); $params->set('noconflictSite', 0); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='content' AND `element`='formatwiki' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('applyFormat', 1); $params->set('convertFormat', 1); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='content' AND `element`='formathtml' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('applyFormat', 1); $params->set('convertFormat', 0); $params->set('sanitizeBefore', 0); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); if (!$plugin->enabled) { $this->enablePlugin('content', 'formathtml'); } } else { $params = new \Hubzero\Config\Registry(); $params->set('applyFormat', 1); $params->set('convertFormat', 0); $params->set('sanitizeBefore', 0); $this->addPluginEntry('content', 'formathtml', 1, $params->toString()); } } }
/** * Down **/ public function down() { $this->addComponentEntry('register'); $rparams = $this->getParams('com_members'); $values = $rparams->toArray(); $this->db->setQuery("SELECT * FROM `#__extensions` WHERE `type`='component' AND `element`='com_register' LIMIT 1"); if ($data = $this->db->loadAssoc()) { $component = new \JTableExtension($this->db); $component->bind($data); $mparams = new \Hubzero\Config\Registry($component->params); foreach ($values as $key => $value) { $mparams->set($key, $value); } $component->params = $mparams->toString(); $component->store(); } }
/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `element`=" . $this->db->quote('novnc') . " AND `folder`=" . $this->db->quote('tools'); $this->db->setQuery($query); $result = $this->db->loadObject(); if ($result && $result->extension_id) { $params = new \Hubzero\Config\Registry($result->params); $params->set('browsers', '*, safari 5.1 *, chrome 26.0 *, iceweasel 38.0 *, firefox 30.0 *, opera 23.0 *, mozilla 5.0 iOS, safari 1.0 Windows, msie 10.0 Windows, ie 10.0'); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($result->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `element`=" . $this->db->quote('java') . " AND `folder`=" . $this->db->quote('tools'); $this->db->setQuery($query); $result = $this->db->loadObject(); if ($result && $result->extension_id) { $params = new \Hubzero\Config\Registry($result->params); $params->set('browsers', '*, chrome 999999.0 *, safari 1.0 *, iceweasel 1.0 *, firefox 1.0 *, opera 1.0 *, IE 3.0 *, mozilla 5.0 iOS, Safari 9999.9'); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($result->extension_id); $this->db->setQuery($query); $this->db->query(); } } }
/** * Save blog settings * * @return void */ private function _savesettings() { // Login check if (User::isGuest()) { return $this->_login(); } if ($this->authorized != 'manager' && $this->authorized != 'admin') { $this->setError(Lang::txt('PLG_COLLECTIONS_BLOG_NOT_AUTH')); return $this->_collections(); } // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); $row = new \Hubzero\Plugin\Params($this->database); $row->loadPlugin($this->group->get('gidNumber'), $this->_type, $this->_name); $row->object_id = $this->group->get('gidNumber'); $row->folder = $this->_type; $row->element = $this->_name; // Get parameters $prms = Request::getVar('params', array(), 'post'); $params = new \Hubzero\Config\Registry($prms); $row->params = $params->toString(); // Check content if (!$row->check()) { $this->setError($row->getError()); return $this->_settings(); } // Store new content if (!$row->store()) { $this->setError($row->getError()); return $this->_settings(); } App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_COLLECTIONS_SETTINGS_SAVED'), 'passed'); }
/** * Save a type * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } $type = Request::getVar('type', array(), 'post'); // Initiate extended database class $row = Type::oneOrNew($type['id'])->set($type); // Get the custom fields $fields = Request::getVar('fields', array(), 'post'); if (is_array($fields)) { $elements = new stdClass(); $elements->fields = array(); foreach ($fields as $val) { if ($val['title']) { $element = new stdClass(); $element->default = isset($val['default']) ? $val['default'] : ''; $element->name = isset($val['name']) && trim($val['name']) != '' ? $val['name'] : $this->_normalize(trim($val['title'])); $element->label = $val['title']; $element->type = isset($val['type']) && trim($val['type']) != '' ? $val['type'] : 'text'; $element->required = isset($val['required']) ? $val['required'] : '0'; foreach ($val as $key => $v) { if (!in_array($key, array('default', 'type', 'title', 'name', 'required', 'options'))) { $element->{$key} = $v; } } if (isset($val['options'])) { $element->options = array(); foreach ($val['options'] as $option) { if (trim($option['label'])) { $opt = new stdClass(); $opt->label = $option['label']; $opt->value = $option['label']; $element->options[] = $opt; } } } $elements->fields[] = $element; } } include_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'elements.php'; $re = new \Components\Resources\Models\Elements($elements); $row->set('customFields', $re->toString()); } // Get parameters $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post')); $row->set('params', $p->toString()); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_RESOURCES_ITEM_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect $this->cancelTask(); }
/** * Save changes to an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $fields = Request::getVar('fields', array(), 'post'); $recurrence = array(); if (isset($fields['minute'])) { $recurrence[] = $fields['minute']['c'] ? $fields['minute']['c'] : $fields['minute']['s']; } if (isset($fields['hour'])) { $recurrence[] = $fields['hour']['c'] ? $fields['hour']['c'] : $fields['hour']['s']; } if (isset($fields['day'])) { $recurrence[] = $fields['day']['c'] ? $fields['day']['c'] : $fields['day']['s']; } if (isset($fields['month'])) { $recurrence[] = $fields['month']['c'] ? $fields['month']['c'] : $fields['month']['s']; } if (isset($fields['dayofweek'])) { $recurrence[] = $fields['dayofweek']['c'] ? $fields['dayofweek']['c'] : $fields['dayofweek']['s']; } if (!empty($recurrence)) { $fields['recurrence'] = implode(' ', $recurrence); } unset($fields['minute']); unset($fields['hour']); unset($fields['day']); unset($fields['month']); unset($fields['dayofweek']); // Initiate extended database class $row = Job::oneOrNew($fields['id'])->set($fields); if ($row->get('recurrence')) { $row->set('next_run', $row->nextRun()); } $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post')); $row->set('params', $p->toString()); // Store content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_CRON_ITEM_SAVED')); // If the task was "apply", // fall back through to the edit form. if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect $this->cancelTask(); }
/** * Save an Import * * @return void */ public function saveTask($redirect = true) { // check token Session::checkToken(); // Get request vars $import = Request::getVar('import', array()); $hooks = Request::getVar('hooks', array()); $params = Request::getVar('params', array()); $fields = Request::getVar('mapping', array()); $file = Request::getVar('file', array(), 'FILES'); // Create import model object $this->import = new \Components\Members\Models\Import(isset($import['id']) ? $import['id'] : null); // Set our hooks $this->import->set('hooks', json_encode($hooks)); // Set our fields $this->import->set('fields', json_encode($fields)); // Load current params $iparams = new \Hubzero\Config\Registry($this->import->get('params')); // Bind incoming params $iparams->parse($params); // Set params on import object $this->import->set('params', $iparams->toString()); // Bind input to model if (!$this->import->bind($import)) { $this->setError($this->import->getError()); return $this->editTask($this->import); } // Is this a new import? $isNew = false; if (!$this->import->exists()) { $isNew = true; // Set the created by/at $this->import->set('created_by', User::get('id')); $this->import->set('created_at', Date::toSql()); } // Do we have a data file /*if ($this->import->get('file')) { // Get record count $importImporter = new \Hubzero\Content\Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); }*/ // Attempt to save if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } // create folder for files if (!$this->_createImportFilespace($this->import)) { return $this->editTask(); } // If we have a file if (is_array($file) && $file['size'] > 0 && $file['error'] == 0) { move_uploaded_file($file['tmp_name'], $this->import->fileSpacePath() . DS . $file['name']); $this->import->set('file', $file['name']); $this->import->set('fields', ''); // Force into the field map view $isNew = true; } // Do we have a data file? if ($this->import->get('file')) { // get record count $importImporter = new \Hubzero\Content\Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // Save again with import count if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask($this->import); } // Inform user & redirect if ($redirect) { if ($isNew) { $this->view->set('import', $this->import)->setLayout('fields')->display(); return; } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_IMPORT_CREATED'), 'passed'); return; } $this->editTask($this->import); }
/** * Save blog settings * * @return void */ private function savesettings() { if (User::isGuest()) { $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE')); return; } if ($this->authorized != 'manager' && $this->authorized != 'admin') { $this->setError(Lang::txt('PLG_GROUPS_FORUM_NOT_AUTHORIZED')); return $this->sections(); } // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); $row = new \Hubzero\Plugin\Params($this->database); if (!$row->bind($settings)) { $this->setError($row->getError()); return $this->settings(); } // Get parameters $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post')); $row->params = $p->toString(); // Check content if (!$row->check()) { $this->setError($row->getError()); return $this->_settings(); } // Store new content if (!$row->store()) { $this->setError($row->getError()); return $this->_settings(); } App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_FORUM_SETTINGS_SAVED')); }
/** * Method is called after user data is stored in the database * * @param array $user holds the new user data * @param boolean $isnew true if a new user is stored * @param boolean $success true if user was succesfully stored in the database * @param string $msg message * @return void */ public function onAfterStoreUser($user, $isnew, $succes, $msg) { $xprofile = \Hubzero\User\Profile::getInstance($user['id']); if (!is_object($xprofile)) { $params = Component::params('com_members'); $hubHomeDir = rtrim($params->get('homedir'), '/'); if (empty($hubHomeDir)) { // try to deduce a viable home directory based on sitename or live_site $sitename = strtolower(Config::get('sitename')); $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1); $sitename = trim($sitename, '/ '); $sitename_e = explode('.', $sitename, 2); if (isset($sitename_e[1])) { $sitename = $sitename_e[0]; } if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) { $sitename = ''; } if (empty($sitename)) { $sitename = strtolower(Request::base()); $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1); $sitename = trim($sitename, '/ '); $sitename_e = explode('.', $sitename, 2); if (isset($sitename_e[1])) { $sitename = $sitename_e[0]; } if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) { $sitename = ''; } } $hubHomeDir = DS . 'home'; if (!empty($sitename)) { $hubHomeDir .= DS . $sitename; } if (!empty($hubHomeDir)) { $db = App::get('db'); $component = new JTableExtension($this->database); $component->load($component->find(array('element' => 'com_members', 'type' => 'component'))); $params = new \Hubzero\Config\Registry($component->params); $params->set('homedir', $hubHomeDir); $component->params = $params->toString(); $component->store(); } } $xprofile = new \Hubzero\User\Profile(); $xprofile->set('gidNumber', $params->get('gidNumber', '100')); $xprofile->set('gid', $params->get('gid', 'users')); $xprofile->set('uidNumber', $user['id']); $xprofile->set('homeDirectory', $hubHomeDir . DS . $user['username']); $xprofile->set('loginShell', '/bin/bash'); $xprofile->set('ftpShell', '/usr/lib/sftp-server'); $xprofile->set('name', $user['name']); $xprofile->set('email', $user['email']); $xprofile->set('emailConfirmed', '3'); $xprofile->set('username', $user['username']); $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']); $xprofile->set('emailConfirmed', -rand(1, pow(2, 31) - 1)); $xprofile->set('public', $params->get('privacy', 0)); if (isset($_SERVER['REMOTE_HOST'])) { $xprofile->set('regHost', $_SERVER['REMOTE_HOST']); } $xprofile->set('registerDate', Date::toSql()); $result = $xprofile->create(); if (!$result) { return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500); } } else { $update = false; $params = Component::params('com_members'); if ($xprofile->get('username') != $user['username']) { $xprofile->set('username', $user['username']); $update = true; } if ($xprofile->get('name') != $user['name']) { $xprofile->set('name', $user['name']); $update = true; } if ($xprofile->get('email') != $user['email']) { $xprofile->set('email', $user['email']); $xprofile->set('emailConfirmed', 0); $update = true; } if ($xprofile->get('emailConfirmed') == '') { $xprofile->set('emailConfirmed', '3'); $update = true; } if ($xprofile->get('gid') == '') { $xprofile->set('gid', $params->get('gid', 'users')); $update = true; } if ($xprofile->get('gidNumber') == '') { $xprofile->set('gidNumber', $params->get('gidNumber', '100')); $update = true; } if ($xprofile->get('loginShell') == '') { $xprofile->set('loginShell', '/bin/bash'); $update = true; } if ($xprofile->get('ftpShell') == '') { $xprofile->set('ftpShell', '/usr/lib/sftp-server'); // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy $xprofile->set('public', $params->get('privacy', 0)); $update = true; } if ($update) { $xprofile->update(); } } // Check if quota exists for the user $params = Component::params('com_members'); if ($params->get('manage_quotas', false)) { require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'quotas_classes.php'; $quota = new \Components\Members\Tables\UsersQuotas($this->database); $quota->load(array('user_id' => $user['id'])); if (!$quota->id) { $class = new \Components\Members\Tables\QuotasClasses($this->database); $class->load(array('alias' => 'default')); if ($class->id) { $quota->set('user_id', $user['id']); $quota->set('class_id', $class->id); $quota->set('soft_blocks', $class->soft_blocks); $quota->set('hard_blocks', $class->hard_blocks); $quota->set('soft_files', $class->soft_files); $quota->set('hard_files', $class->hard_files); $quota->store(); } } } }
/** * Save a wiki page * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Check if they are logged in if (User::isGuest()) { $url = Request::getVar('REQUEST_URI', '', 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url))); return; } // Incoming revision $rev = Request::getVar('revision', array(), 'post', 'none', 2); //$rev['pageid'] = (isset($rev['pageid'])) ? intval($rev['pageid']) : 0; $this->revision = $this->page->revision('current'); $this->revision->set('version', $this->revision->get('version') + 1); if (!$this->revision->bind($rev)) { $this->setError($this->revision->getError()); $this->editTask(); return; } $this->revision->set('id', 0); // Incoming page $page = Request::getVar('page', array(), 'post', 'none', 2); $this->page = new Article(intval($rev['pageid'])); if (!$this->page->bind($page)) { $this->setError($this->page->getError()); $this->editTask(); return; } $this->page->set('pagename', trim(Request::getVar('pagename', '', 'post'))); $this->page->set('scope', trim(Request::getVar('scope', '', 'post'))); // Get parameters $params = new \Hubzero\Config\Registry($this->page->get('params', '')); $params->merge(Request::getVar('params', array(), 'post')); $this->page->set('params', $params->toString()); // Get the previous version to compare against if (!$rev['pageid']) { // New page - save it to the database $this->page->set('created_by', User::get('id')); $old = new Revision(0); } else { // Get the revision before changes $old = $this->page->revision('current'); } // Was the preview button pushed? $this->preview = trim(Request::getVar('preview', '')); if ($this->preview) { // Set the component task if (!$rev['pageid']) { Request::setVar('task', 'new'); $this->_task = 'new'; } else { Request::setVar('task', 'edit'); $this->_task = 'edit'; } // Push on through to the edit form $this->editTask(); return; } // Check content // First, make sure the pagetext isn't empty if ($this->revision->get('pagetext') == '') { $this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_PAGETEXT')); $this->editTask(); return; } // Store new content if (!$this->page->store(true)) { $this->setError($this->page->getError()); $this->editTask(); return; } // Get allowed authors if (!$this->page->updateAuthors(Request::getVar('authors', '', 'post'))) { $this->setError($this->page->getError()); $this->editTask(); return; } // Get the upload path $wpa = new Tables\Attachment($this->database); $path = $wpa->filespace(); // Rename the temporary upload directory if it exist $lid = Request::getInt('lid', 0, 'post'); if ($lid != $this->page->get('id')) { if (is_dir($path . DS . $lid)) { if (!\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))) { $this->setError(\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))); } $wpa->setPageID($lid, $this->page->get('id')); } } $this->revision->set('pageid', $this->page->get('id')); $this->revision->set('pagename', $this->page->get('pagename')); $this->revision->set('scope', $this->page->get('scope')); $this->revision->set('group_cn', $this->page->get('group_cn')); $this->revision->set('version', $this->revision->get('version') + 1); if ($this->page->param('mode', 'wiki') == 'knol') { // Set revisions to NOT approved $this->revision->set('approved', 0); // If an author or the original page creator, set to approved if ($this->page->get('created_by') == User::get('id') || $this->page->isAuthor(User::get('id'))) { $this->revision->set('approved', 1); } } else { // Wiki mode, approve revision $this->revision->set('approved', 1); } // Compare against previous revision // We don't want to create a whole new revision if just the tags were changed if (rtrim($old->get('pagetext')) != rtrim($this->revision->get('pagetext'))) { // Transform the wikitext to HTML $this->revision->set('pagehtml', ''); $this->revision->set('pagehtml', $this->revision->content('parsed')); // Parse attachments /*$a = new Tables\Attachment($this->database); $a->pageid = $this->page->id; $a->path = $path; $this->revision->pagehtml = $a->parse($this->revision->pagehtml);*/ if ($this->page->access('manage') || $this->page->access('edit')) { $this->revision->set('approved', 1); } // Store content if (!$this->revision->store(true)) { $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION')); $this->editTask(); return; } $this->page->set('version_id', $this->revision->get('id')); $this->page->set('modified', $this->revision->get('created')); } else { $this->page->set('modified', Date::toSql()); } if (!$this->page->store(true)) { // This really shouldn't happen. $this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_PAGE')); $this->editTask(); return; } // Process tags $this->page->tag(Request::getVar('tags', '')); // Redirect App::redirect(Route::url($this->page->link())); }
/** * Save changes to the registration * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); if (!is_array($settings) || empty($settings)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_ERROR_MISSING_DATA'), 'error'); return; } $arr = array(); $component = new \JTableExtension($this->database); $component->load($component->find(array('element' => $this->_option, 'type' => 'component'))); $params = new \Hubzero\Config\Registry($component->params); foreach ($settings as $name => $value) { $r = $value['create'] . $value['proxy'] . $value['update'] . $value['edit']; $params->set('registration' . trim($name), trim($r)); } $component->params = $params->toString(); $component->store(); if (App::get('config')->get('caching')) { $handler = App::get('config')->get('cache_handler'); App::get('config')->set($handler, array('cachebase' => PATH_APP . '/cache/site')); $cache = new \Hubzero\Cache\Manager(\App::getRoot()); $cache->storage($handler); $cache->clean('_system'); } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_SAVED')); }
/** * Actions to perform after saving a course * * @param object $model \Components\Courses\Models\Course * @param boolean $isNew Is this a newly created entry? * @return void */ public function onOfferingSave($model) { if (!$model->exists()) { return; } $params = new \Hubzero\Config\Registry($model->get('params')); if ($params->get('store_product', 0)) { $course = \Components\Courses\Models\Course::getInstance($model->get('course_id')); $title = $course->get('title') . ' (' . $model->get('title') . ')'; $description = $course->get('blurb'); $price = $params->get('store_price', '30.00'); $duration = $params->get('store_membership_duration', '1 YEAR'); if (!$params->get('store_product_id', 0)) { include_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Course.php'; $product = new StorefrontModelCourse(); $product->setName($title); $product->setDescription($description); $product->setPrice($price); // We don't want products showing up for non-published courses if ($model->get('state') != 1) { $product->setActiveStatus(0); } else { $product->setActiveStatus(1); } // Membership model: membership duration period (must me in MySQL date format: 1 DAY, 2 MONTH, 3 YEAR...) $product->setTimeToLive($duration); // Course alias id $product->setCourseId($course->get('alias')); $product->setOfferingId($model->get('alias')); try { // Returns object with values, pId is the new product ID to link to $info = $product->add(); $params->set('store_product_id', $info->pId); $model->set('params', $params->toString()); $model->store(); } catch (Exception $e) { $this->setError('ERROR: ' . $e->getMessage()); } } else { $warehouse = new StorefrontModelWarehouse(); try { // Get course by pID returned with $course->add() above $product = $warehouse->getCourse($params->get('store_product_id', 0)); $product->setName($title); $product->setDescription($description); $product->setPrice($price); $product->setTimeToLive($duration); if ($model->get('state') != 1) { $product->setActiveStatus(0); } else { $product->setActiveStatus(1); } $product->update(); } catch (Exception $e) { $this->setError('ERROR: ' . $e->getMessage()); } } } }
/** * Save blog settings * * @return void */ private function _savesettings() { // Login check if (User::isGuest()) { return $this->_login(); } if ($this->authorized != 'manager' && $this->authorized != 'admin') { $this->setError(Lang::txt('PLG_GROUPS_COLLECTIONS_NOT_AUTH')); return $this->_collections(); } // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); $row = \Hubzero\Plugin\Params::oneByPlugin($this->group->get('gidNumber'), $this->_type, $this->_name); $row->set('object_id', $this->group->get('gidNumber')); $row->set('folder', $this->_type); $row->set('element', $this->_name); // Get parameters $prms = Request::getVar('params', array(), 'post'); $params = new \Hubzero\Config\Registry($prms); $row->set('params', $params->toString()); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->_settings(); } // Record the activity $recipients = array(['group', $this->group->get('gidNumber')]); foreach ($this->group->get('managers') as $recipient) { $recipients[] = ['user', $recipient]; } Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'collections.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_COLLECTIONS_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]); App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_COLLECTIONS_SETTINGS_SAVED'), 'passed'); }
/** * Saves changes to a course or saves a new entry if creating * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); // Instantiate a Course object $model = new \Components\Courses\Models\Assetgroup($fields['id']); if (!$model->bind($fields)) { $this->setError($model->getError()); $this->editTask($model); return; } $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post')); $model->set('params', $p->toString()); if (!$model->store(true)) { $this->setError($model->getError()); $this->editTask($model); return; } // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&unit=' . $model->get('unit_id'), false), Lang::txt('COM_COURSES_ASSETGROUP_SAVED')); }
/** * Saves changes to a course or saves a new entry if creating * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); // Instantiate a Course object $model = \Components\Courses\Models\Offering::getInstance($fields['id']); if (!$model->bind($fields)) { $this->setError($model->getError()); $this->editTask($model); return; } $p = new \Hubzero\Config\Registry(''); $p->parse(Request::getVar('params', '', 'post')); // Make sure the logo gets carried over $op = new \Hubzero\Config\Registry($model->get('params')); $p->set('logo', $op->get('logo')); $model->set('params', $p->toString()); if (!$model->store(true)) { $this->setError($model->getError()); $this->editTask($model); return; } if ($this->_task == 'apply') { return $this->editTask($model); } // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&course=' . $model->get('course_id'), false), Lang::txt('COM_COURSES_ITEM_SAVED')); }
/** * Saves a resource * Redirects to main listing * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Initiate extended database class $row = new Resource($this->database); if (!$row->bind($_POST)) { throw new Exception($row->getError(), 400); } $isNew = 0; if ($row->id < 1) { $isNew = 1; } if ($isNew) { // New entry $row->created = $row->created ? $row->created : Date::toSql(); $row->created_by = $row->created_by ? $row->created_by : User::get('id'); $row->access = 0; } else { $old = new Resource($this->database); $old->load($row->id); $created_by_id = Request::getInt('created_by_id', 0); // Updating entry $row->modified = Date::toSql(); $row->modified_by = User::get('id'); if ($created_by_id) { $row->created_by = $row->created_by ? $row->created_by : $created_by_id; } else { $row->created_by = $row->created_by ? $row->created_by : User::get('id'); } } // publish up $row->publish_up = Date::of($row->publish_up, Config::get('offset'))->toSql(); // publish down if (!$row->publish_down || trim($row->publish_down) == '0000-00-00 00:00:00' || trim($row->publish_down) == 'Never') { $row->publish_down = '0000-00-00 00:00:00'; } else { $row->publish_down = Date::of($row->publish_down, Config::get('offset'))->toSql(); } // Get parameters $params = Request::getVar('params', array(), 'post'); if (is_array($params)) { $txt = new \Hubzero\Config\Registry(''); foreach ($params as $k => $v) { $txt->set($k, $v); } $row->params = $txt->toString(); } // Get attributes $attribs = Request::getVar('attrib', array(), 'post'); if (is_array($attribs)) { $txta = new \Hubzero\Config\Registry(''); foreach ($attribs as $k => $v) { if ($k == 'timeof') { if (strtotime(trim($v)) === false) { $v = NULL; } $v = trim($v) ? Date::of($v, Config::get('offset'))->toSql() : NULL; } $txta->set($k, $v); } $row->attribs = $txta->toString(); } // Get custom areas, add wrappers, and compile into fulltxt if (isset($_POST['nbtag'])) { $type = new Type($this->database); $type->load($row->type); include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php'; $elements = new \Components\Resources\Models\Elements(array(), $type->customFields); $schema = $elements->getSchema(); $fields = array(); foreach ($schema->fields as $field) { $fields[$field->name] = $field; } $nbtag = $_POST['nbtag']; $found = array(); foreach ($nbtag as $tagname => $tagcontent) { $f = ''; $row->fulltxt .= "\n" . '<nb:' . $tagname . '>'; if (is_array($tagcontent)) { $c = count($tagcontent); $num = 0; foreach ($tagcontent as $key => $val) { if (trim($val)) { $num++; } $row->fulltxt .= '<' . $key . '>' . trim($val) . '</' . $key . '>'; } if ($c == $num) { $f = 'found'; } } else { $f = trim($tagcontent); if ($f) { $row->fulltxt .= trim($tagcontent); } } $row->fulltxt .= '</nb:' . $tagname . '>' . "\n"; if (!$tagcontent && isset($fields[$tagname]) && $fields[$tagname]->required) { throw new Exception(Lang::txt('RESOURCES_REQUIRED_FIELD_CHECK', $fields[$tagname]->label), 500); } $found[] = $tagname; } foreach ($fields as $field) { if (!in_array($field->name, $found) && $field->required) { $found[] = $field->name; $this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label)); } } } // Code cleaner for xhtml transitional compliance if ($row->type != 7) { $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->fulltxt = str_replace('<br>', '<br />', $row->fulltxt); } // Check content if (!$row->check()) { throw new Exception($row->getError(), 500); } // Store content if (!$row->store()) { throw new Exception($row->getError(), 500); } // Checkin resource $row->checkin(); // Rename the temporary upload directory if it exist $tmpid = Request::getInt('tmpid', 0, 'post'); if ($tmpid != Html::niceidformat($row->id)) { // Build the full paths $path = Html::dateToPath($row->created); $dir_id = Html::niceidformat($row->id); $tmppath = Utilities::buildUploadPath($path . DS . $tmpid); $newpath = Utilities::buildUploadPath($path . DS . $dir_id); // Attempt to rename the temp directory if (\Filesystem::exists($tmppath)) { $result = \Filesystem::move($tmppath, $newpath); if ($result !== true) { $this->setError($result); } } $row->path = str_replace($tmpid, Html::niceidformat($row->id), $row->path); $row->store(); } // Incoming tags $tags = Request::getVar('tags', '', 'post'); // Save the tags $rt = new Tags($row->id); $rt->setTags($tags, User::get('id'), 1, 1); // Incoming authors if ($row->type != 7) { $authorsOldstr = Request::getVar('old_authors', '', 'post'); $authorsNewstr = Request::getVar('new_authors', '', 'post'); if (!$authorsNewstr) { $authorsNewstr = $authorsOldstr; } include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'contributor.php'; $authorsNew = explode(',', $authorsNewstr); $authorsOld = explode(',', $authorsOldstr); // We have either a new ordering or new authors or both if ($authorsNewstr) { for ($i = 0, $n = count($authorsNew); $i < $n; $i++) { $rc = new Contributor($this->database); $rc->subtable = 'resources'; $rc->subid = $row->id; if (is_numeric($authorsNew[$i])) { $rc->authorid = $authorsNew[$i]; } else { $rc->authorid = $rc->getUserId($authorsNew[$i]); } $rc->ordering = $i; $rc->role = trim(Request::getVar($authorsNew[$i] . '_role', '')); $rc->name = trim(Request::getVar($authorsNew[$i] . '_name', '')); $rc->organization = trim(Request::getVar($authorsNew[$i] . '_organization', '')); $authorsNew[$i] = $rc->authorid; if (in_array($authorsNew[$i], $authorsOld)) { //echo 'update: ' . $rc->authorid . ', ' . $rc->role . ', ' . $rc->name . ', ' . $rc->organization . '<br />'; // Updating record $rc->updateAssociation(); } else { //echo 'create: ' . $rc->authorid . ', ' . $rc->role . ', ' . $rc->name . ', ' . $rc->organization . '<br />'; // New record $rc->createAssociation(); } } } // Run through previous author list and check to see if any IDs had been dropped if ($authorsOldstr) { $rc = new Contributor($this->database); for ($i = 0, $n = count($authorsOld); $i < $n; $i++) { if (!in_array($authorsOld[$i], $authorsNew)) { $rc->deleteAssociation($authorsOld[$i], $row->id, 'resources'); } } } } // If this is a child, add parent/child association $pid = Request::getInt('pid', 0, 'post'); if ($isNew && $pid) { $this->_attachChild($row->id, $pid); } // Is this a standalone resource and we need to email approved submissions? if ($row->standalone == 1 && $this->config->get('email_when_approved')) { // If the state went from pending to published if ($row->published == 1 && $old->published == 3) { $this->_emailContributors($row, $this->database); } } // Redirect App::redirect($this->buildRedirectURL($pid), Lang::txt('COM_RESOURCES_ITEM_SAVED')); }
/** * Save an entry * * @return void */ public function saveTask() { $exportmap = array('@OPEN' => null, '@GROUP' => null, '@US' => 'us', '@us' => 'us', '@PU' => 'pu', '@pu' => 'pu', '@D1' => 'd1', '@d1' => 'd1'); // set vars $tool = Request::getVar('tool', array(), 'post'); $tool = array_map('trim', $tool); // Sanitize the input a bit $noHtmlFilter = \JFilterInput::getInstance(); foreach ($tool as $i => $var) { $tool[$i] = $noHtmlFilter->clean($var); } $today = Date::toSql(); $group_prefix = $this->config->get('group_prefix', 'app-'); $dev_suffix = $this->config->get('dev_suffix', '_dev'); // pass data from forms $id = Request::getInt('toolid', 0); $this->_action = Request::getVar('action', ''); $comment = Request::getVar('comment', ''); $editversion = Request::getVar('editversion', 'dev', 'post'); //$toolname = strtolower($tool['toolname']); $oldstatus = array(); // Create a Tool Version object $objV = new \Components\Tools\Tables\Version($this->database); // Create a Tool object $obj = new \Components\Tools\Tables\Tool($this->database); if ($id) { // make sure user is authorized to go further if (!$this->_checkAccess($id)) { App::abort(403, Lang::txt('COM_TOOLS_ALERTNOTAUTH')); return; } } if (!\Components\Tools\Models\Tool::validate($tool, $err, $id)) { // display form with errors //$title = Lang::txt(strtoupper($this->_option)).': '.Lang::txt('COM_TOOLS_EDIT_TOOL'); //Document::setTitle($title); if (is_array($err)) { foreach ($err as $error) { $this->setError($error); } } else { $this->setError($err); } if ($id) { // get tool status $obj->getToolStatus($id, $this->_option, $fstatus, $editversion); $tool['developers'] = $fstatus['developers']; $tool['membergroups'] = $fstatus['membergroups']; $tool['published'] = $fstatus['published']; } $this->editTask($tool); return; } $tool['vncGeometry'] = $tool['vncGeometryX'] . 'x' . $tool['vncGeometryY']; $tool['toolname'] = strtolower($tool['toolname']); $tool['developers'] = array_map('trim', explode(',', $tool['developers'])); $tool['membergroups'] = array_map('trim', explode(',', $tool['membergroups'])); $tool['hostreq'] = array_map('trim', explode(',', $tool['hostreq'])); // save tool info if (!$id) { $hzt = \Components\Tools\Models\Tool::createInstance($tool['toolname']); $hzt->toolname = $tool['toolname']; $hzt->title = $tool['title']; $hzt->published = 0; $hzt->state = 1; $hzt->priority = 3; $hzt->registered = $today; $hzt->state_changed = $today; $hzt->registered_by = User::get('username'); } else { $hzt = \Components\Tools\Models\Tool::getInstance($id); } // get tool id for newly registered tool $this->_toolid = $hzt->id; // save version info $hztv = $hzt->getRevision($editversion); if ($hztv) { $oldstatus = $hztv->toArray(); $oldstatus['toolstate'] = $hzt->state; $oldstatus['membergroups'] = $tool['membergroups']; if ($id) { $oldstatus['developers'] = $obj->getToolDevelopers($id); } } // NEW: save github repo as param $params = ''; $version = $objV->getVersionInfo($this->_toolid, 'dev'); if ($version && !empty($version[0])) { $txt = new \Hubzero\Config\Registry($version[0]->params); } else { $txt = new \Hubzero\Config\Registry(''); } $txt->set('github', $tool['github']); $ptype = empty($tool['publishType']) || $tool['publishType'] == 'standard' ? 'standard' : 'weber='; $txt->set('publishType', $ptype); $params = $txt->toString(); if ($editversion == 'dev') { if ($hztv === false) { Log::debug(__FUNCTION__ . "() HZTV createInstance dev_suffix={$dev_suffix}"); $hztv = \Components\Tools\Models\Version::createInstance($tool['toolname'], $tool['toolname'] . $dev_suffix); $oldstatus = $hztv->toArray(); $oldstatus['toolstate'] = $hzt->state; $oldstatus['membergroups'] = $tool['membergroups']; } if ($id) { $oldstatus['developers'] = $obj->getToolDevelopers($id); } $invokedir = $this->config->get('invokescript_dir', DS . 'apps'); $invokedir = rtrim($invokedir, DS); $hztv->toolid = $this->_toolid; $hztv->toolname = $tool['toolname']; $hztv->title = $tool['title']; $hztv->version = $tool['version']; $hztv->description = $tool['description']; $hztv->toolaccess = $tool['exec']; $hztv->codeaccess = $tool['code']; $hztv->wikiaccess = $tool['wiki']; $hztv->vnc_command = $invokedir . DS . $tool['toolname'] . DS . 'dev' . DS . 'middleware' . DS . 'invoke -T dev'; $hztv->vnc_geometry = $tool['vncGeometry']; $hztv->exportControl = $exportmap[$tool['exec']]; $hztv->state = 3; $hztv->instance = $tool['toolname'] . $dev_suffix; $hztv->mw = $this->config->get('default_mw', 'narwhal'); $hztv->hostreq = $tool['hostreq']; $hztv->params = $params; $hzt->add('version', $hztv->instance); } else { if ($hztv) { $hztv->toolid = $this->_toolid; $hztv->toolname = $tool['toolname']; $hztv->title = $tool['title']; $hztv->version = $tool['version']; $hztv->description = $tool['description']; $hztv->toolaccess = $tool['exec']; $hztv->codeaccess = $tool['code']; $hztv->wikiaccess = $tool['wiki']; $hztv->vnc_geometry = $tool['vncGeometry']; $hztv->exportControl = $exportmap[$tool['exec']]; $hztv->hostreq = $tool['hostreq']; $hzt->add('version', $hztv->instance); } } $this->_setTracAccess($tool['toolname'], $hztv->codeaccess, $hztv->wikiaccess); if ($this->_error) { App::abort(500, $this->_error); return; } // create/update developers group $gid = $hztv->getDevelopmentGroup(); if (empty($gid)) { $hzg = new \Hubzero\User\Group(); $hzg->cn = $group_prefix . strtolower($tool['toolname']); $hzg->create(); $hzg->set('type', 2); $hzg->set('description', Lang::txt('COM_TOOLS_DELEVOPMENT_GROUP', $tool['title'])); $hzg->set('created', Date::toSql()); $hzg->set('created_by', User::get('id')); } else { $hzg = \Hubzero\User\Group::getInstance($gid); } $hzg->set('members', $tool['developers']); $hztrac = \Hubzero\Trac\Project::find_or_create('app:' . $tool['toolname']); $hztrac->add_group_permission('apps', array('WIKI_ADMIN', 'MILESTONE_ADMIN', 'BROWSER_VIEW', 'LOG_VIEW', 'FILE_VIEW', 'CHANGESET_VIEW', 'ROADMAP_VIEW', 'TIMELINE_VIEW', 'SEARCH_VIEW')); $hztrac->add_group_permission($hzg->cn, array('WIKI_ADMIN', 'MILESTONE_ADMIN', 'BROWSER_VIEW', 'LOG_VIEW', 'FILE_VIEW', 'CHANGESET_VIEW', 'ROADMAP_VIEW', 'TIMELINE_VIEW', 'SEARCH_VIEW')); $hztv->set('owner', $hzg->cn); $hztv->add('owner', 'apps'); $hztv->set('member', $tool['membergroups']); // Add repo for new tools $auto_addrepo = $this->config->get('auto_addrepo', 1); if (!$id && $auto_addrepo) { $hzt->update(); // Make sure tool exists in database or gensvn won't configure apachce access to it $hztv->update(); // Make sure tool exists in database or gensvn won't configure apachce access to it // Run add repo $this->_addRepo($output, array('toolname' => $tool['toolname'], 'title' => $tool['title'], 'description' => $tool['description'])); if ($output['class'] != 'error') { $hzt->state = 2; $hzt->update(); } } // get ticket information if (empty($hzt->ticketid)) { $hzt->ticketid = $this->_createTicket($this->_toolid, $tool); } // create resource page $rid = \Components\Tools\Models\Tool::getResourceId($hzt->toolname, $hzt->id); if (empty($rid)) { include_once __DIR__ . DS . 'resource.php'; $resource = new Resource(); $rid = $resource->createPage($this->_toolid, $tool); // save authors by default //$objA = new \Components\Tools\Tables\Author($this->database); //if (!$id) { $objA->saveAuthors($tool['developers'], 'dev', $rid, '', $tool['toolname']); } if (!$id) { require_once __DIR__ . DS . 'authors.php'; $controller = new Authors(); $controller->saveTask(0, $rid, $tool['developers']); //$this->author_save(0, $rid, $tool['developers']); } } // display status page //$this->_task = 'status'; //$this->_msg = $id ? Lang::txt('COM_TOOLS_NOTICE_TOOL_INFO_CHANGED'): Lang::txt('COM_TOOLS_NOTICE_TOOL_INFO_REGISTERED'); $hzg->update(); $hzt->update(); $hztv->update(); // @FIXME: look $status = $hztv->toArray(); $status['toolstate'] = $hzt->state; $status['membergroups'] = $tool['membergroups']; $status['toolname'] = $tool['toolname']; if ($id) { $status['developers'] = $obj->getToolDevelopers($id); } // update history ticket if ($id && $oldstatus != $status && $editversion != 'current') { $this->_newUpdateTicket($hzt->id, $hzt->ticketid, $oldstatus, $status, $comment, 0, 1); } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=status&app=' . $hzt->toolname), $id ? Lang::txt('COM_TOOLS_NOTICE_TOOL_INFO_CHANGED') : Lang::txt('COM_TOOLS_NOTICE_TOOL_INFO_REGISTERED')); }
/** * Save an entry * * @return string */ private function save() { Request::checkToken(); //get request vars $event = Request::getVar('event', array(), 'post'); $event['time_zone'] = Request::getVar('time_zone', -5); $event['params'] = Request::getVar('params', array()); $event['content'] = Request::getVar('content', '', 'post', 'STRING', JREQUEST_ALLOWRAW); $registration = Request::getVar('include-registration', 0); //set vars for saving $event['catid'] = '-1'; $event['state'] = 1; $event['scope'] = 'group'; $event['scope_id'] = $this->group->get('gidNumber'); $event['modified'] = Date::toSql(); $event['modified_by'] = $this->user->get('id'); // repeating rule $event['repeating_rule'] = $this->_buildRepeatingRule(); //if we are updating set modified time and actor if (!isset($event['id']) || $event['id'] == 0) { $event['created'] = Date::toSql(); $event['created_by'] = $this->user->get('id'); } // timezone $timezone = new DateTimezone(Config::get('offset')); //parse publish up date/time if (isset($event['publish_up']) && $event['publish_up'] != '') { // combine date & time if (isset($event['publish_up_time'])) { $event['publish_up'] = $event['publish_up'] . ' ' . $event['publish_up_time']; } $event['publish_up'] = Date::of($event['publish_up'], $timezone)->format("Y-m-d H:i:s"); unset($event['publish_up_time']); } //parse publish down date/time if (isset($event['publish_down']) && $event['publish_down'] != '') { // combine date & time if (isset($event['publish_down_time'])) { $event['publish_down'] = $event['publish_down'] . ' ' . $event['publish_down_time']; } $event['publish_down'] = Date::of($event['publish_down'], $timezone)->format("Y-m-d H:i:s"); unset($event['publish_down_time']); } //parse register by date/time if (isset($event['registerby']) && $event['registerby'] != '') { //remove @ symbol $event['registerby'] = str_replace("@", "", $event['registerby']); $event['registerby'] = Date::of($event['registerby'], $timezone)->format("Y-m-d H:i:s"); } //stringify params if (isset($event['params']) && count($event['params']) > 0) { $params = new \Hubzero\Config\Registry($event['params']); $event['params'] = $params->toString(); } //did we want to turn off registration? if (!$registration) { $event['registerby'] = '0000-00-00 00:00:00'; } //instantiate new event object $eventsModelEvent = new \Components\Events\Models\Event(); // attempt to bind if (!$eventsModelEvent->bind($event)) { $this->setError($eventsModelEvent->getError()); $this->event = $eventsModelEvent; return $this->edit(); } if (isset($event['content']) && $event['content']) { $event['content'] = \Hubzero\Utility\Sanitize::clean($event['content']); } if (isset($event['extra_info']) && $event['extra_info'] && !\Hubzero\Utility\Validate::url($event['extra_info'])) { $this->setError('Website entered does not appear to be a valid URL.'); $this->event = $eventsModelEvent; return $this->edit(); } //make sure we have both start and end time if ($event['publish_up'] == '') { $this->setError('You must enter an event start, an end date is optional.'); $this->event = $eventsModelEvent; return $this->edit(); } //check to make sure end time is greater than start time if (isset($event['publish_down']) && $event['publish_down'] != '0000-00-00 00:00:00' && $event['publish_down'] != '') { $up = strtotime($event['publish_up']); $down = strtotime($event['publish_down']); $allday = isset($event['allday']) && $event['allday'] == 1 ? true : false; // make sure up greater than down when not all day // when all day event up can equal down if ($up >= $down && !$allday || $allday && $up > $down) { $this->setError('You must an event end date greater than the start date.'); $this->event = $eventsModelEvent; return $this->edit(); } } //make sure registration email is valid if ($registration && isset($event['email']) && $event['email'] != '' && !filter_var($event['email'], FILTER_VALIDATE_EMAIL)) { $this->setError('You must enter a valid email address for the events registration admin email.'); $this->event = $eventsModelEvent; return $this->edit(); } //make sure registration email is valid if ($registration && (!isset($event['registerby']) || $event['registerby'] == '')) { $this->setError('You must enter a valid event registration deadline to require registration.'); Request::setVar('includeRegistration', 1); $this->event = $eventsModelEvent; return $this->edit(); } //check to make sure we have valid info if (!$eventsModelEvent->store(true)) { $this->setError('An error occurred when trying to edit the event. Please try again.'); $this->event = $eventsModelEvent; return $this->edit(); } //get the year and month for this event //so we can jump to that spot $year = Date::of(strtotime($event['publish_up']))->format("Y"); $month = Date::of(strtotime($event['publish_up']))->format("m"); //build message $message = Lang::txt('You have successfully created a new group event.'); if (isset($event['id']) && $event['id'] != 0) { $message = Lang::txt('You have successfully edited the group event.'); } //inform user and redirect App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=details&event_id=' . $eventsModelEvent->get('id')), $message, 'passed'); }
/** * Return Module Rendered & Ready For Display * * @return void */ public function moduleAction() { // get module id $moduleId = Request::getInt('moduleid', 0); // get list of modules $modulesList = $this->_loadModules($this->params->get('position', 'memberDashboard')); // load user preferences $preferences = $this->_loadPreferences(); // get module preferences for moduleid $preference = new stdClass(); foreach ($preferences as $p) { if ($p->module == $moduleId) { $preference = $p; break; } } // get the module $module = null; if (in_array($moduleId, array_keys($modulesList))) { $module = $modulesList[$moduleId]; $module->positioning = new stdClass(); $module->positioning->col = 1; $module->positioning->row = 1; $module->positioning->size_x = 1; $module->positioning->size_y = 2; // merge user params with hub wide params if (isset($preference->parameters)) { $params = new \Hubzero\Config\Registry($module->params); $uparams = new \Hubzero\Config\Registry($preference->parameters); $params->merge($uparams); $module->params = $params->toString(); } } // create view object $view = $this->view('module', 'display'); // get application location $view->admin = App::isAdmin(); $view->module = $module; $content = $view->loadTemplate(); $stylesheets = array(); $scripts = array(); $document = Document::getHeadData(); foreach ($document['styleSheets'] as $strSrc => $strAttr) { if (strstr($strSrc, $module->module)) { $stylesheets[] = $strSrc; } } foreach ($document['scripts'] as $strSrc => $strType) { if (strstr($strSrc, $module->module)) { $scripts[] = $strSrc; } } // return content echo json_encode(array('html' => $content, 'assets' => array('scripts' => $scripts, 'stylesheets' => $stylesheets))); exit; }
/** * Method to save the form data. * * @param array $data The form data. * @param boolean $opposite_client Indicates whether the override should not be created for the current client * * @return boolean True on success, false otherwise. * * @since 2.5 */ public function save($data, $opposite_client = false) { require_once JPATH_COMPONENT . '/helpers/languages.php'; $client = User::getState('com_languages.overrides.filter.client', 0); $language = User::getState('com_languages.overrides.filter.language', 'en-GB'); // If the override should be created for both if ($opposite_client) { $client = 1 - $client; } $client = $client ? 'administrator' : 'site'; // Parse the override.ini file in oder to get the keys and strings $filename = PATH_APP . '/bootstrap/' . $client . '/language/overrides/' . $language . '.override.ini'; $strings = LanguagesHelper::parseFile($filename); if (isset($strings[$data['id']])) { // If an existent string was edited check whether // the name of the constant is still the same if ($data['key'] == $data['id']) { // If yes, simply override it $strings[$data['key']] = $data['override']; } else { // If no, delete the old string and prepend the new one unset($strings[$data['id']]); $strings = array($data['key'] => $data['override']) + $strings; } } else { // If it is a new override simply prepend it $strings = array($data['key'] => $data['override']) + $strings; } foreach ($strings as $key => $string) { $strings[$key] = str_replace('"', '"_QQ_"', $string); } // Write override.ini file with the strings $registry = new \Hubzero\Config\Registry($strings); if (!Filesystem::write($filename, $registry->toString('INI'))) { return false; } // If the override should be stored for both clients save // it also for the other one and prevent endless recursion if (isset($data['both']) && $data['both'] && !$opposite_client) { return $this->save($data, true); } return true; }
/** * Save an Import * * @return void */ public function saveTask() { // check token Session::checkToken(); // get request vars $import = Request::getVar('import', array()); $hooks = Request::getVar('hooks', array()); $params = Request::getVar('params', array()); $file = Request::getVar('file', array(), 'FILES'); // create import model object $this->import = new Models\Import(); // set our hooks $this->import->set('hooks', json_encode($hooks)); // load current params $iparams = new \Hubzero\Config\Registry($this->import->get('params')); // bind incoming params $iparams->parse($params); // set params on import object $this->import->set('params', $iparams->toString()); // bind input to model if (!$this->import->bind($import)) { $this->setError($this->import->getError()); return $this->editTask(); } // is this a new import $isNew = false; if (!$this->import->get('id')) { $isNew = true; // set the created by/at $this->import->set('created_by', User::get('id')); $this->import->set('created_at', Date::toSql()); } // do we have a data file if ($this->import->get('file')) { // get record count $importImporter = new Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // attempt to save if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } // is this a new import if ($isNew) { // create folder for files $this->_createImportFilespace($this->import); } // if we have a file if (is_array($file) && $file['size'] > 0 && $file['error'] == 0) { $ext = strtolower(Filesystem::extension($file['name'])); if (!in_array($ext, array('csv', 'xml'))) { $this->setError(Lang::txt('COM_RESOURCES_IMPORT_UNSUPPORTED_FILE_TYPE')); return $this->editTask(); } if (!is_dir($this->import->fileSpacePath())) { Filesystem::makeDirectory($this->import->fileSpacePath()); } move_uploaded_file($file['tmp_name'], $this->import->fileSpacePath() . DS . $file['name']); $this->import->set('file', $file['name']); } // do we have a data file if ($this->import->get('file')) { // get record count $importImporter = new Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // save again with import count if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } //inform user & redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=display', false), Lang::txt('COM_RESOURCES_IMPORT_CREATED'), 'passed'); }
/** * Save blog settings * * @return void */ private function _savesettings() { if (User::isGuest()) { $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE')); return; } if ($this->authorized != 'manager' && $this->authorized != 'admin') { $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED')); return $this->_browse(); } // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); $row = \Hubzero\Plugin\Params::blank()->set($settings); // Get parameters $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post')); $row->set('params', $p->toString()); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->_settings(); } // Record the activity $recipients = array(['group', $this->group->get('gidNumber')]); foreach ($this->group->get('managers') as $recipient) { $recipients[] = ['user', $recipient]; } Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'blog.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]); App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_BLOG_SETTINGS_SAVED'), 'passed'); }
/** * Update a page * * @apiParameter { * "name": "id", * "description": "Entry identifier", * "type": "integer", * "required": true, * "default": null * } * @apiParameter { * "name": "title", * "description": "Entry title", * "type": "string", * "required": true, * "default": null * } * @apiParameter { * "name": "pagename", * "description": "Page name", * "type": "string", * "required": false, * "default": null * } * @apiParameter { * "name": "pagetext", * "description": "Page content", * "type": "string", * "required": true, * "default": null * } * @apiParameter { * "name": "created", * "description": "Created timestamp (YYYY-MM-DD HH:mm:ss)", * "type": "string", * "required": false, * "default": "now" * } * @apiParameter { * "name": "created_by", * "description": "User ID of entry creator", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "state", * "description": "Published state (0 = unpublished, 1 = published)", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "access", * "description": "Access level (0 = public, 1 = registered users, 4 = private)", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "scope", * "description": "Page scope", * "type": "string", * "required": false, * "default": null * } * @apiParameter { * "name": "group_cn", * "description": "Group name the wiki page belongs to", * "type": "string", * "required": false, * "default": "" * } * @apiParameter { * "name": "params", * "description": "Page options", * "type": "array", * "required": false, * "default": null * } * @apiParameter { * "name": "summary", * "description": "Summary of changes made", * "type": "string", * "required": false, * "default": null * } * @return void */ public function updateTask() { $this->requiresAuthentication(); $fields = array('title' => Request::getVar('title', null, '', 'none', 2), 'pagename' => Request::getVar('pagename', null), 'scope' => Request::getVar('scope', null), 'created' => Request::getVar('created', null), 'created_by' => Request::getInt('created_by', null), 'state' => Request::getInt('state', null), 'access' => Request::getInt('access', null), 'group_cn' => Request::getVar('group_cn', null)); if (!$id) { throw new Exception(Lang::txt('COM_TAGS_ERROR_MISSING_DATA'), 422); } $page = new Page($id); if (!$page->exists()) { throw new Exception(Lang::txt('Specified page not found.'), 404); } $revision = $page->revision('current'); if (!$revision->bind($rev)) { throw new Exception($revision->getError(), 500); } $params = new \Hubzero\Config\Registry($page->get('params', '')); $params->merge(Request::getVar('params', array(), 'post')); $page->set('params', $params->toString()); foreach ($fields as $key => $value) { if (!is_null($value)) { $page->set($key, $value); } } $page->set('modified', Date::toSql()); if (!$page->store(true)) { throw new Exception($page->getError(), 500); } if (!$page->updateAuthors(Request::getVar('authors', '', 'post'))) { throw new Exception($page->getError(), 500); } $revision->set('pagetext', Request::getVar('pagetext', '', '', 'none', 2)); $revision->set('summary', Request::getVar('summary', null)); if ($revision->get('pagetext') == '') { $revision->set('id', 0); $revision->set('pageid', $page->get('id')); $revision->set('pagename', $page->get('pagename')); $revision->set('scope', $page->get('scope')); $revision->set('group_cn', $page->get('group_cn')); $revision->set('version', $revision->get('version') + 1); if ($page->param('mode', 'wiki') == 'knol') { // Set revisions to NOT approved $revision->set('approved', 0); // If an author or the original page creator, set to approved if ($page->get('created_by') == User::get('id') || $page->isAuthor(User::get('id'))) { $revision->set('approved', 1); } } else { // Wiki mode, approve revision $revision->set('approved', 1); } $revision->set('pagehtml', $revision->content('parsed')); if ($page->access('manage') || $page->access('edit')) { $revision->set('approved', 1); } // Store content if (!$revision->store(true)) { throw new Exception(Lang::txt('COM_WIKI_ERROR_SAVING_REVISION'), 500); } $page->set('version_id', $revision->get('id')); if (!$page->store(true)) { throw new Exception($page->getError(), 500); } } $page->tag(Request::getVar('tags', '')); $this->send($page->toObject()); }
/** * Map Resource Data * * @return void */ private function _mapResourceData() { // do we want to do a title match? if ($this->_options['titlematch'] == 1 && isset($this->record->type->id)) { $sql = 'SELECT id, title, LEVENSHTEIN( title, ' . $this->_database->quote($this->raw->title) . ' ) as titleDiff FROM `#__resources` WHERE `type`=' . $this->record->type->id . ' HAVING titleDiff < ' . self::TITLE_MATCH; $this->_database->setQuery($sql); $results = $this->_database->loadObjectList('id'); // did we get more then one result? if (count($results) > 1) { $ids = implode(", ", array_keys($results)); throw new Exception(Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_UNABLE_DETECTDUPLICATE', $ids)); } // if we only have one were all good if (count($results) == 1) { // set our id to the matched resource $resource = reset($results); $this->raw->id = $resource->id; // add a notice with link to resource matched $resourceLink = rtrim(str_replace('administrator', '', \Request::base()), DS) . DS . 'resources' . DS . $resource->id; $link = '<a target="_blank" href="' . $resourceLink . '">' . $resourceLink . '</a>'; array_push($this->record->notices, Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_MATCHEDBYTITLE', $link)); } } // do we have a resource id // either passed in the raw data or gotten from the title match if (isset($this->raw->id) && $this->raw->id > 1) { $this->record->resource->load($this->raw->id); } else { $this->raw->standalone = 1; $this->raw->created = \Date::toSql(); $this->raw->created_by = $this->_user->get('id'); // publish up/down if (!isset($this->raw->publish_up)) { $this->raw->publish_up = \Date::toSql(); } if (!isset($this->raw->publish_down)) { $this->raw->publish_down = '0000-00-00 00:00:00'; } } // set modified date/user $this->raw->modified = \Date::toSql(); $this->raw->modified_by = $this->_user->get('id'); // set status if (isset($this->_options['status'])) { $this->raw->published = (int) $this->_options['status']; } // set group if (isset($this->_options['group'])) { $this->raw->group_owner = $this->_options['group']; } // set access if (isset($this->_options['access'])) { $this->raw->access = (int) $this->_options['access']; } // bind resource data $this->record->resource->bind($this->raw); // resource params $params = new \Hubzero\Config\Registry($this->record->resource->params); $this->record->resource->params = $params->toString(); // resource attributes $attribs = new \Hubzero\Config\Registry($this->record->resource->attribs); $this->record->resource->attribs = $attribs->toString(); // full text pieces - to add paragraph tags $fullTextPieces = array_map("trim", explode("\n", $this->record->resource->introtext)); $fullTextPieces = array_values(array_filter($fullTextPieces)); // set the full text $this->record->resource->fulltxt = "<p>" . implode("</p>\n<p>", $fullTextPieces) . "</p>"; if (!isset($this->raw->custom_fields)) { $this->raw->custom_fields = array(); } // bind custom fields to types custom fields if (isset($this->record->type->id)) { $resourcesElements = new \Components\Resources\Models\Elements((array) $this->raw->custom_fields, $this->record->type->customFields); $customFieldsHtml = $resourcesElements->toDatabaseHtml(); // add all custom fields to custom object foreach ($resourcesElements->getSchema()->fields as $field) { $fieldLabel = $field->label; $fieldName = $field->name; $value = isset($this->raw->custom_fields->{$fieldName}) ? $this->raw->custom_fields->{$fieldName} : null; if ($field->type == 'hidden') { $value = isset($field->options[0]) ? $field->options[0]->value : $value; } $this->record->custom->{$fieldLabel} = $value; } } else { $customFieldsHtml = ''; } // add custom fields to fulltxt $this->record->resource->fulltxt .= "\n\n" . $customFieldsHtml; }
/** * Save changes to an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); $recurrence = array(); if (isset($fields['minute'])) { $recurrence[] = $fields['minute']['c'] ? $fields['minute']['c'] : $fields['minute']['s']; } if (isset($fields['hour'])) { $recurrence[] = $fields['hour']['c'] ? $fields['hour']['c'] : $fields['hour']['s']; } if (isset($fields['day'])) { $recurrence[] = $fields['day']['c'] ? $fields['day']['c'] : $fields['day']['s']; } if (isset($fields['month'])) { $recurrence[] = $fields['month']['c'] ? $fields['month']['c'] : $fields['month']['s']; } if (isset($fields['dayofweek'])) { $recurrence[] = $fields['dayofweek']['c'] ? $fields['dayofweek']['c'] : $fields['dayofweek']['s']; } if (!empty($recurrence)) { $fields['recurrence'] = implode(' ', $recurrence); } unset($fields['minute']); unset($fields['hour']); unset($fields['day']); unset($fields['month']); unset($fields['dayofweek']); // Initiate extended database class $row = Job::oneOrNew($fields['id'])->set($fields); if ($row->get('recurrence')) { $row->set('next_run', $row->nextRun()); } $p = new \Hubzero\Config\Registry(Request::getVar('params', '', 'post')); $row->set('params', $p->toString()); // Store content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_CRON_ITEM_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }
/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $fields = Request::getVar('fields', array(), 'post'); $row = Role::oneOrNew(intval($fields['id']))->set($fields); if (!isset($fields['permissions'])) { $fields['permissions'] = array(); } $permissions = new \Hubzero\Config\Registry($fields['permissions']); $row->set('permissions', $permissions->toString()); // Store new content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_GROUPS_ROLE_SAVED')); // Redirect to main listing if ($this->getTask() == 'apply') { return $this->editTask($row); } $this->cancelTask(); }
/** * Save changes to an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $fields = Request::getVar('page', array(), 'post'); $fields = array_map('trim', $fields); $authors = $fields['authors']; $tags = $fields['tags']; unset($fields['authors']); unset($fields['tags']); // Initiate extended database class $page = Page::oneOrNew($fields['id'])->set($fields); // Get parameters $params = Request::getVar('params', array(), 'post'); if (is_array($params)) { $pparams = new \Hubzero\Config\Registry($page->get('params')); $pparams->merge($params); $page->set('params', $pparams->toString()); } // Store new content if (!$page->save()) { Notify::error($page->getError()); return $this->editTask($page); } if (!Author::setForPage($authors, $page->get('id'))) { Notify::error($page->getError()); return $this->editTask($page); } $page->tag($tags); Notify::success(Lang::txt('COM_WIKI_PAGE_SAVED')); if ($this->getTask() == 'apply') { Request::setVar('id', $page->get('id')); return $this->editTask($page); } // Redirect to main listing $this->cancelTask(); }