b2evolution PHP Cross Reference Blogging Systems

Source: /inc/_core/__core.init.php - 1545 lines - 46307 bytes - Summary - Text - Print

Description: This is the init file for the core module. 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 is the init file for the core module.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * }}
  21   *
  22   * @package evocore
  23   *
  24   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  25   * @author fplanque: Francois PLANQUE.
  26   *
  27   * @version $Id: __core.init.php 6136 2014-03-08 07:59:48Z manuel $
  28   */
  29  if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );
  30  
  31  /**
  32   * This is supposed to be overriden by sth more useful when a more useful module is loaded
  33   * Typically should be 'dashboard'
  34   */
  35  $default_ctrl = 'settings';
  36  
  37  /**
  38   * Minimum PHP version required for _core module to function properly.
  39   * This value can't be higher then the application required php version.
  40   */
  41  $required_php_version[ '_core' ] = '5.0';
  42  
  43  /**
  44   * Minimum MYSQL version required for _core module to function properly.
  45   */
  46  $required_mysql_version[ '_core' ] = '5.0.3';
  47  
  48  /**
  49   * Aliases for table names:
  50   *
  51   * (You should not need to change them.
  52   *  If you want to have multiple b2evo installations in a single database you should
  53   *  change {@link $tableprefix} in _basic_config.php)
  54   */
  55  $db_config['aliases'] = array(
  56          'T_antispam'               => $tableprefix.'antispam',
  57          'T_antispam__iprange'      => $tableprefix.'antispam__iprange',
  58          'T_cron__log'              => $tableprefix.'cron__log',
  59          'T_cron__task'             => $tableprefix.'cron__task',
  60          'T_regional__country'      => $tableprefix.'regional__country',
  61          'T_regional__region'       => $tableprefix.'regional__region',
  62          'T_regional__subregion'    => $tableprefix.'regional__subregion',
  63          'T_regional__city'         => $tableprefix.'regional__city',
  64          'T_regional__currency'     => $tableprefix.'regional__currency',
  65          'T_groups'                 => $tableprefix.'groups',
  66          'T_groups__groupsettings'  => $tableprefix.'groups__groupsettings',
  67          'T_global__cache'          => $tableprefix.'global__cache',
  68          'T_i18n_original_string'   => $tableprefix.'i18n_original_string',
  69          'T_i18n_translated_string' => $tableprefix.'i18n_translated_string',
  70          'T_locales'                => $tableprefix.'locales',
  71          'T_plugins'                => $tableprefix.'plugins',
  72          'T_pluginevents'           => $tableprefix.'pluginevents',
  73          'T_pluginsettings'         => $tableprefix.'pluginsettings',
  74          'T_pluginusersettings'     => $tableprefix.'pluginusersettings',
  75          'T_settings'               => $tableprefix.'settings',
  76          'T_users'                  => $tableprefix.'users',
  77          'T_users__fielddefs'       => $tableprefix.'users__fielddefs',
  78          'T_users__fieldgroups'     => $tableprefix.'users__fieldgroups',
  79          'T_users__fields'          => $tableprefix.'users__fields',
  80          'T_users__reports'         => $tableprefix.'users__reports',
  81          'T_users__usersettings'    => $tableprefix.'users__usersettings',
  82          'T_slug'                   => $tableprefix.'slug',
  83          'T_email__log'             => $tableprefix.'email__log',
  84          'T_email__returns'         => $tableprefix.'email__returns',
  85          'T_email__blocked'         => $tableprefix.'email__blocked',
  86      );
  87  
  88  
  89  /**
  90   * Controller mappings.
  91   *
  92   * For each controller name, we associate a controller file to be found in /inc/ .
  93   * The advantage of this indirection is that it is easy to reorganize the controllers into
  94   * subdirectories by modules. It is also easy to deactivate some controllers if you don't
  95   * want to provide this functionality on a given installation.
  96   *
  97   * Note: while the controller mappings might more or less follow the menu structure, we do not merge
  98   * the two tables since we could, at any time, decide to make a skin with a different menu structure.
  99   * The controllers however would most likely remain the same.
 100   *
 101   * @global array
 102   */
 103  $ctrl_mappings = array(
 104          'antispam'         => 'antispam/antispam.ctrl.php',
 105          'crontab'          => 'cron/cronjobs.ctrl.php',
 106          'regional'         => 'regional/regional_dispatch.ctrl.php',
 107          'time'             => 'regional/time.ctrl.php',
 108          'countries'        => 'regional/countries.ctrl.php',
 109          'regions'          => 'regional/regions.ctrl.php',
 110          'subregions'       => 'regional/subregions.ctrl.php',
 111          'cities'           => 'regional/cities.ctrl.php',
 112          'currencies'       => 'regional/currencies.ctrl.php',
 113          'locales'          => 'locales/locales.ctrl.php',
 114          'translation'      => 'locales/translation.ctrl.php',
 115          'plugins'          => 'plugins/plugins.ctrl.php',
 116          'gensettings'      => 'settings/settings.ctrl.php',
 117          'remotepublish'    => 'settings/remotepublish.ctrl.php',
 118          'settings'         => 'settings/settings_dispatch.ctrl.php',
 119          'stats'            => 'sessions/stats.ctrl.php',
 120          'system'           => 'tools/system.ctrl.php',
 121          'user'             => 'users/user.ctrl.php',
 122          'users'            => 'users/users.ctrl.php',
 123          'userfields'       => 'users/userfields.ctrl.php',
 124          'userfieldsgroups' => 'users/userfieldsgroups.ctrl.php',
 125          'usersettings'     => 'users/settings.ctrl.php',
 126          'registration'     => 'users/registration.ctrl.php',
 127          'display'          => 'users/display.ctrl.php',
 128          'groups'           => 'users/groups.ctrl.php',
 129          'upload'           => 'files/upload.ctrl.php',
 130          'slugs'            => 'slugs/slugs.ctrl.php',
 131          'email'            => 'tools/email.ctrl.php',
 132          'newsletter'       => 'newsletter/newsletter.ctrl.php',
 133      );
 134  
 135  
 136  /**
 137   * Get the CountryCache
 138   *
 139   * @param string The text that gets used for the "None" option in the objects options list (Default: T_('Unknown')).
 140   * @return CountryCache
 141   */
 142  function & get_CountryCache( $allow_none_text = NULL )
 143  {
 144      global $CountryCache;
 145  
 146      if( ! isset( $CountryCache ) )
 147      {    // Cache doesn't exist yet:
 148          if( ! isset( $allow_none_text ) )
 149          {
 150              $allow_none_text = T_('Unknown');
 151          }
 152          $CountryCache = new DataObjectCache( 'Country', true, 'T_regional__country', 'ctry_', 'ctry_ID', 'ctry_code', 'ctry_name', $allow_none_text );
 153      }
 154  
 155      return $CountryCache;
 156  }
 157  
 158  
 159  /**
 160   * Get the RegionCache
 161   *
 162   * @return RegionCache
 163   */
 164  function & get_RegionCache()
 165  {
 166      global $RegionCache;
 167  
 168      if( ! isset( $RegionCache ) )
 169      {    // Cache doesn't exist yet:
 170          $RegionCache = new DataObjectCache( 'Region', false, 'T_regional__region', 'rgn_', 'rgn_ID', 'rgn_name', 'rgn_name', T_('Unknown') );
 171      }
 172  
 173      return $RegionCache;
 174  }
 175  
 176  
 177  /**
 178   * Get the SubregionCache
 179   *
 180   * @return SubregionCache
 181   */
 182  function & get_SubregionCache()
 183  {
 184      global $SubregionCache;
 185  
 186      if( ! isset( $SubregionCache ) )
 187      {    // Cache doesn't exist yet:
 188          $SubregionCache = new DataObjectCache( 'Subregion', false, 'T_regional__subregion', 'subrg_', 'subrg_ID', 'subrg_name', 'subrg_name', T_('Unknown') );
 189      }
 190  
 191      return $SubregionCache;
 192  }
 193  
 194  
 195  /**
 196   * Get the CityCache
 197   *
 198   * @return CityCache
 199   */
 200  function & get_CityCache()
 201  {
 202      global $CityCache;
 203  
 204      if( ! isset( $CityCache ) )
 205      {    // Cache doesn't exist yet:
 206          $CityCache = new DataObjectCache( 'City', false, 'T_regional__city', 'city_', 'city_ID', 'city_name', 'city_name', T_('Unknown') );
 207      }
 208  
 209      return $CityCache;
 210  }
 211  
 212  
 213  /**
 214   * Get the CurrencyCache
 215   *
 216   * @return CurrencyCache
 217   */
 218  function & get_CurrencyCache()
 219  {
 220      global $CurrencyCache;
 221  
 222      if( ! isset( $CurrencyCache ) )
 223      {    // Cache doesn't exist yet:
 224          $CurrencyCache = new DataObjectCache( 'Currency', true, 'T_regional__currency', 'curr_', 'curr_ID', 'curr_code', 'curr_code');
 225      }
 226  
 227      return $CurrencyCache;
 228  }
 229  
 230  
 231  /**
 232   * Get the GroupCache
 233   *
 234   * @param boolean TRUE to ignore cached object and create new cache object
 235   * @param string The text that gets used for the "None" option in the objects options list (Default: T_('No group')).
 236   * @return GroupCache
 237   */
 238  function & get_GroupCache( $force_cache = false, $allow_none_text = NULL )
 239  {
 240      global $Plugins;
 241      global $GroupCache;
 242  
 243      if( $force_cache || ! isset( $GroupCache ) )
 244      { // Cache doesn't exist yet:
 245          if( is_null( $allow_none_text ) )
 246          { // Set default value for "None" option
 247              $allow_none_text = T_('No group');
 248          }
 249          $Plugins->get_object_from_cacheplugin_or_create( 'GroupCache', 'new DataObjectCache( \'Group\', true, \'T_groups\', \'grp_\', \'grp_ID\', \'grp_name\', \'\', \''.str_replace( "'", "\'", $allow_none_text ).'\' )' );
 250      }
 251  
 252      return $GroupCache;
 253  }
 254  
 255  
 256  /**
 257   * Get the Plugins_admin
 258   *
 259   * @return Plugins_admin
 260   */
 261  function & get_Plugins_admin()
 262  {
 263      global $Plugins_admin;
 264  
 265      if( ! isset( $Plugins_admin ) )
 266      {    // Cache doesn't exist yet:
 267          load_class( 'plugins/model/_plugins_admin.class.php', 'Plugins_admin' );
 268          $Plugins_admin = new Plugins_admin(); // COPY (FUNC)
 269      }
 270  
 271      return $Plugins_admin;
 272  }
 273  
 274  
 275  /**
 276   * Get the UserCache
 277   *
 278   * @return UserCache
 279   */
 280  function & get_UserCache()
 281  {
 282      global $UserCache;
 283  
 284      if( ! isset( $UserCache ) )
 285      {    // Cache doesn't exist yet:
 286          load_class( 'users/model/_usercache.class.php', 'UserCache' );
 287          $UserCache = new UserCache(); // COPY (FUNC)
 288      }
 289  
 290      return $UserCache;
 291  }
 292  
 293  
 294  /**
 295   * Get the UserFieldCache
 296   *
 297   * @return UserFieldCache
 298   */
 299  function & get_UserFieldCache()
 300  {
 301      global $UserFieldCache;
 302  
 303      if( ! isset( $UserFieldCache ) )
 304      {    // Cache doesn't exist yet:
 305          $UserFieldCache = new DataObjectCache( 'Userfield', false, 'T_users__fielddefs', 'ufdf_', 'ufdf_ID', 'ufdf_name', 'ufdf_name' ); // COPY (FUNC)
 306      }
 307  
 308      return $UserFieldCache;
 309  }
 310  
 311  
 312  /**
 313   * Get the UserFieldGroupCache
 314   *
 315   * @return UserFieldGroupCache
 316   */
 317  function & get_UserFieldGroupCache()
 318  {
 319      global $UserFieldGroupCache;
 320  
 321      if( ! isset( $UserFieldGroupCache ) )
 322      {    // Cache doesn't exist yet:
 323          $UserFieldGroupCache = new DataObjectCache( 'UserfieldGroup', false, 'T_users__fieldgroups', 'ufgp_', 'ufgp_ID', 'ufgp_name', 'ufgp_name' ); // COPY (FUNC)
 324      }
 325  
 326      return $UserFieldGroupCache;
 327  }
 328  
 329  
 330  /**
 331   * Get the SlugCache
 332   *
 333   * @return SlugCache
 334   */
 335  function & get_SlugCache()
 336  {
 337      global $SlugCache;
 338  
 339      if( ! isset( $SlugCache ) )
 340      {    // Cache doesn't exist yet:
 341          $SlugCache = new DataObjectCache( 'Slug', false, 'T_slug', 'slug_', 'slug_ID', 'slug_title', 'slug_title' );
 342      }
 343  
 344      return $SlugCache;
 345  }
 346  
 347  
 348  /**
 349   * Get the IPRangeCache
 350   *
 351   * @return IPRangeCache
 352   */
 353  function & get_IPRangeCache()
 354  {
 355      global $IPRangeCache;
 356  
 357      if( ! isset( $IPRangeCache ) )
 358      {    // Cache doesn't exist yet:
 359          load_class( 'antispam/model/_iprangecache.class.php', 'IPRangeCache' );
 360          $IPRangeCache = new IPRangeCache();
 361      }
 362  
 363      return $IPRangeCache;
 364  }
 365  
 366  
 367  /**
 368   * Get the EmailBlockedCache
 369   *
 370   * @return EmailBlockedCache
 371   */
 372  function & get_EmailBlockedCache()
 373  {
 374      global $EmailBlockedCache;
 375  
 376      if( ! isset( $EmailBlockedCache ) )
 377      {    // Cache doesn't exist yet:
 378          $EmailBlockedCache = new DataObjectCache( 'EmailBlocked', false, 'T_email__blocked', 'emblk_', 'emblk_ID', 'emblk_address' );
 379      }
 380  
 381      return $EmailBlockedCache;
 382  }
 383  
 384  
 385  /**
 386   * Get the CronjobCache
 387   *
 388   * @return CronjobCache
 389   */
 390  function & get_CronjobCache()
 391  {
 392      global $CronjobCache;
 393  
 394      if( ! isset( $CronjobCache ) )
 395      {    // Cache doesn't exist yet:
 396          load_class( 'cron/model/_cronjob.class.php', 'Cronjob' );
 397          $CronjobCache = new DataObjectCache( 'Cronjob', false, 'T_cron__task', 'ctsk_', 'ctsk_ID', 'ctsk_name', 'ctsk_name', T_('Unknown') );
 398      }
 399  
 400      return $CronjobCache;
 401  }
 402  
 403  
 404  /**
 405   * _core_Module definition
 406   */
 407  class _core_Module extends Module
 408  {
 409      /**
 410       * Do the initializations. Called from in _main.inc.php.
 411       * This is typically where classes matching DB tables for this module are registered/loaded.
 412       *
 413       * Note: this should only load/register things that are going to be needed application wide,
 414       * for example: for constructing menus.
 415       * Anything that is needed only in a specific controller should be loaded only there.
 416       * Anything that is needed only in a specific view should be loaded only there.
 417       */
 418  	function init()
 419      {
 420          $this->check_required_php_version( '_core' );
 421  
 422          load_class( '_core/model/dataobjects/_dataobjectcache.class.php', 'DataObjectCache' );
 423          load_class( 'generic/model/_genericelement.class.php', 'GenericElement' );
 424          load_class( 'generic/model/_genericcache.class.php', 'GenericCache' );
 425          load_funcs( 'users/model/_user.funcs.php' );
 426          load_funcs( '_core/_template.funcs.php' );
 427          load_funcs( '_core/ui/forms/_form.funcs.php');
 428          load_class( '_core/ui/forms/_form.class.php', 'Form' );
 429          load_class( '_core/model/db/_sql.class.php', 'SQL' );
 430          load_class( '_core/ui/results/_results.class.php', 'Results' );
 431          load_class( '_core/model/_blockcache.class.php', 'BlockCache' );
 432          load_class( 'slugs/model/_slug.class.php', 'Slug' );
 433          load_class( 'antispam/model/_iprange.class.php', 'IPRange' );
 434      }
 435  
 436  
 437      /**
 438       * Get default module permissions
 439       *
 440       * @param integer Group ID
 441       * @return array
 442       */
 443  	function get_default_group_permissions( $grp_ID )
 444      {
 445          switch( $grp_ID )
 446          {
 447              case 1:        // Administrators (group ID 1) have permission by default:
 448                  $permadmin = 'normal';
 449                  $permusers = 'edit';
 450                  $permoptions = 'edit';
 451                  $permspam = 'edit';
 452                  $permslugs = 'edit';
 453                  $permtemplates = 'allowed';
 454                  $permemails = 'edit';
 455                  $def_notification = 'full';
 456                  break;
 457  
 458              case 2:        // Privileged bloggers (group ID 2) have permission by default:
 459                  $permadmin = 'normal';
 460                  $permusers = 'view';
 461                  $permoptions = 'view';
 462                  $permspam = 'edit';
 463                  $permslugs = 'none';
 464                  $permtemplates = 'denied';
 465                  $permemails = 'view';
 466                  $def_notification = 'short';
 467                  break;
 468  
 469              case 3:        // Bloggers (group ID 3) have permission by default:
 470                  $permadmin = 'normal';
 471                  $permusers = 'none';
 472                  $permoptions = 'none';
 473                  $permspam = 'view';
 474                  $permslugs = 'none';
 475                  $permtemplates = 'denied';
 476                  $permemails = 'none';
 477                  $def_notification = 'short';
 478                  break;
 479  
 480              case 5:        // Spam/Suspect  (group ID 5) have permission by default:
 481                  $permadmin = 'no_toolbar';
 482                  $permusers = 'none';
 483                  $permoptions = 'none';
 484                  $permspam = 'none';
 485                  $permslugs = 'none';
 486                  $permtemplates = 'denied';
 487                  $permemails = 'none';
 488                  $def_notification = 'short';
 489                  break;
 490  
 491              default:
 492                  // Other groups have no permission by default
 493                  $permadmin = 'none';
 494                  $permusers = 'none';
 495                  $permoptions = 'none';
 496                  $permspam = 'none';
 497                  $permslugs = 'none';
 498                  $permtemplates = 'denied';
 499                  $permemails = 'none';
 500                  $def_notification = 'short';
 501                  break;
 502          }
 503  
 504          // We can return as many default permissions as we want:
 505          // e.g. array ( permission_name => permission_value, ... , ... )
 506          return $permissions = array(
 507              'perm_admin' => $permadmin,
 508              'perm_users' => $permusers,
 509              'perm_options' => $permoptions,
 510              'perm_spamblacklist' => $permspam,
 511              'perm_slugs' => $permslugs,
 512              'perm_templates' => $permtemplates,
 513              'perm_emails' => $permemails,
 514              'pm_notif' => $def_notification,
 515              'comment_subscription_notif' => $def_notification,
 516              'comment_moderation_notif' => $def_notification,
 517              'post_subscription_notif' => $def_notification,
 518              'post_moderation_notif' => $def_notification,
 519           );
 520      }
 521  
 522  
 523      /**
 524       * Get available group permissions
 525       *
 526       * @return array
 527       */
 528  	function get_available_group_permissions( $grp_ID = NULL )
 529      {
 530          $none_option = array( 'none', T_( 'No Access' ), '' );
 531          $view_option = array( 'view', T_( 'View only' ), '' );
 532          $full_option = array( 'edit', T_( 'Full Access' ), '' );
 533          $view_details = array( 'view', T_('View details') );
 534          $edit_option = array( 'edit', T_('Edit/delete all') );
 535          // 'label' is used in the group form as label for radio buttons group
 536          // 'user_func' function used to check user permission. This function should be defined in Module.
 537          // 'group_func' function used to check group permission. This function should be defined in Module.
 538          // 'perm_block' group form block where this permissions will be displayed. Now available, the following blocks: additional, system
 539          // 'options' is permission options
 540          // 'perm_type' is used in the group form to decide to show radiobox or checkbox
 541          // 'field_lines' is used in the group form to decide to show radio options in multiple lines or not
 542          if( $grp_ID == 1 )
 543          {
 544              $perm_admin_values = array(
 545                  'label' => T_( 'Access to Admin area' ),
 546                  'perm_block' => 'core_general',
 547                  'perm_type' => 'info',
 548                  'info' => T_( 'Visible link' ),
 549              );
 550              $perm_users_values = array(
 551                  'label' => T_( 'Users & Groups' ),
 552                  'perm_block' => 'core',
 553                  'perm_type' => 'info',
 554                  'info' => T_( 'Full Access' ),
 555              );
 556          }
 557          else
 558          {
 559              $perm_admin_values = array(
 560                  'label' => T_( 'Access to Admin area' ),
 561                  'user_func'  => 'check_admin_user_perm',
 562                  'group_func' => 'check_admin_group_perm',
 563                  'perm_block' => 'core_general',
 564                  'options'  => array(
 565                      array( 'no_toolbar', T_( 'No Toolbar' ) ),
 566                      $none_option,
 567                      array( 'restricted', T_( 'Restricted' ) ),
 568                      array( 'normal', T_( 'Normal' ) ) ),
 569                  'perm_type' => 'radiobox',
 570                  'field_lines' => false,
 571              );
 572              $perm_users_values = array(
 573                  'label' => T_('Users & Groups'),
 574                  'user_func'  => 'check_core_user_perm',
 575                  'group_func' => 'check_core_group_perm',
 576                  'perm_block' => 'core',
 577                  'options'  => array( $none_option, $view_details, $edit_option ),
 578                  'perm_type' => 'radiobox',
 579                  'field_lines' => false,
 580              );
 581          }
 582  
 583          $notification_options = array(
 584                  array( 'short', T_( 'Short' ) ),
 585                  array( 'full', T_( 'Full text' ) ) );
 586          $notifications_array = array(
 587                  'group_func' => 'check_notification',
 588                  'perm_block' => 'notifications',
 589                  'options' => $notification_options,
 590                  'perm_type' => 'radiobox',
 591                  'field_note' => T_( 'Selecting "Full text" may generate email containing unwanted spam.' ),
 592                  'field_lines' => false,
 593          );
 594  
 595          $permissions = array(
 596              'perm_admin' => $perm_admin_values,
 597              'perm_users' => $perm_users_values,
 598              'perm_options' => array(
 599                  'label' => T_('Settings'),
 600                  'user_func'  => 'check_core_user_perm',
 601                  'group_func' => 'check_core_group_perm',
 602                  'perm_block' => 'core',
 603                  'options'  => array( $none_option, $view_details, $edit_option ),
 604                  'perm_type' => 'radiobox',
 605                  'field_lines' => false,
 606                  ),
 607              'perm_spamblacklist' => array(
 608                  'label' => T_( 'Antispam' ),
 609                  'user_func'  => 'check_core_user_perm',
 610                  'group_func' => 'check_core_group_perm',
 611                  'perm_block' => 'core2',
 612                  'options'  => array( $none_option, $view_option, $full_option ),
 613                  'perm_type' => 'radiobox',
 614                  'field_lines' => false,
 615                  ),
 616              'perm_slugs' => array(
 617                  'label' => T_('Slug manager'),
 618                  'user_func'  => 'check_core_user_perm',
 619                  'group_func' => 'check_core_group_perm',
 620                  'perm_block' => 'core2',
 621                  'options'  => array( $none_option, $view_option, $full_option ),
 622                  'perm_type' => 'radiobox',
 623                  'field_lines' => false,
 624                  ),
 625              'perm_emails' => array(
 626                  'label' => T_('Email management'),
 627                  'user_func'  => 'check_core_user_perm',
 628                  'group_func' => 'check_core_group_perm',
 629                  'perm_block' => 'core2',
 630                  'options'  => array( $none_option, $view_details, $edit_option ),
 631                  'perm_type' => 'radiobox',
 632                  'field_lines' => false,
 633                  ),
 634              'perm_templates' => array(
 635                  'label' => T_('Skins'),
 636                  'user_func'  => 'check_template_user_perm',
 637                  'group_func' => 'check_template_group_perm',
 638                  'perm_block' => 'core3',
 639                  'perm_type' => 'checkbox',
 640                  'note' => T_( 'Check to allow access to skin files.' ),
 641                  ),
 642              'pm_notif' => array_merge( 
 643                  array( 'label' => T_( 'New Private Message notifications' ) ), $notifications_array
 644                  ),
 645              'comment_subscription_notif' => array_merge(
 646                  array( 'label' => T_( 'New Comment subscription notifications' ) ), $notifications_array
 647                  ),
 648              'comment_moderation_notif' => array_merge(
 649                  array( 'label' => T_( 'New Comment moderation notifications' ) ), $notifications_array
 650                  ),
 651              'post_subscription_notif' => array_merge(
 652                  array( 'label' => T_( 'New Post subscription notifications' ) ), $notifications_array
 653                  ),
 654              'post_moderation_notif' => array_merge(
 655                  array( 'label' => T_( 'New Post moderation notifications' ) ), $notifications_array
 656                  ),
 657              );
 658          return $permissions;
 659      }
 660  
 661  
 662      /**
 663       * Check admin permission for the group
 664       */
 665  	function check_admin_group_perm( $permlevel, $permvalue, $permtarget )
 666      {
 667          $perm = false;
 668          switch( $permvalue )
 669          {
 670              case 'full':
 671              case 'normal':
 672                  if( $permlevel == 'normal' )
 673                  {
 674                      $perm = true;
 675                      break;
 676                  }
 677  
 678              case 'restricted':
 679                  if( $permlevel == 'restricted' || $permlevel == 'any' )
 680                  {
 681                      $perm = true;
 682                      break;
 683                  }
 684  
 685              case 'none':
 686                  // display toolbar check
 687                  if( $permlevel == 'toolbar' )
 688                  { // Even in case of No Access the toolbar must be displayed
 689                      $perm = true;
 690                      break;
 691                  }
 692          }
 693  
 694          return $perm;
 695      }
 696  
 697  
 698      /**
 699       * Check a permission for the user. ( see 'user_func' in get_available_group_permissions() function  )
 700       *
 701       * @param string Requested permission level
 702       * @param string Permission value, this is the value on the database
 703       * @param mixed Permission target (blog ID, array of cat IDs...)
 704       * @return boolean True on success (permission is granted), false if permission is not granted
 705       */
 706  	function check_core_user_perm( $permlevel, $permvalue, $permtarget )
 707      {
 708          return true;
 709      }
 710  
 711      /**
 712       * Check a permission for the group. ( see 'group_func' in get_available_group_permissions() function )
 713       *
 714       * @param string Requested permission level
 715       * @param string Permission value
 716       * @param mixed Permission target (blog ID, array of cat IDs...)
 717       * @return boolean True on success (permission is granted), false if permission is not granted
 718       */
 719  	function check_core_group_perm( $permlevel, $permvalue, $permtarget )
 720      {
 721          $perm = false;
 722          switch ( $permvalue )
 723          {
 724              case 'edit':
 725                  // Users has edit perms
 726                  if( $permlevel == 'edit' )
 727                  {
 728                      $perm = true;
 729                      break;
 730                  }
 731  
 732              case 'view':
 733                  // Users has view perms
 734                  if( $permlevel == 'view' )
 735                  {
 736                      $perm = true;
 737                      break;
 738                  }
 739  
 740          }
 741  
 742          return $perm;
 743      }
 744  
 745      /**
 746       * Check permission for the group
 747       */
 748  	function check_template_group_perm( $permlevel, $permvalue, $permtarget )
 749      {
 750          // Only 'allowed' value means group has permission
 751          return $permvalue == 'allowed';
 752      }
 753  
 754      /**
 755       * Check notification setting
 756       */
 757  	function check_notification( $permlevel, $permvalue, $permtarget )
 758      {
 759          // Check if user should receive full text notification or not. In every other case short notificaiton must be sent.
 760          return $permvalue == 'full';
 761      }
 762  
 763      /**
 764       * Build teh evobar menu
 765       */
 766  	function build_evobar_menu()
 767      {
 768          /**
 769           * @var Menu
 770           */
 771          global $topleft_Menu, $topright_Menu;
 772          global $current_User;
 773          global $home_url, $admin_url, $dispatcher, $debug, $seo_page_type, $robots_index;
 774          global $Blog, $blog;
 775  
 776          global $Settings;
 777  
 778          $perm_admin_normal = $current_User->check_perm( 'admin', 'normal' );
 779          $perm_admin_restricted = $current_User->check_perm( 'admin', 'restricted' );
 780          $entries = NULL;
 781  
 782          if( $perm_admin_normal )
 783          {    // Normal Access to Admin:
 784              $entries = array(
 785                  'b2evo' => array(
 786                          'text' => '<strong>b2evolution</strong>',
 787                          'href' => $home_url,
 788                      ),
 789                  'dashboard' => array(
 790                          'text' => T_('Dashboard'),
 791                          'href' => $admin_url,
 792                          'title' => T_('Go to admin dashboard'),
 793                      ),
 794                  'see' => array(
 795                          'text' => T_('See'),
 796                          'href' => $home_url,
 797                          'title' => T_('See the home page'),
 798                      ),
 799                  'write' => array(
 800                          'text' => T_('Write'),
 801                          'title' => T_('No blog is currently selected'),
 802                          'disabled' => true,
 803                      ),
 804                  'blog' => array(
 805                          'text' => T_('Blog'),
 806                          'title' => T_('No blog is currently selected'),
 807                          'disabled' => true,
 808                      ),
 809                  'tools' => array(
 810                          'text' => T_('More'),
 811                          'disabled' => true,
 812                      ),
 813              );
 814          }
 815          elseif( $perm_admin_restricted )
 816          {    // restricted Access to Admin:
 817              $entries = array(
 818                  'see' => array(
 819                          'text' => T_('Site'),
 820                          'href' => $home_url,
 821                          'title' => T_('See the home page'),
 822                      ),
 823              );
 824              if( $current_User->check_perm( 'blogs', 'create' ) )
 825              {
 826                  $entries[ 'blog' ] = array(
 827                      'text' => T_('Blog'),
 828                      'title' => T_('No blog is currently selected'),
 829                      'disabled' => true,
 830                  );
 831              }
 832              $entries[ 'tools' ] = array(
 833                  'text' => T_('More'),
 834                  'disabled' => true,
 835              );
 836          }
 837  
 838  
 839          if( !empty($Blog) )
 840          {    // A blog is currently selected:
 841              if( $perm_admin_normal )
 842              {
 843                  $entries['dashboard']['href'] = $admin_url.'?blog='.$Blog->ID;
 844              }
 845  
 846              if( $perm_admin_restricted )
 847              {
 848                  $entries['see']['href'] = $Blog->get( 'url' );
 849                  $entries['see']['title'] = T_('See the public view of this blog');
 850              }
 851  
 852              if( $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) )
 853              { // We have permission to add a post with at least one status:
 854                  $write_item_url = $Blog->get_write_item_url();
 855                  if( $write_item_url )
 856                  { // write item URL is not empty, so it's sure that user can create new post
 857                      if( !$perm_admin_normal )
 858                      {
 859                          $entries[ 'write' ] = array(
 860                              'text' => T_('Write'),
 861                          );
 862                      }
 863                      $entries['write']['href'] = $write_item_url;
 864                      $entries['write']['disabled'] = false;
 865                      $entries['write']['title'] = T_('Write a new post into this blog');
 866                  }
 867              }
 868  
 869              if( $perm_admin_normal )
 870              {
 871                  if( empty( $write_item_url) )
 872                  { // Display restricted message on this blog
 873                      $entries['write']['title'] = T_('You don\'t have permission to post into this blog');
 874                  }
 875  
 876                  // BLOG MENU:
 877                  $items_url = $admin_url.'?ctrl=items&amp;blog='.$Blog->ID.'&amp;filter=restore';
 878                  $entries['blog']['href'] = $items_url;
 879                  $entries['blog']['disabled'] = false;
 880                  $entries['blog']['title'] = T_('Manage this blog');
 881  
 882                  if( $Blog->get( 'type' ) == 'manual' )
 883                  { // Manual Pages
 884                      $entries['blog']['entries']['manual'] = array(
 885                                      'text' => T_('Manual Pages').'&hellip;',
 886                                      'href' => $items_url.'&amp;tab=manual',
 887                                  );
 888                  }
 889  
 890                  $entries['blog']['entries']['posts'] = array(
 891                                  'text' => T_('Posts').'&hellip;',
 892                                  'href' => $items_url,
 893                              );
 894  
 895                  // Check if user has permission for published, draft or depreceted comments (any of these)
 896                  if( $current_User->check_perm( 'blog_comments', 'edit', false, $Blog->ID ) )
 897                  {    // Comments:
 898                      $entries['blog']['entries']['comments'] = array(
 899                              'text' => T_('Comments').'&hellip;',
 900                              'href' => $admin_url.'?ctrl=comments&amp;blog='.$Blog->ID.'&amp;filter=restore',
 901                          );
 902                  }
 903  
 904                  // Chapters / Categories:
 905                  if( $current_User->check_perm( 'blog_cats', 'edit', false, $Blog->ID ) )
 906                  {    // Either permission for a specific blog or the global permission:
 907                      $entries['blog']['entries']['chapters'] = array(
 908                              'text' => T_('Categories').'&hellip;',
 909                              'href' => $admin_url.'?ctrl=chapters&amp;blog='.$Blog->ID,
 910                          );
 911                  }
 912  
 913                  // PLACE HOLDER FOR FILES MODULE:
 914                  $entries['blog']['entries']['files'] = NULL;
 915  
 916                  // BLOG SETTINGS:
 917                  if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) )
 918                  {    // We have permission to edit blog properties:
 919                      $blog_param = '&amp;blog='.$Blog->ID;
 920  
 921                      if( ! empty($entries['blog']['entries']) )
 922                      {    // There are already entries aboce, insert a separator:
 923                          $entries['blog']['entries'][] = array(
 924                              'separator' => true,
 925                          );
 926                      }
 927                      $entries['blog']['entries']['general'] = array(
 928                                  'text' => T_('Blog settings'),
 929                                  'href' => $admin_url.'?ctrl=coll_settings'.$blog_param,
 930                                  'entries' => array(
 931                                      'general' => array(
 932                                          'text' => T_('General').'&hellip;',
 933                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=general'.$blog_param,
 934                                      ),
 935                                      'features' => array(
 936                                          'text' => T_('Features').'&hellip;',
 937                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=features'.$blog_param,
 938                                      ),
 939                                      'skin' => array(
 940                                          'text' => T_('Skin').'&hellip;',
 941                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=skin'.$blog_param,
 942                                      ),
 943                                      'plugin_settings' => array(
 944                                          'text' => T_('Plugins').'&hellip;',
 945                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=plugin_settings'.$blog_param,
 946                                      ),
 947                                      'widgets' => array(
 948                                          'text' => T_('Widgets').'&hellip;',
 949                                          'href' => $admin_url.'?ctrl=widgets'.$blog_param,
 950                                      ),
 951                                      'urls' => array(
 952                                          'text' => T_('URLs').'&hellip;',
 953                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=urls'.$blog_param,
 954                                      ),
 955                                      'seo' => array(
 956                                          'text' => T_('SEO').'&hellip;',
 957                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=seo'.$blog_param,
 958                                      ),
 959                                      'advanced' => array(
 960                                          'text' => T_('Advanced').'&hellip;',
 961                                          'href' => $admin_url.'?ctrl=coll_settings&amp;tab=advanced'.$blog_param,
 962                                      ),
 963                                  )
 964                          );
 965  
 966                          if( $Blog && $Blog->advanced_perms )
 967                          {
 968                              $entries['blog']['entries']['general']['entries']['userperms'] = array(
 969                                  'text' => T_('User perms').'&hellip;',
 970                                  'href' => $admin_url.'?ctrl=coll_settings&amp;tab=perm'.$blog_param,
 971                              );
 972                              $entries['blog']['entries']['general']['entries']['groupperms'] = array(
 973                                  'text' => T_('Group perms').'&hellip;',
 974                                  'href' => $admin_url.'?ctrl=coll_settings&amp;tab=permgroup'.$blog_param,
 975                              );
 976                          }
 977                  }
 978              }
 979          }
 980  
 981          // SYSTEM MENU:
 982          if( $perm_admin_restricted )
 983          {
 984              if( $debug )
 985              {
 986                  $debug_text = 'DEBUG: ';
 987                  if( !empty($seo_page_type) )
 988                  {    // Set in skin_init()
 989                      $debug_text = $seo_page_type.': ';
 990                  }
 991                  if( $robots_index === false )
 992                  {
 993                      $debug_text .= 'NO INDEX';
 994                  }
 995                  else
 996                  {
 997                      $debug_text .= 'do index';
 998                  }
 999  
1000                  $entries['tools']['entries']['noindex'] = array(
1001                          'text' => $debug_text,
1002                          'disabled' => true,
1003                      );
1004                  $entries['tools']['entries'][''] = array(
1005                          'separator' => true,
1006                      );
1007              }
1008  
1009              if( $current_User->check_perm( 'users', 'view' ) )
1010              {    // Users:
1011                  $entries['tools']['disabled'] = false;
1012                  $entries['tools']['entries']['users'] = array(
1013                          'text' => T_('Users').'&hellip;',
1014                          'href' => $admin_url.'?ctrl=users',
1015                      );
1016              }
1017  
1018              // PLACE HOLDER FOR MESSAGING MODULE:
1019              $entries['tools']['entries']['messaging'] = NULL;
1020  
1021              // PLACE HOLDER FOR FILES MODULE:
1022              $entries['tools']['entries']['files'] = NULL;
1023  
1024              $perm_spam = $current_User->check_perm( 'spamblacklist', 'view' );
1025              $perm_options = $current_User->check_perm( 'options', 'view' );
1026              $perm_emails = $current_User->check_perm( 'emails', 'view' );
1027              $perm_slugs = $current_User->check_perm( 'slugs', 'view' );
1028              $perm_maintenance = $current_User->check_perm( 'perm_maintenance', 'upgrade' );
1029  
1030              if( $perm_spam || $perm_options || $perm_slugs || $perm_maintenance )
1031              {
1032                  if( $perm_emails )
1033                  {
1034                      $entries['tools']['entries']['email'] = array(
1035                              'text' => T_('Emails'),
1036                              'href' => $admin_url.'?ctrl=email',
1037                              'entries' => array(
1038                                  'blocked' => array(
1039                                      'text' => T_('Addresses').'&hellip;',
1040                                      'href' => $admin_url.'?ctrl=email' ),
1041                                  'sent' => array(
1042                                      'text' => T_('Sent').'&hellip;',
1043                                      'href' => $admin_url.'?ctrl=email&amp;tab=sent' ),
1044                                  'return' => array(
1045                                      'text' => T_('Returned').'&hellip;',
1046                                      'href' => $admin_url.'?ctrl=email&amp;tab=return' ),
1047                                  'settings' => array(
1048                                      'text' => T_('Settings').'&hellip;',
1049                                      'href' => $admin_url.'?ctrl=email&amp;tab=settings' ),
1050                                  )
1051                          );
1052                  }
1053  
1054                  $entries['tools']['disabled'] = false;
1055                  $entries['tools']['entries']['tools_sep'] = array(
1056                          'separator' => true,
1057                      );
1058  
1059                  if( $perm_options )
1060                  {
1061                      $entries['tools']['entries']['status'] = array(
1062                              'text' => T_('System status').'&hellip;',
1063                              'href' => $admin_url.'?ctrl=system',
1064                          );
1065                  }
1066  
1067                  if( $perm_options )
1068                  {
1069                          $entries['tools']['entries']['crontab'] = array(
1070                                      'text' => T_('Scheduler').'&hellip;',
1071                                      'href' => $admin_url.'?ctrl=crontab',
1072                                  );
1073                  }
1074  
1075                  if( $perm_spam )
1076                  {
1077                      $entries['tools']['entries']['antispam'] = array(
1078                              'text' => T_('Antispam'),
1079                              'href' => $admin_url.'?ctrl=antispam',
1080                              'entries' => array(
1081                                      'blacklist' => array(
1082                                          'text' => T_('Blacklist').'&hellip;',
1083                                          'href' => $admin_url.'?ctrl=antispam' )
1084                                  )
1085                          );
1086  
1087                      if( $perm_options )
1088                      {    // If we have access to options, then we add a submenu:
1089                          $entries['tools']['entries']['antispam']['entries']['ipranges'] = array(
1090                                  'text' => T_('IP Ranges').'&hellip;',
1091                                  'href' => $admin_url.'?ctrl=antispam&amp;tab3=ipranges' );
1092  
1093                          $entries['tools']['entries']['antispam']['entries']['settings'] = array(
1094                                  'text' => T_('Settings').'&hellip;',
1095                                  'href' => $admin_url.'?ctrl=antispam&amp;tab3=settings' );
1096  
1097                          if( $current_User->check_perm( 'options', 'edit' ) )
1098                          {
1099                              $entries['tools']['entries']['antispam']['entries']['tools'] = array(
1100                                      'text' => T_('Tools').'&hellip;',
1101                                      'href' => $admin_url.'?ctrl=antispam&amp;tab3=tools' );
1102                          }
1103                      }
1104                  }
1105  
1106                  if( $perm_slugs )
1107                  {
1108                      $entries['tools']['entries']['slugs'] = array(
1109                              'text' => T_('Slugs').'&hellip;',
1110                              'href' => $admin_url.'?ctrl=slugs'
1111                          );
1112                  }
1113              }
1114  
1115  
1116              if( $perm_options )
1117              {    // Global settings:
1118                  $entries['tools']['entries']['general'] = array(
1119                          'text' => T_('General').'&hellip;',
1120                          'href' => $admin_url.'?ctrl=gensettings',
1121                      );
1122                  $entries['tools']['entries']['regional'] = array(
1123                          'text' => T_('Regional'),
1124                          'href' => $admin_url.'?ctrl=regional',
1125                          'entries' => array(
1126                              'locales' => array(
1127                                  'text' => T_('Locales').'&hellip;',
1128                                  'href' => $admin_url.'?ctrl=locales' ),
1129                              'time' => array(
1130                                  'text' => T_('Time').'&hellip;',
1131                                  'href' => $admin_url.'?ctrl=time' ),
1132                              'countries' => array(
1133                                  'text' => T_('Countries').'&hellip;',
1134                                  'href' => $admin_url.'?ctrl=countries' ),
1135                              'regions' => array(
1136                                  'text' => T_('Regions').'&hellip;',
1137                                  'href' => $admin_url.'?ctrl=regions' ),
1138                              'subregions' => array(
1139                                  'text' => T_('Sub-regions').'&hellip;',
1140                                  'href' => $admin_url.'?ctrl=subregions' ),
1141                              'cities' => array(
1142                                  'text' => T_('Cities').'&hellip;',
1143                                  'href' => $admin_url.'?ctrl=cities' ),
1144                              'currencies' => array(
1145                                  'text' => T_('Currencies').'&hellip;',
1146                                  'href' => $admin_url.'?ctrl=currencies' ),
1147                          )
1148                      );
1149                  $entries['tools']['entries']['plugins'] = array(
1150                          'text' => T_('Plugins').'&hellip;',
1151                          'href' => $admin_url.'?ctrl=plugins',
1152                      );
1153                  $entries['tools']['entries']['remote'] = array(
1154                          'text' => T_('Remote publishing').'&hellip;',
1155                          'href' => $admin_url.'?ctrl=remotepublish',
1156                      );
1157                  $entries['tools']['entries']['maintenance'] = array(
1158                          'text' => T_('Maintenance'),
1159                          'href' => $admin_url.'?ctrl=tools',
1160                          'entries' => array(
1161                              'tools' => array(
1162                                  'text' => T_('Tools').'&hellip;',
1163                                  'href' => $admin_url.'?ctrl=tools' ),
1164                              'import' => array(
1165                                  'text' => T_('Import').'&hellip;',
1166                                  'href' => $admin_url.'?ctrl=tools&amp;tab3=import' ),
1167                              'test' => array(
1168                                  'text' => T_('Testing').'&hellip;',
1169                                  'href' => $admin_url.'?ctrl=tools&amp;tab3=test' ),
1170                              'backup' => array(
1171                                  'text' => T_('Backup').'&hellip;',
1172                                  'href' => $admin_url.'?ctrl=backup' ),
1173                              'upgrade' => array(
1174                                  'text' => T_('Check for updates').'&hellip;',
1175                                  'href' => $admin_url.'?ctrl=upgrade' ),
1176                              )
1177                      );
1178              }
1179          }
1180  
1181          global $debug, $debug_jslog;
1182          if( $debug || $debug_jslog )
1183          {    // Show JS log menu if debug is enabled
1184              $entries['jslog'] = array(
1185                  'text'  => T_('JS log'),
1186                  'title' => T_('JS log'),
1187                  'class' => 'jslog_switcher'
1188              );
1189          }
1190  
1191          if( $entries !== NULL )
1192          {
1193              $topleft_Menu->add_menu_entries( NULL, $entries );
1194          }
1195  
1196  
1197  
1198  
1199          // ---------------------------------------------------------------------------
1200  
1201          /*
1202           * RIGHT MENU
1203           */
1204          global $localtimenow, $is_admin_page;
1205  
1206          $entries = array(
1207              'userprefs' => array(
1208                      'text' => $current_User->get_avatar_imgtag( 'crop-top-15x15', '', 'top' ).' <strong>'.$current_User->get_colored_login().'</strong>',
1209                      'href' => get_user_profile_url(),
1210                      'entries' => array(
1211                          'profile' => array(
1212                                  'text' => T_('Edit your profile').'&hellip;',
1213                                  'href' => get_user_profile_url(),
1214                              ),
1215                          'avatar' => array(
1216                                  'text' => T_('Your profile picture').'&hellip;',
1217                                  'href' => get_user_avatar_url(),
1218                              ),
1219                          'pwdchange' => array(
1220                                  'text' => T_('Change password').'&hellip;',
1221                                  'href' => get_user_pwdchange_url(),
1222                              ),
1223                          'userprefs' => array(
1224                                  'text' => T_('Preferences').'&hellip;',
1225                                  'href' => get_user_preferences_url(),
1226                              ),
1227                          'subs' => array(
1228                                  'text' => T_('Notifications').'&hellip;',
1229                                  'href' => get_user_subs_url(),
1230                              ),
1231                          ),
1232                  ),
1233              'time' => array(
1234                      'text' => date( locale_shorttimefmt(), $localtimenow ),
1235                      // fp> TODO href to Timezone settings if permission
1236                      'disabled' => true,
1237                      'class' => 'noborder',
1238                  ),
1239          );
1240  
1241          // ADMIN SKINS:
1242          if( $is_admin_page )
1243          {
1244              $admin_skins = get_admin_skins();
1245              if( count( $admin_skins ) > 1 )
1246              {    // We have several admin skins available: display switcher:
1247                  $entries['userprefs']['entries']['admskins_sep'] = array(
1248                          'separator' => true,
1249                      );
1250                  $entries['userprefs']['entries']['admskins'] = array(
1251                          'text' => T_('Admin skin'),
1252                      );
1253                  $redirect_to = rawurlencode(regenerate_url('', '', '', '&'));
1254                  foreach( $admin_skins as $admin_skin )
1255                  {
1256                      $entries['userprefs']['entries']['admskins']['entries'][$admin_skin] = array(
1257                              'text' => $admin_skin,
1258                              'href' => $dispatcher.'?ctrl=users&amp;action=change_admin_skin&amp;new_admin_skin='.rawurlencode($admin_skin)
1259                                  .'&amp;redirect_to='.$redirect_to
1260                          );
1261                  }
1262              }
1263          }
1264  
1265  
1266          $entries['userprefs']['entries']['logout_sep'] = array(
1267                  'separator' => true,
1268              );
1269          $entries['userprefs']['entries']['logout'] = array(
1270                  'text' => T_('Logout'),
1271                  'href' => get_user_logout_url(),
1272              );
1273  
1274          // AB switch:
1275          if( $perm_admin_normal )
1276          {    // User must have permission to access admin...
1277              if( $is_admin_page )
1278              {
1279                  if( !empty( $Blog ) )
1280                  {
1281                      $entries['abswitch'] = array(
1282                              'text' => T_('Blog').' '.get_icon('switch-to-blog'),
1283                              'href' => $Blog->get( 'url' ),
1284                          );
1285                  }
1286                  else
1287                  {
1288                      $entries['abswitch'] = array(
1289                              'text' => T_('Home').' '.get_icon('switch-to-blog'),
1290                              'href' => $home_url,
1291                          );
1292                  }
1293              }
1294              else
1295              {
1296                  $entries['abswitch'] = array(
1297                          'text' => T_('Admin').' '.get_icon('switch-to-admin'),
1298                          'href' => $admin_url,
1299                      );
1300              }
1301          }
1302  
1303          $topright_Menu->add_menu_entries( NULL, $entries );
1304  
1305          $topright_Menu->add_menu_entries( NULL, array(
1306              'logout' => array(
1307                  'text' => T_('Logout').' '.get_icon('close'),
1308                  'class' => 'rollover_sprite',
1309                  'href' => get_user_logout_url(),
1310                  )
1311           ) );
1312  
1313      }
1314  
1315  
1316      /**
1317       * Builds the 3rd half of the menu. This is the one with the configuration features
1318       *
1319       * At some point this might be displayed differently than the 1st half.
1320       */
1321  	function build_menu_3()
1322      {
1323          global $blog, $loc_transinfo, $ctrl, $dispatcher, $Settings;
1324          /**
1325           * @var User
1326           */
1327          global $current_User;
1328          global $Blog;
1329          /**
1330           * @var AdminUI_general
1331           */
1332          global $AdminUI;
1333  
1334          $perm_admin_normal = $current_User->check_perm( 'admin', 'normal' );
1335          $perm_options = $current_User->check_perm( 'options', 'view' );
1336          $perm_users = $current_User->check_perm( 'users', 'view' );
1337  
1338          /**** Users | My profile ****/
1339          if( $perm_admin_normal && $perm_users )
1340          { // Permission to view users:
1341              $users_entries = array(
1342                          'text' => T_('Users'),
1343                          'title' => T_('User management'),
1344                          'href' => '?ctrl=users' );
1345  
1346              $user_ID = param( 'user_ID', 'integer', NULL );
1347          }
1348          else
1349          {
1350              $user_ID = $current_User->ID;
1351              // Only perm to view his own profile:
1352              $users_entries = array(
1353                          'text' => T_('My profile'),
1354                          'title' => T_('User profile'),
1355                          'href' => '?ctrl=user&amp;user_tab=profile&amp;user_ID='.$user_ID );
1356          }
1357  
1358          if( $perm_admin_normal && $perm_users )
1359          { // Has permission for viewing all users
1360              // fp> the following submenu needs even further breakdown.
1361              $users_entries['entries'] = array(
1362                      'users' => array(
1363                          'text' => T_('Users'),
1364                          'href' => '?ctrl=users' ),
1365                      'stats' => array(
1366                          'text' => T_('Stats'),
1367                          'href' => '?ctrl=users&amp;tab=stats' ),
1368                      'groups' => array(
1369                          'text' => T_('User groups'),
1370                          'href' => '?ctrl=groups' ),
1371                      'usersettings' => array(
1372                          'text' => T_('User settings'),
1373                          'href' => '?ctrl=usersettings',
1374                          'entries' => array(
1375                              'usersettings' => array(
1376                                  'text' => T_('Profiles'),
1377                                  'href' => '?ctrl=usersettings' ),
1378                              'registration' => array(
1379                                  'text' => T_('Registration'),
1380                                  'href' => '?ctrl=registration' ),
1381                              'display' => array(
1382                                  'text' => T_('Display'),
1383                                  'href' => '?ctrl=display' ),
1384                              'userfields' => array(
1385                                  'text' => T_('User fields'),
1386                                  'href' => '?ctrl=userfields' ),
1387                              ),
1388                          ),
1389                  );
1390          }
1391  
1392          $AdminUI->add_menu_entries( NULL, array( 'users' => $users_entries ) );
1393  
1394          /**** Emails ****/
1395          $perm_emails = $current_User->check_perm( 'emails', 'view' );
1396          if( $perm_admin_normal && $perm_options && $perm_emails )
1397          { // Permission to view email management:
1398              $AdminUI->add_menu_entries( NULL, array( 'email' => array(
1399                      'text' => T_('Emails'),
1400                      'href' => '?ctrl=email',
1401                      'entries' => array(
1402                          'blocked' => array(
1403                              'text' => T_('Addresses'),
1404                              'href' => '?ctrl=email' ),
1405                          'sent' => array(
1406                              'text' => T_('Sent'),
1407                              'href' => '?ctrl=email&amp;tab=sent' ),
1408                          'return' => array(
1409                              'text' => T_('Returned'),
1410                              'href' => '?ctrl=email&amp;tab=return' ),
1411                          'settings' => array(
1412                              'text' => T_('Settings'),
1413                              'href' => '?ctrl=email&amp;tab=settings' ),
1414                          ) ) ) );
1415          }
1416  
1417          /**** System ****/
1418          if( $perm_admin_normal && $perm_options )
1419          {    // Permission to view settings:
1420              $AdminUI->add_menu_entries( NULL, array(
1421                          'options' => array(
1422                              'text' => T_('System'),
1423                              'href' => $dispatcher.'?ctrl=system'
1424                  ) ) );
1425  
1426              $perm_spam = $current_User->check_perm( 'spamblacklist', 'view' );
1427              $perm_slugs = $current_User->check_perm( 'slugs', 'view' );
1428  
1429              if( $perm_admin_normal && ( $perm_options || $perm_spam || $perm_slugs ) )
1430              {    // Permission to view tools, antispam or slugs.
1431                  if( $perm_options )
1432                  {    // Permission to view settings:
1433                      // FP> This assumes that we don't let regular users access the tools, including plugin tools.
1434                      $AdminUI->add_menu_entries( 'options', array(
1435                          'system' => array(
1436                              'text' => T_('Status'),
1437                              'href' => '?ctrl=system' ),
1438                          'cron' => array(
1439                              'text' => T_('Scheduler'),
1440                              'href' => '?ctrl=crontab' ) ) );
1441                  }
1442                  if( $perm_spam )
1443                  {    // Permission to view antispam:
1444                      /*if( !$perm_options )
1445                      {
1446                          $tools_entries['tools']['href'] = '?ctrl=antispam';
1447                      }*/
1448                      $AdminUI->add_menu_entries( 'options', array(
1449                          'antispam' => array(
1450                              'text' => T_('Antispam'),
1451                              'href' => '?ctrl=antispam',
1452                              'entries' => array(
1453                                  'blacklist' => array(
1454                                      'text' => T_('Blacklist'),
1455                                      'href' => '?ctrl=antispam' ) ) ) ) );
1456  
1457                      if( $perm_options )
1458                      {    // If we have access to options, then we add a submenu:
1459                          $AdminUI->add_menu_entries( array( 'options', 'antispam' ), array(
1460                              'ipranges' => array(
1461                                  'text' => T_('IP Ranges'),
1462                                  'href' => '?ctrl=antispam&amp;tab3=ipranges' ) ) );
1463  
1464                          $AdminUI->add_menu_entries( array( 'options', 'antispam' ), array(
1465                              'settings' => array(
1466                                  'text' => T_('Settings'),
1467                                  'href' => '?ctrl=antispam&amp;tab3=settings' ) ) );
1468  
1469                          if( $current_User->check_perm( 'options', 'edit' ) )
1470                          {
1471                              $AdminUI->add_menu_entries( array( 'options', 'antispam' ), array(
1472                                  'tools' => array(
1473                                      'text' => T_('Tools'),
1474                                      'href' => '?ctrl=antispam&amp;tab3=tools' ) ) );
1475                          }
1476                      }
1477                  }
1478  
1479                  if( $perm_slugs )
1480                  {    // Permission to view slugs:
1481                      /*if( !$perm_options && !$perm_spam )
1482                      {
1483                          $tools_entries['tools']['href'] = '?ctrl=slugs';
1484                      }*/
1485                      $AdminUI->add_menu_entries( 'options', array(
1486                          'slugs' => array(
1487                              'text' => T_('Slugs'),
1488                              'href' => '?ctrl=slugs' ) ) );
1489                  }
1490              }
1491  
1492  
1493              $AdminUI->add_menu_entries( 'options', array(
1494                  'general' => array(
1495                      'text' => T_('General'),
1496                      'href' => '?ctrl=gensettings' ),
1497                  'regional' => array(
1498                      'text' => T_('Regional'),
1499                      'href' => '?ctrl=regional',
1500                      'entries' => array(
1501                          'locales' => array(
1502                              'text' => T_('Locales'),
1503                              'href' => '?ctrl=locales'.( (isset($loc_transinfo) && $loc_transinfo) ? '&amp;loc_transinfo=1' : '' ) ),
1504                          'time' => array(
1505                              'text' => T_('Time'),
1506                              'href' => '?ctrl=time' ),
1507                          'countries' => array(
1508                              'text' => T_('Countries'),
1509                              'href' => '?ctrl=countries' ),
1510                          'regions' => array(
1511                              'text' => T_('Regions'),
1512                              'href' => '?ctrl=regions' ),
1513                          'subregions' => array(
1514                              'text' => T_('Sub-regions'),
1515                              'href' => '?ctrl=subregions' ),
1516                          'cities' => array(
1517                              'text' => T_('Cities'),
1518                              'href' => '?ctrl=cities' ),
1519                          'currencies' => array(
1520                              'text' => T_('Currencies'),
1521                              'href' => '?ctrl=currencies' ),
1522                          ) ),
1523                  'plugins' => array(
1524                      'text' => T_('Plugins'),
1525                      'href' => '?ctrl=plugins'),
1526                  'remotepublish' => array(
1527                      'text' => T_('Remote Publishing'),
1528                      'href' => '?ctrl=remotepublish',
1529                      'entries' => array(
1530                          'eblog' => array(
1531                              'text' => T_('Post by Email'),
1532                              'href' => '?ctrl=remotepublish&amp;tab=eblog' ),
1533                          'xmlrpc' => array(
1534                              'text' => T_('XML-RPC'),
1535                              'href' => '?ctrl=remotepublish&amp;tab=xmlrpc' )
1536                      ) ),
1537              ) );
1538          }
1539  
1540      }
1541  }
1542  
1543  $_core_Module = new _core_Module();
1544  
1545  ?>

title

Description

title

Description

title

Description

title

title

Body