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_System_Modules
* @subpackage Admin_Messages
* @license http://www.gnu.org/copyleft/gpl.html
* 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 output string
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_admin_main.htm');
* add a new admin message
* This is a standard function that is called whenever an administrator
* wishes to create a new module item
* @return string HTML output string
// Assign the default language
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_admin_new.htm');
* This is a standard function that is called with the results of the
* form supplied by Admin_Messages_admin_new() to create a new item
* @see Admin_Messages_admin_new()
* @param string $args['title'] the title of the admin message
* @param string $args['content'] the text of the admin message
* @param string $args['language'] the language of the admin message
* @param int $args['active'] active status of the admin message
* @param int $args['expire'] the expiry date of the message
* @param int $args['view'] who can view the message
* @return bool true if creation successful, false otherwiise
// Confirm authorisation code.
// Notable by its absence there is no security check here.
// Create the admin message
array('title' => $message['title'],
'content' => $message['content'],
'language' => isset ($message['language']) ? $message['language'] : '',
'active' => $message['active'],
'expire' => $message['expire'],
'view' => $message['view']));
// The return value of the function is checked
// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
* modify an Admin Message
* This is a standard function that is called whenever an administrator
* wishes to modify a current module item
* @param int $args['mid'] the id of the admin message to modify
* @param int $args['objectid'] generic object id maps to mid if present
* @return string HTML output string
$item = pnModAPIFunc('Admin_Messages', 'user', 'get', array('mid' => $mid));
$pnRender->assign($item);
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_admin_modify.htm');
* This is a standard function that is called with the results of the
* form supplied by Admin_Messages_admin_modify() to update a current item
* @see Admin_Messages_admin_modify()
* @param int $args['mid'] the id of the admin message to update
* @param int $args['objectid'] generic object id maps to mid if present
* @param string $args['title'] the title of the admin message
* @param string $args['content'] the text of the admin message
* @param string $args['language'] the language of the admin message
* @param int $args['active'] active status of the admin message
* @param int $args['expire'] the expiry date of the message
* @param int $args['view'] who can view the message
* @return bool true if successful, false otherwise
if (!empty($message['objectid'])) {
$message['mid'] = $message['objectid'];
// Confirm authorisation code.
// Notable by its absence there is no security check here.
// Update the admin message
array('mid' => $message['mid'],
'title' => $message['title'],
'content' => $message['content'],
'language' => isset ($message['language']) ? $message['language'] : '',
'active' => $message['active'],
'expire' => $message['expire'],
'oldtime' => $message['oldtime'],
'changestartday' => $message['changestartday'],
'view' => $message['view']))) {
// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
* 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 int $args['mid'] the id of the admin message to delete
* @param int $args['objectid'] generic object id maps to mid if present
* @param bool $args['confirmation'] confirmation of the deletion
* @return mixed HTML output string if no confirmation, true if succesful, false otherwise
$objectid = FormUtil::getPassedValue('objectid', isset ($args['objectid']) ? $args['objectid'] : null, 'REQUEST');
// Get the existing admin message
$item = pnModAPIFunc('Admin_Messages', 'user', 'get', array('mid' => $mid));
// Check for confirmation.
if (empty($confirmation)) {
$pnRender->assign('mid', $mid);
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_admin_delete.htm');
// If we get here it means that the user has confirmed the action
// Confirm authorisation code.
// Delete the admin message
// The return value of the function is checked
// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
* @param int $startnum the start item id for the pager
* @return string HTML output 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('Admin_Messages', 'itemsperpage')));
foreach ($items as $item) {
array('mid' => $item['mid']));
if ($fullitem['language'] == '') {
$fullitem['language'] = _ALL;
$row[] = $fullitem['language'];
switch ($fullitem['view']) {
$row[] = $fullitem['view'];
if ($fullitem['active'] == 1) {
if ($fullitem['expire'] == 0) {
} else if ($fullitem['expire']/ 86400 == 1) {
$expire = $fullitem['expire']/ 86400 . ' ' . _DAY;
$expire = $fullitem['expire']/ 86400 . ' ' . _DAYS;
if ($fullitem['expire'] == 0) {
// Options for the item. Note that each item has the appropriate
// levels of authentication checked to ensure that it is suitable
$options[] = array('url' => pnModURL('Admin_Messages', 'admin', 'modify', array('mid' => $item['mid'])),
$options[] = array('url' => pnModURL('Admin_Messages', 'admin', 'delete', array('mid' => $item['mid'])),
'image' => '14_layer_deletelayer.gif',
$rows[] = array( 'mid' => $item['mid'],
'title' => $item['title'],
'language' => $fullitem['language'],
'view' => $fullitem['view'],
'expiredate' => $expiredate,
$pnRender->assign('items', $rows);
// Assign the information required to create the pager
$pnRender->assign('pager', array('numitems' => pnModAPIFunc('Admin_Messages', 'user', 'countitems'),
'itemsperpage' => pnModGetVar('Admin_Messages', 'itemsperpage')));
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_admin_view.htm');
* This is a standard function to modify the configuration parameters of the
* @return string HTML output string
// Number of items to display per page
// Return the output that has been generated by this function
return $pnRender->fetch('admin_messages_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
* @see Admin_Messages_admin_modifyconfig()
* @param int $itemsperpage the number messages per page in the admin panel
* @return bool true if successful, false otherwise
// Confirm authorisation code.
// Update module variables.
if ($itemsperpage < 1) $itemsperpage = 25;
pnModSetVar('Admin_Messages', 'itemsperpage', $itemsperpage);
pnModSetVar('Admin_Messages', 'allowsearchinactive', $allowsearchinactive);
// Let any other modules know that the modules configuration has been updated
pnModCallHooks('module','updateconfig','Admin_Messages', array('module' => 'Admin_Messages'));
// the module configuration has been updated successfuly
// This function generated no output, and so now it is complete we redirect
// the user to an appropriate page for them to carry on their work
|