Source for file weblink.php
Documentation is available at weblink.php
* @subpackage com_weblinks
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @subpackage com_weblinks
* Method to add a new record.
* @return boolean True if the article can be added, false if not.
// Redirect to the return page.
* Method override to check if you can add a new record.
* @param array $data An array of input data.
protected function allowAdd($data =
array())
// If the category has been passed in the URL check it.
$allow =
$user->authorise('core.create', $this->option.
'.category.'.
$categoryId);
// In the absense of better information, revert to the component permissions.
* Method to check if you can add a new record.
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
protected function allowEdit($data =
array(), $key =
'id')
$recordId = (int) isset
($data[$key]) ?
$data[$key] :
0;
$categoryId = (int)
$this->getModel()->getItem($recordId)->catid;
// The category has been set. Check the category permissions.
// Since there is no asset tracking, revert to the component permissions.
* Method to cancel an edit.
* @param string $key The name of the primary key of the URL variable.
* @return Boolean True if access level checks pass, false otherwise.
public function cancel($key =
'w_id')
// Redirect to the return page.
* Method to edit an existing record.
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
* @return Boolean True if access level check and checkout passes, false otherwise.
public function edit($key =
null, $urlVar =
'w_id')
$result =
parent::edit($key, $urlVar);
* Method to get a model object, loading it if required.
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
* @return object The model.
public function getModel($name =
'form', $prefix =
'', $config =
array('ignore_request' =>
true))
$model =
parent::getModel($name, $prefix, $config);
* Gets the URL arguments to append to an item redirect.
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
* @return string The arguments to append to the redirect URL.
$itemId =
$this->input->getInt('Itemid');
$append .=
'&Itemid='.
$itemId;
* If a "return" variable has been passed in the request
* @return string The return URL.
$return =
$this->input->get('return', null, 'base64');
* Function that allows child controller access to model data after the data has been saved.
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
protected function postSaveHook(JModelLegacy $model, $validData =
array())
* Method to save a record.
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
* @return Boolean True if successful, false otherwise.
public function save($key =
null, $urlVar =
'w_id')
$result =
parent::save($key, $urlVar);
// If ok, redirect to the return page.
// Get the ID from the request
$id =
$this->input->getInt('id');
// Get the model, requiring published items
$modelLink =
$this->getModel('Weblink', '', array('ignore_request' =>
true));
$modelLink->setState('filter.published', 1);
$link =
$modelLink->getItem($id);
// Make sure the item was found.
// Check whether item access level allows access.
$groups =
$user->getAuthorisedViewLevels();
// Check whether category access level allows access.
$modelCat =
$this->getModel('Category', 'WeblinksModel', array('ignore_request' =>
true));
$modelCat->setState('filter.published', 1);
$category =
$modelCat->getCategory($link->catid);
// Make sure the category was found.
// Check whether item access level allows access.
if (!in_array($category->access, $groups))
// TODO: Probably should check for a valid http link
Documentation generated on Tue, 19 Nov 2013 15:18:25 +0100 by phpDocumentor 1.4.3