[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/class/ -> removeclass.php (source)

   1  <?php
   2  //
   3  //
   4  // SOFTWARE NAME: eZ publish
   5  // SOFTWARE RELEASE: 3.9.0
   6  // BUILD VERSION: 17785
   7  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   8  // SOFTWARE LICENSE: GNU General Public License v2.0
   9  // NOTICE: >
  10  //   This program is free software; you can redistribute it and/or
  11  //   modify it under the terms of version 2.0  of the GNU General
  12  //   Public License as published by the Free Software Foundation.
  13  //
  14  //   This program is distributed in the hope that it will be useful,
  15  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17  //   GNU General Public License for more details.
  18  //
  19  //   You should have received a copy of version 2.0 of the GNU General
  20  //   Public License along with this program; if not, write to the Free
  21  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22  //   MA 02110-1301, USA.
  23  //
  24  //
  25  
  26  include_once ( "kernel/classes/ezcontentclass.php" );
  27  include_once ( "lib/ezutils/classes/ezhttppersistence.php" );
  28  include_once ( "kernel/classes/ezcontentclassclassgroup.php" );
  29  include_once ( "lib/ezutils/classes/ezini.php" );
  30  include_once ( 'kernel/classes/ezcontentobjecttreenode.php' );
  31  
  32  $Module =& $Params["Module"];
  33  $GroupID = null;
  34  if ( isset( $Params["GroupID"] ) )
  35      $GroupID =& $Params["GroupID"];
  36  $http =& eZHTTPTool::instance();
  37  $deleteIDArray = $http->sessionVariable( "DeleteClassIDArray" );
  38  $DeleteResult = array();
  39  $alreadyRemoved = array();
  40  
  41  if ( !$http->hasPostVariable( 'ConfirmButton' ) && !$http->hasPostVariable( 'CancelButton' ) && $GroupID != null )
  42  {
  43      // we will remove class - group relations rather than classes if they belongs to more than 1 group:
  44      $updateDeleteIDArray = true;
  45      foreach ( array_keys( $deleteIDArray ) as $key )
  46      {
  47          $classID = $deleteIDArray[$key];
  48          // for each classes tagged for deleting:
  49          $class = eZContentClass::fetch( $classID );
  50          if ( $class )
  51          {
  52              // find out to how many groups the class belongs:
  53              $classInGroups = $class->attribute( 'ingroup_list' );
  54              if ( count( $classInGroups ) != 1 )
  55              {
  56                  // remove class - group relation:
  57                  include_once ( "kernel/class/ezclassfunctions.php" );
  58                  eZClassFunctions::removeGroup( $classID, null, array( $GroupID ) );
  59                  $alreadyRemoved[] = array( 'id' => $classID,
  60                                             'name' => $class->attribute( 'name' ) );
  61                  $updateDeleteIDArray = true;
  62                  unset( $deleteIDArray[$key] );
  63              }
  64          }
  65      }
  66      if ( $updateDeleteIDArray )
  67      {
  68          // we aren't going to remove classes already processed:
  69          $http->setSessionVariable( 'DeleteClassIDArray', $deleteIDArray );
  70      }
  71      if ( count( $deleteIDArray ) == 0 )
  72      {
  73          // we don't need anything to confirm:
  74          return $Module->redirectTo( '/class/classlist/' . $GroupID );
  75      }
  76  }
  77  
  78  if ( $http->hasPostVariable( "ConfirmButton" ) )
  79  {
  80      foreach ( $deleteIDArray as $deleteID )
  81      {
  82          include_once ( 'kernel/classes/ezcontentclassoperations.php' );
  83          eZContentClassOperations::remove( $deleteID );
  84      }
  85      return $Module->redirectTo( '/class/classlist/' . $GroupID );
  86  }
  87  if ( $http->hasPostVariable( "CancelButton" ) )
  88  {
  89      return $Module->redirectTo( '/class/classlist/' . $GroupID );
  90  }
  91  
  92  $canRemoveCount = 0;
  93  foreach ( $deleteIDArray as $deleteID )
  94  {
  95      $ClassObjectsCount = 0;
  96      $class = eZContentClass::fetch( $deleteID );
  97      if ( $class != null )
  98      {
  99          $class = eZContentClass::fetch( $deleteID );
 100          $ClassID = $class->attribute( 'id' );
 101          $ClassName = $class->attribute( 'name' );
 102          if ( !$class->isRemovable() )
 103          {
 104              $item = array( "className" => $ClassName,
 105                             'objectCount' => 0,
 106                             "is_removable" => false,
 107                             'reason' => $class->removableInformation() );
 108              $DeleteResult[] = $item;
 109              continue;
 110          }
 111          ++$canRemoveCount;
 112          $classObjects = eZContentObject::fetchSameClassList( $ClassID );
 113          $ClassObjectsCount = count( $classObjects );
 114          $item = array( "className" => $ClassName,
 115                         "is_removable" => true,
 116                         "objectCount" => $ClassObjectsCount );
 117          $DeleteResult[] = $item;
 118      }
 119  }
 120  
 121  $canRemove = ( $canRemoveCount > 0 );
 122  
 123  $Module->setTitle( ezi18n( 'kernel/class', 'Remove classes %class_id', null, array( '%class_id' => $ClassID ) ) );
 124  include_once ( "kernel/common/template.php" );
 125  $tpl =& templateInit();
 126  
 127  $tpl->setVariable( 'module', $Module );
 128  $tpl->setVariable( 'GroupID', $GroupID );
 129  $tpl->setVariable( 'DeleteResult', $DeleteResult );
 130  $tpl->setVariable( 'already_removed', $alreadyRemoved );
 131  $tpl->setVariable( 'can_remove', $canRemove );
 132  
 133  $Result = array();
 134  $Result['content'] =& $tpl->fetch( "design:class/removeclass.tpl" );
 135  $Result['path'] = array( array( 'url' => '/class/grouplist/',
 136                                  'text' => ezi18n( 'kernel/class', 'Classes' ) ) );
 137  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7