/** * Method to run batch operations. * * @param jmodel $model The model of the component being processed. * * @return boolean True if successful, false otherwise and internal error is set. */ public function batch($model) { // Initialise variables. $input = JFactory::getApplication()->input; $vars = $input->post->get('batch', array(), 'array'); $cid = $input->post->get('cid', array(), 'array'); $data = array(); $data['success'] = "true"; $data['messages'] = array(); $data['data'] = array(); // Build an array of item contexts to check $contexts = array(); foreach ($cid as $id) { // If we're coming from com_categories, we need to use extension vs. option if (isset($this->extension)) { $option = $this->extension; } else { $option = $this->option; } $contexts[$id] = $option . '.' . $this->context . '.' . $id; } // Attempt to run the batch operation. if ($model->batch($vars, $cid, $contexts)) { $data['messages'][] = JText::_('JLIB_APPLICATION_SUCCESS_BATCH'); $this->sendResponse($data); } else { $data['success'] = "false"; $data['messages'][] = JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_FAILED', $model->getError()); $this->sendResponse($data); } }