コード例 #1
0
 private function getUgroupIdsPermissions(Docman_Item $item, UGroupLiteralizer $literalizer, Project $project)
 {
     $ugroups_ids = $literalizer->getUgroupIds($item->getId(), self::PERMISSIONS_TYPE);
     $parent_item = $this->getParentItem($item, $project);
     if ($parent_item) {
         $parent_ugroups_ids = $this->getUgroupIdsPermissions($parent_item, $literalizer, $project);
         $ugroups_ids = $this->mergeUgroupIds($parent_ugroups_ids, $ugroups_ids);
     }
     return array_values($ugroups_ids);
 }
コード例 #2
0
 private function getUgroupIdsPermissions(Docman_Item $item, UGroupLiteralizer $literalizer, Project $project)
 {
     $ugroups_ids = $literalizer->getUgroupIds($project, $item->getId(), self::PERMISSIONS_TYPE);
     if (empty($ugroups_ids)) {
         $ugroups_ids = PermissionsManager::instance()->getAuthorizedUgroupIds($project->getID(), 'PLUGIN_DOCMAN_ADMIN');
     }
     $parent_item = $this->getParentItem($item, $project);
     if ($parent_item) {
         $parent_ugroups_ids = $this->getUgroupIdsPermissions($parent_item, $literalizer, $project);
         $ugroups_ids = $this->mergeUgroupIds($parent_ugroups_ids, $ugroups_ids);
     }
     return array_values($ugroups_ids);
 }
コード例 #3
0
 /**
  * Builds the indexed data for first indexation
  *
  * @param Docman_Item    $item
  * @param Docman_Version $version
  *
  * @return array
  */
 public function getIndexedDataForItemVersion(Docman_Item $item)
 {
     $hardcoded_metadata = array('id' => $item->getId(), 'group_id' => $item->getGroupId(), 'title' => $item->getTitle(), 'description' => $item->getDescription(), 'create_date' => date('c', $item->getCreateDate()), 'update_date' => date('c', $item->getUpdateDate()), 'permissions' => $this->permissions_manager->exportPermissions($item), 'approval_table_comments' => $this->getDocumentApprovalTableComments($item), 'owner' => $item->getOwnerId());
     if ($item->getObsolescenceDate()) {
         $hardcoded_metadata['obsolescence_date'] = date('c', $item->getObsolescenceDate());
     }
     return $hardcoded_metadata;
 }
コード例 #4
0
 private function getIndexedData(Docman_Item $item, Docman_Version $version)
 {
     return array('id' => $item->getId(), 'group_id' => $item->getGroupId(), 'title' => $item->getTitle(), 'description' => $item->getDescription(), 'permissions' => $this->permissions_manager->exportPermissions($item), 'file' => $this->fileContentEncode($version->getPath()));
 }
コード例 #5
0
 /**
  * @param Docman_Item  $item  The id of the item
  * @param bool         $force true if you want to bypass permissions checking (@see permission_add_ugroup)
  * @param PFUser         $user  The current user
  */
 private function setPermissionsOnItem(Docman_Item $item, $force, PFUser $user)
 {
     $permission_definition = array(100 => array('order' => 0, 'type' => null, 'label' => null, 'previous' => null), 1 => array('order' => 1, 'type' => 'PLUGIN_DOCMAN_READ', 'label' => permission_get_name('PLUGIN_DOCMAN_READ'), 'previous' => 0), 2 => array('order' => 2, 'type' => 'PLUGIN_DOCMAN_WRITE', 'label' => permission_get_name('PLUGIN_DOCMAN_WRITE'), 'previous' => 1), 3 => array('order' => 3, 'type' => 'PLUGIN_DOCMAN_MANAGE', 'label' => permission_get_name('PLUGIN_DOCMAN_MANAGE'), 'previous' => 2));
     $permissions = $this->_controler->request->get('permissions');
     $old_permissions = permission_get_ugroups_permissions($item->getGroupId(), $item->getId(), array('PLUGIN_DOCMAN_READ', 'PLUGIN_DOCMAN_WRITE', 'PLUGIN_DOCMAN_MANAGE'), false);
     $done_permissions = array();
     $history = array('PLUGIN_DOCMAN_READ' => false, 'PLUGIN_DOCMAN_WRITE' => false, 'PLUGIN_DOCMAN_MANAGE' => false);
     foreach ($permissions as $ugroup_id => $wanted_permission) {
         $this->_setPermission($item->getGroupId(), $item->getId(), $permission_definition, $old_permissions, $done_permissions, $ugroup_id, $permissions, $history, $force);
     }
     $updated = false;
     foreach ($history as $perm => $put_in_history) {
         if ($put_in_history) {
             permission_add_history($item->getGroupId(), $perm, $item->getId());
             $updated = true;
         }
     }
     $this->_controler->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'info_perms_updated'));
     // If requested by user, apply permissions recursively on sub items
     if ($this->_controler->request->get('recursive')) {
         //clone permissions for sub items
         // Recursive application via a callback of Docman_Actions::recursivePermissions in
         // Docman_ItemFactory::breathFirst
         $item_factory = $this->_getItemFactory();
         $item_factory->breathFirst($item->getId(), array(&$this, 'recursivePermissions'), array('id' => $item->getId()));
         $this->_controler->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'info_perms_recursive_updated'));
     }
 }
コード例 #6
0
 /**
  * Release locked item
  *
  * @param Docman_Item $item Item to lock
  *
  * @return Boolean
  */
 function unlock($item)
 {
     $dao = $this->getDao();
     return $dao->delLock($item->getId());
 }
