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

Source for file pnuser.php

Documentation is available at pnuser.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: pnuser.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Value_Addons
  10.  * @subpackage Credits
  11.  */
  12.  
  13. /**
  14.  * Credits_user_list
  15.  *
  16.  * Lists Information and Credits for all User Modules.
  17.  * @author Rob Brandt
  18.  * @return HTML output string
  19.  */
  20. function credits_user_main()
  21. {
  22.     // Security Check
  23.     if (!SecurityUtil::checkPermission('Credits::''::'ACCESS_READ)) {
  24.         return LogUtil::registerPermissionError();
  25.     }
  26.  
  27.     // Define the cache id
  28.     if (SecurityUtil::checkPermission('::''::'ACCESS_ADMIN)) {
  29.         $cacheid 0;
  30.     else {
  31.         $cacheid 1;
  32.     }
  33.  
  34.     // Create output object
  35.     $pnRender pnRender::getInstance('Credits');
  36.  
  37.     // define the cache id
  38.     $pnRender->cache_id $cacheid;
  39.  
  40.     // check out if the contents are cached.
  41.     // If this is the case, we do not need to make DB queries.
  42.     if ($pnRender->is_cached('credits_user_main.htm')) {
  43.        return $pnRender->fetch('credits_user_main.htm');
  44.     }
  45.  
  46.     // define array of filetypes for future use
  47.     $filetypes DataUtil::formatForOS(array('credits''help''changelog''license'));
  48.  
  49.     // If the user is site admin then get all modules including admin only modules
  50.     if (SecurityUtil::checkPermission('::''::'ACCESS_ADMIN)) {
  51.         $modules pnModGetAllMods();
  52.         $cacheid 0;
  53.     else {
  54.         $modules pnModGetUserMods();
  55.         $cacheid 1;
  56.     }
  57.  
  58.     foreach ($modules as $key => $module{
  59.         if ($module['type'== 3{
  60.             $rootdir 'system/';
  61.         else {
  62.             $rootdir 'modules/';
  63.         }
  64.         $osmoddir DataUtil::formatForOS($module['directory']);
  65.         foreach ($filetypes as $filetype{
  66.             if (!file_exists($rootdir.$osmoddir.'/'.$module[$filetype])) {
  67.                 $modules[$key][$filetype'';
  68.             }
  69.         }
  70.         // explode the contact and author arrays to allow for
  71.         // multiple authors and contacts
  72.         $modules[$key]['author'explode(','$module['author']);
  73.         $modules[$key]['contact'explode(','$module['contact']);
  74.  
  75.         // check if an e-mail address is given as the contact
  76.         foreach($modules[$key]['contact'as $contactid => $contact{
  77.             $contact trim($contact);
  78.             if (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$"$contact)) {
  79.                 $modules[$key]['contact'][$contactid'mailto:' $contact;
  80.             }
  81.         }
  82.     }
  83.  
  84.     $themes pnThemeGetAllThemes();
  85.     foreach ($themes as $key => $theme{
  86.         // check that the actual files exist
  87.         $osthemedir DataUtil::formatForOS($theme['directory']);
  88.         foreach ($filetypes as $filetype{
  89.             if (!file_exists('themes/'.$osthemedir.'/'.$theme[$filetype])) {
  90.                 $themes[$key][$filetype'';
  91.             }
  92.         }
  93.  
  94.         // explode the contact and author arrays to allow for
  95.         // multiple authors and contacts
  96.         $themes[$key]['author'explode(','$theme['author']);
  97.         $themes[$key]['contact'explode(','$theme['contact']);
  98.  
  99.         // check if an e-mail address is given as the contact
  100.         foreach($themes[$key]['contact'as $contactid => $contact{
  101.             $contact trim($contact);
  102.             if (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$"$contact)) {
  103.                 $themes[$key]['contact'][$contactid'mailto:' $contact;
  104.             }
  105.         }
  106.     }
  107.  
  108.     // highly unlikely but check if we have no modules returned
  109.     if ($modules == false{
  110.         return DataUtil::formatForDisplayHTML(_CREDITSNOMODS);
  111.     }
  112.  
  113.     // assign content to user
  114.     $pnRender->assign('modules'$modules);
  115.     $pnRender->assign('themes'$themes);
  116.  
  117.     return $pnRender->fetch('credits_user_main.htm');
  118. }
  119.  
  120. /**
  121.  * Credits user display
  122.  *
  123.  * Displays modules documentation
  124.  * @author Rob Brandt
  125.  * @return HTML output string
  126.  */
  127. function credits_user_display($args{
  128.  
  129.     if (!SecurityUtil::checkPermission('Credits::''::'ACCESS_READ)) {
  130.         return LogUtil::registerPermissionError();
  131.     }
  132.  
  133.     $mod = (string)FormUtil::getPassedValue('mod'isset($args['mod']$args['mod'null'GET');
  134.     $filetype = (string)FormUtil::getPassedValue('filetype'isset($args['filetype']$args['filetype'null'GET');
  135.  
  136.     // work out the version number, the display name for the module (or core)
  137.     // and the directory(ies) to locate the files
  138.     if ($mod == 'core'{
  139.         $modinfo array();
  140.         $modinfo['name''core';
  141.         $modinfo['version'PN_VERSION_NUM;
  142.         $modinfo['displayname'PN_VERSION_ID;
  143.         $modinfo['directory''core';
  144.     elseif (isset($mod&& pnModAvailable($mod)) {
  145.         $modinfo pnModGetInfo(pnModGetIDFromName($mod));
  146.         if (!is_array($modinfo)) {
  147.             return DataUtil::formatForDisplayHTML(_CREDITSNOEXIST);
  148.         }
  149.     elseif (isset($mod)) {
  150.         $modinfo pnThemeGetInfo(pnThemeGetIDFromName($mod));
  151.         if (!is_array($modinfo)) {
  152.             return DataUtil::formatForDisplayHTML(_CREDITSNOEXIST);
  153.         }
  154.     else {
  155.         return DataUtil::formatForDisplayHTML(_CREDITSNOEXIST);
  156.     }
  157.  
  158.     // Create output object
  159.     $pnRender pnRender::getInstance('Credits');
  160.  
  161.     // define the cache id
  162.     $pnRender->cache_id md5($modinfo['directory'].$filetype);
  163.  
  164.     // check out if the contents are cached.
  165.     // If this is the case, we do not need to make DB queries.
  166.     if ($pnRender->is_cached('credits_user_display.htm')) {
  167.         return $pnRender->fetch('credits_user_display.htm');
  168.     }
  169.  
  170.     // now lets locate the module version info
  171.     if ($mod == 'core'{
  172.         switch ($filetype{
  173.         case 'credits':
  174.             $filename 'docs/CREDITS.txt';
  175.             break;
  176.         case 'license':
  177.             $filename 'docs/COPYING.txt';
  178.             break;
  179.         }
  180.     else {
  181.         if (pnModAvailable($modinfo['name'])) {
  182.             if ($modinfo['type'== 3{
  183.                 $filename 'system/'.DataUtil::formatForOS($modinfo['directory']).'/'.DataUtil::formatForOS($modinfo[$filetype]);
  184.             else {
  185.                 $filename 'modules/'.DataUtil::formatForOS($modinfo['directory']).'/'.DataUtil::formatForOS($modinfo[$filetype]);
  186.             }
  187.         else {
  188.             $filename 'themes/'.DataUtil::formatForOS($modinfo['directory']).'/'.DataUtil::formatForOS($modinfo[$filetype]);
  189.         }
  190.     }
  191.  
  192.     if (file_exists($filename)) {
  193.         $thefile implode('',file($filename));
  194.         $thefile DataUtil::formatForDisplay($thefile);
  195.     else {
  196.         $thefile DataUtil::formatForDisplay(_CREDITSNOEXIST);
  197.     }
  198.  
  199.     // assign the values to the template
  200.     $pnRender->assign('heading'constant('_CREDITS' strtoupper($filetype)));
  201.     $pnRender->assign($modinfo);
  202.     $pnRender->assign('thefile'$thefile);
  203.     $pnRender->assign('filetype'$filetype);
  204.  
  205.     // create a fake numeric item id to allow display hooks work properly
  206.     $pnRender->assign('itemid'$pnRender->cache_id);
  207.  
  208.     return $pnRender->fetch('credits_user_display.htm');
  209. }

Documentation generated on Fri, 18 Jul 2008 21:54:56 +0200 by phpDocumentor 1.4.1