Exemple #1
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/fabrik.php';
     $canDo = FabrikHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_GROUPS'), 'groups.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNew('group.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('group.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.edit.state')) {
         if ($this->state->get('filter.state') != 2) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('groups.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('groups.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         }
     }
     if (JFactory::getUser()->authorise('core.manage', 'com_checkin')) {
         JToolBarHelper::custom('groups.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'groups.delete', 'JTOOLBAR_EMPTY_TRASH');
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('groups.trash', 'JTOOLBAR_TRASH');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_fabrik');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_COMPONENTS_FABRIK_GROUPS', false, JText::_('JHELP_COMPONENTS_FABRIK_GROUPS'));
 }
Exemple #2
0
 /**
  * Method to display a view.
  */
 public function display()
 {
     $this->default_view = 'home';
     require_once JPATH_COMPONENT . '/helpers/fabrik.php';
     parent::display();
     // Load the submenu.
     FabrikHelper::addSubmenu(JRequest::getWord('view', 'lists'));
 }
Exemple #3
0
 /**
  * show the form in the admin
  */
 function view()
 {
     $document =& JFactory::getDocument();
     $model = JModel::getInstance('Form', 'FabrikFEModel');
     JRequest::setVar('view', 'details');
     $viewType = $document->getType();
     $this->setPath('view', COM_FABRIK_FRONTEND . DS . 'views');
     $viewLayout = JRequest::getCmd('layout', 'default');
     $view =& $this->getView('form', $viewType, '');
     $view->setModel($model, true);
     // Set the layout
     $view->setLayout($viewLayout);
     //todo check for cached version
     JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_FORMS'), 'forms.png');
     $view->display();
     FabrikHelper::addSubmenu(JRequest::getWord('view', 'lists'));
 }
Exemple #4
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     $canDo = FabrikHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title($isNew ? JText::_('COM_FABRIK_MANAGER_PACKAGE_NEW') : JText::_('COM_FABRIK_MANAGER_PACKAGE_EDIT'), 'package.png');
     if ($isNew) {
         // For new records, check the create permission.
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('package.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('package.save', 'JTOOLBAR_SAVE');
             JToolBarHelper::addNew('package.save2new', 'JTOOLBAR_SAVE_AND_NEW');
         }
         JToolBarHelper::cancel('package.cancel', 'JTOOLBAR_CANCEL');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('package.apply', 'JTOOLBAR_APPLY');
                 JToolBarHelper::save('package.save', 'JTOOLBAR_SAVE');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::addNew('package.save2new', 'JTOOLBAR_SAVE_AND_NEW');
                 }
             }
         }
         if ($canDo->get('core.create')) {
             JToolBarHelper::custom('package.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
         }
         JToolBarHelper::cancel('package.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_COMPONENTS_FABRIK_PACKAGE_EDIT', false, JText::_('JHELP_COMPONENTS_FABRIK_PACKAGE_EDIT'));
 }
Exemple #5
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/fabrik.php';
     $canDo = FabrikHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_LISTS'), 'lists.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNew('list.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('list.edit', 'JTOOLBAR_EDIT');
     }
     JToolBarHelper::custom('list.copy', 'copy.png', 'copy_f2.png', 'COM_FABRIK_COPY');
     if ($canDo->get('core.edit.state')) {
         if ($this->state->get('filter.state') != 2) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('lists.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('lists.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         }
     }
     JToolBarHelper::divider();
     if ($canDo->get('core.create')) {
         JToolBarHelper::custom('import.display', 'upload.png', 'upload_f2.png', 'COM_FABRIK_IMPORT', false);
     }
     JToolBarHelper::divider();
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'lists.delete', 'JTOOLBAR_EMPTY_TRASH');
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('lists.trash', 'JTOOLBAR_TRASH');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_fabrik');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_COMPONENTS_FABRIK_LISTS');
 }
Exemple #6
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     $canDo = FabrikHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title($isNew ? JText::_('COM_FABRIK_MANAGER_FORM_NEW') : JText::_('COM_FABRIK_MANAGER_FORM_EDIT'), 'form.png');
     if ($isNew) {
         // For new records, check the create permission.
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('form.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('form.save', 'JTOOLBAR_SAVE');
             JToolBarHelper::addNew('form.save2new', 'JTOOLBAR_SAVE_AND_NEW');
         }
         JToolBarHelper::cancel('form.cancel', 'JTOOLBAR_CANCEL');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('form.apply', 'JTOOLBAR_APPLY');
                 JToolBarHelper::save('form.save', 'JTOOLBAR_SAVE');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::addNew('form.save2new', 'JTOOLBAR_SAVE_AND_NEW');
                 }
             }
         }
         // $$$ rob no save as copy as this gets complicated due to renaming lists, groups etc. Users should copy from list view.
         JToolBarHelper::cancel('form.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_COMPONENTS_FABRIK_FORMS_EDIT', false, JText::_('JHELP_COMPONENTS_FABRIK_FORMS_EDIT'));
 }
Exemple #7
0
	/**
	 * show the lists data in the admin
	 */

	public function view()
	{
		$cid = JRequest::getVar('cid', array(0), 'method', 'array');
		if(is_array($cid)){$cid = $cid[0];}
		$cid = JRequest::getInt('listid', $cid);
		// grab the model and set its id
		$model = JModel::getInstance('List', 'FabrikFEModel');
		$model->setState('list.id', $cid);
		$viewType	= JFactory::getDocument()->getType();
		//use the front end renderer to show the table
		$this->setPath('view', COM_FABRIK_FRONTEND.DS.'views');

		$viewLayout	= JRequest::getCmd('layout', 'default');
		$view = & $this->getView($this->view_item, $viewType, '');
		$view->setModel($model, true);
		// Set the layout
		$view->setLayout($viewLayout);
		JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_LISTS'), 'lists.png');
		$view->display();
		FabrikHelper::addSubmenu(JRequest::getWord('view', 'lists'));
	}