コード例 #7
0
ファイル: Reminder.class.php プロジェクト: pombredanne/tuleap
 /**
  * Retrieve url to access a given docman item
  *
  * @param Docman_Item $table The approval table that its reminder notification will be sent
  *
  * @return String
  */
 private function getItemUrl(Docman_Item $docmanItem)
 {
     $baseUrl = get_server_url() . '/plugins/docman/?group_id=' . $docmanItem->getGroupId();
     $itemUrl = $baseUrl . '&action=show&id=' . $docmanItem->getId();
     return $itemUrl;
 }
コード例 #8
0
 /**
  * Returns the list of users monitoring the given item with an array associated to the item the user actually monitors:
  * getListeningUsers(item(10))
  * =>
  *  array(101 => item(10) // The user is monitoring the item(10) directly
  *        102 => item(20) // The user is monitoring item(10) through item(20) "sub-hierarchy"
  *  )
  *
  * @param Docman_Item $item  Item which listenners will be retrieved
  * @param Array       $users Array where listeners are inserted.
  * @param String      $type  Type of listener, in order to retrieve listeners that monitor this item on a sub-hierarchy or not.
  *
  * @return Array
  */
 public function getListeningUsers(Docman_Item $item, $users = array(), $type = PLUGIN_DOCMAN_NOTIFICATION)
 {
     $dar = $this->dao->searchUserIdByObjectIdAndType($item->getId(), $type ? $type : PLUGIN_DOCMAN_NOTIFICATION_CASCADE);
     if ($dar) {
         foreach ($dar as $user) {
             if (!array_key_exists($user['user_id'], $users)) {
                 $users[$user['user_id']] = $item;
             }
         }
     }
     if ($id = $item->getParentId()) {
         $item = $this->_item_factory->getItemFromDb($id);
         $users = $this->getListeningUsers($item, $users, PLUGIN_DOCMAN_NOTIFICATION_CASCADE);
     }
     return $users;
 }
コード例 #9
0
 /**
  * Returns the list of values that watermark the document
  * 
  * @param Docman_Item $item
  * 
  * @return Array of Docman_MetadataListOfValuesElement
  */
 public function getWatermarkingValues($item)
 {
     if (!isset($this->_watermarkedValues[$item->getId()])) {
         $md = $this->_getWatermarkedMetadata($item->getGroupId());
         $this->_getWatermarkingValues($item, $md);
     }
     return $this->_watermarkedValues[$item->getId()];
 }
コード例 #10
0
 public function add(Docman_Item $item)
 {
     $this->item_ids[] = $item->getId();
 }
コード例 #11
0
 /**
  * List versions of the item that are deleted but not already purged
  *
  * @param Docman_Item $item
  *
  * @return Array()
  */
 function listVersionsToPurgeForItem($item)
 {
     $dao = $this->_getVersionDao();
     $dar = $dao->listVersionsToPurgeByItemId($item->getId());
     if ($dar && !$dar->isError() && $dar->rowCount() > 0) {
         $list = array();
         foreach ($dar as $row) {
             $version = new Docman_Version($row);
             $list[] = $version;
         }
         return $list;
     }
     return false;
 }
コード例 #12
0
 /**
  * Get the JS action for the item/user couple
  * 
  * @param Docman_Item $item
  */
 function getActionForItem($item)
 {
     $js = 'docman.addActionForItem(' . $item->getId() . ', ';
     $params = array();
     $itemMenuVisitor =& new Docman_View_GetMenuItemsVisitor($this->_controller->getUser(), $item->getGroupId());
     $user_actions = $item->accept($itemMenuVisitor, $params);
     $js .= $this->phpArrayToJsArray($user_actions);
     $js .= ");\n";
     return $js;
 }
コード例 #13
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();
 }
コード例 #14
0
 private function getDocmanSerializedParameters(Docman_Item $item, array $additional_params = array())
 {
     return implode(SystemEvent::PARAMETER_SEPARATOR, array_merge(array($item->getGroupId(), $item->getId()), $additional_params));
 }
コード例 #15
0
 /**
  * Mark the deleted item as purged
  *
  * @param Docman_Item $item
  *
  * @return Boolean
  */
 public function purgeDeletedItem($item)
 {
     $dao = $this->_getItemDao();
     return $dao->setPurgeDate($item->getId(), time());
 }
コード例 #16
0
 /**
  * Remove an indexed document
  *
  * @param Docman_Item $item The item to delete
  */
 public function delete(Docman_Item $item)
 {
     $this->logger->debug('delete document #' . $item->getId());
     try {
         $this->client->getIndexedElement($item->getGroupId(), $item->getId());
         $this->client->delete($item->getGroupId(), $item->getId());
     } catch (ElasticSearch_ElementNotIndexed $exception) {
         $this->logger->debug('element #' . $item->getId() . ' not indexed, nothing to delete');
         return;
     }
 }
コード例 #17
0
 private function createSystemEvent($type, $priority, Docman_Item $item, $additional_params = '')
 {
     if ($this->isAllowed($item->getGroupId())) {
         $params = $item->getGroupId() . SystemEvent::PARAMETER_SEPARATOR . $item->getId();
         if ($additional_params) {
             $params .= SystemEvent::PARAMETER_SEPARATOR . $additional_params;
         }
         SystemEventManager::instance()->createEvent($type, $params, $priority);
     }
 }