Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / modules / hitcount [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
10 Aug 2002 17:45:54 | postnuke_official/html/modules/hitcount | pninit.php,1.2,1.3 pnuser.php,1.2,1.3 pnuserapi.php,1.2,1.3 | Mike |
move userapi_hit to adminapi_update, introduce item create/delete hooks, and category delete hook |
Update of /home/cvsroot/postnuke_official/html/modules/hitcount In directory ns7.hostnuke.net:/tmp/cvs-serv1304 Modified Files: pninit.php pnuser.php pnuserapi.php Log Message: move userapi_hit to adminapi_update, introduce item create/delete hooks, and category delete hook Index: pninit.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/hitcount/pninit.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pninit.php 8 Aug 2002 23:00:19 -0000 1.2 --- pninit.php 10 Aug 2002 17:45:51 -0000 1.3 *************** *** 113,122 **** // Set up module hooks ! if (!pnModRegisterHook('item', ! 'display', ! 'GUI', ! 'hitcount', ! 'user', ! 'display')) { return false; } --- 113,138 ---- // Set up module hooks ! ! // when a module item is displayed ! // (use pnVarSetCached('Hooks.hitcount','save', 1) to tell hitcount *not* ! // to display the hit count, but to save it in 'Hooks.hitcount', 'value') ! if (!pnModRegisterHook('item', 'display', 'GUI', ! 'hitcount', 'user', 'display')) { ! return false; ! } ! // when a module item is created (set extrainfo to the module name ?) ! if (!pnModRegisterHook('item', 'create', 'API', ! 'hitcount', 'admin', 'create')) { ! return false; ! } ! // when a module item is deleted (set extrainfo to the module name ?) ! if (!pnModRegisterHook('item', 'delete', 'API', ! 'hitcount', 'admin', 'delete')) { ! return false; ! } ! // when a whole module is removed, e.g. via the modules admin screen ! // (set object ID to the module name !) ! if (!pnModRegisterHook('category', 'delete', 'API', ! 'hitcount', 'admin', 'deleteall')) { return false; } *************** *** 155,166 **** { // Remove module hooks ! if (!pnModUnregisterHook('item', ! 'display', ! 'GUI', ! 'hitcount', ! 'user', ! 'display')) { pnSessionSetVar('errormsg', pnML('Could not unregister hook')); - // return false; } --- 171,189 ---- { // Remove module hooks ! if (!pnModUnregisterHook('item', 'display', 'GUI', ! 'hitcount', 'user', 'display')) { ! pnSessionSetVar('errormsg', pnML('Could not unregister hook')); ! } ! if (!pnModUnregisterHook('item', 'create', 'API', ! 'hitcount', 'admin', 'create')) { ! pnSessionSetVar('errormsg', pnML('Could not unregister hook')); ! } ! if (!pnModUnregisterHook('item', 'delete', 'API', ! 'hitcount', 'admin', 'delete')) { ! pnSessionSetVar('errormsg', pnML('Could not unregister hook')); ! } ! if (!pnModUnregisterHook('category', 'delete', 'API', ! 'hitcount', 'admin', 'deleteall')) { pnSessionSetVar('errormsg', pnML('Could not unregister hook')); } Index: pnuser.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/hitcount/pnuser.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pnuser.php 8 Aug 2002 23:00:19 -0000 1.2 --- pnuser.php 10 Aug 2002 17:45:51 -0000 1.3 *************** *** 24,28 **** /** ! * the main user function */ function hitcount_user_main() --- 24,28 ---- /** ! * the main user function (nothing interesting here - might be removed) */ function hitcount_user_main() *************** *** 38,43 **** /** ! * add a hit for a specific item, and display the hitcount (or save the ! * hit count in the variable cache 'Hooks.hitcount', variable 'value') * * @param $args['objectid'] ID of the item this hitcount is for --- 38,45 ---- /** ! * add a hit for a specific item, and display the hitcount (= display hook) ! * ! * (use pnVarSetCached('Hooks.hitcount','save', 1) to tell hitcount *not* ! * to display the hit count, but to save it in 'Hooks.hitcount', 'value') * * @param $args['objectid'] ID of the item this hitcount is for *************** *** 52,56 **** // Load API ! if (!pnModAPILoad('hitcount', 'user')) { return _LOADFAILED; } --- 54,58 ---- // Load API ! if (!pnModAPILoad('hitcount', 'admin')) { return _LOADFAILED; } *************** *** 59,65 **** $args['modname'] = pnModGetName(); $hitcount = pnModAPIFunc('hitcount', ! 'user', ! 'hit', ! $args); if (isset($hitcount)) { --- 61,67 ---- $args['modname'] = pnModGetName(); $hitcount = pnModAPIFunc('hitcount', ! 'admin', ! 'update', ! $args); if (isset($hitcount)) { *************** *** 69,73 **** return '(' . $hitcount . ' ' . pnML('Reads') . ')'; } else { ! pnVarSetCached('Hooks.hitcount','value',$hitcount - 1); } } --- 71,75 ---- return '(' . $hitcount . ' ' . pnML('Reads') . ')'; } else { ! pnVarSetCached('Hooks.hitcount','value',$hitcount); } } Index: pnuserapi.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/hitcount/pnuserapi.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pnuserapi.php 8 Aug 2002 23:00:19 -0000 1.2 --- pnuserapi.php 10 Aug 2002 17:45:51 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- // Purpose of file: Hitcount Hook User API // ---------------------------------------------------------------------- + /** * get a hitcount for a specific item *************** *** 27,31 **** * @param $args['objectid'] ID of the item this hitcount is for * @returns int ! * @return hits the corresponding hit count, or boid if no hit exists */ function hitcount_userapi_get($args) --- 28,32 ---- * @param $args['objectid'] ID of the item this hitcount is for * @returns int ! * @return hits the corresponding hit count, or void if no hit exists */ function hitcount_userapi_get($args) *************** *** 73,179 **** return $hits; - } - - /** - * hit an item - * @param $args['modname'] module name of the item to hit - * @param $args['objectid'] ID of the item to hit - * @param $args['hits'] (optional) number of current hits - * @returns int - * @return the new hitcount for this item - */ - function hitcount_userapi_hit($args) - { - // Get arguments from argument array - extract($args); - - // Argument check - if ((!isset($modname)) || - (!isset($objectid))) { - pnSessionSetVar('errormsg', _MODARGSERROR); - return; - } - if (!isset($hits)) { - $hits = 0; - } - - // Security check - if (!pnSecAuthAction(0, 'Hitcount::', "$modname::$objectid", ACCESS_OVERVIEW)) { - return; - } - - $modid = pnModGetIDFromName($modname); - if (empty($modid)) { - pnSessionSetVar('errormsg', _MODARGSERROR); - return; - } - - // TODO: yeah, this is just a quick & dirty adaptation from ratings for now :-) - - // Database information - list($dbconn) = pnDBGetConn(); - $pntable = pnDBGetTables(); - $hitcounttable = $pntable['hitcount']; - - // Get current information on hits - $sql = "SELECT pn_hitcountid, - pn_hits - FROM $hitcounttable - WHERE pn_moduleid = '" . pnVarPrepForStore($modid) . "' - AND pn_itemid = '" . pnVarPrepForStore($objectid) . "'"; - $result = $dbconn->Execute($sql); - - if ($dbconn->ErrorNo() != 0) { - pnSessionSetVar('errormsg', 'SQL Error'); - return; - } - - if (!$result->EOF) { - // Update current hitcount - list($hcid, $oldhits) = $result->fields; - $result->close(); - - if ($oldhits > $hits) { - $newhits = $oldhits + 1; - } else { - $newhits = $hits + 1; - } - - // Insert new hitcount - $sql = "UPDATE $hitcounttable - SET pn_hits = " . pnVarPrepForStore($newhits) . " - WHERE pn_hitcountid = $hcid"; - $dbconn->Execute($sql); - - if ($dbconn->ErrorNo() != 0) { - pnSessionSetVar('errormsg', 'SQL Error'); - return; - } - } else { - $result->close(); - - $newhits = $hits + 1; - - // Get a new hitcount ID - $hcid = $dbconn->GenId($hitcounttable); - // Create new hitcount - $sql = "INSERT INTO $hitcounttable(pn_hitcountid, - pn_moduleid, - pn_itemid, - pn_hits) - VALUES ($hcid, - '" . pnVarPrepForStore($modid) . "', - '" . pnVarPrepForStore($objectid) . "', - '" . pnVarPrepForStore($newhits) . "')"; - - $dbconn->Execute($sql); - - if ($dbconn->ErrorNo() != 0) { - pnSessionSetVar('errormsg', 'SQL Error'); - return; - } - } - - return $newhits; } --- 74,77 ----
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |