Source for file pnadminapi.php
Documentation is available at pnadminapi.php
* Zikula Application Framework
* @copyright (c) 2002, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: pnadminapi.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Value_Addons
* create a new hitcount item (= create hook for type 'item')
* @param $args['objectid'] ID of the object
* @param $args['extrainfo'] extra information
* @param $args['modname'] name of the calling module (not used in hook calls)
* @param $args['hits'] optional hit count for the item (not used in hook calls)
* @return mixed hitcount item ID on success, void on failure
if (!isset ($args['objectid']) || !is_numeric($args['objectid'])) {
// When called via hooks, modname wil be empty, but we get it from the
if (empty($args['modname'])) {
// TODO: re-evaluate this for hook calls !!
// Security check - important to do this as early on as possible to
// avoid potential security holes or just too much wasted processing
if (!isset ($args['hits']) || !is_numeric($args['hits'])) {
$hitcount['moduleid'] = (int) $modid;
$hitcount['itemid'] = (int) $args['objectid'];
$hitcount['hits'] = (int) $args['hits'];
// hmmm, I think we'll skip calling more hooks here... :-)
//pnModCallHooks('item', 'create', $hcid, 'hitcountid');
// Return the id of the newly created item to the calling process
// (not that this will be of any used when called via hooks, but
// who knows where else this might be used)
return $hitcount['hitcountid'];
* delete a hitcount item (delete hook for type 'item')
* @param $args['objectid'] ID of the object
* @param $args['extrainfo'] extra information
* @param $args['modname'] name of the calling module (not used in hook calls)
* @return bool true on success, false on failure
if (!isset ($args['objectid']) || !is_numeric($args['objectid'])) {
// When called via hooks, modname wil be empty, but we get it from the
if (empty($args['modname'])) {
// TODO: re-evaluate this for hook calls !!
// Security check - important to do this as early on as possible to
// avoid potential security holes or just too much wasted processing
// hmmm, I think we'll skip calling more hooks here... :-)
//pnModCallHooks('item', 'delete', $exid, '');
// Let the calling process know that we have finished successfully
* update a hitcount item (used by display hook hitcount_user_display)
* @param $args['modname'] name of the calling module (see _user_display)
* @param $args['objectid'] ID of the object
* @param $args['extrainfo'] extra information (unused here)
* @param $args['hits'] (optional) hit count for the item
* @return mixed the new hitcount for this item, or void on failure
if (!isset ($args['objectid']) || !is_numeric($args['objectid'])) {
// When called via hooks, modname wil be empty, but we get it from the
if (empty($args['modname'])) {
// TODO: re-evaluate this for hook calls !!
// Security check - important to do this as early on as possible to
// avoid potential security holes or just too much wasted processing
array('objectid' => $args['objectid'],
'modname' => $args['modname']));
// create the item if necessary
array('objectid' => $args['objectid'],
'modname' => $args['modname']));
return; // throw back whatever it was that failed
$oldhits = $result['hits'];
$hitcounttable = $pntable['hitcount'];
// set to the new hit count
if (!empty($args['hits']) && is_numeric($args['hits'])) {
$sql = "UPDATE $hitcounttable
$sql = "UPDATE $hitcounttable
SET pn_hits = pn_hits + 1
$args['hits'] = $oldhits + 1;
// Return the new hitcount (give or take a few other hits in the meantime)
* clean up hits for a removed module
* @param $args['extrainfo'] array extrainfo array
* @return array extrainfo array
if (!isset ($args['extrainfo'])) {
$args['extrainfo'] = array();
// When called via hooks, the module name may be empty, so we get it from
if (empty($args['extrainfo']['module'])) {
$modname = $args['extrainfo']['module'];
$hitcounttable = $pntable['hitcount'];
return $args['extrainfo'];
|