function searchItemsInReports($groupId, $reportId = null) { $sql = 'SELECT i.*' . ' FROM plugin_docman_report r' . ' JOIN plugin_docman_item i ON (i.item_id = r.item_id)' . ' WHERE r.group_id = ' . $this->da->escapeInt($groupId) . ' AND r.item_id != 0 ' . ' AND r.item_id IS NOT NULL ' . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i'); if ($reportId !== null) { $sql .= ' AND r.report_id = ' . $this->da->escapeInt($reportId); } return $this->retrieve($sql); }
public function searchAllItemsNotWatermarked($groupId) { $sql = 'SELECT i.item_id, i.title, excluded_log.time' . ' FROM plugin_docman_item i' . ' INNER JOIN plugin_docmanwatermark_item_excluded excluded USING (item_id)' . ' INNER JOIN plugin_docmanwatermark_item_excluded_log excluded_log USING (item_id)' . ' WHERE i.group_id = ' . $this->da->quoteSmart($groupId) . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i') . ' ORDER BY i.item_id DESC, excluded_log.time DESC'; $dar = $this->retrieve($sql); if ($dar && !$dar->isError()) { return $dar; } return false; }
function getAllApprovalTableForUser($userId) { // Item $sql_item = 'SELECT t.table_id, i.item_id, i.group_id, t.date, i.title, g.group_name, t.status' . ',' . Docman_ApprovalTableDao::getTableStatusFields() . ' FROM plugin_docman_approval t' . ' LEFT JOIN ' . Docman_ApprovalTableDao::getTableStatusJoin('app_u', 't') . ' JOIN plugin_docman_item i ON (i.item_id = t.item_id)' . ' JOIN groups g ON (g.group_id = i.group_id)' . ' WHERE t.table_owner = ' . $this->da->escapeInt($userId) . ' AND t.status IN (' . PLUGIN_DOCMAN_APPROVAL_TABLE_DISABLED . ', ' . PLUGIN_DOCMAN_APPROVAL_TABLE_ENABLED . ')' . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i') . ' AND g.status = \'A\'' . ' GROUP BY ' . Docman_ApprovalTableDao::getTableStatusGroupBy('t'); // Version $sql_ver = 'SELECT t.table_id, i.item_id, i.group_id, t.date, i.title, g.group_name, t.status' . ',' . Docman_ApprovalTableDao::getTableStatusFields() . ' FROM plugin_docman_approval t' . ' LEFT JOIN ' . Docman_ApprovalTableDao::getTableStatusJoin('app_u', 't') . ' JOIN plugin_docman_version v' . ' ON (v.id = t.version_id)' . ' JOIN plugin_docman_item AS i' . ' ON (i.item_id = v.item_id)' . ' JOIN groups g' . ' ON (g.group_id = i.group_id)' . ' WHERE t.table_owner = ' . $this->da->escapeInt($userId) . ' AND t.status IN (' . PLUGIN_DOCMAN_APPROVAL_TABLE_DISABLED . ', ' . PLUGIN_DOCMAN_APPROVAL_TABLE_ENABLED . ')' . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i') . ' AND g.status = \'A\'' . ' GROUP BY ' . Docman_ApprovalTableDao::getTableStatusGroupBy('t'); $sql = '(' . $sql_item . ') UNION ALL (' . $sql_ver . ') ORDER BY group_name ASC, date ASC'; //echo $sql; return $this->retrieve($sql); }
/** * Return an item (we don't know the group_id) * @param int $item_id the id of the item to retrieve * @return Docman_Item */ protected function getItem($item_id) { $item = null; $dao = new Docman_ItemDao(CodendiDataAccess::instance()); if ($row = $dao->searchByid($item_id)->getRow()) { $item = Docman_ItemFactory::instance($row['group_id'])->getItemFromRow($row); $dPm = Docman_PermissionsManager::instance($row['group_id']); $user = UserManager::instance()->getCurrentUser(); if (!$dPm->userCanRead($user, $item->getId())) { $item = false; } } return $item; }
/** * Retreive lock info for several items. * * @param Array $itemIds * * @return DataAccessResult */ function searchLocksForItemIds(array $itemIds) { $sql = 'SELECT l.item_id, l.user_id' . ' FROM plugin_docman_item_lock l' . ' JOIN plugin_docman_item i ON (i.item_id = l.item_id)' . ' WHERE i.item_id IN (' . implode(',', $itemIds) . ')' . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i'); return $this->retrieve($sql); }
/** * This returns ids of docman items that refrence a wiki page in a project. Returned item shouldn't be obsolete or deleted. * * @param string $wikipage wiki page name * @param int $group_id project id. * * @return array $ids ids of docman items that reference the wiki page. */ function getItemIdByWikiPageAndGroupId($wikipage, $group_id) { $ids = array(); $sql = sprintf('SELECT item_id' . ' FROM plugin_docman_item i' . ' WHERE i.wiki_page = \'%s\'' . ' AND i.group_id = %d' . ' AND ' . Docman_ItemDao::getCommonExcludeStmt('i'), db_es($wikipage), db_ei($group_id)); $res = $this->retrieve($sql); if ($res && !$res->isError()) { if ($res->rowCount() > 1) { $res->rewind(); while ($res->valid()) { $row = $res->current(); $ids[] = $row['item_id']; $res->next(); } return $ids; } else { $res->rewind(); if ($res->valid()) { $row = $res->current(); $id = $row['item_id']; return $id; } } } else { return null; } }