コード例 #1
0
 /**
  * 
  * Enter description here ...
  *
  * @param Docman_Folder $item
  * @param $params
  */
 public function visitFolder(&$item, $params = array())
 {
     //delete all sub items before
     $items = $item->getAllItems();
     if (isset($params['parent'])) {
         $parent = $params['parent'];
     } else {
         $parent = $this->_getItemFactory()->getItemFromDb($item->getParentId());
     }
     $one_item_has_not_been_deleted = false;
     if ($items->size()) {
         $it =& $items->iterator();
         while ($it->valid()) {
             $o =& $it->current();
             $params['parent'] =& $item;
             if (!$o->accept($this, $params)) {
                 $one_item_has_not_been_deleted = true;
             }
             $it->next();
         }
     }
     if ($one_item_has_not_been_deleted) {
         $this->response->addFeedback('error', $GLOBALS['Language']->getText('plugin_docman', 'error_delete_notempty', $item->getTitle()));
         return false;
     } else {
         //Mark the folder as deleted;
         $params['parent'] =& $parent;
         return $this->_deleteItem($item, $params);
     }
 }
コード例 #2
0
 /**
  * Perform paste operation after a copy
  *
  * @param Docman_Item   $itemToPaste   Item to paste
  * @param Docman_Folder $newParentItem New parent item
  * @param PFUser          $user          User who perform the paste
  * @param String        $ordering      Where the item should be paste within the new folder
  * @param Boolean       $importMd      Do we need to import metadata from another project
  * @param String        $dataRoot      Where the docman data stand on hard drive
  *
  * @return void
  */
 protected function _doCopyPaste($itemToPaste, $newParentItem, $user, $ordering, $importMd, $dataRoot)
 {
     $srcMdFactory = new Docman_MetadataFactory($itemToPaste->getGroupId());
     // Import metadata if asked
     if ($importMd) {
         $srcMdFactory->exportMetadata($newParentItem->getGroupId());
     }
     // Get mapping between the 2 definitions
     $mdMapping = array();
     $srcMdFactory->getMetadataMapping($newParentItem->getGroupId(), $mdMapping);
     // Permissions
     if ($itemToPaste->getGroupId() != $newParentItem->getGroupId()) {
         $ugroupsMapping = false;
     } else {
         $ugroupsMapping = true;
     }
     //
     // Action
     $itemFactory = $this->_getItemFactory();
     $item_mapping = $itemFactory->cloneItems($itemToPaste->getGroupId(), $newParentItem->getGroupId(), $user, $mdMapping, $ugroupsMapping, $dataRoot, $itemToPaste->getId(), $newParentItem->getId(), $ordering);
     $event_manager = EventManager::instance();
     $event_manager->processEvent(PLUGIN_DOCMAN_EVENT_COPY, array('item' => $itemFactory->getItemFromDb($item_mapping[$itemToPaste->getId()])));
     $itemFactory->delCopyPreference();
     $itemFactory->delCutPreference();
 }
コード例 #3
0
 /**
  * Perform paste operation after a copy
  *
  * @param Docman_Item   $itemToPaste   Item to paste
  * @param Docman_Folder $newParentItem New parent item
  * @param User          $user          User who perform the paste
  * @param String        $ordering      Where the item should be paste within the new folder
  * @param Boolean       $importMd      Do we need to import metadata from another project
  * @param String        $dataRoot      Where the docman data stand on hard drive
  *
  * @return void
  */
 protected function _doCopyPaste($itemToPaste, $newParentItem, $user, $ordering, $importMd, $dataRoot)
 {
     $srcMdFactory = new Docman_MetadataFactory($itemToPaste->getGroupId());
     // Import metadata if asked
     if ($importMd) {
         $srcMdFactory->exportMetadata($newParentItem->getGroupId());
     }
     // Get mapping between the 2 definitions
     $mdMapping = array();
     $srcMdFactory->getMetadataMapping($newParentItem->getGroupId(), $mdMapping);
     // Permissions
     if ($itemToPaste->getGroupId() != $newParentItem->getGroupId()) {
         $ugroupsMapping = false;
     } else {
         $ugroupsMapping = true;
     }
     //
     // Action
     $itemFactory = $this->_getItemFactory();
     $itemFactory->cloneItems($itemToPaste->getGroupId(), $newParentItem->getGroupId(), $user, $mdMapping, $ugroupsMapping, $dataRoot, $itemToPaste->getId(), $newParentItem->getId(), $ordering);
     $itemFactory->delCopyPreference();
     $itemFactory->delCutPreference();
 }