Zikula_System_Modules
[ class tree: Zikula_System_Modules ] [ index: Zikula_System_Modules ] [ all elements ]

Source for file pnadmin.php

Documentation is available at pnadmin.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2002, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: pnadmin.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_System_Modules
  10.  * @subpackage Admin
  11.  */
  12.  
  13. /**
  14.  * the main administration function
  15.  * This function is the default function, and is called whenever the
  16.  * module is initiated without defining arguments.  As such it can
  17.  * be used for a number of things, but most commonly it either just
  18.  * shows the module menu and returns or calls whatever the module
  19.  * designer feels should be the default function (often this is the
  20.  * view() function)
  21.  * @author Mark West
  22.  * @return string HTML string
  23.  */
  24. function Admin_admin_main()
  25. {
  26.     return Admin_admin_view();
  27. }
  28.  
  29. /**
  30.  * Add a new admin category
  31.  * This is a standard function that is called whenever an administrator
  32.  * wishes to create a new module item
  33.  * @author Mark West
  34.  * @return string HTML string
  35.  */
  36. function Admin_admin_new()
  37. {
  38.     if (!SecurityUtil::checkPermission('Admin::Item''::'ACCESS_ADD)) {
  39.         return LogUtil::registerError(_MODULENOAUTH403);
  40.     }
  41.  
  42.     $pnRender pnRender::getInstance('Admin'false);
  43.  
  44.     // Return the output that has been generated by this function
  45.     return $pnRender->fetch('admin_admin_new.htm');
  46. }
  47.  
  48. /**
  49.  * This is a standard function that is called with the results of the
  50.  * form supplied by admin_admin_new() to create a new category
  51.  * @author Mark West
  52.  * @see Admin_admin_new()
  53.  * @param string $args['catname'] the name of the category to be created
  54.  * @param string $args['description'] the description of the category to be created
  55.  * @return mixed category id if create successful, false otherwise
  56.  */
  57. function Admin_admin_create($args)
  58. {
  59.     $category FormUtil::getPassedValue('category'isset($args['category']$args['category'null'POST');
  60.  
  61.     if (!SecurityUtil::confirmAuthKey()) {
  62.         return LogUtil::registerAuthidError (pnModURL('Admin''admin''view'));
  63.     }
  64.  
  65.     $cid pnModAPIFunc('Admin''admin''create',
  66.                         array('catname' => $category['catname'],
  67.                               'description' => $category['description']));
  68.  
  69.     if ($cid != false{
  70.         // Success
  71.         LogUtil::registerStatus (pnML('_CREATEITEMSUCCEDED'array('i' => _CATEGORY)));
  72.     }
  73.  
  74.     return pnRedirect(pnModURL('Admin''admin''view'));
  75. }
  76.  
  77. /**
  78.  * Modify a category
  79.  * This is a standard function that is called whenever an administrator
  80.  * wishes to modify an admin category
  81.  * @author Mark West
  82.  * @param int $args['cid'] category id
  83.  * @param int $args['objectid'] generic object id maps to cid if present
  84.  * @return string HTML string
  85.  */
  86. function Admin_admin_modify($args)
  87. {
  88.     $cid FormUtil::getPassedValue('cid'isset($args['cid']$args['cid'null'GET');
  89.     $objectid FormUtil::getPassedValue('objectid'isset($args['objectid']$args['objectid'null'GET');
  90.  
  91.     if (!empty($objectid)) {
  92.         $cid $objectid;
  93.     }
  94.  
  95.     $pnRender pnRender::getInstance('Admin'false);
  96.  
  97.     $item pnModAPIFunc('Admin''admin''get'array('cid' => $cid));
  98.  
  99.     if ($item == false{
  100.         return LogUtil::registerError(pnML('_NOSUCHITEMFOUND'array('i' => _CATEGORY))404);
  101.     }
  102.  
  103.     if (!SecurityUtil::checkPermission('Admin::Category'"$item[catname]::$cid"ACCESS_EDIT)) {
  104.         return LogUtil::registerError(_MODULENOAUTH403);
  105.     }
  106.  
  107.     $pnRender->assign($item);
  108.     return $pnRender->fetch('admin_admin_modify.htm');
  109. }
  110.  
  111. /**
  112.  * This is a standard function that is called with the results of the
  113.  * form supplied by template_admin_modify() to update a current item
  114.  * @author Mark West
  115.  * @see Admin_admin_modify()
  116.  * @param int $args['cid'] the id of the item to be updated
  117.  * @param int $args['objectid'] generic object id maps to cid if present
  118.  * @param string $args['catname'] the name of the category to be updated
  119.  * @param string $args['description'] the description of the item to be updated
  120.  * @return bool true if update successful, false otherwise
  121.  */
  122. function Admin_admin_update($args)
  123. {
  124.     $category FormUtil::getPassedValue('category'isset($args['category']$args['category'null'POST');
  125.     if (!empty($category['objectid'])) {
  126.         $category['cid'$category['objectid'];
  127.     }
  128.  
  129.     if (!SecurityUtil::confirmAuthKey()) {
  130.         return LogUtil::registerAuthidError (pnModURL('Admin''admin''view'));
  131.     }
  132.  
  133.     if (pnModAPIFunc('Admin''admin''update',
  134.                     array('cid' => $category['cid'],
  135.                           'catname' => $category['catname'],
  136.                           'description' => $category['description']))) {
  137.         // Success
  138.         LogUtil::registerStatus (pnML('_UPDATEITEMSUCCEDED'array('i' => _CATEGORY)));
  139.     }
  140.  
  141.     return pnRedirect(pnModURL('Admin''admin''view'));
  142. }
  143.  
  144. /**
  145.  * delete item
  146.  * This is a standard function that is called whenever an administrator
  147.  * wishes to delete a current module item.  Note that this function is
  148.  * the equivalent of both of the modify() and update() functions above as
  149.  * it both creates a form and processes its output.  This is fine for
  150.  * simpler functions, but for more complex operations such as creation and
  151.  * modification it is generally easier to separate them into separate
  152.  * functions.  There is no requirement in the Zikula MDG to do one or the
  153.  * other, so either or both can be used as seen appropriate by the module
  154.  * developer
  155.  * @author Mark West
  156.  * @param int $args['cid'] the id of the category to be deleted
  157.  * @param int $args['objectid'] generic object id maps to cid if present
  158.  * @param bool $args['confirmation'] confirmation that this item can be deleted
  159.  * @return mixed HTML string if confirmation is null, true if delete successful, false otherwise
  160.  */
  161. function Admin_admin_delete($args)
  162. {
  163.     $cid FormUtil::getPassedValue('cid'isset($args['cid']$args['cid'null'REQUEST');
  164.     $objectid FormUtil::getPassedValue('objectid'isset($args['objectid']$args['objectid'null'REQUEST');
  165.     $confirmation FormUtil::getPassedValue('confirmation'null'POST');
  166.      if (!empty($objectid)) {
  167.          $cid $objectid;
  168.      }
  169.  
  170.     $item pnModAPIFunc('Admin''admin''get'array('cid' => $cid));
  171.  
  172.     if ($item == false{
  173.         return LogUtil::registerError(pnML('_NOSUCHITEMFOUND'array('i' => _CATEGORY))404);
  174.     }
  175.  
  176.     if (!SecurityUtil::checkPermission('Admin::Category'"$item[catname]::$cid"ACCESS_DELETE)) {
  177.         return LogUtil::registerError(_MODULENOAUTH403);
  178.     }
  179.  
  180.     // Check for confirmation.
  181.     if (empty($confirmation)) {
  182.         // No confirmation yet - display a suitable form to obtain confirmation
  183.         // of this action from the user
  184.         $pnRender pnRender::getInstance('Admin'false);
  185.         $pnRender->assign('cid'$cid);
  186.         return $pnRender->fetch('admin_admin_delete.htm');
  187.     }
  188.  
  189.     if (!SecurityUtil::confirmAuthKey()) {
  190.         return LogUtil::registerAuthidError (pnModURL('Admin''admin''view'));
  191.     }
  192.  
  193.     if (pnModAPIFunc('Admin''admin''delete'array('cid' => $cid))) {
  194.         // Success
  195.         LogUtil::registerStatus (pnML('_DELETEITEMSUCCEDED'array('i' => _CATEGORY)));
  196.     }
  197.  
  198.     return pnRedirect(pnModURL('Admin''admin''view'));
  199. }
  200.  
  201. /**
  202.  * View all admin categories
  203.  * @author Mark West
  204.  * @param int $startnum the starting id to view from - optional
  205.  * @return string HTML string
  206.  */
  207. function Admin_admin_view($args array())
  208. {
  209.     if (!SecurityUtil::checkPermission('Admin::''::'ACCESS_EDIT)) {
  210.         return LogUtil::registerError(_MODULENOAUTH403);
  211.     }
  212.  
  213.     $startnum FormUtil::getPassedValue('startnum'isset($args['startnum']$args['startnum'null'GET');
  214.  
  215.     $pnRender pnRender::getInstance('Admin'false);
  216.  
  217.     $items pnModAPIFunc('Admin''admin''getall',
  218.                            array('startnum' => $startnum,
  219.                                  'numitems' => pnModGetVar('Admin''itemsperpage')));
  220.     $rows array();
  221.     foreach ($items as $item{
  222.         if (SecurityUtil::checkPermission('Admin::'"$item[catname]::$item[cid]"ACCESS_READ)) {
  223.             // Options for the item.
  224.             $options array();
  225.             if (SecurityUtil::checkPermission('Admin::'"$item[catname]::$item[cid]"ACCESS_EDIT)) {
  226.                 $options[array('url' => pnModURL('Admin''admin''modify'array('cid' => $item['cid'])),
  227.                                    'image' => 'xedit.gif',
  228.                                    'title' => _EDIT);
  229.                 if (SecurityUtil::checkPermission('Admin::'"$item[catname]::$item[cid]"ACCESS_DELETE)) {
  230.                     $options[array('url' => pnModURL('Admin''admin''delete'array('cid' => $item['cid'])),
  231.                                        'image' => '14_layer_deletelayer.gif',
  232.                                        'title' => _DELETE);
  233.                 }
  234.             }
  235.             $item['options'$options;
  236.             $rows[$item;
  237.         }
  238.     }
  239.     $pnRender->assign('items'$rows);
  240.  
  241.     $pnRender->assign('pager'array('numitems' => pnModAPIFunc('Admin''admin''countitems'),
  242.                                      'itemsperpage' => pnModGetVar('Admin''itemsperpage')));
  243.     // Return the output that has been generated by this function
  244.     return $pnRender->fetch('admin_admin_view.htm');
  245. }
  246.  
  247. /**
  248.  * Display main admin panel for a category
  249.  * @author Mark West
  250.  * @param int $args['acid'] the id of the category to be displayed
  251.  * @return string HTML string
  252.  */
  253. function Admin_admin_adminpanel($args)
  254. {
  255.     if (!SecurityUtil::checkPermission('::''::'ACCESS_EDIT)) {
  256.         // suppress admin display - return to index.
  257.         return pnRedirect(pnConfigGetVar('entrypoint''index.php'));
  258.     }
  259.  
  260.     // Create output object
  261.     $pnRender pnRender::getInstance('Admin'false);
  262.  
  263.     if (!pnModGetVar('Admin''ignoreinstallercheck'&& pnConfigGetVar('development'== 0{
  264.         // check if install.php or install folder exist
  265.         $installexists file_exists('install.php'|| file_exists('install');
  266.         // check if the Zikula Swiss Army Knife exists
  267.         $psakexists file_exists('psak.php');
  268.         // if either one them is true we show a warning and do not let the admin go to
  269.         // the admin panel
  270.         if ($installexists==true || $psakexists==true{
  271.             $pnRender->assign('installexists'$installexists);
  272.             $pnRender->assign('psakexists'$psakexists);
  273.             $pnRender->assign('adminpanellink'pnModURL('Admin','admin''adminpanel'));
  274.             return $pnRender->fetch('admin_admin_warning.htm');
  275.         }
  276.     }
  277.  
  278.     // Now prepare the display of the admin panel by getting the relevant info.
  279.  
  280.     // Get parameters from whatever input we need.
  281.     $acid FormUtil::getPassedValue('acid'(isset($args['acid']$args['acid'null)'GET');
  282.  
  283.     // cid isn't set, so we check the last session var lastcid to see where the admin has been before.
  284.     if (empty($acid)) {
  285.         $acid SessionUtil::getVar('lastacid');
  286.         if (empty($acid)) {
  287.             // cid is still not set, go to the default category
  288.             $acid pnModGetVar('Admin''startcategory');
  289.         }
  290.     }
  291.  
  292.     // now we know where we are or where the admin wants us to go to, lets store it in a
  293.     // session var for later use
  294.     SessionUtil::setVar('lastacid'$acid);
  295.  
  296.     // Add category menu to output
  297.     $pnRender->assign('menu'Admin_admin_categorymenu(array('acid' => $acid)));
  298.  
  299.     // Admin_admin_categorymenu may have changed the acid. In this case it has been
  300.     // stored to lastacid so we need to read it again now
  301.     $acid SessionUtil::getVar('lastacid');
  302.  
  303.     // Handle the case where the current/default category does not contain any accessible items
  304.     // (the current user may just have admin access to a single module)
  305.     if (empty($acid)) {
  306.         $acid pnModGetVar('Admin''startcategory');
  307.     }
  308.  
  309.     // Get Datails on the selected category
  310.     $category pnModAPIFunc('Admin''admin''get',
  311.                               array('cid' => $acid));
  312.  
  313.     if (!$category{
  314.         // get the default category
  315.         $acid pnModGetVar('Admin''startcategory');
  316.         $category pnModAPIFunc('Admin''admin''get',
  317.                                   array('cid' => $acid));
  318.     }
  319.  
  320.     // assign the category
  321.     $pnRender->assign('category'$category);
  322.  
  323.     // assign all module vars
  324.     $pnRender->assign(pnModGetVar('Admin'));
  325.  
  326.     // get admin capable modules
  327.     $adminmodules pnModGetAdminMods();
  328.     $adminlinks array();
  329.     foreach ($adminmodules as $adminmodule{
  330.         if (SecurityUtil::checkPermission("$adminmodule[name]::"'::'ACCESS_EDIT)) {
  331.             $catid pnModAPIFunc('Admin''admin''getmodcategory',
  332.                                   array('mid' => pnModGetIDFromName($adminmodule['name'])));
  333.             if (($catid == $acid|| (($catid == false&& ($acid == pnModGetVar('Admin''defaultcategory')))) {
  334.                 $modinfo pnModGetInfo(pnModGetIDFromName($adminmodule['name']));
  335.                 if ($modinfo['type'== || $modinfo['type'== 3{
  336.                     $menutexturl pnModURL($modinfo['name']'admin');
  337.                     $menutext $modinfo['displayname'];
  338.                     $menutexttitle $modinfo['description'];
  339.                     $modpath ($modinfo['type'== 3'system' 'modules';
  340.                 else {
  341.                     $menutexturl 'admin.php?module=' $modinfo['name'];
  342.                     $menutext $modinfo['displayname'];
  343.                     $menutexttitle =  $modinfo['description'];
  344.                     $modpath 'modules';
  345.                 }
  346.                 $osmoddir DataUtil::formatForOS($modinfo['directory']);
  347.                 $adminicons array($modpath '/' $osmoddir '/pnimages/admin.gif'
  348.                                     $modpath '/' $osmoddir '/pnimages/admin.jpg',
  349.                                     $modpath '/' $osmoddir '/pnimages/admin.jpeg',
  350.                                     $modpath '/' $osmoddir '/pnimages/admin.png',
  351.                                     $modpath '/' $osmoddir '/images/admin.gif'
  352.                                     'system/Admin/pnimages/default.gif');
  353.                 foreach($adminicons as $adminicon{
  354.                     if(file_exists($adminicon&& is_readable($adminicon)) {
  355.                         break;
  356.                     }
  357.                 }
  358.                 $adminlinks[array('menutexturl' => $menutexturl,
  359.                                       'menutext' => $menutext,
  360.                                       'menutexttitle' => $menutexttitle,
  361.                                       'modname' => $modinfo['name'],
  362.                                       'adminicon' => $adminicon);
  363.             }
  364.         }
  365.     }
  366.     $pnRender->assign('adminlinks'$adminlinks);
  367.  
  368.     // work out what stylesheet is being used to render to the admin panel
  369.     $css pnModGetVar('Admin''modulestylesheet');
  370.     $cssfile explode('.'$css);
  371.  
  372.     // Return the output that has been generated by this function
  373.     if ($pnRender->template_exists('admin_admin_adminpanel_'.$cssfile[0].'.htm')) {
  374.         return $pnRender->fetch('admin_admin_adminpanel_'.$cssfile[0].'.htm');
  375.     else {
  376.         return $pnRender->fetch('admin_admin_adminpanel.htm');
  377.     }
  378. }
  379.  
  380. /**
  381.  * This is a standard function to modify the configuration parameters of the
  382.  * module
  383.  * @author Mark West
  384.  * @return string HTML string
  385.  */
  386. {
  387.     if (!SecurityUtil::checkPermission('Admin::''::'ACCESS_ADMIN)) {
  388.         return LogUtil::registerError(_MODULENOAUTH403);
  389.     }
  390.  
  391.     // Create output object
  392.     $pnRender pnRender::getInstance('Admin'false);
  393.  
  394.     // get admin capable mods
  395.     $adminmodules pnModGetAdminMods();
  396.  
  397.     // Get all categories
  398.     $categories pnModAPIFunc('Admin''admin''getall');
  399.     $pnRender->assign('categories'$categories);
  400.  
  401.     // assign all the module vars
  402.     $pnRender->assign(pnModGetVar('Admin'));
  403.  
  404.     $modulecatories array();
  405.     foreach ($adminmodules as $adminmodule{
  406.         // Get the category assigned to this module
  407.         $category pnModAPIFunc('Admin''admin''getmodcategory',
  408.                                   array('mid' => pnModGetIDFromName($adminmodule['name'])));
  409.  
  410.         if ($category === false{
  411.             // it's not set, so we use the default category
  412.             $category pnModGetVar('Admin''defaultcategory');
  413.         }
  414.         // output module category selection
  415.         $modulecategories[array('displayname' => $adminmodule['displayname'],
  416.                                     'name' => $adminmodule['name'],
  417.                                     'category' => $category);
  418.     }
  419.     $pnRender->assign('modulecategories'$modulecategories);
  420.     // Return the output that has been generated by this function
  421.     return $pnRender->fetch('admin_admin_modifyconfig.htm');
  422. }
  423.  
  424. /**
  425.  * This is a standard function to update the configuration parameters of the
  426.  * module given the information passed back by the modification form
  427.  * @author Mark West
  428.  * @see Admin_admin_modifyconfig()
  429.  * @param int $modulesperrow the number of modules to display per row in the admin panel
  430.  * @param int $admingraphic switch for display of admin icons
  431.  * @param int $modulename,... the id of the category to set for each module
  432.  * @return string HTML string
  433.  */
  434. {
  435.     if (!SecurityUtil::checkPermission('Admin::''::'ACCESS_ADMIN)) {
  436.         return LogUtil::registerError(_MODULENOAUTH403);
  437.     }
  438.  
  439.     if (!SecurityUtil::confirmAuthKey()) {
  440.         return LogUtil::registerAuthidError (pnModURL('Admin''admin''view'));
  441.     }
  442.  
  443.     // set modules per row module var
  444.     $modulesperrow FormUtil::getPassedValue('modulesperrow'5'POST');
  445.     if (!is_numeric($modulesperrow)) {
  446.         LogUtil::registerError (pnML('_MUSTBENUMERIC'array('s' => _ADMIN_MODULESPERROW)));
  447.     else {
  448.         pnModSetVar('Admin''modulesperrow'$modulesperrow);
  449.     }
  450.  
  451.     // set the ignore installer check module var
  452.     $ignoreinstallercheck FormUtil::getPassedValue('ignoreinstallercheck'false'POST');
  453.     pnModSetVar('Admin''ignoreinstallercheck'$ignoreinstallercheck);
  454.  
  455.     // set modules per row module var
  456.     $itemsperpage FormUtil::getPassedValue('itemsperpage'5'POST');
  457.     if (!is_numeric($itemsperpage)) {
  458.         LogUtil::registerError (pnML('_MUSTBENUMERIC'array('s' => _ADMIN_MODULESPERPAGE)));
  459.     else {
  460.         pnModSetVar('Admin''itemsperpage'$itemsperpage);
  461.     }
  462.  
  463.     // set stylesheet to render module
  464.     $modulestylesheet FormUtil::getPassedValue('modulestylesheet''navtabs.css''POST');
  465.     pnModSetVar('Admin''modulestylesheet'$modulestylesheet);
  466.  
  467.     // set admin icons config var (should be moved to module var at some point)
  468.     $admingraphic FormUtil::getPassedValue('admingraphic'0'POST');
  469.     pnModSetVar('Admin''admingraphic'$admingraphic);
  470.  
  471.     // set start category module var
  472.     $startcategory FormUtil::getPassedValue('startcategory'1'POST');
  473.     pnModSetVar('Admin''startcategory'$startcategory);
  474.  
  475.     // set default category module var
  476.     $defaultcategory FormUtil::getPassedValue('defaultcategory'1'POST');
  477.     pnModSetVar('Admin''defaultcategory'$defaultcategory);
  478.  
  479.     // set the admin theme module var
  480.     $admintheme FormUtil::getPassedValue('admintheme'null'POST');
  481.     pnModSetVar('Admin''admintheme'$admintheme);
  482.  
  483.     // get admin modules
  484.     $adminmodules pnModGetAdminMods();
  485.  
  486.     foreach ($adminmodules as $adminmodule{
  487.         $category FormUtil::getPassedValue($adminmodule['name']null'POST');
  488.  
  489.         if ($category{
  490.             // Add the module to the category
  491.             $result pnModAPIFunc('Admin''admin''addmodtocategory',
  492.                                    array('module' => $adminmodule['name'],
  493.                                          'category' => $category));
  494.             if ($result == false{
  495.                 LogUtil::registerError (_ADMIN_FAILEDADDMODTOCAT);
  496.                 return pnRedirect(pnModURL('Admin''admin''view'));
  497.             }
  498.         }
  499.     }
  500.  
  501.     // Let any other modules know that the modules configuration has been updated
  502.     pnModCallHooks('module','updateconfig','Admin'array('module' => 'Admin'));
  503.  
  504.     // the module configuration has been updated successfuly
  505.  
  506.     // This function generated no output, and so now it is complete we redirect
  507.     // the user to an appropriate page for them to carry on their work
  508.     return pnRedirect(pnModURL('Admin''admin''main'));
  509. }
  510.  
  511. /**
  512.  * Main category menu
  513.  * @author Mark West
  514.  * @return string HTML string
  515.  */
  516. function Admin_admin_categorymenu($args)
  517. {
  518.     $pnRender pnRender::getInstance('Admin'false);
  519.  
  520.     // get the current category
  521.     $acid FormUtil::getPassedValue('acid'isset($args['acid']$args['acid'SessionUtil::getVar('lastacid')'GET');
  522.     if (empty($acid)) {
  523.         // cid is still not set, go to the default category
  524.         $acid pnModGetVar('Admin''startcategory');
  525.     }
  526.  
  527.     // Get all categories
  528.     $items pnModAPIFunc('Admin''admin''getall');
  529.  
  530.     // get admin capable modules
  531.     $adminmodules pnModGetAdminMods();
  532.     $adminlinks array();
  533.  
  534.     foreach ($adminmodules as $adminmodule{
  535.         if (SecurityUtil::checkPermission("$adminmodule[name]::"'::'ACCESS_EDIT)) {
  536.             $catid pnModAPIFunc('Admin''admin''getmodcategory'array('mid' => $adminmodule['id']));
  537.             if ($adminmodule['type'== || $adminmodule['type'== 3{
  538.                 $menutexturl pnModURL($adminmodule['name']'admin');
  539.                 $menutext $adminmodule['displayname'];
  540.                 $menutexttitle $adminmodule['description'];
  541.             else {
  542.                 $menutexturl 'admin.php?module=' $adminmodule['name'];
  543.                 $menutext $adminmodule['displayname'];
  544.                 $menutexttitle =  $adminmodule['description'];
  545.             }
  546.             $adminlinks[$catid][array('menutexturl' => $menutexturl,
  547.                                           'menutext' => $menutext,
  548.                                           'menutexttitle' => $menutexttitle,
  549.                                           'modname' => $adminmodule['name']);
  550.         }
  551.     }
  552.  
  553.     $menuoptions array();
  554.     $possible_cids array();
  555.     $permission false;
  556.  
  557.     if (isset($items&& is_array($items)) {
  558.         foreach($items as $item{
  559.             // only categories containing modules where the current user has permissions will
  560.             // be shown, all others will be hidden
  561.             // admin will see all categories
  562.             if ( (isset($adminlinks[$item['cid']]&& count($adminlinks[$item['cid']]) )
  563.                 || SecurityUtil::checkPermission('.*''.*'ACCESS_ADMIN) ) {
  564.                 $menuoption array('url'         => pnModURL('Admin','admin','adminpanel'array('acid' => $item['cid'])),
  565.                                     'title'       => $item['catname'],
  566.                                     'description' => $item['description'],
  567.                                     'cid'         => $item['cid']);
  568.                 if (isset($adminlinks[$item['cid']])) {
  569.                     $menuoption['items'$adminlinks[$item['cid']];
  570.                 else {
  571.                     $menuoption['items'array();
  572.                 }
  573.                 $menuoptions[$menuoption;
  574.                 $possible_cids[$item['cid'];
  575.                 if ($acid==$item['cid']{
  576.                     $permission =true;
  577.                 }
  578.             }
  579.         }
  580.     }
  581.  
  582.     // if permission is false we are not allowed to see this category because its
  583.     // empty and we are not admin
  584.     if ($permission==false{
  585.         // show the first category
  586.         $acid = (int)$possible_cids[0];
  587.     }
  588.     // store it
  589.     SessionUtil::setVar('lastcid'$acid);
  590.  
  591.     $pnRender->assign('currentcat'$acid);
  592.     $pnRender->assign('menuoptions'$menuoptions);
  593.  
  594.     // zikula baseline security analyzer
  595.     // check for magic_quotes
  596.     $pnRender->assign('magic_quotes_gpc'DataUtil::getBooleanIniValue('magic_quotes_gpc'));
  597.  
  598.     // check for register_globals
  599.     $pnRender->assign('register_globals'DataUtil::getBooleanIniValue('register_globals'));
  600.  
  601.     // check for config.php beeing writable
  602.     // cannot rely on is_writable() because it falsely reports a number of cases - drak
  603.     $config_php @fopen('config/config.php''a');
  604.     if ($config_php === true{
  605.         fclose($config_php);
  606.     }
  607.     $pnRender->assign('config_php'(bool)$config_php);
  608.  
  609.     // check for upgrade.php
  610.     $upgrade_php = (bool) file_exists('upgrade.php');
  611.     $pnRender->assign('upgrade_php'$upgrade_php);
  612.  
  613.     // check for legacy mode
  614.     $legacy_mode = (bool) pnConfigGetVar('loadlegacy');
  615.     $pnRender->assign('legacy_mode'$legacy_mode);
  616.  
  617.     // check for .htaccess in /pnTemp
  618.     if ($GLOBALS['PNConfig']['System']['temp']{
  619.           // default installation, check for .htaccess
  620.         $pntemp_htaccess = (bool) file_exists($GLOBALS['PNConfig']['System']['temp'].'/.htaccess');
  621.     else {
  622.           // already customized, admin should know about what he's doing...
  623.           $pntemp_htaccess true;
  624.     }
  625.     $pnRender->assign('pntemp_htaccess'$pntemp_htaccess);
  626.  
  627.     // check for anticracker
  628.     $scactive = (bool) pnModAvailable('SecurityCenter');
  629.     $scenabled = (bool) pnConfigGetVar('enableanticracker');
  630.     $pnRender->assign('scactive'$scactive);
  631.     $pnRender->assign('scenabled'$scenabled);
  632.  
  633.     // check for safehtml outputfilter
  634.     $safehtml = (bool) (pnModAvailable('SecurityCenter'&& pnConfigGetVar('outputfilter'== 1);
  635.     $pnRender->assign('safehtml'$safehtml);
  636.  
  637.     // work out what stylesheet is being used to render to the admin panel
  638.     $css pnModGetVar('Admin''modulestylesheet');
  639.     $cssfile explode('.'$css);
  640.  
  641.     // Return the output that has been generated by this function
  642.     if ($pnRender->template_exists('admin_admin_categorymenu_'.$cssfile[0].'.htm')) {
  643.         return $pnRender->fetch('admin_admin_categorymenu_'.$cssfile[0].'.htm');
  644.     else {
  645.         return $pnRender->fetch('admin_admin_categorymenu.htm');
  646.     }
  647. }
  648.  
  649. /**
  650.  * display the module help page
  651.  *
  652.  */
  653. function Admin_admin_help()
  654. {
  655.     if (!SecurityUtil::checkPermission('Admin::''::'ACCESS_ADMIN)) {
  656.         return LogUtil::registerError(_MODULENOAUTH403);
  657.     }
  658.     $pnRender pnRender::getInstance('Admin'false);
  659.     return $pnRender->fetch('admin_admin_help.htm');
  660. }

Documentation generated on Fri, 18 Jul 2008 21:51:04 +0200 by phpDocumentor 1.4.1