/** * Clone reports of one project into another one * * @param $srcReport Original report. * @param $dstGroupId Id of the destination project. * @param $metadataMapping Mapping between $srcReport project metadata and $dstGroupId metadata (for fields associated to reports). * @param $user User who will own the newly created reports. * @param $forceScopeToI Force scope of the new reports to I (individual). * @param $itemMapping Mapping between $srcReport project items and $dstGroupId items (for folders associated to report). */ function cloneReport($srcReport, $dstGroupId, $metadataMapping, $user, $forceScopeToI = false, $itemMapping = array()) { $dstReportFactory = new Docman_ReportFactory($dstGroupId); $srcFilterFactory = new Docman_FilterFactory($this->groupId); // Create new report // @php5: clone $dstReport = clone $srcReport; $dstReport->setGroupId($dstGroupId); $dstReport->setUserId($user->getId()); if ($forceScopeToI) { $dstReport->setScope('I'); } // Be carful with reports associated to an item. if ($srcReport->getGroupId() != $dstGroupId) { if ($srcReport->getItemId() !== null && $srcReport->getItemId() != 0 && isset($itemMapping[$srcReport->getItemId()])) { $dstReport->setItemId($itemMapping[$srcReport->getItemId()]); } else { $dstReport->setItemId(0); } } // Save report $rId = $dstReportFactory->createReport($dstReport); if ($rId !== false) { $dstReport->setId($rId); // Copy filters $srcFilterFactory->copy($srcReport, $dstReport, $metadataMapping); return true; } else { return false; } }
/** * */ function getSelectedFilters($params, &$displayedFilters) { $html = ''; $html .= '<table class="docman_form">'; $fi = $this->report->getFilterIterator(); $trashLinkBase = $this->view->_buildSearchUrl($params, array('del_filter' => '')); if ($fi->count() == 0) { $html .= '<div style="text-align:center; font-style:italic;">'; $filterFactory = new Docman_FilterFactory($this->report->getGroupId()); $f = $filterFactory->getFakeGlobalSearchFilter(); $html .= $this->_getFilterDisplayBox($f, $params, false, $displayedFilters); $html .= '</div>'; } // Display filters fields $fi->rewind(); while ($fi->valid()) { $f =& $fi->current(); $html .= $this->_getFilterDisplayBox($f, $params, $trashLinkBase, $displayedFilters); $fi->next(); } $ci = $this->report->getColumnIterator(); $ci->rewind(); while ($ci->valid()) { $c = $ci->current(); $html .= $c->getSortSelectorHtml(); $ci->next(); } $html .= '</table>'; return $html; }
function getItemTypeSearchMetadata() { $filterFactory = new Docman_FilterFactory($this->groupId); return $filterFactory->getItemTypeSearchMetadata(); }