[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/files/model/ -> _fileroot.class.php (source)

   1  <?php
   2  /**

   3   * This file implements the FileRoot 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-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   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: _fileroot.class.php,v 1.2 2007/11/01 04:31:25 fplanque Exp $

  28   */
  29  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  30  
  31  
  32  /**

  33   * This class provides info about a File Root.

  34   *

  35   * A FileRoot describes a directory available for media file storage, under access permission.

  36   *

  37   * @package evocore

  38   */
  39  class FileRoot
  40  {
  41      /**

  42       * Type: 'user', 'group' or 'collection'.

  43       *

  44       * Note: group is not implemented yet. Absolute will probably be deprecated.

  45       */
  46      var $type;
  47  
  48      /**

  49       * ID of user, group or collection.

  50       */
  51      var $in_type_ID;
  52  
  53      /**

  54       * Unique Root ID constructed from type and in_type_ID

  55       * @var string

  56       */
  57      var $ID;
  58  
  59      /**

  60       * Name of the root

  61       */
  62      var $name;
  63  
  64      /**

  65       * Absolute path, ending with slash

  66       */
  67      var $ads_path;
  68  
  69      /**

  70       * Absolute URL, ending with slash

  71       */
  72      var $ads_url;
  73  
  74  
  75      /**

  76       * Constructor

  77       *

  78       * Will fail if non existent User or Blog is requested.

  79       * But specific access permissions on (threfore existence of) this User or Blog should have been tested before anyway.

  80       *

  81       * @param string Root type: 'user', 'group' or 'collection'

  82       * @param integer ID of the user, the group or the collection the file belongs to...

  83       * @param boolean Create the directory, if it does not exist yet?

  84       */
  85  	function FileRoot( $root_type, $root_in_type_ID, $create = true )
  86      {
  87          // Store type:

  88          $this->type = $root_type;
  89          // Store ID in type:

  90          $this->in_type_ID = $root_in_type_ID;
  91          // Generate unique ID:

  92          $this->ID = FileRoot::gen_ID( $root_type, $root_in_type_ID );
  93  
  94          switch( $root_type )
  95          {
  96              case 'user':
  97                  $UserCache = & get_Cache( 'UserCache' );
  98                  $User = & $UserCache->get_by_ID( $root_in_type_ID );
  99                  $this->name = $User->get( 'preferredname' ); //.' ('. /* TRANS: short for "user" */ T_('u').')';
 100                  $this->ads_path = $User->get_media_dir( $create );
 101                  $this->ads_url = $User->get_media_url();
 102                  return;
 103  
 104              case 'collection':
 105                  $BlogCache = & get_Cache( 'BlogCache' );
 106                  /**

 107                   * @var Blog

 108                   */
 109                  $Blog = & $BlogCache->get_by_ID( $root_in_type_ID );
 110                  $this->name = $Blog->get( 'shortname' ); //.' ('. /* TRANS: short for "blog" */ T_('b').')';
 111                  $this->ads_path = $Blog->get_media_dir( $create );
 112                  $this->ads_url = $Blog->get_media_url();
 113                  return;
 114  
 115          case 'skins':
 116              // fp> some stuff here should go out of here... but I don't know where to put it yet. I'll see after the Skin refactoring.

 117              global $Settings, $Debuglog;
 118              /**

 119               * @var User

 120               */
 121              global $current_User;
 122               if( ! $Settings->get( 'fm_enable_roots_skins' ) )
 123                  { // Skins root is disabled:
 124                      $Debuglog->add( 'Attempt to access skins dir, but this feature is globally disabled', 'files' );
 125                  }
 126                  elseif( ! $current_User->check_perm( 'templates' ) )
 127                  {    // No perm to access templates:
 128                      $Debuglog->add( 'Attempt to access skins dir, but no permission', 'files' );
 129                  }
 130                  else
 131                  {
 132                      global $skins_path, $skins_url;
 133                      $this->name = T_('Skins');
 134                      $this->ads_path = $skins_path;
 135                      $this->ads_url = $skins_url;
 136                  }
 137                  return;
 138          }
 139  
 140          debug_die( "Root_type=$root_type not supported" );
 141      }
 142  
 143  
 144  	function get_typegroupname()
 145      {
 146          switch( $this->type )
 147          {
 148              case 'user':
 149                  return NT_('User roots');
 150  
 151              case 'collection':
 152                  return NT_('Blog roots');
 153  
 154              default:
 155                  return NT_('Special roots');
 156          }
 157      }
 158  
 159      /**

 160       * @static

 161       */
 162  	function gen_ID( $root_type, $root_in_type_ID )
 163      {
 164          switch( $root_type )
 165          {
 166              case 'user':
 167              case 'collection':
 168              case 'skins':
 169                  return $root_type.'_'.$root_in_type_ID;
 170          }
 171  
 172          debug_die( "Root_type=$root_type not supported" );
 173      }
 174  
 175  }
 176  
 177  
 178  /*

 179   * $Log: _fileroot.class.php,v $

 180   * Revision 1.2  2007/11/01 04:31:25  fplanque

 181   * Better root browsing (roots are groupes by type + only one root is shown at a time)

 182   *

 183   * Revision 1.1  2007/06/25 10:59:56  fplanque

 184   * MODULES (refactored MVC)

 185   *

 186   * Revision 1.14  2007/04/26 00:11:10  fplanque

 187   * (c) 2007

 188   *

 189   * Revision 1.13  2007/02/11 15:16:49  fplanque

 190   * doc

 191   *

 192   * Revision 1.11  2006/12/10 03:04:16  blueyed

 193   * TRANS note for "u" and "b"

 194   *

 195   * Revision 1.10  2006/12/08 01:53:18  fplanque

 196   * Added missing skin access switch

 197   *

 198   * Revision 1.9  2006/12/07 15:23:42  fplanque

 199   * filemanager enhanced, refactored, extended to skins directory

 200   *

 201   * Revision 1.8  2006/11/24 18:27:24  blueyed

 202   * Fixed link to b2evo CVS browsing interface in file docblocks

 203   */
 204  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics