load($cid); return $row; } function save() { $mainframe = JFactory::getApplication(); $row = JTable::getInstance('K2UserGroup', 'Table'); if (!$row->bind(JRequest::get('post'))) { $mainframe->redirect('index.php?option=com_k2&view=usergroups', $row->getError(), 'error'); } if (!$row->check()) { $mainframe->redirect('index.php?option=com_k2&view=usergroup&cid='.$row->id, $row->getError(), 'error'); } if (!$row->store()) { $mainframe->redirect('index.php?option=com_k2&view=usergroups', $row->getError(), 'error'); } $cache = JFactory::getCache('com_k2'); $cache->clean(); switch(JRequest::getCmd('task')) { case 'apply' : $msg = JText::_('K2_CHANGES_TO_USER_GROUP_SAVED'); $link = 'index.php?option=com_k2&view=usergroup&cid='.$row->id; break; case 'save' : default : $msg = JText::_('K2_USER_GROUP_SAVED'); $link = 'index.php?option=com_k2&view=usergroups'; break; } $mainframe->redirect($link, $msg); } }