Example #1
0
 public function saveSubmission()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $type = YRequest::getString('type');
     $template = YRequest::getString('template');
     $layout = YRequest::getString('layout');
     $positions = YRequest::getVar('positions', array(), 'post', 'array');
     unset($positions['unassigned']);
     // for template, module
     if ($template) {
         $path = $this->application->getPath() . '/templates/' . $template;
     }
     // get renderer
     $renderer = new ItemRenderer();
     $renderer->addPath($path);
     // clean config
     $config = $renderer->getConfig('item');
     foreach ($config->toArray() as $key => $value) {
         $parts = explode('.', $key);
         if ($parts[0] == $this->group && !$this->application->getType($parts[1])) {
             $config->remove($key);
         }
     }
     // save config
     $config->set($this->group . '.' . $type . '.' . $layout, $positions);
     $renderer->saveConfig($config, $path . '/renderer/item/positions.config');
     switch ($this->getTask()) {
         case 'applysubmission':
             $link = $this->baseurl . '&task=assignsubmission&type=' . $type . '&layout=' . $layout;
             $link .= $template ? '&template=' . $template : null;
             break;
         default:
             $link = $this->baseurl . '&task=types';
             break;
     }
     $this->setRedirect($link, JText::_('Submitable Elements Assigned'));
 }