Exemple #8
0
 /**
  * save the form
  * @param array $data (the jform part of the request data)
  */
 function save($data)
 {
     $this->populateState();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $config = JFactory::getConfig();
     $date = JFactory::getDate();
     $row = $this->getTable();
     $id = $data['id'];
     $row->load($id);
     $this->setState('list.id', $id);
     $this->setState('list.form_id', $row->form_id);
     $feModel = $this->getFEModel();
     $formModel = $this->getFormModel();
     if (!$row->bind($data)) {
         $this->setError($row->getError());
         return false;
     }
     $filter = new JFilterInput(null, null, 1, 1);
     $introduction = JRequest::getVar('introduction', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $row->introduction = $filter->clean($introduction);
     $row->order_by = json_encode(JRequest::getVar('order_by', array(), 'post', 'array'));
     $row->order_dir = json_encode(JRequest::getVar('order_dir', array(), 'post', 'array'));
     if (!$row->check()) {
         $this->setError($row->getError());
         return false;
     }
     $isNew = true;
     if ($id == 0) {
         if ($row->created == '') {
             $row->created = $date->toMySQL();
         }
         //save the row now
         $row->store();
         $isNew = false;
         $newtable = trim(JArrayHelper::getValue($data, '_database_name'));
         // $$$ hugh - added some more sanity checking on table name, get rid of non-alphanumeric and _
         // @TODO - should prolly use a helper for this, like FabrikString::clean()
         // but need to think about case issues first
         $newtable = preg_replace('#[^0-9a-zA-Z_]#', '_', $newtable);
         //check the entered database table doesnt already exist
         if ($newtable != '' && $this->getFEModel()->databaseTableExists($newtable)) {
             $this->setError(JText::_('COM_FABRIK_DATABASE_TABLE_ALREADY_EXISTS'));
             return false;
         }
         if (!$this->canCreateDbTable()) {
             $this->setError(Jtext::_('COM_FABRIK_INSUFFICIENT_RIGHTS_TO_CREATE_TABLE'));
             return false;
         }
         //create fabrik form
         $formModel =& $this->createLinkedForm();
         $row->form_id = $this->getState('list.form_id');
         //create fabrik group
         $groupData = array("name" => $row->label, "label" => $row->label);
         JRequest::setVar('_createGroup', 1, 'post');
         $groupId = $this->createLinkedGroup($groupData, false);
         if ($newtable == '') {
             //new fabrik table but existing db table
             $this->createLinkedElements($groupId);
         } else {
             $row->db_table_name = $newtable;
             $row->db_primary_key = $newtable . '.id';
             $row->auto_inc = 1;
             $res = $feModel->createDBTable($formModel, $newtable);
         }
     }
     // 	save params - this file no longer exists? do we use models/table.xml instead??
     $params = new fabrikParams($row->params, JPATH_COMPONENT . DS . 'xml' . DS . 'table.xml');
     if ($row->id != 0) {
         $datenow = JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     FabrikHelper::prepareSaveDate($row->publish_down);
     FabrikHelper::prepareSaveDate($row->created);
     FabrikHelper::prepareSaveDate($row->publish_up);
     $pk = JArrayHelper::getValue($data, 'db_primary_key');
     if ($pk == '') {
         $fields = $row->getFields();
         $key = $row->getKeyName();
         //store without namequotes as thats db specific
         $row->db_primary_key = $row->db_table_name . "." . $key;
         $row->auto_inc = stristr($fields[$key]->Extra, 'auto_increment') ? true : false;
     }
     if (!$row->store()) {
         $this->setError($row->getError());
         return false;
     }
     $pk = $row->db_primary_key;
     $this->updateJoins($data);
     $feModel->setTable($row);
     //needed to ensure pk field is not quoted
     if (!$feModel->isView()) {
         // this was only run on a new table - but I've put it here so that if you upload a new table you can ensure that its columns are fixed
         //$this->makeSafeTableColumns();
         $this->updatePrimaryKey($row->db_primary_key, $row->auto_inc);
     }
     //make an array of elments and a presumed index size
     //map is then used in creating indexes
     $map = array();
     $groups =& $this->getFormModel()->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels =& $groupModel->getMyElements();
         foreach ($elementModels as $element) {
             //int elements cant have a index size attrib
             // $$$ hugh neither can DATETIME
             $coltype = $element->getFieldDescription();
             if (JString::stristr($coltype, 'int')) {
                 $size = '';
             } else {
                 if (JString::stristr($coltype, 'datetime')) {
                     $size = '';
                 } else {
                     $size = '10';
                 }
             }
             $map[$element->getFullName(false, false, false)] = $size;
             $map[$element->getElement()->id] = $size;
         }
     }
     //update indexes (added array_key_exists check as these may be during after CSV import)
     if (!empty($aOrderBy) && array_key_exists($row->order_by, $map)) {
         foreach ($aOrderBy as $orderBy) {
             if (array_key_exists($orderBy, $map)) {
                 $feModel->addIndex($orderBy, 'tableorder', 'INDEX', $map[$orderBy]);
             }
         }
     }
     if ($row->group_by !== '' && array_key_exists($row->group_by, $map)) {
         $feModel->addIndex($row->group_by, 'groupby', 'INDEX', $map["{$row->group_by}"]);
     }
     if ($params->get('group_by_order') !== '') {
         $feModel->addIndex($params->get('group_by_order'), 'groupbyorder', 'INDEX', $map[$params->get('group_by_order')]);
     }
     $afilterFields = $params->get('filter-fields', '', '_default', 'array');
     foreach ($afilterFields as $field) {
         if (array_key_exists($field, $map)) {
             $feModel->addIndex($field, 'prefilter', 'INDEX', $map[$field]);
         }
     }
     if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomfish' . DS . 'contentelements')) {
         if ($params->get('allow-data-translation')) {
             if (!$this->makeJoomfishXML()) {
                 $this->setError(JTEXT::_("Unable to make Joomfish XML file"));
                 return false;
             }
         } else {
             $this->removeJoomfishXML();
         }
     }
     $pkName = $row->getKeyName();
     if (isset($row->{$pkName})) {
         $this->setState($this->getName() . '.id', $row->{$pkName});
     }
     $this->setState($this->getName() . '.new', $isNew);
     return true;
 }
