b2evolution PHP Cross Reference Blogging Systems

Source: /inc/items/model/_itemtypecache.class.php - 112 lines - 3697 bytes - Summary - Text - Print

Description: This file implements the item type cache class. 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 implements the item type cache class.
   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   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
  22   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package evocore
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author fplanque: Francois PLANQUE.
  30   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  31   *
  32   * @version $Id: _itemtypecache.class.php 6425 2014-04-08 09:24:40Z yura $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  load_class( '_core/model/dataobjects/_dataobjectcache.class.php', 'DataObjectCache' );
  37  
  38  /**
  39   * ItemTypeCache Class
  40   *
  41   * @package evocore
  42   */
  43  class ItemTypeCache extends DataObjectCache
  44  {
  45      /**
  46       * Item type cache for each collection
  47       */
  48      var $col_cache = array();
  49  
  50      /**
  51       * Default item type for each collection
  52       */
  53      var $col_default = array();
  54  
  55  
  56      /**
  57       * Constructor
  58       *
  59       * @param table Database row
  60       */
  61  	function ItemTypeCache()
  62      {
  63          // Call parent constructor:
  64          parent::DataObjectCache( 'ItemType', true, 'T_items__type', 'ptyp_', 'ptyp_ID', 'ptyp_name', 'ptyp_ID' );
  65      }
  66  
  67  
  68      /**
  69       * Returns a form option list which only contains post types that can
  70       * be used by the current user (and in the current blog's context).
  71       *
  72       * The user cannot use any post type IDs listed in the {@see $posttypes_reserved_IDs}
  73       * array; to use the "Page", "Intro-*", "Podcast" and "Sidebar link"
  74       * post types, the current blog must grant the blog_page, blog_intro,
  75       * blog_podcast and blog_sidebar permission, respectively (see blog
  76       * user/group permissions).
  77       * 
  78       * @param integer The selected ID.
  79       * @param boolean Provide a choice for "none" with ID ''
  80       * @param string  Callback method name.
  81       * @return string
  82       */
  83  	function get_option_list_usable_only( $default = 0, $allow_none = false, $method = 'get_name' )
  84      {
  85          global $posttypes_reserved_IDs, $posttypes_perms, $current_User, $Blog;
  86  
  87          // Compile an array of post type IDs to exclude:
  88          $exclude_posttype_IDs = $posttypes_reserved_IDs;
  89  
  90          foreach( $posttypes_perms as $l_permname => $l_posttype_IDs )
  91          {
  92              if( ! $current_User->check_perm( 'blog_'.$l_permname, 'edit', false, $Blog->ID ) )
  93              {    // No permission to use this post type(s):
  94                  $exclude_posttype_IDs = array_merge( $exclude_posttype_IDs, $l_posttype_IDs );
  95              }
  96          }
  97  
  98          return $this->get_option_list( $default, $allow_none, $method, $exclude_posttype_IDs );
  99      }
 100  
 101      /**
 102       * For use by Universal Item List widget
 103       */
 104  	function get_option_array()
 105      {
 106          global $posttypes_reserved_IDs;
 107  
 108          return parent::get_option_array( 'get_name', $posttypes_reserved_IDs );
 109      }
 110  }
 111  
 112  ?>

title

Description

title

Description

title

Description

title

title

Body