Source for file pnadmin.php
Documentation is available at pnadmin.php
* Zikula Application Framework
* @copyright (c) 2002, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: pnadmin.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Value_Addons
* the main administration function
* This function is the default function, and is called whenever the
* module is initiated without defining arguments. As such it can
* be used for a number of things, but most commonly it either just
* shows the module menu and returns or calls whatever the module
* designer feels should be the default function (often this is the
* @return string HTML string
// Return the output that has been generated by this function
return $pnRender->fetch('ephemerids_admin_main.htm');
* This is a standard function that is called whenever an administrator
* wishes to create a new module item
* @return string HTML string
// Assign the default language
// Return the output that has been generated by this function
return $pnRender->fetch('ephemerids_admin_new.htm');
* This is a standard function that is called with the results of the
* form supplied by Ephemerids_admin_new() to create a new item
* @param 'Date_Day' the day of the emphererid
* @param 'Date_Month' the month of the emphererid
* @param 'Date_Year' the year of the emphererid
* @param 'content' the ephmerid description
* @param 'language' the language of the ephemerid
* @return mixed ephemerid id on success, false on failiure
// Get parameters from whatever input we need
$ephemerid = FormUtil::getPassedValue('ephemerid', isset ($args['ephemerid']) ? $args['ephemerid'] : null, 'POST');
// Confirm authorisation code.
// Notable by its absence there is no security check here. This is because
// the security check is carried out within the API function
// Create the ephemerid via the API
array('did' => $ephemerid['Date_Day'],
'mid' => $ephemerid['Date_Month'],
'yid' => $ephemerid['Date_Year'],
'content' => $ephemerid['content'],
'language' => isset ($ephemerid['language']) ? $ephemerid['language'] : ''));
* This is a standard function that is called whenever an administrator
* wishes to modify a current module item
* @param 'eid' the id of the item to be modified
* @param 'objectid' generic object id maps to eid if presents
* @return string HTML string
$item = pnModAPIFunc('Ephemerids', 'user', 'get', array('eid' => $eid));
// calulate date for use in template
$item['date'] = $item['yid'] . '-' . $item['mid'] . '-' . $item['did'];
// assign the item to the template
$pnRender->assign( $item);
// Return the output that has been generated by this function
return $pnRender->fetch('ephemerids_admin_modify.htm');
* This is a standard function that is called with the results of the
* form supplied by Ephemerids_admin_modify() to update a current item
* @param 'eid' the id of the ephemerid
* @param 'objectid' generic object id maps to eid if present
* @param 'Date_Day' the day of the emphererid
* @param 'Date_Month' the month of the emphererid
* @param 'Date_Year' the year of the emphererid
* @param 'content' the ephmerid description
* @param 'language' the language of the ephemerid
* @return bool true on update success, false on failiure
// Get parameters from whatever input we need
$ephemerid = FormUtil::getPassedValue('ephemerid', isset ($args['ephemerid']) ? $args['ephemerid'] : null, 'POST');
if (!empty($ephemerid['objectid'])) {
$ephemerid['eid'] = $ephemerid['objectid'];
// Confirm authorisation code.
// Notable by its absence there is no security check here. This is because
// the security check is carried out within the API function
array('eid' => $ephemerid['eid'],
'did' => $ephemerid['Date_Day'],
'mid' => $ephemerid['Date_Month'],
'yid' => $ephemerid['Date_Year'],
'content' => $ephemerid['content'],
'language' => isset ($ephemerid['language']) ? $ephemerid['language'] : ''))) {
* This is a standard function that is called whenever an administrator
* wishes to delete a current module item. Note that this function is
* the equivalent of both of the modify() and update() functions above as
* it both creates a form and processes its output. This is fine for
* simpler functions, but for more complex operations such as creation and
* modification it is generally easier to separate them into separate
* functions. There is no requirement in the Zikula MDG to do one or the
* other, so either or both can be used as seen appropriate by the module
* @param 'eid' the id of the ephemerid to be deleted
* @param 'objectid' generic object id maps to eid if present
* @param 'confirmation' confirmation that this item can be deleted
* @return mixed HTML string if no confirmation, true if delete successful, false otherwise
$objectid = FormUtil::getPassedValue('objectid', isset ($args['objectid']) ? $args['objectid'] : null, 'REQUEST');
$item = pnModAPIFunc('Ephemerids', 'user', 'get', array('eid' => $eid));
// Check for confirmation.
if (empty($confirmation)) {
// No confirmation yet - display a suitable form to obtain confirmation
// of this action from the user
$pnRender->assign('eid', $eid);
// Return the output that has been generated by this function
return $pnRender->fetch('ephemerids_admin_delete.htm');
// If we get here it means that the user has confirmed the action
// Confirm authorisation code.
if (pnModAPIFunc('Ephemerids', 'admin', 'delete', array('eid' => $eid))) {
* This is a standard function called to present the administrator with a list
* of all items held by the module.
* @return string HTML string
// The user API function is called. This takes the number of items
// required and the first number in the list of all items, which we
// obtained from the input and gets us the information on the appropriate
array('startnum' => $startnum,
'numitems' => pnModGetVar('Ephemerids', 'itemsperpage')));
if (isset ($items) && is_array($items)) {
foreach ($items as $item) {
$options[] = array('url' => pnModURL('Ephemerids', 'admin', 'modify', array('eid' => $item['eid'])),
$options[] = array('url' => pnModURL('Ephemerids', 'admin', 'delete', array('eid' => $item['eid'])),
'image' => '14_layer_deletelayer.gif',
$item['options'] = $options;
$pnRender->assign('ephemerids', $ephemerids);
// Assign the values for the smarty plugin to produce a pager
$pnRender->assign('pager', array('numitems' => pnModAPIFunc('Ephemerids', 'user', 'countitems'),
'itemsperpage' => pnModGetVar('Ephemerids', 'itemsperpage')));
return $pnRender->fetch('ephemerids_admin_view.htm');
* This is a standard function to modify the configuration parameters of the
* @return stringHTML string
// Number of items to display per page
// Return the output that has been generated by this function
return $pnRender->fetch('ephemerids_admin_modifyconfig.htm');
* This is a standard function to update the configuration parameters of the
* module given the information passed back by the modification form
* @return bool true if update successful, false otherwise
// Confirm authorisation code
pnModSetVar('Ephemerids', 'itemsperpage', $itemsperpage);
// Let any other modules know that the modules configuration has been updated
pnModCallHooks('module','updateconfig','Ephemerids', array('module' => 'Ephemerids'));
// the module configuration has been updated successfuly
|