class_CopyPasteHandler.inc 9.40 KiB
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2003-2010  Cajus Pollmeier
  Copyright (C) 2011-2017  FusionDirectory
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
/*!
 * \file class_CopyPasteHandler.inc
 * Source code for class CopyPasteHandle
/*!
 * \brief This class contains all function to copy and paste
class CopyPasteHandler
  var $current = FALSE;
  /*!
   * \brief This array contains all dns of the currently copied objects
  protected $objectList = [];
  /*!
   * \brief This array contains all remaining objects to paste
  protected $queue = [];
  /*!
   *  \brief The dn of the last edited object
  protected $lastdn = '';
  protected $disallowed_objects = [];
  protected $objects_to_fix     = [];
  protected $clean_objects      = [];
  protected $require_update     = FALSE;
  /*!
   * \brief Create CP handler
  function __construct ()
  /*!
   * \brief Entry entry to Copy & Paste queue.
   * A Queue entry is represented as follows.
   *  array['method']     - 'copy' or 'cut'
   *  array['dn']         - the dn of the object added to the queue
   *  array['type']       - Object type
   * \param String $dn The dn of the object added to the queue
   * \param String $action Copy or Cut
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
* \param String $type the type of the object */ function add_to_queue ($dn, $action, $type) { @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue'); if (!in_array($action, ['cut','copy'])) { trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action)); return FALSE; } $tmp = []; $tmp['method'] = $action; $tmp['dn'] = $dn; $tmp['type'] = $type; $infos = objects::infos($type); $tmp['aclCategory'] = $infos['aclCategory']; $tmp['mainTab'] = $infos['mainTab']; $tmp['parent'] = NULL; $this->queue[] = $tmp; if ($action == 'copy') { $this->objectList[] = $tmp; } $this->require_update = TRUE; return TRUE; } /*! * \brief This removes all objects from queue. * Remove hdd dumps of current entries too. * Remove entries older than 24 hours. */ function cleanup_queue () { $this->current = FALSE; $this->require_update = TRUE; $this->queue = []; $this->objectList = []; } /*! * \brief This resets the queue to allow pasting again. */ function resetPaste () { $this->current = FALSE; $this->require_update = TRUE; $this->queue = $this->objectList; } /*! * \brief Check if there are still entries the object queue */ function entries_queued () { return ((count($this->queue) > 0) || ($this->current !== FALSE)); } /*! * \brief Paste one entry from LDAP */ protected function load_entry_from_ldap ($entry) { @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap'); if (!isset($entry['tab_class']) && !isset($entry['type'])) {