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_modules / feproc [ view in CVS ]
| Date | Directory [filter] | File(s) [view] | Author [filter] |
| 16 Dec 2002 00:43:59 | postnuke_modules/feproc | index.html,NONE,1.1 index.php,NONE,1.1 pnadmin.php,NONE,1.1 pnadminapi.php,NONE,1.1 pnhandleradmin.php,NONE,1.1 pnhandleradminapi.php,NONE,1.1 pnhandleruserapi.php,NONE,1.1 pninit.php,NONE,1.1 pnsessionapi.php,NONE,1.1 pnstandardapi.php,NONE,1.1 pntables. | judgej |
| New FEproc module to take over from fetax. | |||
Update of /home/cvsroot/postnuke_modules/feproc
In directory ns7.hostnuke.net:/tmp/cvs-serv3115/modules/feproc
Added Files:
index.html index.php pnadmin.php pnadminapi.php
pnhandleradmin.php pnhandleradminapi.php pnhandleruserapi.php
pninit.php pnsessionapi.php pnstandardapi.php pntables.php
pnuser.php pnuserapi.php pnversion.php
Log Message:
New FEproc module to take over from fetax.
--- NEW FILE: index.html ---
--- NEW FILE: index.php ---
<?php
if (!defined("LOADED_AS_MODULE"))
{
die ("You can't access this file directly...");
}
pnRedirect(pnModURL('FEproc', 'admin', 'view'));
?>
--- NEW FILE: pnadmin.php ---
<?php
// ----------------------------------------------------------------------
// FEproc - Mail template backend module for FormExpress for
// POST-NUKE Content Management System
// Copyright (C) 2002 by Jason Judge
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
[...1518 lines suppressed...]
$columns[] = $output->URL(pnModURL('feproc',
'admin',
'modifyconfig'),
/*TODO: _FXNEWTEMPLATE*/ 'Configuration');
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->TableAddRow($columns);
$output->SetInputMode(_PNH_PARSEINPUT);
// END OF ROWS
$output->TableEnd();
// Return the output that has been generated by this function
return $output->GetOutput();
}
?>
--- NEW FILE: pnadminapi.php ---
<?php
// ----------------------------------------------------------------------
// FEproc - Mail template backend module for FormExpress for
// POST-NUKE Content Management System
// Copyright (C) 2002 by Jason Judge
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jason Judge. Based on template by
// Jim MacDonald
// ----------------------------------------------------------------------
/*******************
* SETS
*******************/
/**
* create a new set item TODO
* @param $args['name'] name of the template
* @param $args['description'] description of the template
* @returns int
* @return set item ID on success, false on failure
*/
function feproc_adminapi_createset($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
if (!isset($name) ||
!isset($description)
)
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "::", ACCESS_ADD)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
// Load handler user API.
if (!pnModAPILoad('feproc', 'handleruser'))
{
$output->Text(_FXMODLOADFAILED . ' feproc:handleruser');
return $output->GetOutput();
}
// Get database setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Get next ID in table.
$sql = "SELECT MAX($wfcolumn[id]) + 1 FROM $wftable";
$result = $dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXCREATEFAILED . ' ' . $sql);
return false;
}
list($nextId) = $result->fields;
if (empty($nextId))
{
$nextId = 1;
}
// Does not appear to work.
//$nextId = $dbconn->GenId($wftable);
// Add item.
$sql = "INSERT INTO $wftable (
$wfcolumn[id],
$wfcolumn[name],
$wfcolumn[description],
$wfcolumn[type],
$wfcolumn[setid],
$wfcolumn[handlerid],
$wfcolumn[failureid],
$wfcolumn[successid],
$wfcolumn[secure],
$wfcolumn[attributes])
VALUES (
$nextId,
'" . pnVarPrepForStore($name) . "',
'" . pnVarPrepForStore($description) . "',
'set',
$nextId,
0,
0,
0,
0,
NULL)";
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXCREATEFAILED . ' ' . $sql);
return false;
}
// Get the ID of the item that we inserted.
$setid = $dbconn->PO_Insert_ID($wftable, $wfcolumn['id']);
// Let any hooks know that we have created a new item. As this is a
// create hook we're passing 'id' as the extra info, which is the
// argument that all of the other functions use to reference this
// item
// TODO: this is not a standard item
pnModCallHooks('item', 'createset', $setid, 'setid');
// Return the id of the newly created item to the calling process
return $setid;
}
/**
* update a set item
* @param $args['hid'] the ID of the item
* @param $args['name'] the new name of the item
* @param $args['description'] the new description of the item
* @param $args['...'] the actual template
* TODO: complete parameter list
*/
function feproc_adminapi_updateset($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
// TODO: success and failure stage IDs
if (!isset($setid) ||
!isset($name) ||
!isset($description)/* ||
!isset($attributes)*/)
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
if (!isset($secure))
{
$secure = 0;
}
if (!pnModAPILoad('feproc', 'user'))
{
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
return false;
}
// The API function is called.
$item = pnModAPIFunc('feproc', 'user', 'getset',
array('setid' => $setid)
);
if ($item == false)
{
pnSessionSetVar('errormsg', 'No such set'); //TODO
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_EDIT)) // TODO
{
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
// Get database setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Update the item.
$sql = "UPDATE $wftable
SET $wfcolumn[name] = '" . pnVarPrepForStore($name) . "',
$wfcolumn[description] = '" . pnVarPrepForStore($description) . "',
$wfcolumn[successid] = '" . pnVarPrepForStore($startstageid) . "'
WHERE $wfcolumn[id] = " . pnVarPrepForStore($setid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXUPDATEFAILED . ' ' . $sql);
return false;
}
// Let the calling process know that we have finished successfully
return true;
}
/**
* delete a feproc handler item
* @param $args['hid'] ID of the item
* @returns bool
* @return true on success, false on failure
* TODO: don't allow a delete if the handler is being used by any workflow set stages.
*/
function feproc_adminapi_deleteset($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
if (!isset($setid)) {
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_DELETE)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
if (!pnModAPILoad('feproc', 'admin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'viewset', array('setid' => $setid)));
return true;
}
if (!pnModAPILoad('feproc', 'user')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'viewset', array('setid' => $setid)));
return true;
}
// Check if there are any stages that have not been deleted yet.
$stages = pnModAPIFunc('feproc', 'user', 'getallstages',
array('setid' => $setid));
if (is_array($stages))
{
pnSessionSetVar('errormsg', "Must delete all stages before the set can be deleted.");
pnRedirect(pnModURL('feproc', 'admin', 'viewset', array('setid' => $setid)));
return true;
}
// The API function is called.
$item = pnModAPIFunc('feproc', 'user', 'getset',
array('setid' => $setid));
if ($item == false) {
pnSessionSetVar('errormsg', "Set $setid does not exist");
return false;
}
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Delete the item.
$sql = "DELETE FROM $wftable
WHERE $wfcolumn[id] = " . pnVarPrepForStore($setid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return.
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXDELETEFAILED);
return false;
}
// Let any hooks know that we have deleted an item.
// TODO: distinguish between different types of item.
pnModCallHooks('item', 'deleteset', $setid, 'setid');
// Let the calling process know that we have finished successfully
return true;
}
/*******************
* STAGES
*******************/
/**
* create a new stage item
* @param $args['name'] name of the template
* @param $args['description'] description of the template
* TODO...
* @returns int
* @return stage item ID on success, false on failure
*/
function feproc_adminapi_createstage($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
if (!isset($name) ||
!isset($description) ||
!isset($handlertype) ||
!isset($setid) ||
!isset($hid))
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
if (!isset($secure))
{
$secure = 0;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "::", ACCESS_ADD)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
// Load handler user API.
if (!pnModAPILoad('feproc', 'handleruser'))
{
$output->Text(_FXMODLOADFAILED . ' feproc:handleruser');
return $output->GetOutput();
}
// TODO: create default attributes for the stage.
// The attributes come from the handler details.
// Get the handler.
$sattributes = false;
if ($handlertype <> 'formexpress' && $handlertype <> 'form')
{
if ($handler = pnModAPIFunc(
'feproc', 'handleruser', 'gethandler',
array('hid' => $hid)))
{
if (is_array($handler['attributes']))
{
$sattributes = array();
foreach ($handler['attributes'] as $key => $attribute)
{
$sattributes[$key] = $attribute['default'];
}
}
}
}
$sattributes = serialize($sattributes);
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Get next ID in table.
$sql = "SELECT MAX($wfcolumn[id]) + 1 FROM $wftable";
$result = $dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXCREATEFAILED . ' ' . $sql);
return false;
}
list($nextId) = $result->fields;
if (empty($nextId))
{
$nextId = 1;
}
// Does not appear to work.
//$nextId = $dbconn->GenId($wftable);
// Add item.
$sql = "INSERT INTO $wftable (
$wfcolumn[id],
$wfcolumn[name],
$wfcolumn[description],
$wfcolumn[type],
$wfcolumn[setid],
$wfcolumn[handlerid],
$wfcolumn[secure],
$wfcolumn[attributes])
VALUES (
$nextId,
'" . pnVarPrepForStore($name) . "',
'" . pnVarPrepForStore($description) . "',
'" . pnVarPrepForStore($handlertype) . "',
'" . pnVarPrepForStore($setid) . "',
'" . pnVarPrepForStore($hid) . "',
'" . pnVarPrepForStore($secure) . "',
'" . pnVarPrepForStore($sattributes) . "')";
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXCREATEFAILED . ' ' . $sql);
return false;
}
// Get the ID of the item that we inserted.
$stageid = $dbconn->PO_Insert_ID($wftable, $wfcolumn['id']);
// Let any hooks know that we have created a new item.
// TODO: this is not a standard item
pnModCallHooks('item', 'createstage', $stageid, 'stageid');
// Return the id of the newly created item to the calling process
return $stageid;
}
/**
* update a template item
* @param $args['hid'] the ID of the item
* @param $args['name'] the new name of the item
* @param $args['description'] the new description of the item
* @param $args['...'] the actual template
* TODO: complete parameter list
*/
function feproc_adminapi_updatestage($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
if (!isset($stageid) ||
!isset($name) ||
!isset($description)/* ||
!isset($attributes)*/)
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
if (!isset($secure))
{
$secure = 0;
}
if (!isset($successid))
{
$successid = 0;
}
if (!isset($failureid))
{
$failureid = 0;
}
if (!pnModAPILoad('feproc', 'user'))
{
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
return false;
}
// The API function is called.
$item = pnModAPIFunc('feproc', 'user', 'getstage',
array('stageid' => $stageid)
);
if ($item == false)
{
pnSessionSetVar('errormsg', 'No such stage'); //TODO
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_EDIT)) // TODO
{
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
// The attributes will be an array.
if ($attributes == null || empty($attributes) || !isset($attributes))
{
$attributes = false;
}
$sattributes = serialize($attributes);
// Get database setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Update the item.
$sql = "UPDATE $wftable
SET $wfcolumn[name] = '" . pnVarPrepForStore($name) . "',
$wfcolumn[description] = '" . pnVarPrepForStore($description) . "',
$wfcolumn[secure] = '" . pnVarPrepForStore($secure) . "',
$wfcolumn[successid] = '" . pnVarPrepForStore($successid) . "',
$wfcolumn[failureid] = '" . pnVarPrepForStore($failureid) . "',
$wfcolumn[attributes] = '" . pnVarPrepForStore($sattributes) . "'
WHERE $wfcolumn[id] = " . pnVarPrepForStore($stageid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXUPDATEFAILED . ' ' . $sql);
return false;
}
// Let the calling process know that we have finished successfully
return true;
}
/**
* delete a feproc handler item
* @param $args['hid'] ID of the item
* @returns bool
* @return true on success, false on failure
* TODO: don't allow a delete if the handler is being used by any workflow set stages.
*/
function feproc_adminapi_deletestage($args)
{
// Get arguments from argument array.
extract($args);
// Argument check.
if (!isset($stageid) || !isset($setid)) {
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_DELETE)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
if (!pnModAPILoad('feproc', 'admin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'viewset', array('setid' => $setid)));
return true;
}
if (!pnModAPILoad('feproc', 'user')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'viewset', array('setid' => $setid)));
return true;
}
// The API function is called.
$item = pnModAPIFunc('feproc', 'user', 'getstage',
array('stageid' => $stageid));
if ($item == false) {
pnSessionSetVar('errormsg', "Stage $stageid does not exist");
return false;
}
// Get database setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$wftable = $pntable['feproc_workflow'];
$wfcolumn = &$pntable['feproc_workflow_column'];
// Delete the item.
$sql = "DELETE FROM $wftable
WHERE $wfcolumn[id] = " . pnVarPrepForStore($stageid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return.
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXDELETEFAILED);
return false;
}
// Update any other stages that point to the deleted item (so there are no
// dead-ends).
$sql = "UPDATE $wftable
SET $wfcolumn[successid] = 0
WHERE $wfcolumn[successid] = " . pnVarPrepForStore($stageid);
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXDELETEFAILED);
return false;
}
$sql = "UPDATE $wftable
SET $wfcolumn[failureid] = 0
WHERE $wfcolumn[failureid] = " . pnVarPrepForStore($stageid);
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXDELETEFAILED);
return false;
}
// Let any hooks know that we have deleted an item.
// TODO: distinguish between different types of item.
pnModCallHooks('item', 'deletestage', $stageid, 'stageid');
// Let the calling process know that we have finished successfully
return true;
}
?>
--- NEW FILE: pnhandleradmin.php ---
<?php
// ----------------------------------------------------------------------
// FEproc - Mail template backend module for FormExpress for
// POST-NUKE Content Management System
// Copyright (C) 2002 by Jason Judge
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jorn Lind-Nielsen. Based on template by
// Jim MacDonald
// ----------------------------------------------------------------------
/**
* view items
*/
function feproc_handleradmin_view()
{
// Get parameters from whatever input we need.
$startnum = pnVarCleanFromInput('startnum');
// Create output object - this object will store all of our output so that
// we can return it easily when required.
$output = new pnHTML();
if (!pnSecAuthAction(0, 'FEproc::Handler', '::', ACCESS_EDIT)) {
$output->Text(_FXNOAUTH);
return $output->GetOutput();
}
// Load the admin module so we have the menu.
// TODO: rename menu function so proper call can be made.
if (!pnModLoad('feproc', 'admin')) {
$output->Text(_FXMODLOADFAILED);
return $output->GetOutput();
}
// Add menu to output - it helps if all of the module pages have a standard
// menu at their head to aid in navigation
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(feproc_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Load API. If the API fails to load an appropriate
// error message is posted and the function returns
if (!pnModAPILoad('feproc', 'handleruser')) {
$output->Text(_FXMODLOADFAILED);
return $output->GetOutput();
}
// The 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
// items.
$items = pnModAPIFunc('feproc', 'handleruser', 'getallhandlers',
array('startnum' => $startnum,
'numitems' => 10/* FIXME pnModGetVar('FEproc',
'itemsperpage')*/));
// Start output table
$output->TableStart(_FXFETAXHANDLERS,
array(_FXID,
_FXNAME,
_FXDESCRIPTION,
_FXTYPE,
_FXSOURCE,
_FXOPTIONS), 1);
foreach ($items as $item)
{
$row = array();
// Output whatever we found
$row[] = "$item[hid]";
$row[] = "$item[name]";
$row[] = $item['description'];
$row[] = $item['type'];
$row[] = $item['source'];
// Options for the item
$options = array();
$output->SetOutputMode(_PNH_RETURNOUTPUT);
$options[] = $output->URL(pnModURL('feproc',
'handleradmin',
'helphandler',
array('hid' => $item['hid'])),
_FXHELP );
$options[] = $output->URL(pnModURL('feproc',
'handleradmin',
'delete',
array('hid' => $item['hid'])),
_FXDELETE);
$options = join(' | ', $options);
$output->SetInputMode(_PNH_VERBATIMINPUT);
$row[] = $output->Text($options);
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->TableAddRow($row, 'left');
$output->SetInputMode(_PNH_PARSEINPUT);
}
$row = array(null, null, null, null, _FXSOURCEKEY, null);
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->TableAddRow($row, 'left');
$output->SetInputMode(_PNH_PARSEINPUT);
$output->TableEnd();
// Call the pnHTML helper function to produce a pager in case of there
// being many items to display.
//
// Note that this function includes another user API function. The
// function returns a simple count of the total number of items in the item
// table so that the pager function can do its job properly
$output->Pager($startnum,
pnModAPIFunc('feproc', 'handleruser', 'counthandlers'),
pnModURL('feproc',
'handleruser',
'view',
array('startnum' => '%%')),
10 /* FIXME pnModGetVar('FEproc', 'itemsperpage')*/);
$modinfo = pnModGetInfo(pnModGetIDFromName('feproc'));
// Return the output that has been generated by this function
return $output->GetOutput();
}
/**
* delete item
* @param 'hid' the id of the item to be deleted
* @param 'confirmation' confirmation that this item can be deleted
*/
function feproc_handleradmin_delete($args)
{
// Get parameters from whatever input we need.
list($hid,
$objectid,
$confirmation) = pnVarCleanFromInput('hid',
'objectid',
'confirmation');
// User functions of this type can be called by other modules.
// pnVarCleanFromInput().
extract($args);
// Check to see if we have been passed $objectid.
if (!empty($objectid))
{
$hid = $objectid;
}
$output = new pnHTML();
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::Handler', "::$hid", ACCESS_DELETE)) {
$output->Text(_FXNOAUTH);
return $output->GetOutput();
}
// Load API. If the API fails to load an appropriate
// error message is posted and the function returns
if (!pnModAPILoad('feproc', 'handleradmin')) {
$output->Text(_FXMODLOADFAILED);
return $output->GetOutput();
}
if (!pnModAPILoad('feproc', 'handleruser')) {
$output->Text(_FXMODLOADFAILED);
return $output->GetOutput();
}
// Load main admin module so we can call up the menu.
if (!pnModLoad('feproc', 'admin')) {
$output->Text(_FXMODLOADFAILED);
return $output->GetOutput();
}
// The user API function is called.
$item = pnModAPIFunc('feproc',
'handleruser',
'gethandler',
array('hid' => $hid));
if ($item == false) {
$output->Text(_FXNOSUCHHANDLER);
return $output->GetOutput();
}
// Check for confirmation.
if (empty($confirmation))
{
// No confirmation yet - display a suitable form to obtain confirmation
// of this action from the user
// Create output object - this object will store all of our output so
// that we can return it easily when required
$output = new pnHTML();
// Add menu to output - it helps if all of the module pages have a
// standard menu at their head to aid in navigation
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(feproc_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Title - putting a title at the head of each page reminds the user
// what they are doing
$output->Title(_FXDELETEHANDLER);
// Add confirmation to output.
$output->ConfirmAction(_FXCONFIRMHANDLERDELETE . " '$item[name]'",
pnModURL('feproc',
'handleradmin',
'delete'),
_FXCANCELHANDLERDELETE,
pnModURL('feproc',
'handleradmin',
'view'),
array('hid' => $hid));
// Return the output that has been generated by this function
return $output->GetOutput();
}
// If we get here it means that the user has confirmed the action
// Confirm authorisation code.
if (!pnSecConfirmAuthKey()) {
pnSessionSetVar('errormsg', _FXBADAUTHKEY);
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// The API function is called.
if (pnModAPIFunc('feproc',
'handleradmin',
'delete',
array('hid' => $hid))) {
// Success
pnSessionSetVar('statusmsg', _FXHANDLERDELETED);
}
// 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
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
// Return
return true;
}
/**
* add new item
* This is a standard function that is called whenever an administrator
* wishes to create a new module item
*/
function feproc_handleradmin_new()
{
// For the menu.
if (!pnModLoad('feproc', 'admin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
if (!pnModAPILoad('feproc', 'handleradmin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Create output object.
$output = new pnHTML();
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::Handler', '::', ACCESS_ADD)) {
$output->Text(_FXNOAUTH);
return $output->GetOutput();
}
// Add menu to output.
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(feproc_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Title - putting a title ad the head of each page reminds the user what
// they are doing
$output->Title(_FXADDHANDLER);
// Start form.
$output->FormStart(pnModURL('feproc', 'handleradmin', 'scanmodule'));
// Add an authorisation ID.
$output->FormHidden('authid', pnSecGenAuthKey());
// Start the table that holds the information to be input.
$output->TableStart();
// Get a list of modules on the system
$modules = pnModGetUserMods();
$feprocid = '';
foreach ($modules as $module)
{
$data[] = Array(
'id' => $module['name'],
'name' => $module['displayname'] . ': ' . $module['description']
);
}
$row = array();
$output->SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output->Text(pnVarPrepForDisplay(_FXCHOOSEMODULE));
$row[] = $output->FormSelectMultiple('modulename', $data, 0, 1, 'feproc');
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->TableAddrow($row, 'left');
$output->SetInputMode(_PNH_PARSEINPUT);
$output->TableEnd();
// End form
$output->Linebreak(2);
$output->FormSubmit(_FXSCANMODULE);
$output->FormEnd();
// Return the output that has been generated by this function
return $output->GetOutput();
}
/**
* add new item
* Having chosen a module, scan that module for feproc APIs.
*/
function feproc_handleradmin_scanmodule()
{
// For the menu.
if (!pnModLoad('feproc', 'admin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' admin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Handler admin functions.
if (!pnModAPILoad('feproc', 'handleradmin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' handleradmin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Create output object.
$output = new pnHTML();
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::Handler', '::', ACCESS_ADD)) {
$output->Text(_FXNOAUTH);
return $output->GetOutput();
}
$modulename = pnVarCleanFromInput('modulename');
// Add menu to output.
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(feproc_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Title - putting a title ad the head of each page reminds the user what
// they are doing
$output->Title(_FXADDHANDLER);
// Start form.
$output->FormStart(pnModURL('feproc', 'handleradmin', 'addhandlers'));
// Add an authorisation ID.
$output->FormHidden('authid', pnSecGenAuthKey());
// Start the table that holds the information to be input.
$output->TableStart(_FXCHOOSEHANDLERS,
array(_FXNAME,
_FXDESCRIPTION,
_FXTYPE,
_FXSOURCE,
_FXOPTIONS), 1);
// Scan the module and get the handlers (if any).
$handlers = pnModAPIFunc('feproc',
'handleradmin',
'modulehandlers',
array('modulename' => $modulename));
// Other hidden values to identify the module.
$output->FormHidden('modulename', $modulename);
// Loop for each handler found.
if (is_array($handlers))
{
$output->SetInputMode(_PNH_VERBATIMINPUT);
foreach($handlers as $handler)
{
$row = Array();
$row[] = $handler['name'];
$row[] = $handler['description'];
$row[] = $handler['type'];
$row[] = $handler['source'];
// TODO: this should be a checkbox.
$output->SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output->FormCheckbox('sources[]', false, $handler['source'], 'checkbox') .' '. _FXIMPORTFLAG;
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->TableAddRow($row, 'left');
}
$row = Array('', '', '', _FXSOURCEKEY);
$output->SetOutputMode(_PNH_RETURNOUTPUT);
$row[] = $output->FormCheckbox('allsources', true, '1', 'checkbox') .' '. _FXIMPORTALLFLAG;
$output->SetOutputMode(_PNH_KEEPOUTPUT);
$output->TableAddRow($row, 'left');
$output->SetInputMode(_PNH_PARSEINPUT);
}
$output->TableEnd();
if (!is_array($handlers))
{
// TODO: ml message.
$output->Text(_FXNOHANDLERSINMODULE . $modulename . '"');
}
// End form
$output->Linebreak(2);
$output->FormSubmit(_FXIMPORTHANDLERS);
$output->FormEnd();
// Return the output that has been generated by this function
return $output->GetOutput();
}
/**
* add new item
* Having chosen a module, scanned that module and selected the APIs for importing,
* now do the import.
*/
function feproc_handleradmin_addhandlers()
{
$output = new pnHTML();
// For the menu.
if (!pnModLoad('feproc', 'admin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' admin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Handler admin functions.
if (!pnModAPILoad('feproc', 'handleradmin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' handleradmin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Handler user functions.
if (!pnModAPILoad('feproc', 'handleruser')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' handleradmin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
list($modulename, $sources, $allsources) =
pnVarCleanFromInput('modulename', 'sources', 'allsources');
// Add menu to output.
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Text(feproc_adminmenu());
$output->SetInputMode(_PNH_PARSEINPUT);
// Get the handlers for the module.
$handlers = pnModAPIFunc('feproc',
'handleradmin',
'modulehandlers',
array('modulename' => $modulename));
// $sources will not be set if user did not select any handlers for import.
if (!is_array($sources))
{
$sources = Array();
}
// Loop for the handlers and import the required ones.
if (is_array($handlers))
{
foreach ($handlers as $handler)
{
// If this is one for importing, then do so.
if ($allsources || in_array($handler['source'], $sources))
{
// Yes - import this one.
//$output->Text("$handler[source] ");
$output->Linebreak();
// Get the existing handler, if it exists.
if ($item = pnModAPIFunc('feproc', 'handleruser', 'gethandler',
array('source' => $handler['source'])
))
{
// Already exists: update the handler.
$result = pnModAPIFunc('feproc', 'handleradmin', 'update',
array(
'hid' => $item['hid'],
'name' => $handler['name'],
'description' => $handler['description'],
'type' => $handler['type'],
'version' => $handler['version'],
'modulename' => $handler['module'],
'apiname' => $handler['apiname'],
'apifunc' => $handler['apifunc'],
'attributes' => $handler['attributes']
)
);
if ($result)
{
// TODO: ml strings.
$output->Text("Updated handler: " . $handler['source']);
} else {
$output->Text("Error updating handler: " . $handler['source']);
}
$output->Linebreak();
} else {
$result = pnModAPIFunc('feproc', 'handleradmin', 'create',
array(
'name' => $handler['name'],
'description' => $handler['description'],
'type' => $handler['type'],
'version' => $handler['version'],
'modulename' => $handler['module'],
'apiname' => $handler['apiname'],
'apifunc' => $handler['apifunc'],
'attributes' => $handler['attributes']
)
);
if ($result)
{
// TODO: ml strings.
$output->Text("Inserted handler: " . $handler['source']);
} else {
$output->Text("Error inserting handler: " . $handler['source']);
}
$output->Linebreak();
}
}
}
} else {
// TODO: ml message.
// Module should have been stopped before getting here.
$output->Text(_FXNOHANDLERSINMODULE . $modulename . '"');
}
return $output->GetOutput();
}
/**
* help page for a handler
* Display the help page for a handler.
*/
function feproc_handleradmin_helphandler()
{
$output = new pnHTML();
// Handler user functions.
if (!pnModAPILoad('feproc', 'handleruser')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' handleradmin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
$hid = pnVarCleanFromInput('hid');
if (!isset($hid) || !is_numeric($hid))
{
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
}
// Get the item
$item = pnModAPIFunc(
'feproc', 'handleruser', 'gethandler',
array('hid' => $hid)
);
if (! $item)
{
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
// Now load the API for the item and call the help function.
if (!pnModAPILoad($item['modulename'], $item['apiname'])) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED . ' handleradmin');
pnRedirect(pnModURL('feproc', 'handleradmin', 'view'));
return true;
}
$help = pnModAPIFunc(
$item['modulename'], $item['apiname'], $item['apifunc'],
array('action' => 'help')
);
$info = pnModAPIFunc(
$item['modulename'], $item['apiname'], $item['apifunc'],
array('action' => 'info')
);
if ($help)
{
$output->SetInputMode(_PNH_VERBATIMINPUT);
$output->Title('Handler Help');
$output->Text("<strong>Overview:</strong><br/>");
$output->Text("Handler Type: $item[type]<br/>");
$output->Text("Source Module: $item[modulename]<br/>");
$output->Text("API Name In Module: $item[apiname]<br/>");
$output->Text("Function Name In API: $item[apifunc]<br/>");
if (is_array($info['attributes']))
{
$output->Text("<br/>");
$output->Text("<strong>Function Attributes:</strong>");
$output->Text('<ul>');
foreach ($info['attributes'] as $key => $item)
{
$output->Text('<li>'.pnVarPrepHTMLdisplay("$key ($item[description]) type=$item[type]"));
if ($item['type'] == 'list')
{
$output->Text('<ol>');
foreach($item['list'] as $listitem)
{
if ($listitem == '')
{
$listitem = '<NULL>';
}
$output->Text(pnVarPrepHTMLdisplay("<li>$listitem</li>"));
}
$output->Text('</ol>');
}
$output->Text('</li>');
}
$output->Text('</ul>');
}
$output->Text("<br/>");
$output->Text("<strong>Description:</strong><br/>");
// The help function will format its own HTML, so send output verbatim.
$output->Text($help);
$output->SetInputMode(_PNH_PARSEINPUT);
} else {
// TODO: ml string
$output->Text(_FXHANDLERNOHELP);
}
return $output->GetOutput();
}
?>
--- NEW FILE: pnhandleradminapi.php ---
<?php
// ----------------------------------------------------------------------
// FEproc - Mail template backend module for FormExpress for
// POST-NUKE Content Management System
// Copyright (C) 2002 by Jason Judge
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jason Judge. Based on template by
// Jim MacDonald
// ----------------------------------------------------------------------
/**
* create a new template item
* @param $args['name'] name of the template
* @param $args['description'] description of the template
* @param $args['template'] actual template
* @returns int
* @return template item ID on success, false on failure
*/
function feproc_handleradminapi_create($args)
{
// Get arguments from argument array.
extract($args);
// Argument check - make sure that all required arguments are present,
// if not then set an appropriate error message and return
if (!isset($name) ||
!isset($description) ||
!isset($type) ||
!isset($version) ||
!isset($modulename) ||
!isset($apiname) ||
!isset($apifunc) ||
!isset($attributes))
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "::", ACCESS_ADD)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
$sattributes = serialize($attributes);
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlertable = $pntable['feproc_handlers'];
$handlercolumn = &$pntable['feproc_handlers_column'];
// Get next ID in table - this is required prior to any insert that
// uses a unique ID, and ensures that the ID generation is carried
// out in a database-portable fashion
$nextId = $dbconn->GenId($handlertable);
// Add item.
$sql = "INSERT INTO $handlertable (
$handlercolumn[id],
$handlercolumn[name],
$handlercolumn[description],
$handlercolumn[type],
$handlercolumn[version],
$handlercolumn[modulename],
$handlercolumn[apiname],
$handlercolumn[apifunc],
$handlercolumn[attributes])
VALUES (
$nextId,
'" . pnVarPrepForStore($name) . "',
'" . pnVarPrepForStore($description) . "',
'" . pnVarPrepForStore($type) . "',
'" . pnVarPrepForStore($version) . "',
'" . pnVarPrepForStore($modulename) . "',
'" . pnVarPrepForStore($apiname) . "',
'" . pnVarPrepForStore($apifunc) . "',
'" . pnVarPrepForStore($sattributes) . "')";
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXCREATEFAILED . ' ' . $sql);
return false;
}
// Get the ID of the item that we inserted. It is possible, although
// very unlikely, that this is different from $nextId as obtained
// above, but it is better to be safe than sorry in this situation
$hid = $dbconn->PO_Insert_ID($handlertable, $handlercolumn['id']);
// Let any hooks know that we have created a new item.
// TODO: this is not a standard item
pnModCallHooks('item', 'create', $hid, 'hid');
// Return the id of the newly created item to the calling process
return $hid;
}
/**
* delete a feproc handler item
* @param $args['hid'] ID of the item
* @returns bool
* @return true on success, false on failure
* TODO: don't allow a delete if the handler is being used by any workflow set stages.
*/
function feproc_handleradminapi_delete($args)
{
// Get arguments from argument array.
extract($args);
// Argument check - make sure that all required arguments are present,
// if not then set an appropriate error message and return.
if (!isset($hid)) {
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_DELETE)) {
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
if (!pnModAPILoad('feproc', 'handleruser')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'view'));
return true;
}
// The API function is called. This takes the item ID which
// we obtained from the input and gets us the information on the
// appropriate item. If the item does not exist we post an appropriate
// message and return
$item = pnModAPIFunc('feproc',
'handleruser',
'gethandler',
array('hid' => $hid));
if ($item == false) {
pnSessionSetVar('errormsg', _FXNOSUCHTEMPLATE);
return false;
}
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlertable = $pntable['feproc_handlers'];
$handlercolumn = &$pntable['feproc_handlers_column'];
// Delete the item - the formatting here is not mandatory, but it does
// make the SQL statement relatively easy to read. Also, separating
// out the sql statement from the Execute() command allows for simpler
// debug operation if it is ever needed
$sql = "DELETE FROM $handlertable
WHERE $handlercolumn[id] = " . pnVarPrepForStore($hid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXDELETEFAILED);
return false;
}
// Let any hooks know that we have deleted an item. As this is a
// delete hook we're not passing any extra info
// TODO: distinguish between different types of item.
pnModCallHooks('item', 'delete', $hid, 'hid');
// Let the calling process know that we have finished successfully
return true;
}
/**
* update a template item
* @param $args['hid'] the ID of the item
* @param $args['name'] the new name of the item
* @param $args['description'] the new description of the item
* @param $args['...'] the actual template
* TODO: complete parameter list
*/
function feproc_handleradminapi_update($args)
{
// Get arguments from argument array.
extract($args);
// Argument check - make sure that all required arguments are present,
// if not then set an appropriate error message and return
if (!isset($hid) ||
!isset($name) ||
!isset($description) ||
!isset($type) ||
!isset($version) ||
!isset($modulename) ||
!isset($apiname) ||
!isset($apifunc) ||
!isset($attributes))
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
if (!pnModAPILoad('feproc', 'handleruser'))
{
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
return false;
}
// The API function is called. This takes the item ID which
// we obtained from the input and gets us the information on the
// appropriate item. If the item does not exist we post an appropriate
// message and return
$item = pnModAPIFunc('feproc',
'handleruser',
'gethandler',
array('hid' => $hid));
if ($item == false)
{
pnSessionSetVar('errormsg', _FXNOSUCHTEMPLATE);
return false;
}
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "$hid::", ACCESS_EDIT))
{
pnSessionSetVar('errormsg', _FXNOAUTH);
return false;
}
// The attributes will be an array.
$sattributes = serialize($attributes);
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlertable = $pntable['feproc_handlers'];
$handlercolumn = &$pntable['feproc_handlers_column'];
// Update the item.
$sql = "UPDATE $handlertable
SET $handlercolumn[name] = '" . pnVarPrepForStore($name) . "',
$handlercolumn[description] = '" . pnVarPrepForStore($description) . "',
$handlercolumn[type] = '" . pnVarPrepForStore($type) . "',
$handlercolumn[version] = '" . pnVarPrepForStore($version) . "',
$handlercolumn[modulename] = '" . pnVarPrepForStore($modulename) . "',
$handlercolumn[apiname] = '" . pnVarPrepForStore($apiname) . "',
$handlercolumn[apifunc] = '" . pnVarPrepForStore($apifunc) . "',
$handlercolumn[attributes] = '" . pnVarPrepForStore($sattributes) . "'
WHERE $handlercolumn[id] = " . pnVarPrepForStore($hid);
$dbconn->Execute($sql);
// Check for an error with the database code, and if so set an
// appropriate error message and return
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _FXUPDATEFAILED . ' ' . $sql);
return false;
}
// Let the calling process know that we have finished successfully
return true;
}
/**
* Get a list of APIs for a module.
* TODO: the module may not have any APIs - handle that.
*/
function feproc_handleradminapi_moduleapilist($args)
{
extract($args);
$moduleinfo = pnModGetInfo(pnModGetIDFromName($modulename));
$directory = $moduleinfo['directory'];
$osfile = "modules/$directory/pn*api.php";
$apilist = Array();
$dh = opendir("modules/$directory");
while ($file = readdir($dh))
{
// TODO: are there any rules on the characters in a name? Letter case?
if (ereg('^pn(.+)api.php$', $file, $regs))
{
$apilist[] = Array('modulename' => $modulename, 'apiname' => $regs[1]);
}
}
if (empty($apilist))
{
$apilist = false;
}
return $apilist;
}
/**
* Get a list of fetix handlers for a module.
* $modulename - name of module.
*/
function feproc_handleradminapi_modulehandlers($args)
{
extract($args);
if (!pnModAPILoad('feproc', 'handleradmin')) {
pnSessionSetVar('errormsg', _FXMODLOADFAILED);
pnRedirect(pnModURL('feproc', 'admin', 'view'));
return true;
}
// Get the list of APIs for the module.
// TODO: handle there being no APIs in the module.
$apilist = pnModAPIFunc('feproc',
'handleradmin',
'moduleapilist',
array('modulename' => $modulename));
if (!$apilist)
{
return false;
}
$handlerlist = Array();
// Loop for each API and hunt for handlers.
foreach($apilist as $api)
{
$apimodule = $api['modulename'];
$apiname = $api['apiname'];
if (pnModAPILoad($apimodule, $apiname))
{
// The API has loaded okay.
// Load a list of fetix handlers, if any.
if ($handlerindex = pnModAPIFunc($apimodule, $apiname, 'feprochandlerindex'))
{
// There is a feproc handler here. Grab the details.
// Store the info details in the result array.
// Now get the details for each handler in turn.
foreach($handlerindex as $handler)
{
$info = Array();
// Load the API handler function and get its info.
if ($info = pnModAPIFunc($apimodule, $apiname, $handler['apifunc'], Array('action' => 'info')))
{
// Add a few more fields.
$info['module'] = $apimodule;
$info['apiname'] = $apiname;
$info['apifunc'] = $handler['apifunc'];
$info['source'] = $info['type'] .':'. $apimodule .':'. $apiname .':'. $handler['apifunc'];
// Store the handler in the array.
$handlerlist[] = $info;
}
}
}
}
}
if (empty($handlerlist))
{
$handlerlist = false;
}
return $handlerlist;
}
?>
--- NEW FILE: pnhandleruserapi.php ---
<?php
// ----------------------------------------------------------------------
// FEproc - Mail template backend module for FormExpress for
// POST-NUKE Content Management System
// Copyright (C) 2002 by Jason Judge
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WIthOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jason Judge. Based on template by
// Jim MacDonald
// ----------------------------------------------------------------------
/**
* Count the number of handlers available.
* @returns int
* @return number of handlers available.
*/
function feproc_handleruserapi_counthandlers()
{
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', '::', ACCESS_READ))
{
return false;
}
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlerTable = $pntable['feproc_handlers'];
$handlerColumn = $pntable['feproc_handlers_column'];
$sql = "SELECT COUNT(*)
FROM $handlerTable";
$result = $dbconn->Execute($sql);
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($dbconn->ErrorNo() != 0)
{
pnSessionSetVar('errormsg', _FXGETFAILED);
return false;
}
list($count) = $result->fields;
// Close result set.
$result->Close();
return $count;
}
/**
* Get handler specification
* The input parameters 'hid' and 'hname' are mutualy exclusive - use only
* one of them (either hid or name).
* @param args['hid'] handler id
* @param args['hname'] handler name
* @returns associative array
* (id,name,description,TODO)
* @return handler specification
*/
function feproc_handleruserapi_gethandler($args)
{
// Get arguments from argument array.
extract($args);
// Argument check - make sure that all required arguments are present,
// if not then set an appropriate error message and return
if (!isset($hid) && !isset($name) && !isset($source))
{
pnSessionSetVar('errormsg', _FXMODARGSERROR);
return false;
}
// Get database setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlerTable = $pntable['feproc_handlers'];
$handlerColumn = $pntable['feproc_handlers_column'];
if (isset($hid))
{
$where = "$handlerColumn[id] = " . pnVarPrepForStore($hid) . "";
}
elseif (isset($name))
{
$where = "$handlerColumn[name] = '" . pnVarPrepForStore($name) . "'";
}
elseif (isset($source))
{
list($type, $modulename, $apiname, $apifunc) = split(':', $source, 4);
$where = "$handlerColumn[type] = '" . pnVarPrepForStore($type) . "'"
. " and $handlerColumn[modulename] = '" . pnVarPrepForStore($modulename) . "'"
. " and $handlerColumn[apiname] = '" . pnVarPrepForStore($apiname) . "'"
. " and $handlerColumn[apifunc] = '" . pnVarPrepForStore($apifunc) . "'"
;
}
$sql = "SELECT $handlerColumn[id],
$handlerColumn[name],
$handlerColumn[description],
$handlerColumn[type],
$handlerColumn[version],
$handlerColumn[modulename],
$handlerColumn[apiname],
$handlerColumn[apifunc],
$handlerColumn[attributes]
FROM $handlerTable
WHERE $where";
$result = $dbconn->Execute($sql);
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($dbconn->ErrorNo() != 0)
{
pnSessionSetVar('errormsg', _FXGETFAILED);
return false;
}
if ($result->EOF)
{
$handler = false;
} else {
$handler = array( 'hid' => $result->fields[0],
'name' => $result->fields[1],
'description' => $result->fields[2],
'type' => $result->fields[3],
'version' => $result->fields[4],
'modulename' => $result->fields[5],
'apiname' => $result->fields[6],
'apifunc' => $result->fields[7],
'attributes' => unserialize($result->fields[8]),
'source' => $result->fields[3] .':'. $result->fields[5] .':'. $result->fields[6] .':'. $result->fields[7]);
}
// Close result set.
$result->Close();
return $handler;
}
/**
* Get list of all handlers
* @param $args['startnum'] first handler number (starting from 1)
* @param $args['numitems'] number of handlers
* @returns array of associative arrays
* (id,name,description,type)
* @return array of all handlers
*/
function feproc_handleruserapi_getallhandlers($args)
{
// Get arguments from argument array.
extract($args);
// Argument check
if (!isset($startnum))
{
$startnum = 0;
} else {
--$startnum;
}
if (!isset($numitems))
{
$numitems = 999999;
}
$handlers = array();
// Early security check.
if (!pnSecAuthAction(0, 'FEproc::', "::", ACCESS_READ))
{
return $handlers;
}
// Get datbase setup.
list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$handlerTable = $pntable['feproc_handlers'];
$handlerColumn = $pntable['feproc_handlers_column'];
$where = "1=1";
if ($type)
{
$where .= " AND $handlerColumn[type] = '" . pnVarPrepForStore($type) . "'";
}
$sql = buildsimplequery('feproc_handlers',
array('id','name','description','type','modulename','apiname','apifunc'),
$where,
"$handlerColumn[name]",
$numitems,
$startnum);
$result = $dbcView 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 |