b2evolution PHP Cross Reference Blogging Systems

Source: /inc/_core/model/_module.class.php - 317 lines - 7872 bytes - Summary - Text - Print

Description: This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file is part of the evoCore framework - {@link http://evocore.net/}
   4   * See also {@link http://sourceforge.net/projects/evocms/}.
   5   *
   6   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   7   *
   8   * {@internal License choice
   9   * - If you have received this file as part of a package, please find the license.txt file in
  10   *   the same folder or the closest folder above for complete license terms.
  11   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  12   *   then you must choose one of the following licenses before using the file:
  13   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  14   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  15   * }}
  16   *
  17   * @package evocore
  18   *
  19   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  20   * @author fplanque: Francois PLANQUE.
  21   *
  22   * @version $Id: _module.class.php 6136 2014-03-08 07:59:48Z manuel $
  23   */
  24  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  25  
  26  /**
  27   * Module class (only useful if derived)
  28   */
  29  class Module
  30  {
  31      /**
  32       * Do the initializations. Called from in _main.inc.php.
  33       * This is typically where classes matching DB tables for this module are registered/loaded.
  34       *
  35       * Note: this should only load/register things that are going to be needed application wide,
  36       * for example: for constructing menus.
  37       * Anything that is needed only in a specific controller should be loaded only there.
  38       * Anything that is needed only in a specific view should be loaded only there.
  39       */
  40  	function init()
  41      {
  42      }
  43  
  44      /**
  45       * Build teh evobar menu
  46       */
  47  	function build_evobar_menu()
  48      {
  49      }
  50  
  51  
  52      /**
  53       * Builds the 1st half of the menu. This is the one with the most important features
  54       */
  55  	function build_menu_1()
  56      {
  57      }
  58  
  59    /**
  60       * Builds the 2nd half of the menu. This is the one with the configuration features
  61       *
  62       * At some point this might be displayed differently than the 1st half.
  63       */
  64  	function build_menu_2()
  65      {
  66      }
  67  
  68  
  69      /**
  70       * Builds the 3rd half of the menu. This is the one with the configuration features
  71       *
  72       * At some point this might be displayed differently than the 1st half.
  73       */
  74  	function build_menu_3()
  75      {
  76      }
  77  
  78  
  79      /**
  80       * Provide translation in the context of this module:
  81       *
  82       * You can override this in specific modules.
  83       * Note: no fancy i18n mechanisme is provided at this point. We may add one in the future.
  84       * Especially if we have our own T_() extractor and multiple POT files.
  85       *
  86       * @param mixed $string
  87       * @param mixed $req_locale
  88       * @return string
  89       */
  90      function T_( $string, $req_locale = '' )
  91      {
  92          return T_( $string, $req_locale );
  93      }
  94  
  95  
  96      /**
  97       * could be used e.g. by a google_analytics plugin to add the javascript snippet
  98       */
  99  	function SkinEndHtmlBody()
 100      {
 101      }
 102  
 103      /**
 104       * Upgrade the module's tables in b2evo database
 105       */
 106  	function upgrade_b2evo_tables()
 107      {
 108      }
 109  
 110      /**
 111       * Create the module's own demo content
 112       */
 113  	function create_demo_contents()
 114      {
 115      }
 116  
 117      /**
 118       * Displays the module's collection feature settings
 119       *
 120       * @param array
 121       *         array['Form'] - where to display;
 122       *         array['edited_Blog'] - which blog properties should be displayed;
 123       */
 124  	function display_collection_features( $params )
 125      {
 126      }
 127  
 128      /**
 129       * Updates the module's collection feature settings
 130       *
 131       * @param array
 132       *         array['edited_Blog'] - which blog properties should be updated;
 133       */
 134  	function update_collection_features( $params )
 135      {
 136      }
 137  
 138      /**
 139       * Displays the module's collection comments settings
 140       *
 141       * @param array
 142       *         array['Form'] - where to display;
 143       *         array['edited_Blog'] - which blog properties should be displayed;
 144       */
 145  	function display_collection_comments( $params )
 146      {
 147      }
 148  
 149      /**
 150       * Updates the module's collection comments settings
 151       *
 152       * @param array
 153       *         array['edited_Blog'] - which blog properties should be updated;
 154       */
 155  	function update_collection_comments( $params )
 156      {
 157      }
 158  
 159      /**
 160       * Displays the module's item settings
 161       *
 162       * @param array
 163       *         array['Form'] - where to display;
 164       *         array['Blog'] - which blog item is it;
 165       *         array['edited_Item'] - which item is it;
 166       */
 167  	function display_item_settings( $params )
 168      {
 169      }
 170  
 171      /**
 172       * Updates the module's collection feature settings
 173       *
 174       * @param array
 175       *         array['edited_Item'] - which item setting should be updated;
 176       */
 177  	function update_item_settings( $params )
 178      {
 179      }
 180  
 181      /**
 182       * Update Item after insert
 183       *
 184       * @param array
 185       *         array['edited_Item'] - which item setting should be updated;
 186       */
 187  	function update_item_after_insert( $params )
 188      {
 189      }
 190  
 191      /**
 192       * Get "where" clause for item statuses
 193       *
 194       * @param array
 195       *         array['statuses'] - which items statuses are used to show
 196       */
 197  	function get_item_statuses_where_clause( $params )
 198      {
 199      }
 200  
 201      /**
 202       * Call method at the end of constructor of class Item
 203       *
 204       * @param array
 205       *         array['Item'] - which item setting should be updated;
 206       */
 207  	function constructor_item( $params )
 208      {
 209      }
 210  
 211  
 212      /**
 213       * Update thread after creating new object "Thread"
 214       *
 215       * @param array
 216       *         array['Thread'] - which thread setting should be updated;
 217       */
 218  	function update_new_thread( $params )
 219      {
 220      }
 221  
 222  
 223      /**
 224       * Allows the module to do something before displaying the comments for a post.
 225       *
 226       * @param array
 227       */
 228  	function before_comments( $params )
 229      {
 230      }
 231  
 232  
 233      /**
 234       * Check module permission
 235       *
 236       * @param string Permission name
 237       * @param string Requested permission level
 238       * @param mixed Permission target (blog ID, array of cat IDs...)
 239       * @param string function name
 240       * $param object user's Group - can't be NULL
 241       * @return boolean True on success (permission is granted), false if permission is not granted
 242       *                 NULL if permission not implemented.
 243       */
 244  	function check_perm( $permname, $permlevel, $permtarget, $function, $Group )
 245      {
 246          if( empty( $Group ) )
 247          { // group must be set
 248              return NULL;
 249          }
 250  
 251          $GroupSettings = & $Group->get_GroupSettings();
 252  
 253          if( array_key_exists( $permname, $GroupSettings->permission_modules ) )
 254          {    // Requested permission found in the group settings
 255              $Module = & $GLOBALS[$GroupSettings->permission_modules[$permname].'_Module'];
 256              if( method_exists( $Module, 'get_available_group_permissions' ) )
 257              {    // Function to get available permission exists
 258                  $permissions = $Module->get_available_group_permissions();
 259                  if( array_key_exists( $permname, $permissions ) )
 260                  {    // Requested permission found in available permisssion list
 261                      $permission = $permissions[$permname];
 262                      if( array_key_exists( $function, $permission ) )
 263                      {    // Function to check permission exists
 264                          $function = $permission[$function];
 265                          if( method_exists( $Module, $function ) )
 266                          {    // We can call check permission function
 267                              return $Module->{$function}( $permlevel, $GroupSettings->get( $permname, $Group->ID ), $permtarget );
 268                          }
 269                      }
 270                  }
 271              }
 272          }
 273  
 274          // Required parameters of check permission function not found
 275          return NULL;
 276      }
 277  
 278  
 279      /**
 280       * Get contacts list params
 281       */
 282  	function get_contacts_list_params()
 283      {
 284      }
 285  
 286  
 287      /**
 288       * Switch actions for contacts
 289       *
 290       * @param array
 291       */
 292  	function switch_contacts_actions( $params = array() )
 293      {
 294      }
 295  
 296  
 297      /**
 298       * Check Minimum PHP version required for the module
 299       * 
 300       * @param string module name/id
 301       */
 302  	function check_required_php_version( $module )
 303      {
 304          global $app_name, $app_version, $required_php_version;
 305  
 306          $php_version = phpversion();
 307          if( version_compare( $php_version, $required_php_version[ $module ], '<' ) )
 308          {
 309              $error_message = sprintf( 'You cannot use %1s module of %2$s %3$s on this server because it requires PHP version %4$s or higher. You are running version %5$s.',
 310                                  $module, $app_name, $app_version, $required_php_version[ $module ], $php_version );
 311  
 312              die('<h1>Insufficient Requirements</h1><p>'.$error_message.'</p>');
 313          }
 314      }
 315  }
 316  
 317  ?>

title

Description

title

Description

title

Description

title

title

Body