function report_import()
 {
     $groupId = $this->_controler->_actionParams['sGroupId'];
     $importReportId = $this->_controler->_actionParams['sImportReportId'];
     $importGroupId = $this->_controler->_actionParams['sImportGroupId'];
     $user =& $this->_controler->getUser();
     // Any user can importreports from any public projects and from
     // Private projects he is member of.
     $pm = ProjectManager::instance();
     $go = $pm->getProject($importGroupId);
     if ($go != false && ($go->isPublic() || !$go->isPublic() && $go->userIsMember())) {
         $srcReportFactory = new Docman_ReportFactory($importGroupId);
         // Get the mapping between src and current project metadata definition.
         $mdMap = array();
         $srcMdFactory = new Docman_MetadataFactory($importGroupId);
         $srcMdFactory->getMetadataMapping($groupId, $mdMap);
         // Get the mapping between src and current project items definition for the item involved
         // in the reports.
         $itemMapping = array();
         // Get involved items
         $srcReportItems = $srcReportFactory->getReportsItems($importReportId);
         if (count($srcReportItems) > 0) {
             // Get the subtree from the original docman on which reports applies
             $srcItemFactory = new Docman_ItemFactory($importGroupId);
             $srcItemTree = $srcItemFactory->getItemTreeFromLeaves($srcReportItems, $user);
             if ($srcItemTree !== null) {
                 // Final step: find in the current ($groupId) docman
                 $dstItemFactory = new Docman_ItemFactory($groupId);
                 $itemMapping = $dstItemFactory->getItemMapping($srcItemTree);
             }
         }
         // If user is admin he can create 'P' report otherwise everything is 'I'
         $forceScope = true;
         if ($this->_controler->userCanAdmin()) {
             $forceScope = false;
         }
         if ($importReportId !== null) {
             // Import only one report
             $report = $srcReportFactory->getReportById($importReportId);
             if ($report !== null) {
                 // User can import Project wide reports or his own Individual reports.
                 if ($report->getScope() == 'P' || $report->getScope() == 'I' && $report->getUserId() == $user->getId()) {
                     $srcReportFactory->cloneReport($report, $groupId, $mdMap, $user, $forceScope, $itemMapping);
                     $this->_controler->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'report_clone_success'));
                 } else {
                     $this->_controler->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'report_err_clone_iorp'));
                 }
             } else {
                 $this->_controler->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'report_err_notfound', array($importReportId)));
             }
         } else {
             // Import all personal and project reports from the given project.
             $srcReportFactory->copy($groupId, $mdMap, $user, $forceScope, $itemMapping);
             $this->_controler->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'report_clone_success'));
         }
     } else {
         $this->_controler->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_generic'));
     }
 }