/**
* Batch language changes for a group of rows.
*
* @param string $value The new value matching a language.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 2.5
*/
protected function batchLanguage($value, $pks, $contexts)
{
// Initialize re-usable member properties, and re-usable local variables
$this->initBatch();
foreach ($pks as $pk) {
if ($this->user->authorise('core.edit', $contexts[$pk])) {
$this->table->reset();
$this->table->load($pk);
$this->table->language = $value;
$event = new BeforeBatchEvent($this->event_before_batch, ['src' => $this->table, 'type' => 'language']);
$this->dispatchEvent($event);
// Check the row.
if (!$this->table->check()) {
$this->setError($this->table->getError());
return false;
}
if (!$this->table->store()) {
$this->setError($this->table->getError());
return false;
}
} else {
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}