Exemple #9
0
 /**
  * Save a visualization
  */
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $task = JRequest::getCmd('task');
     $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
     $className = JRequest::getVar('plugin', 'calendar', 'post');
     $pluginModel =& $pluginManager->getPlugIn($className, 'visualization');
     $id = JRequest::getInt('id', 0, 'post');
     $pluginModel->setId($id);
     $row =& JTable::getInstance('visualization', 'Table');
     $post = JRequest::get('post');
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     //$filter	= new JFilterInput(null, null, 1, 1);
     list($dofilter, $filter) = FabrikWorker::getContentFilter();
     $intro_text = JRequest::getVar('intro_text', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $row->intro_text = $dofilter ? $filter->clean($intro_text) : $intro_text;
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $row->bind($details);
     // 	save params
     $pluginModel->attribs =& $row->attribs;
     $params = $pluginModel->getParams();
     $row->attribs = $params->updateAttribsFromParams(JRequest::getVar('params', array(), 'post', 'array'));
     FabrikHelper::prepareSaveDate($row->publish_down);
     FabrikHelper::prepareSaveDate($row->created);
     FabrikHelper::prepareSaveDate($row->publish_up);
     $user =& JFactory::getUser();
     if ($row->id != 0) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     if (!$row->store()) {
         return JError::raiseWarning(500, $row->getError());
     }
     $row->checkin();
     switch ($task) {
         case 'apply':
             $link = 'index.php?option=com_fabrik&c=visualization&task=edit&cid[]=' . $row->id;
             $msg = JText::_('VISUALIZATION SAVED');
             break;
         case 'save':
         default:
             $link = 'index.php?option=com_fabrik&c=visualization';
             $msg = JText::_('VISUALIZATION SAVED');
             break;
     }
     $this->setRedirect($link, $msg);
 }
Exemple #10
0
 /**
  * Save a connection
  */
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     // clear form from session
     $session =& JFactory::getSession();
     $session->clear('com_fabrik.admin.form.edit.model');
     jimport('joomla.utilities.date');
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $formModel =& JModel::getInstance('Form', 'FabrikModel');
     $formModel->setId(JRequest::getInt('id'));
     $formModel->getForm();
     $row =& JTable::getInstance('form', 'Table');
     $post = JRequest::get('post');
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     list($dofilter, $filter) = FabrikWorker::getContentFilter();
     //$filter	= new JFilterInput(null, null, 1, 1);
     $intro = JRequest::getVar('intro', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $row->intro = $dofilter ? $filter->clean($intro) : $intro;
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $row->bind($details);
     FabrikHelper::prepareSaveDate($row->publish_down);
     FabrikHelper::prepareSaveDate($row->created);
     FabrikHelper::prepareSaveDate($row->publish_up);
     // save params
     $params = new fabrikParams($row->attribs, JPATH_COMPONENT . DS . 'model' . DS . 'form.xml');
     $row->attribs = $params->updateAttribsFromParams(JRequest::getVar('params', array(), 'post', 'array'));
     if ($row->id != 0) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     if (!$row->store()) {
         return JError::raiseWarning(500, $row->getError());
     }
     $row->checkin();
     $formModel->_id = $row->id;
     $formModel->_form =& $row;
     $formModel->saveFormGroups();
     $task = JRequest::getCmd('task');
     switch ($task) {
         case 'apply':
             $link = 'index.php?option=com_fabrik&c=form&task=edit&cid[]=' . $row->id;
             break;
         case 'save':
         default:
             $link = 'index.php?option=com_fabrik&c=form';
             break;
     }
     $cache =& JFactory::getCache('com_fabrik');
     $cache->clean();
     $this->setRedirect($link, JText::_('FORM SAVED'));
     //for prefab
     return $formModel;
 }
