/** * Helper method for fetching a single row and pass it to K2 response. * This is triggered by the edit function. * Usually there will be no need to override this function. * * @param integer $id The id of the row to edit. * * @return void */ protected function setRow($id) { $component = JComponentHelper::getComponent('com_k2'); $row = new stdClass(); $row->id = $component->id; K2Response::setRow($row); }
/** * Helper method for fetching a single row and pass it to K2 response. * This is triggered by the edit function. * Usually there will be no need to override this function. * * @param integer $id The id of the row to edit. * * @return void */ protected function setRow($id) { // Create row $row = new stdClass(); $row->importArticles = false; $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_k2')) { $row->importArticles = true; } K2Response::setRow($row); }
/** * Helper method for fetching a single row and pass it to K2 response. * This is triggered by the edit function. * Usually there will be no need to override this function. * * @param integer $id The id of the row to edit. * * @return void */ protected function setRow($id) { $row = new stdClass(); $db = JFactory::getDBO(); $row->dbVersion = $db->getVersion(); $row->phpVersion = phpversion(); $row->server = $this->getServer(); $row->gd = extension_loaded('gd'); if ($row->gd) { $gdinfo = gd_info(); $row->gdVersion = $gdinfo['GD Version']; } $row->mediaFolder = is_writable(JPATH_SITE . '/media/k2'); $row->attachmentsFolder = is_writable(JPATH_SITE . '/media/k2/attachments'); $row->categoriesFolder = is_writable(JPATH_SITE . '/media/k2/categories'); $row->galleriesFolder = is_writable(JPATH_SITE . '/media/k2/galleries'); $row->itemsFolder = is_writable(JPATH_SITE . '/media/k2/items'); $row->usersFolder = is_writable(JPATH_SITE . '/media/k2/users'); $row->mediaFolder = is_writable(JPATH_SITE . '/media/k2/media'); $row->cacheFolder = is_writable(JPATH_SITE . '/cache'); $row->maxFileUploadSize = ini_get('upload_max_filesize'); $row->memoryLimit = ini_get('memory_limit'); $row->allowURLFopen = ini_get('allow_url_fopen'); $row->mod_k2_comments = JFile::exists(JPATH_SITE . '/modules/mod_k2_comments/mod_k2_comments.php'); $row->mod_k2_content = JFile::exists(JPATH_SITE . '/modules/mod_k2_content/mod_k2_content.php'); $row->mod_k2_tools = JFile::exists(JPATH_SITE . '/modules/mod_k2_tools/mod_k2_tools.php'); $row->mod_k2_user = JFile::exists(JPATH_SITE . '/modules/mod_k2_user/mod_k2_user.php'); $row->mod_k2_users = JFile::exists(JPATH_SITE . '/modules/mod_k2_users/mod_k2_users.php'); $row->mod_k2_quickicons = JFile::exists(JPATH_ADMINISTRATOR . '/modules/mod_k2_quickicons/mod_k2_quickicons.php'); $row->mod_k2_stats = JFile::exists(JPATH_ADMINISTRATOR . '/modules/mod_k2_stats/mod_k2_stats.php'); $row->plg_finder_k2 = JFile::exists(JPATH_SITE . '/plugins/finder/k2/k2.php'); $row->plg_search_k2 = JFile::exists(JPATH_SITE . '/plugins/search/k2/k2.php'); $row->plg_system_k2 = JFile::exists(JPATH_SITE . '/plugins/system/k2/k2.php'); $row->plg_user_k2 = JFile::exists(JPATH_SITE . '/plugins/user/k2/k2.php'); $row->plg_finder_k2_enabled = JPluginHelper::isEnabled('finder', 'k2'); $row->plg_search_k2_enabled = JPluginHelper::isEnabled('search', 'k2'); $row->plg_system_k2_enabled = JPluginHelper::isEnabled('system', 'k2'); $row->plg_user_k2_enabled = JPluginHelper::isEnabled('user', 'k2'); $row->plg_content_allvideos = JFile::exists(JPATH_SITE . '/plugins/content/jw_allvideos/jw_allvideos.php'); $row->plg_content_sigpro = JFile::exists(JPATH_SITE . '/plugins/content/jw_sigpro/jw_sigpro.php'); K2Response::setRow($row); }
/** * Create function. * Creates a new resource and stores it to the database. * * @return void */ protected function create() { // Check for token JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN')); // Get input data $data = $this->getInputData(); // Ensure we are not passed with an id $data['id'] = null; // Pass data to the model $this->model->setState('data', $data); // Save $result = $this->model->save(); // Handle save result if ($result) { // Save was successful try to checkin the row if (!$this->model->checkin($this->model->getState('id'))) { // An error occured while trying to checkin. Notify the client. K2Response::throwError($this->model->getError()); } // Row saved. Pass the id of the new object to the client. $row = new stdClass(); $row->id = $this->model->getState('id'); K2Response::setRow($row); K2Response::setStatus(true); } else { // An error occured while saving. Notify the client. K2Response::throwError($this->model->getError()); } }
/** * Helper method for fetching a single row and pass it to K2 response. * This is triggered by the edit function. * Usually there will be no need to override this function. * * @param integer $id The id of the row to edit. * * @return void */ protected function setRow($id) { // Get model $model = $this->getModel(); // Checkout the row if needed if ($id) { if (!$model->checkout($id)) { JFactory::getApplication()->enqueueMessage($model->getError()); } } // Get the row $model->setState('id', $id); $row = $model->getRow(); // Prepare row $this->prepareRow($row); // Set K2 response row K2Response::setRow($row); }