registerTask( 'add' , 'edit' ); $this->registerTask( 'accesspublic', 'accessMenu'); $this->registerTask( 'accessregistered', 'accessMenu'); $this->registerTask( 'accessspecial', 'accessMenu'); $this->registerTask( 'exportxml', 'exportXML'); $this->registerTask( 'importxml', 'importXML'); } /** * display the edit form * @return void */ function edit() { $thismodel = $this->getModel( 'sqlexcelsettings' ); $thismodel->checkout(); JRequest::setVar( 'view', 'sqlexcelsettings' ); JRequest::setVar( 'layout', 'form' ); JRequest::setVar('hidemainmenu', 1); parent::display(); } /** * Apply changes to the record * @return void */ function apply() { $this->save(); $msg = JText::_( 'Settings Saved' ); $this->setRedirect( 'index.php?option=com_sql2excel&view=sqlexcelsettings', $msg ); } /** * Save a record * @return void */ function save() { $post = JRequest::get('post'); $post['sqlhelplinks'] = JRequest::getVar( 'sqlhelplinks', '', 'post', 'string', JREQUEST_ALLOWRAW ); $post['badwords'] = JRequest::getVar( 'badwords', '', 'post', 'string', JREQUEST_ALLOWRAW ); //$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); //$post['id'] = (int) $cid[0]; // 0 for new, or actual ID when editing $model = $this->getModel( 'sqlexcelsettings' ); $res = $model->store($post); if ( $res ) { $msg = JText::_( 'Settings Saved' ); } else { $msg = JText::_( 'ERROR! Failed to save the settings!' ); } $this->setRedirect( 'index.php?option=com_sql2excel&view=sql2excel', $msg ); } /** * remove record(s) * @return void */ function remove() { $model = $this->getModel('sqlexcelworkbook'); if(!$model->delete()) { $msg = JText::_( 'Error: One or More Categories Could not be Deleted' ); } else { $msg = JText::_( 'Workbook(s) Deleted' ); } $this->setRedirect( 'index.php?option=com_sql2excel&view=sqlexcelworkbooks', $msg ); } function accessMenu() { $post = JRequest::get('post'); $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); $access = $post['task']; switch ($access) { case 'accessregistered': $access_id= 1; break; case 'accessspecial': $access_id= 2; break; case 'accesspublic': default: $access_id= 0; break; } $model = $this->getModel( 'sqlexcelworkbook' ); $model->accessmenu($cid[0],$access_id); $model->checkin(); $link = 'index.php?option=com_sql2excel&view=sqlexcelworkbooks'; $this->setRedirect($link); } /** * cancel editing a record * @return void */ function cancel() { $msg = JText::_( 'Operation Cancelled' ); $this->setRedirect( 'index.php?option=com_sql2excel&view=sql2excel', $msg ); } /** * Export Settings to XML file * @return void */ function exportXML() { $model = $this->getModel('sqlexcelsettings'); if($model->exportXML() ) { // XML file feed to the browser by the model exit; } else { echo "\n"; $link = 'index.php?option=com_sql2excel&view=sqlexcelsettings'; $this->setRedirect( $link, 'EXPORT XML FAILED' ); } } /** * Import Settings from XML file * @return void */ function importXML() { $link = 'index.php?option=com_sql2excel&view=sqlexcelimportsettings'; $this->setRedirect( $link ); } }