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

Source for file messages.php

Documentation is available at messages.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2001, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: messages.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_Messages
  11.  */
  12.  
  13. /**
  14.  * initialise block
  15.  * @author Jim McDonald <jim@mcdee.net>
  16.  * @link http://www.mcdee.net
  17.  */
  18. {
  19.     // Security
  20.     pnSecAddSchema('Admin_Messages:messagesblock:''block title::');
  21. }
  22.  
  23. /**
  24.  * get information on block
  25.  * @author Jim McDonald <jim@mcdee.net>
  26.  * @link http://www.mcdee.net
  27.  * @return array blockinfo array
  28.  */
  29. {
  30.     // Values
  31.     return array('text_type' => 'Messages',
  32.                  'module' => 'Admin_Messages',
  33.                  'text_type_long' => 'Show Admin Messages',
  34.                  'allow_multiple' => true,
  35.                  'form_content' => false,
  36.                  'form_refresh' => false,
  37.                  'show_preview' => true);
  38. }
  39.  
  40. /**
  41.  * display block
  42.  * @author Jim McDonald <jim@mcdee.net>
  43.  * @link http://www.mcdee.net
  44.  * @param 'row' blockinfo array
  45.  * @return string HTML output string
  46.  */
  47. {
  48.     // set default values
  49.     // The default is to remove the title so that a specific block template override for the admin
  50.     // messages block isn't required (one that doesn't display the standard block title0 since this
  51.     // module provides it's own title to items.
  52.     if (!empty($row['title'])) {
  53.         $row['title''';
  54.     }
  55.  
  56.     //security check
  57.     if (!SecurityUtil::checkPermission('Admin_Messages:messagesblock:'"$row[title]::"ACCESS_READ)) {
  58.         return;
  59.     }
  60.  
  61.     // Check the module is available
  62.     if (!pnModAvailable('Admin_Messages')) {
  63.         return;
  64.     }
  65.  
  66.     // Create output object
  67.     $pnRender pnRender::getInstance('Admin_Messages');
  68.  
  69.     // Define the cacheid
  70.     $pnRender->cache_id pnUserGetVar('uid');
  71.  
  72.     // check out if the contents are cached.
  73.     if ($pnRender->is_cached('admin_messages_block_messages.htm')) {
  74.         // Populate block info and pass to theme
  75.         $row['content'$pnRender->fetch('admin_messages_block_messages.htm');
  76.         return pnBlockThemeBlock($row);
  77.     }
  78.  
  79.     // call the api function
  80.     $messages pnModAPIFunc('Admin_Messages''user''getactive');
  81.  
  82.     if (!$messages)
  83.         $messages array();
  84.  
  85.     $messagestodisplay array();
  86.     foreach ($messages as $message{
  87.         $show 0;
  88.         // Since the API has already done the permissions check
  89.         // there's no need to duplicate the checks here.
  90.         // We'll still the support admin panel 'permission' settings
  91.         // as these are still useful as a quick solution
  92.         switch($message['view']{
  93.         case 1:
  94.             // Message for everyone
  95.             $show 1;
  96.             break;
  97.         case 2:
  98.             // Message for users
  99.             if (pnUserLoggedIn()) {
  100.                 $show 1;
  101.             }
  102.             break;
  103.         case 3:
  104.             // Messages for non-users
  105.             if (!pnUserLoggedIn()) {
  106.                 $show 1;
  107.             }
  108.             break;
  109.         case 4:
  110.              // Messages for administrators of any description
  111.              if (SecurityUtil::checkPermission('::''::'ACCESS_ADMIN)) {
  112.                  $show 1;
  113.              }
  114.              break;
  115.         }
  116.         if ($show{
  117.             $messagestodisplay[$message;
  118.         }
  119.     }
  120.  
  121.     // check for an empty result set
  122.     if (empty($messagestodisplay)) return;
  123.  
  124.     $pnRender->assign('messages'$messagestodisplay);
  125.  
  126.     // Populate block info and pass to theme
  127.     $row['content'$pnRender->fetch('admin_messages_block_messages.htm');
  128.  
  129.     return pnBlockThemeBlock($row);
  130.  
  131. }

Documentation generated on Fri, 18 Jul 2008 21:47:44 +0200 by phpDocumentor 1.4.1