Back to AdminModel class

Method checkCategoryId

protected bool
checkCategoryId
(mixed $categoryId)
Method to check the validity of the category ID for batch copy and move
Parameters
  • int $categoryId The category ID to check
Returns
  • bool
Since
  • 3.2
Class: AdminModel
Project: Joomla

Method checkCategoryId - Source code

/**
 * Method to check the validity of the category ID for batch copy and move
 *
 * @param   integer  $categoryId  The category ID to check
 *
 * @return  boolean
 *
 * @since   3.2
 */
protected function checkCategoryId($categoryId)
{
    // Check that the category exists
    if ($categoryId) {
        $categoryTable = Table::getInstance('Category');
        if (!$categoryTable->load($categoryId)) {
            if ($error = $categoryTable->getError()) {
                // Fatal error
                $this->setError($error);
                return false;
            } else {
                $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
                return false;
            }
        }
    }
    if (empty($categoryId)) {
        $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
        return false;
    }
    // Check that the user has create permission for the component
    $extension = Factory::getApplication()->input->get('option', '');
    $user = Factory::getUser();
    if (!$user->authorise('core.create', $extension . '.category.' . $categoryId)) {
        $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
        return false;
    }
    return true;
}