Пример #1
0
 /**
  * Register the service provider.
  *
  * @return  void
  */
 public function register()
 {
     $this->app['menu.manager'] = function ($app) {
         return $manager = new Manager();
     };
     $this->app['menu'] = function ($app) {
         $options = ['language_filter' => null, 'language' => null, 'access' => \User::getAuthorisedViewLevels()];
         $options['db'] = $app->get('db');
         if ($app->has('language.filter')) {
             $options['language_filter'] = $app->get('language.filter');
             $options['language'] = $app->get('language')->getTag();
         }
         return $app['menu.manager']->menu($app['client']->name, $options);
     };
     $this->app['menu.params'] = function ($app) {
         $params = new Registry();
         $menu = $app['menu']->getActive();
         if (is_object($menu)) {
             $params->parse($menu->params);
         } else {
             if ($app->has('component')) {
                 $temp = clone $app['component']->params('com_menus');
                 $params->merge($temp);
             }
         }
         return $params;
     };
 }
Пример #2
0
 /**
  * Renders a module script and returns the results as a string
  *
  * @param   string  $module   The name of the module to render
  * @param   array   $attribs  Associative array of values
  * @param   string  $content  If present, module information from the buffer will be used
  * @return  string  The output of the script
  */
 public function render($module, $attribs = array(), $content = null)
 {
     if (!is_object($module)) {
         $title = isset($attribs['title']) ? $attribs['title'] : null;
         $module = \App::get('module')->byName($module, $title);
         if (!is_object($module)) {
             if (is_null($content)) {
                 return '';
             } else {
                 // If module isn't found in the database but data has been pushed in the buffer
                 // we want to render it
                 $tmp = $module;
                 $module = new stdClass();
                 $module->params = null;
                 $module->module = $tmp;
                 $module->id = 0;
                 $module->user = 0;
             }
         }
     }
     // Set the module content
     if (!is_null($content)) {
         $module->content = $content;
     }
     // Get module parameters
     $params = new Registry($module->params);
     // Use parameters from template
     if (isset($attribs['params'])) {
         $template_params = new Registry(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($template_params);
         $module = clone $module;
         $module->params = (string) $params;
     }
     return \App::get('module')->render($module, $attribs);
 }
 /**
  * Register the service provider.
  *
  * @return  void
  */
 public function register()
 {
     $this->app['menu.manager'] = function ($app) {
         return $manager = new Manager();
     };
     $this->app['menu'] = function ($app) {
         return $app['menu.manager']->menu($app['client']->name);
     };
     $this->app['menu.params'] = function ($app) {
         $params = new Registry();
         $menu = $app['menu']->getActive();
         if (is_object($menu)) {
             $params->parse($menu->params);
         } else {
             if ($app->has('component')) {
                 $temp = clone $app['component']->params('com_menus');
                 $params->merge($temp);
             }
         }
         return $params;
     };
 }
Пример #4
0
 /**
  * Saves changes to a group or saves a new entry if creating
  *
  * @return void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $g = Request::getVar('group', array(), 'post', 'none', 2);
     $g = $this->_multiArrayMap('trim', $g);
     // Instantiate a Group object
     $group = new Group();
     // Is this a new entry or updating?
     $isNew = false;
     if (!$g['gidNumber']) {
         $isNew = true;
         // Set the task - if anything fails and we re-enter edit mode
         // we need to know if we were creating new or editing existing
         $this->_task = 'new';
         $before = new Group();
     } else {
         $this->_task = 'edit';
         // Load the group
         $group->read($g['gidNumber']);
         $before = clone $group;
     }
     $task = $this->_task == 'edit' ? 'edit' : 'create';
     if (!$this->authorize($task, $group)) {
         return;
     }
     // Check for any missing info
     if (!$g['cn']) {
         $this->setError(Lang::txt('COM_GROUPS_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_ID'));
     }
     if (!$g['description']) {
         $this->setError(Lang::txt('COM_GROUPS_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_TITLE'));
     }
     // Push back into edit mode if any errors
     if ($this->getError()) {
         $this->view->setLayout('edit');
         $this->view->group = $group;
         // Set any errors
         if ($this->getError()) {
             $this->view->setError($this->getError());
         }
         // Output the HTML
         $this->view->display();
         return;
     }
     $g['cn'] = strtolower($g['cn']);
     // Ensure the data passed is valid
     if (!$this->_validCn($g['cn'], true)) {
         $this->setError(Lang::txt('COM_GROUPS_ERROR_INVALID_ID'));
     }
     //only check if cn exists if we are creating or have changed the cn
     if ($this->_task == 'new' || $group->get('cn') != $g['cn']) {
         if (Group::exists($g['cn'], true)) {
             $this->setError(Lang::txt('COM_GROUPS_ERROR_GROUP_ALREADY_EXIST'));
         }
     }
     // Push back into edit mode if any errors
     if ($this->getError()) {
         $this->view->setLayout('edit');
         $this->view->group = $group;
         // Set any errors
         if ($this->getError()) {
             $this->view->setError($this->getError());
         }
         // Output the HTML
         $this->view->display();
         return;
     }
     // group params
     $gparams = new Registry($group->get('params'));
     $gparams->merge(new Registry($g['params']));
     // set membership control param
     $membership_control = isset($g['params']['membership_control']) ? 1 : 0;
     $gparams->set('membership_control', $membership_control);
     $params = $gparams->toString();
     // Set the group changes and save
     $group->set('cn', $g['cn']);
     $group->set('type', $g['type']);
     if ($isNew) {
         $group->create();
         $group->set('published', 1);
         $group->set('approved', 1);
         $group->set('created', Date::toSql());
         $group->set('created_by', User::get('id'));
         $group->add('managers', array(User::get('id')));
         $group->add('members', array(User::get('id')));
     }
     $group->set('description', $g['description']);
     $group->set('discoverability', $g['discoverability']);
     $group->set('join_policy', $g['join_policy']);
     $group->set('public_desc', $g['public_desc']);
     $group->set('private_desc', $g['private_desc']);
     $group->set('restrict_msg', $g['restrict_msg']);
     $group->set('logo', $g['logo']);
     $group->set('plugins', $g['plugins']);
     $group->set('discussion_email_autosubscribe', $g['discussion_email_autosubscribe']);
     $group->set('params', $params);
     $group->update();
     // create home page
     if ($isNew) {
         // create page
         $page = new Page(array('gidNumber' => $group->get('gidNumber'), 'parent' => 0, 'lft' => 1, 'rgt' => 2, 'depth' => 0, 'alias' => 'overview', 'title' => 'Overview', 'state' => 1, 'privacy' => 'default', 'home' => 1));
         $page->store(false);
         // create page version
         $version = new Page\Version(array('pageid' => $page->get('id'), 'version' => 1, 'content' => "<!-- {FORMAT:HTML} -->\n<p>[[Group.DefaultHomePage()]]</p>", 'created' => Date::of('now')->toSql(), 'created_by' => User::get('id'), 'approved' => 1));
         $version->store(false);
     }
     // Get plugins
     Event::trigger('groups.onGroupAfterSave', array($before, $group));
     // log edit
     Log::log(array('gidNumber' => $group->get('gidNumber'), 'action' => 'group_edited', 'comments' => 'edited by administrator'));
     // handle special groups
     if ($group->isSuperGroup()) {
         $this->_handleSuperGroup($group);
         // git lab stuff
         $this->_handSuperGroupGitlab($group);
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_GROUPS_SAVED'));
 }
Пример #5
0
 /**
  * Render the module.
  *
  * @param   object  $module   A module object.
  * @param   array   $attribs  An array of attributes for the module (probably from the XML).
  * @return  string  The HTML content of the module output.
  */
 public function render($module, $attribs = array())
 {
     static $chrome;
     if (null !== $this->profiler) {
         $this->profiler->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     // Record the scope.
     $scope = $this->app->has('scope') ? $this->app->get('scope') : null;
     // Set scope to component name
     $this->app->set('scope', $module->module);
     // Get module parameters
     $params = new Registry($module->params);
     if (isset($attribs['params'])) {
         $customparams = new Registry(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($customparams);
         $module->params = $params->toString();
     }
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = PATH_CORE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     // $module->user is a check for 1.0 custom modules and is deprecated refactoring
     if (file_exists($path)) {
         $this->app['language']->load($module->module, PATH_APP . DS . 'bootstrap' . DS . $this->app['client']->name, null, false, true) || $this->app['language']->load($module->module, dirname($path), null, false, true);
         $content = '';
         ob_start();
         include $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     include_once PATH_CORE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = $this->app['template']->path . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             include_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     // Make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     // Dynamically add outline style
     if ($this->outline()) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     // Revert the scope
     $this->app->forget('scope');
     $this->app->set('scope', $scope);
     if (null !== $this->profiler) {
         $this->profiler->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     return $module->content;
 }
Пример #6
0
 /**
  * Load the editor
  *
  * @param   array  $config  Associative array of editor config paramaters
  * @return  mixed
  */
 protected function load($config = array())
 {
     // Check whether editor is already loaded
     if (!is_null($this->editor)) {
         return;
     }
     // Build the path to the needed editor plugin
     $name = (string) preg_replace('/[^A-Z0-9_\\.-]/i', '', $this->name);
     $name = ltrim($name, '.');
     $path = PATH_CORE . '/plugins/editors/' . $name . '/' . $name . '.php';
     if (!is_file($path)) {
         \Notify::error(Lang::txt('JLIB_HTML_EDITOR_CANNOT_LOAD'));
         return false;
     }
     // Require plugin file
     require_once $path;
     // Get the plugin
     $plugin = Plugin::byType('editors', $this->name);
     $params = new Registry($plugin->params);
     $params->merge($config);
     $plugin->params = $params;
     // Build editor plugin classname
     $name = 'plgEditor' . $this->name;
     if ($this->editor = new $name($this, (array) $plugin)) {
         // Load plugin parameters
         $this->initialise();
         Plugin::import('editors-xtd');
     }
 }
Пример #7
0
 /**
  *  Save group settings
  *
  * @return 		void
  */
 public function saveTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask(Lang::txt('COM_GROUPS_CREATE_MUST_BE_LOGGED_IN'));
         return;
     }
     Request::checkToken();
     // Incoming
     $g_gidNumber = Request::getInt('gidNumber', 0, 'post');
     $c_gidNumber = Request::getVar('gidNumber', 0, 'post');
     if ((string) $g_gidNumber !== (string) $c_gidNumber) {
         App::abort(404, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
     }
     if (!$g_gidNumber && !User::authorise('core.create', $this->_option) || $g_gidNumber && !User::authorise('core.edit', $this->_option)) {
         return App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'), 'warning');
     }
     $g_cn = trim(Request::getVar('cn', '', 'post'));
     $g_description = preg_replace('/\\s+/', ' ', trim(Request::getVar('description', Lang::txt('NONE'), 'post')));
     $g_discoverability = Request::getInt('discoverability', 0, 'post');
     $g_public_desc = Sanitize::stripScripts(trim(Request::getVar('public_desc', '', 'post', 'none', 2)));
     $g_private_desc = Sanitize::stripScripts(trim(Request::getVar('private_desc', '', 'post', 'none', 2)));
     $g_restrict_msg = Sanitize::stripScripts(trim(Request::getVar('restrict_msg', '', 'post', 'none', 2)));
     $g_join_policy = Request::getInt('join_policy', 0, 'post');
     $tags = trim(Request::getVar('tags', ''));
     $lid = Request::getInt('lid', 0, 'post');
     $customization = Request::getVar('group', '', 'POST', 'none', 2);
     $plugins = Request::getVar('group_plugin', '', 'POST');
     $params = Request::getVar('params', array(), 'POST');
     $g_discussion_email_autosubscribe = Request::getInt('discussion_email_autosubscribe', 0, 'post');
     //Check authorization
     if ($this->_authorize() != 'manager' && $g_gidNumber != 0 && !$this->_authorizedForTask('group.edit')) {
         $this->_errorHandler(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'));
     }
     //are we editing or creating
     if ($g_gidNumber) {
         $group = Group::getInstance($g_gidNumber);
         $this->_task = 'edit';
         $before = Group::getInstance($g_gidNumber);
     } else {
         $this->_task = 'new';
         $group = new Group();
         $before = new Group();
     }
     // Check for any missing info
     if (!$g_cn) {
         $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_DETAILS_FIELD_CN'), 'error');
     }
     if (!$g_description) {
         $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_DETAILS_FIELD_DESCRIPTION'), 'error');
     }
     // Ensure the data passed is valid
     if ($g_cn == 'new' || $g_cn == 'browse') {
         $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_INVALID_ID'), 'error');
     }
     if (!$this->_validCn($g_cn)) {
         $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_INVALID_ID'), 'error');
     }
     if ($this->_task == 'new' && Group::exists($g_cn, true)) {
         $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_ID_TAKEN'), 'error');
     }
     // Get the logo
     $logo = '';
     if (isset($customization['logo'])) {
         $logo_parts = explode("/", $customization['logo']);
         $logo = array_pop($logo_parts);
     }
     // Plugin settings
     $plugin_access = '';
     foreach ($plugins as $plugin) {
         $plugin_access .= $plugin['name'] . '=' . $plugin['access'] . ',' . "\n";
     }
     // Run content through validation and spam filters
     if (trim($g_public_desc)) {
         $results = Event::trigger('content.onContentBeforeSave', array('com_groups.group.public_desc', &$g_public_desc, $this->_task == 'new'));
         foreach ($results as $result) {
             if ($result === false) {
                 $this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_FAILED_VALIDATION'), 'error');
                 break;
             }
         }
     }
     // Push back into edit mode if any errors
     if ($this->getNotifications()) {
         $group->set('cn', $g_cn);
         $group->set('description', $g_description);
         $group->set('public_desc', $g_public_desc);
         $group->set('private_desc', $g_private_desc);
         $group->set('join_policy', $g_join_policy);
         $group->set('restrict_msg', $g_restrict_msg);
         $group->set('discoverability', $g_discoverability);
         $group->set('discussion_email_autosubscribe', $g_discussion_email_autosubscribe);
         $group->set('logo', $logo);
         $group->set('plugins', $plugin_access);
         $this->lid = $lid;
         $this->group = $group;
         $this->tags = $tags;
         $this->editTask();
         return;
     }
     // Build the e-mail message
     if ($this->_task == 'new') {
         $subject = Lang::txt('COM_GROUPS_SAVE_EMAIL_REQUESTED_SUBJECT', $g_cn);
         $type = 'groups_created';
     } else {
         $subject = Lang::txt('COM_GROUPS_SAVE_EMAIL_UPDATED_SUBJECT', $g_cn);
         $type = 'groups_changed';
     }
     if ($this->_task == 'new') {
         $group->set('cn', $g_cn);
         $group->set('type', 1);
         $group->set('published', 1);
         $group->set('approved', $this->config->get('auto_approve', 1));
         $group->set('created', Date::toSql());
         $group->set('created_by', User::get('id'));
         $group->add('managers', array(User::get('id')));
         $group->add('members', array(User::get('id')));
         $group->create();
     }
     // merge incoming settings with existing params
     $params = new Registry($params);
     $gParams = new Registry($group->get('params'));
     $gParams->merge($params);
     //set group vars & Save group
     $group->set('description', $g_description);
     $group->set('public_desc', $g_public_desc);
     $group->set('private_desc', $g_private_desc);
     $group->set('join_policy', $g_join_policy);
     $group->set('restrict_msg', $g_restrict_msg);
     $group->set('discoverability', $g_discoverability);
     $group->set('logo', $logo);
     $group->set('plugins', $plugin_access);
     $group->set('discussion_email_autosubscribe', $g_discussion_email_autosubscribe);
     $group->set('params', $gParams->toString());
     $group->update();
     // Process tags
     $gt = new Tags($group->get('gidNumber'));
     $gt->setTags($tags, User::get('id'));
     // Rename the temporary upload directory if it exist
     $log_comments = '';
     Event::trigger('groups.onGroupAfterSave', array($before, $group));
     if ($this->_task == 'new') {
         if ($lid != $group->get('gidNumber')) {
             $config = $this->config;
             $bp = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/groups'), DS);
             if (is_dir($bp . DS . $lid)) {
                 rename($bp . DS . $lid, $bp . DS . $group->get('gidNumber'));
             }
         }
         $log_action = 'group_created';
         // Trigger the functions that delete associated content
         // Should return logs of what was deleted
         $logs = Event::trigger('groups.onGroupNew', array($group));
         if (count($logs) > 0) {
             $log_comments .= implode('', $logs);
         }
     } else {
         $log_action = 'group_edited';
     }
     // log invites
     Log::log(array('gidNumber' => $group->get('gidNumber'), 'action' => $log_action, 'comments' => $log_comments));
     // Build the e-mail message
     // Note: this is done *before* pushing the changes to the group so we can show, in the message, what was changed
     $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'saved'));
     $eview->option = $this->_option;
     $eview->user = User::getRoot();
     $eview->group = $group;
     $message['plaintext'] = $eview->loadTemplate();
     $message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']);
     $eview->setLayout('saved');
     $message['multipart'] = $eview->loadTemplate();
     $message['multipart'] = str_replace("\n", "\r\n", $message['multipart']);
     // Get the administrator e-mail
     $emailadmin = Config::get('mailfrom');
     // Get the "from" info
     $from = array('name' => Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_name)), 'email' => Config::get('mailfrom'));
     //only email managers if updating group
     if ($type == 'groups_changed') {
         // build array of managers
         $managers = $group->get('managers');
         // create new message
         Plugin::import('xmessage');
         if (!Event::trigger('onSendMessage', array($type, $subject, $message, $from, $managers, $this->_option))) {
             $this->setNotification(Lang::txt('GROUPS_ERROR_EMAIL_MANAGERS_FAILED'), 'error');
         }
     }
     //only inform site admin if the group wasn't auto-approved
     if (!$this->config->get('auto_approve', 1) && $group->get('approved') == 0) {
         // create approval subject
         $subject = Lang::txt('COM_GROUPS_SAVE_WAITING_APPROVAL', Config::get('sitename'));
         // build approval message
         $link = 'https://' . trim($_SERVER['HTTP_HOST'], DS) . DS . 'groups' . DS . $group->get('cn');
         $link2 = 'https://' . trim($_SERVER['HTTP_HOST'], DS) . DS . 'administrator';
         $html = Lang::txt('COM_GROUPS_SAVE_WAITING_APPROVAL_DESC', $group->get('description'), $link, $link2);
         $plain = Lang::txt('COM_GROUPS_SAVE_WAITING_APPROVAL_DESC', $group->get('description'), $link, $link2);
         // create new message
         $message = new \Hubzero\Mail\Message();
         // build message object and send
         $message->setSubject($subject)->addFrom($from['email'], $from['name'])->setTo($emailadmin)->addHeader('X-Mailer', 'PHP/' . phpversion())->addHeader('X-Component', 'com_groups')->addHeader('X-Component-Object', 'group_pending_approval')->addHeader('X-Component-ObjectId', $group->get('gidNumber'))->addPart($plain, 'text/plain')->addPart($html, 'text/html')->send();
     }
     // create home page
     if ($this->_task == 'new') {
         // create page
         $page = new Page(array('gidNumber' => $group->get('gidNumber'), 'parent' => 0, 'lft' => 1, 'rgt' => 2, 'depth' => 0, 'alias' => 'overview', 'title' => 'Overview', 'state' => 1, 'privacy' => 'default', 'home' => 1));
         $page->store(false);
         // create page version
         $version = new Page\Version(array('pageid' => $page->get('id'), 'version' => 1, 'content' => "<!-- {FORMAT:HTML} -->\n<p>[[Group.DefaultHomePage()]]</p>", 'created' => Date::toSql(), 'created_by' => User::get('id'), 'approved' => 1));
         $version->store(false);
     }
     // Show success message to user
     if ($this->_task == 'new') {
         $this->setNotification(Lang::txt('COM_GROUPS_CREATED_SUCCESS', $group->get('description')), 'passed');
     } else {
         $this->setNotification(Lang::txt('COM_GROUPS_UPDATED_SUCCESS', $group->get('description')), 'passed');
     }
     // Redirect back to the group page
     App::redirect(Route::url('index.php?option=' . $this->_option . '&cn=' . $group->get('cn')));
     return;
 }
Пример #8
0
 /**
  * Settings for group citations
  *
  * @param null
  * @return void
  *
  *
  */
 private function _settings()
 {
     if ($_POST) {
         $display = Request::getVar('display', '');
         $format = Request::getVar('citation-format', '');
         $params = json_decode($this->group->get('params'));
         if (!is_object($params)) {
             $params = new stdClass();
         }
         // craft a clever name
         $name = "custom-group-" . $this->group->cn;
         // fetch or create new format
         $citationFormat = \Components\Citations\Models\Format::oneOrNew($format);
         // if the setting a custom group citation type
         if ($citationFormat->isNew() || $citationFormat->style == $name && !$citationFormat->isNew()) {
             $citationFormat->set(array('format' => Request::getVar('template'), 'style' => $name));
             // save format
             $citationFormat->save();
             // update group
             $params->citationFormat = $citationFormat->id;
         } else {
             // returned value from format select box
             $params->citationFormat = $format;
         }
         // more parameters for citations
         $params->display = Request::getVar('display', '');
         $params->include_coins = Request::getVar('include_coins', '');
         $params->coins_only = Request::getVar('coins_only', '');
         $params->citations_show_tags = Request::getVar('citations_show_tags', '');
         $params->citations_show_badges = Request::getVar('citations_show_badges', '');
         // update the group parameters
         $gParams = new Registry($params);
         $gParams->merge($params);
         $this->group->set('params', $gParams->toString());
         $this->group->update();
         // redirect after save
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_SETTINGS_SAVED'), 'success');
         return;
     } else {
         // instansiate the view
         $view = $this->view('default', 'settings');
         // pass the group through
         $view->group = $this->group;
         // get group settings
         $params = json_decode($this->group->get('params'));
         $view->include_coins = isset($params->include_coins) ? $params->include_coins : "false";
         $view->coins_only = isset($params->coins_only) ? $params->coins_only : "false";
         $view->citations_show_tags = isset($params->citations_show_tags) ? $params->citations_show_tags : "true";
         $view->citations_show_badges = isset($params->citations_show_badges) ? $params->citations_show_badges : "true";
         $citationsFormat = isset($params->citationFormat) ? $params->citationFormat : 1;
         // intended for the case that the group's custom
         // format is removed from the jos_citations_format
         try {
             $view->currentFormat = \Components\Citations\Models\Format::oneOrFail($citationsFormat);
         } catch (\Exception $e) {
             $view->currentFormat = \Components\Citations\Models\Format::all()->where('style', 'like', 'ieee');
         }
         // get the name of the current format (see if it's custom)
         // the name of the custom format
         $name = "custom-group-" . $this->group->cn;
         $custom = \Components\Citations\Models\Format::all()->where('style', 'LIKE', $name)->count();
         if ($custom > 0) {
             // show the menu entry for the custom
             $view->customFormat = true;
         } else {
             // show menu item for new custom format
             $view->customFormat = false;
         }
         // get formats
         $view->formats = \Components\Citations\Models\Format::all()->where('style', 'NOT LIKE', '%custom-group-%')->where('style', 'NOT LIKE', '%custom-member-%')->orWhere('style', '=', $name)->rows()->toObject();
         $view->templateKeys = \Components\Citations\Models\Format::all()->getTemplateKeys();
         // Output HTML
         foreach ($this->getErrors() as $error) {
             $view->setError($error);
         }
         return $view->loadTemplate();
     }
 }