*
* @param object Group object.
* @param array (all fields from doc_groups) OR doc_group id from database.
- * @return boolean success.
+ * @return boolean True on success.
* @access public
*/
function DocumentGroup(&$Group, $data = false) {
if ($data) {
if (is_array($data)) {
$this->data_array =& $data;
-//
-// should verify group_id
-//
+ if ($this->data_array['group_id'] != $this->Group->getID()) {
+ $this->setError('DocumentGroup:: '. _('Group_id in db result does not match Group Object'));
+ $this->data_array = null;
+ return false;
+ }
return true;
} else {
if (!$this->fetchData($data)) {
* @access public
*/
function fetchData($id) {
- $res = db_query_params('SELECT * FROM doc_groups WHERE doc_group = $1',
- array($id));
+ $res = db_query_params('SELECT * FROM doc_groups WHERE doc_group = $1 and group_id = $2',
+ array($id, $this->Group->getID()));
if (!$res || db_numrows($res) < 1) {
$this->setError(_('Invalid Document Folder ID'));
return false;
}
$this->data_array = db_fetch_array($res);
+ $this->data_array['numberFiles'] = array();
db_free_result($res);
return true;
}
}
}
+ function getNumberOfDocuments($stateId = 1) {
+ if (isset($this->data_array['numberFiles'][$stateId]))
+ return $this->data_array['numberFiles'][$stateId];
+
+ $res = db_query_params('select count(*) from docdata_vw where doc_group = $1 and group_id = $2 and stateid = $3',
+ array($this->getID(), $this->Group->getID(), $stateId));
+ if (!$res) {
+ return 0;
+ }
+ $arr = db_fetch_array($res);
+ $this->data_array['numberFiles'][$stateId] = $arr[0];
+ return $arr[0];
+ }
+
/**
* hasSubgroup - Checks if this group has a specified subgroup associated to it
*
* @access public
*/
function getPath($url = false, $includename = true) {
+
$returnPath = '';
if ($this->getParentID()) {
$parentDg = new DocumentGroup($this->Group, $this->getParentID());
}
if ($includename) {
if ($url) {
- $returnPath .= '/'.util_make_link('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getID(),$this->getName());
+ $browselink = '/docman/?view=listfile&dirid='.$this->getID();
+ if (isset($GLOBALS['childgroup_id']) && $GLOBALS['childgroup_id']) {
+ $browselink .= '&childgroup_id='.$GLOBALS['childgroup_id'];
+ }
+ $browselink .= '&group_id='.$GLOBALS['group_id'];
+ $returnPath .= '/'.util_make_link($browselink, $this->getName(), array('title' => _('Browse this folder'), 'class' => 'tabtitle'));
} else {
$returnPath .= '/'.$this->getName();
}
}
+ if (!strlen($returnPath))
+ $returnPath = '/';
+
return $returnPath;
}