Exemple #11
0
 /**
  * save the table from admin
  *
  * @return Jerror if not saved true if saved ok
  */
 function save()
 {
     $session =& JFactory::getSession();
     $app =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $config =& JFactory::getConfig();
     $id = JRequest::getInt('id', 0, 'post');
     $this->setId($id);
     $row =& $this->getTable(false, false);
     $formModel =& JModel::getInstance('Form', 'FabrikModel');
     $post = JRequest::get('post');
     if (!$row->bind($post)) {
         return JError::raiseWarning(500, $row->getError());
     }
     list($dofilter, $filter) = FabrikWorker::getContentFilter();
     $introduction = JRequest::getVar('introduction', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $row->introduction = $dofilter ? $filter->clean($introduction) : $introduction;
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $row->bind($details);
     $aOrderBy = JRequest::getVar('order_by', array(), 'post', 'array');
     $row->order_by = implode(GROUPSPLITTER2, $aOrderBy);
     $aOrderDir = JRequest::getVar('order_dir', array(), 'post', 'array');
     $row->order_dir = implode(GROUPSPLITTER2, $aOrderDir);
     if (!$row->check()) {
         $app->setError($row->getError());
         return JError::raiseWarning(500, $row->getError());
     }
     if ($id == 0) {
         $newtable = trim(JRequest::getVar('_database_name', '', 'post'));
         // $$$ hugh - added some more sanity checking on table name, get rid of non-alphanumeric and _
         // @TODO - should prolly use a helper for this, like FabrikString::clean()
         // but need to think about case issues first
         $newtable = preg_replace('#[^0-9a-zA-Z_]#', '_', $newtable);
         //check the entered database table doesnt already exist
         if ($newtable != '' && $this->databaseTableExists($newtable)) {
             return JError::raiseWarning(500, JText::_('DATABASE TABLE ALREADY EXISTS'));
         }
         if (!$this->canCreateDbTable()) {
             return JError::raiseWarning(500, Jtext::_('YOUR_DB_USER_HAS_INSUFFICIENT_RIGHTS_TO_CREATE_TABLE'));
         }
         //create fabrik form
         $formModel =& $this->_createLinkedForm();
         //create fabrik group
         $groupData = array("name" => $row->label, "label" => $row->label);
         JRequest::setVar('_createGroup', 1, 'post');
         if ($newtable != '') {
             $groupId = $this->_createLinkedGroup($groupData, false);
             $row->db_table_name = $newtable;
             $row->db_primary_key = "`" . $newtable . '`.`id`';
             $row->auto_inc = 1;
             $res = $this->createDBTable($formModel, $newtable);
         } else {
             // 2.0.5 balsamiq to fabrik tmpl generator sets up group properties in session, if we find those lets make
             // n groups each with their own groupid
             $groupDatas = array($groupData);
             if ($session->has('com_fabrik.list.create.groupmap')) {
                 $groupDatas =& $session->get('com_fabrik.list.create.groupmap');
             }
             $groupMap = array();
             foreach ($groupDatas as $x => $groupData) {
                 $groupId = $this->_createLinkedGroup($groupData, false);
                 $groupMap[$x] = $groupId;
             }
             //set element group ids
             if ($session->has('com_fabrik.list.create.elementmap')) {
                 $map = (array) $session->get('com_fabrik.list.create.elementmap');
                 foreach ($map as &$m) {
                     $groupMapId = array_key_exists('groupid', $m) ? $m['groupid'] : 0;
                     $m['groupid'] = $groupMap[$groupMapId];
                 }
                 $session->set('com_fabrik.list.create.elementmap', $map);
             }
             // save elements in group
             foreach ($groupMap as $groupId) {
                 $this->_createLinkedElements($groupId, $post);
             }
         }
         //	set the tables form id
         $this->_updateFormId($formModel->_form->id);
     }
     // 	save params - this file no longer exists? do we use models/table.xml instead??
     $params = new fabrikParams($row->attribs, JPATH_COMPONENT . DS . 'xml' . DS . 'table.xml');
     $row->attribs = $params->updateAttribsFromParams(JRequest::getVar('params', array(), 'post', 'array'));
     $row->rows_per_page = JRequest::getInt('rows_per_page', 10, 'post');
     if ($row->id != 0) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     FabrikHelper::prepareSaveDate($row->publish_down);
     FabrikHelper::prepareSaveDate($row->created);
     FabrikHelper::prepareSaveDate($row->publish_up);
     $pk = JRequest::getVar('db_primary_key');
     if ($pk == '') {
         $aKey = $this->getPrimaryKeyAndExtra();
         $aKey = $aKey[0];
         $row->db_primary_key = "`" . $row->db_table_name . "`.`" . $aKey['colname'] . "`";
         $row->auto_inc = stristr($aKey['extra'], 'auto_increment') ? true : false;
     }
     if (!$row->store()) {
         return JError::raiseWarning(500, $row->getError());
     }
     // load in all the tables data - even if it wasnt in the post data
     $table =& $this->getTable();
     //needed if saving a table for first time (otherwise id = 0)
     $this->setId($table->id);
     $this->updateJoins();
     if (!$this->isView()) {
         // this was only run on a new table - but I've put it here so that if you upload a new table you can ensure that its columns are fixed
         $this->makeSafeTableColumns();
         $this->updatePrimaryKey($row->db_primary_key, $row->auto_inc);
     }
     $row->checkin();
     //make an array of elments and a presumed index size
     //map is then used in creating indexes
     $map = array();
     $groups =& $this->getForm()->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels =& $groupModel->getMyElements();
         foreach ($elementModels as $element) {
             //int elements cant have a index size attrib
             // $$$ hugh neither can DATETIME
             $coltype = $element->getFieldDescription();
             if (JString::stristr($coltype, 'int')) {
                 $size = '';
             } else {
                 if (JString::stristr($coltype, 'datetime')) {
                     $size = '';
                 } else {
                     $size = 10;
                     // $$$ hugh - adding index will barf if key size > varchar size.
                     $matches = array();
                     if (preg_match('/varchar\\((\\d+)\\)/i', $coltype, $matches)) {
                         $varchar_size = (int) $matches[1];
                         if ($varchar_size < 10) {
                             $size = $varchar_size;
                         }
                     }
                 }
             }
             $map[$element->getFullName(false, false, false)] = $size;
             $map[$element->getElement()->id] = $size;
         }
     }
     //update indexes (added array_key_exists check as these may be during after CSV import)
     if (!empty($aOrderBy) && array_key_exists($row->order_by, $map)) {
         foreach ($aOrderBy as $orderBy) {
             if (array_key_exists($orderBy, $map)) {
                 $this->addIndex($orderBy, 'tableorder', 'INDEX', $map[$orderBy]);
             }
         }
     }
     if ($row->group_by !== '' && array_key_exists($row->group_by, $map)) {
         $this->addIndex($row->group_by, 'groupby', 'INDEX', $map["{$row->group_by}"]);
     }
     if ($params->get('group_by_order') !== '') {
         $this->addIndex($params->get('group_by_order'), 'groupbyorder', 'INDEX', $map[$params->get('group_by_order')]);
     }
     $afilterFields = $params->get('filter-fields', '', '_default', 'array');
     foreach ($afilterFields as $field) {
         $field = str_replace('`', '', $field);
         $this->addIndex($field, 'prefilter', 'INDEX', $map[$field]);
     }
     if (JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomfish' . DS . 'contentelements')) {
         if ($params->get('allow-data-translation')) {
             if (!$this->makeJoomfishXML()) {
                 JError::raiseNotice('E_ERROR', JTEXT::_("Unable to make Joomfish XML file"));
             }
         } else {
             $this->removeJoomfishXML();
         }
     }
     return true;
 }