Source for file pnSecurity.php
Documentation is available at pnSecurity.php
* Zikula Application Framework
* @copyright (c) 2001, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: pnSecurity.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* Notes on security system
* UID -1 corresponds to 'all users', includes unregistered users
* GID -1 corresponds to 'all groups', includes unregistered users
* UID 0 corresponds to unregistered users
* GID 0 corresponds to unregistered users
* Defines for access levels
define('ACCESS_OVERVIEW', 100);
define('ACCESS_COMMENT', 300);
define('ACCESS_MODERATE', 400);
* Translation functions - avoids globals in external code
// Translate level -> name
return $accessnames[$level];
* @return array of access names
static $accessnames = array( 0 => _ACCESS_NONE,
* addinstanceschemainfo - register an instance schema with the security
* Will fail if an attempt is made to overwrite an existing schema
* @param unknown_type $component
* @param unknown_type $schema
* @param unknown_type $component
* @param unknown_type $schema
if (!empty($GLOBALS['schemas'][$component])) {
$GLOBALS['schemas'][$component] = $schema;
* Enter description here...
* @see SecurityUtil::checkPermission()
* @param unknown_type $testrealm
* @param unknown_type $testcomponent
* @param unknown_type $testinstance
* @param unknown_type $testlevel
function authorised($testrealm, $testcomponent, $testinstance, $testlevel)
// Wrapper for new pnSecAuthAction() function
return pnSecAuthAction($testrealm, $testcomponent, $testinstance, $testlevel);
* see if a user is authorised to carry out a particular task
* @see SecurityUtil::checkPermission()
* @param realm the realm under test
* @param component the component under test
* @param instance the instance under test
* @param level the level of access required
* @return bool true if authorised, false if not
function pnSecAuthAction($testrealm, $testcomponent, $testinstance, $testlevel, $testuser= null)
LogUtil::log('Function pnSecAuthAction() is deprecated. Please use SecurityUtil::checkPermission() instead.', 'STRICT');
* get authorisation information for this user
* @see SecurityUtil::getAuthInfo()
* @return array two element array of user and group permissions
LogUtil::log('Function pnSecGetAuthInfo() is deprecated. Please use SecurityUtil::getAuthInfo() instead.', 'STRICT');
* calculate security level for a test item
* @see SecurityUtil::getSecurityLevel
* @param perms $ array of permissions to test against
* @param testrealm $ realm of item under test
* @param testcomponent $ component of item under test
* @param testinstance $ instance of item under test
* @return int matching security level
function pnSecGetLevel($perms, $testrealm, $testcomponent, $testinstance)
LogUtil::log('Function pnSecGetLevel() is deprecated. Please use SecurityUtil::getSecurityLevel() instead.', 'STRICT');
* generate an authorisation key
* The authorisation key is used to confirm that actions requested by a
* particular user have followed the correct path. Any stage that an
* action could be made (e.g. a form or a 'delete' button) this function
* must be called and the resultant string passed to the client as either
* a GET or POST variable. When the action then takes place it first calls
* <code>pnSecConfirmAuthKey()</code> to ensure that the operation has
* indeed been manually requested by the user and that the key is valid
* @see SecurityUtil::generateAuthKey
* @param modname $ the module this authorisation key is for (optional)
* @return string an encrypted key for use in authorisation of operations
LogUtil::log('Function pnSecGenAuthKey() is deprecated. Please use SecurityUtil::generateAuthKey() instead.', 'STRICT');
* confirm an authorisation key is valid
* See description of <code>pnSecGenAuthKey</code> for information on
* @see SecurityUtil::confirmAuthKey()
* @return bool true if the key is valid, false if it is not
LogUtil::log('Function pnSecConfirmAuthKey() is deprecated. Please use SecurityUtil::confirmAuthKey() instead.', 'STRICT');
|