/**
* Associative array of data from db.
*
- * @var array $data_array.
+ * @var array $data_array.
*/
var $data_array;
/**
* The Group object.
*
- * @var object $Group.
+ * @var object $Group.
*/
- var $Group;
+ var $Group;
/**
* The Search engine path.
*
- * @var string $engine_path
+ * @var string $engine_path
*/
var $engine_path;
* @param array The associative array of data.
* @return boolean success.
*/
- function Document(&$Group, $docid=false, $arr=false, $engine = "") {
+ function Document(&$Group, $docid = false, $arr = false, $engine = '') {
$this->Error();
if (!$Group || !is_object($Group)) {
$this->setNotValidGroupObjectError();
return false;
}
if ($Group->isError()) {
- $this->setError('Document:: '.$Group->getErrorMessage());
+ $this->setError('Document:: '. $Group->getErrorMessage());
return false;
}
$this->Group =& $Group;
} else {
$this->data_array =& $arr;
if ($this->data_array['group_id'] != $this->Group->getID()) {
- $this->setError(_('Group_id in db result does not match Group Object'));
+ $this->setError('Document:: '. _('Group_id in db result does not match Group Object'));
$this->data_array = null;
return false;
}
}
if (!$this->isPublic()) {
- $perm =& $this->Group->getPermission ();
+ $perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isMember()) {
$this->setPermissionDeniedError();
* @param string The description of this document.
* @return boolean success.
*/
- function create($filename,$filetype,$data,$doc_group,$title,$description) {
+ function create($filename, $filetype, $data, $doc_group, $title, $description) {
if (strlen($title) < 5) {
$this->setError(_('Title Must Be At Least 5 Characters'));
return false;
}
$result = db_query_params('SELECT filename,doc_group from docdata_vw where filename = $1 and doc_group = $2',
- array($filename,$doc_group));
+ array($filename, $doc_group));
if (!$result || db_numrows($res) > 0) {
$this->setError(_('Document already published in this directory'));
$doc_initstatus = '3';
// If Editor - uploaded Documents are ACTIVE
- if ( session_loggedin() ) {
+ if (session_loggedin()) {
$perm =& $this->Group->getPermission ();
if ($perm && is_object($perm) && $perm->isDocEditor()) {
$doc_initstatus = '1';
// key words for in-document search
if ($this->Group->useDocmanSearch()) {
- $kw = new Parsedata ($this->engine_path);
- $kwords = $kw->get_parse_data ($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+ $kw = new Parsedata($this->engine_path);
+ $kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
} else {
$kwords ='';
}
db_begin();
$result = db_query_params('INSERT INTO doc_data (group_id,title,description,createdate,doc_group,
- stateid,filename,filetype,filesize,data_words,created_by)
- VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)',
- array($this->Group->getId(),
+ stateid,filename,filetype,filesize,data_words,created_by)
+ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)',
+ array($this->Group->getId(),
htmlspecialchars($title),
htmlspecialchars($description),
time(),
return false;
}
- $docid=db_insertid($result,'doc_data','docid');
+ $docid = db_insertid($result,'doc_data','docid');
switch ($this->Group->getStorageAPI()) {
- case 'DB':
- $result = db_query_params('UPDATE doc_data set data = $1 where docid = $2',
- array(base64_encode($data),$docid));
- if (!$result) {
- $this->setError(_('Error Adding Document:').' '.db_error().$result);
+ case 'DB': {
+ $result = db_query_params('UPDATE doc_data set data = $1 where docid = $2',
+ array(base64_encode($data),$docid));
+ if (!$result) {
+ $this->setError(_('Error Adding Document:').' '.db_error().$result);
+ db_rollback();
+ return false;
+ }
+ break;
+ }
+ default: {
+ $this->setError(_('Error Adding Document: No Storage API'));
db_rollback();
return false;
}
- break;
- default:
- $this->setError(_('Error Adding Document: No Storage API'));
- db_rollback();
- return false;
}
if (!$this->fetchData($docid)) {
* @return boolean success
*/
function fetchData($docid) {
- $res = db_query_params ('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
- array ($docid,
- $this->Group->getID()));
+ $res = db_query_params('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
+ array($docid, $this->Group->getID()));
if (!$res || db_numrows($res) < 1) {
$this->setError(_('Document:: Invalid docid'));
return false;
/**
* getName - get the name of this document.
*
- * @return string The name of this document.
+ * @return string The name of this document.
*/
function getName() {
return $this->data_array['title'];
/**
* getDescription - the description of this document.
*
- * @return string The description.
+ * @return string The description.
*/
function getDescription() {
return $this->data_array['description'];
function isURL() {
return ($this->data_array['filetype'] == 'URL');
}
-
+
/**
* isText - whether this document is a text document and not a binary one.
*
*/
function isText() {
$doctype = $this->data_array['filetype'];
- if (preg_match('|^text/|i',$doctype)) { // text plain, text html, text x-patch, etc
+ if (preg_match('|^text/|i', $doctype)) { // text plain, text html, text x-patch, etc
return true;
- }
+ }
return false;
}
-
+
/**
* isHtml - whether this document is a html document.
*
$doctype = $this->data_array['filetype'];
if (preg_match('/html/i',$doctype)) {
return true;
- }
+ }
return false;
- }
+ }
/**
* isPublic - whether this document is available to the general public.
* @return boolean is_public.
*/
function isPublic() {
- return (($this->data_array['stateid'] == 1) ? true : false);
+ return (($this->data_array['stateid'] == 1) ? true : false);
}
/**
/**
* getStateName - the statename of this document.
*
- * @return string The statename.
+ * @return string The statename.
*/
function getStateName() {
return $this->data_array['state_name'];
/**
* getDocGroupName - the doc_group_name of this document.
*
- * @return string The docgroupname.
+ * @return string The docgroupname.
*/
function getDocGroupName() {
return $this->data_array['group_name'];
/**
* getCreatorUserName - the unix name of the person who created this document.
*
- * @return string The unix name of the creator.
+ * @return string The unix name of the creator.
*/
function getCreatorUserName() {
return $this->data_array['user_name'];
/**
* getCreatorRealName - the real name of the person who created this document.
*
- * @return string The real name of the creator.
+ * @return string The real name of the creator.
*/
function getCreatorRealName() {
return $this->data_array['realname'];
/**
* getCreatorEmail - the email of the person who created this document.
*
- * @return string The email of the creator.
+ * @return string The email of the creator.
*/
function getCreatorEmail() {
return $this->data_array['email'];
/**
* getFileName - the filename of this document.
*
- * @return string The filename.
+ * @return string The filename.
*/
function getFileName() {
return $this->data_array['filename'];
/**
* getFileType - the filetype of this document.
*
- * @return string The filetype.
+ * @return string The filetype.
*/
function getFileType() {
return $this->data_array['filetype'];
/**
* getFileData - the filedata of this document.
*
- * @return string The filedata.
+ * @return string The filedata.
*/
function getFileData() {
//
// Because this could be a large string, we only fetch if we actually need it
//
- $res = db_query_params ('SELECT data FROM doc_data WHERE docid=$1',
- array ($this->getID())) ;
+ $res = db_query_params('SELECT data FROM doc_data WHERE docid=$1',array($this->getID()));
return base64_decode(db_result($res,0,'data'));
}
-
+
/**
* getFileSize - Return the size of the document
*
function getFileSize() {
return $this->data_array['filesize'];
}
+
/**
* getUpdated - get the time this document was updated.
*
- * @return int The epoch date this document was updated.
+ * @return int The epoch date this document was updated.
*/
function getUpdated() {
return $this->data_array['updatedate'];
/**
* getCreated - get the time this document was created.
*
- * @return int The epoch date this document was created.
+ * @return int The epoch date this document was created.
*/
function getCreated() {
return $this->data_array['createdate'];
/**
* getLocked - get the lock status of this document.
*
- * @return int The lock status of this document.
+ * @return int The lock status of this document.
*/
function getLocked() {
return $this->data_array['locked'];
/**
* getLockdate - get the lock time of this document.
*
- * @return int The lock time of this document.
+ * @return int The lock time of this document.
*/
function getLockdate() {
return $this->data_array['lockdate'];
/**
* getLockedBy - get the user id who set lock on this document.
*
- * @return int The user id who set lock on this document.
+ * @return int The user id who set lock on this document.
*/
function getLockedBy() {
return $this->data_array['locked_by'];
/**
* getReservedBy - get the owner of the reversed status of this document.
*
- * @return int The owner of the reversed status of this document.
+ * @return int The owner of the reversed status of this document.
*/
function getReservedBy() {
return $this->data_array['reserved_by'];
/**
* getReserved - get the reversed status of this document.
*
- * @return int The reversed status of this document.
+ * @return int The reversed status of this document.
*/
function getReserved() {
return $this->data_array['reserved'];
if ( $i > 0 )
$comma = ',';
- $values .=$comma.$arr['email'];
+ $values .= $comma.$arr['email'];
$i++;
}
}
$condition = 'user_id='.$userid.' AND';
}
$result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE '.$condition.' doc_id=$1',
- array ($this->getID()));
+ array($this->getID()));
if (!$result || db_numrows($result) < 1)
return false;
*/
function removeMonitoredBy($userid) {
$result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id=$1 AND user_id=$2',
- array ($this->getID(), $userid));
+ array ($this->getID(), $userid));
if (!$result) {
$this->setError(_('Unable To Remove Monitor').' : '.db_error());
*/
function addMonitoredBy($userid) {
$result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE user_id=$1 AND doc_id=$2',
- array ($userid, $this->getID()));
+ array($userid, $this->getID()));
if (!$result || db_numrows($result) < 1) {
$result = db_query_params('INSERT INTO docdata_monitored_docman (doc_id,user_id) VALUES ($1,$2)',
- array ($this->getID(), $userid));
+ array($this->getID(), $userid));
if (!$result) {
$this->setError(_('Unable To Add Monitor').' : '.db_error());
* @return boolean success.
*/
function setState($stateid) {
- $res = db_query_params ('UPDATE doc_data SET
- stateid=$1
- WHERE group_id=$2
- AND docid=$3',
- array ($stateid,
- $this->Group->getID(),
- $this->getID())
- );
+ $res = db_query_params('UPDATE doc_data SET
+ stateid=$1
+ WHERE group_id=$2
+ AND docid=$3',
+ array($stateid,
+ $this->Group->getID(),
+ $this->getID())
+ );
if (!$res || db_affected_rows($res) < 1) {
$this->setOnUpdateError(db_error());
return false;
* @param time the epoch time
* @return boolean success
*/
- function setLock($stateLock,$userid=NULL,$thistime=0) {
+ function setLock($stateLock, $userid = NULL, $thistime = 0) {
$res = db_query_params ('UPDATE doc_data SET
locked=$1,
locked_by=$2,
lockdate=$3
WHERE group_id=$4
AND docid=$5',
- array ($stateLock,
+ array($stateLock,
$userid,
$thistime,
$this->Group->getID(),
- $this->getID())
- );
+ $this->getID())
+ );
if (!$res || db_affected_rows($res) < 1) {
$this->setOnUpdateError(_('Document lock failed').' '.db_error());
return false;
* @param int The ID of the owner : by default : noone
* @return boolean success
*/
- function setReservedBy($statusReserved,$idReserver=NULL) {
- $res = db_query_params ('UPDATE doc_data SET
+ function setReservedBy($statusReserved, $idReserver = NULL) {
+ $res = db_query_params('UPDATE doc_data SET
reserved=$1,
reserved_by=$2
WHERE group_id=$3
AND docid=$4',
- array ($statusReserved,
+ array($statusReserved,
$idReserver,
$this->Group->getID(),
$this->getID())
* @param int The state id of the doc_states table.
* @return boolean success.
*/
- function update($filename,$filetype,$data,$doc_group,$title,$description,$stateid) {
+ function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid) {
global $LUSER;
- $perm =& $this->Group->getPermission ();
+ $perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
return false;
}
-
if ($this->getLockedBy() != $LUSER->getID()) {
$this->setPermissionDeniedError();
return false;
}
$result = db_query_params('SELECT filename,doc_group from docdata_vw',
- array($filename,$doc_group));
+ array($filename, $doc_group));
if ($data) {
if (!$result || db_numrows($res) > 0) {
}
}
-
$res = db_query_params ('UPDATE doc_data SET
- title=$1,
- description=$2,
- stateid=$3,
- doc_group=$4,
- filetype=$5,
- filename=$6,
- updatedate=$7,
- locked=$8,
- locked_by=$9
- WHERE group_id=$10
- AND docid=$11',
- array (htmlspecialchars($title),
- htmlspecialchars($description),
- $stateid,
- $doc_group,
- $filetype,
- $filename,
- time(),
- 0,
- NULL,
- $this->Group->getID(),
- $this->getID())) ;
+ title=$1,
+ description=$2,
+ stateid=$3,
+ doc_group=$4,
+ filetype=$5,
+ filename=$6,
+ updatedate=$7,
+ locked=$8,
+ locked_by=$9
+ WHERE group_id=$10
+ AND docid=$11',
+ array(htmlspecialchars($title),
+ htmlspecialchars($description),
+ $stateid,
+ $doc_group,
+ $filetype,
+ $filename,
+ time(),
+ 0,
+ NULL,
+ $this->Group->getID(),
+ $this->getID())
+ );
if (!$res || db_affected_rows($res) < 1) {
$this->setOnUpdateError(db_error());
// key words for in-document search
if ($this->Group->useDocmanSearch()) {
- $kw = new Parsedata ($this->engine_path);
- $kwords = $kw->get_parse_data ($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
+ $kw = new Parsedata($this->engine_path);
+ $kwords = $kw->get_parse_data($data1, htmlspecialchars($title), htmlspecialchars($description), $filetype);
} else {
$kwords = '';
}
$res = db_query_params ('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
- array (strlen($data),
+ array(strlen($data),
$kwords,
$this->Group->getID(),
- $this->getID())) ;
+ $this->getID())
+ );
if (!$res || db_affected_rows($res) < 1) {
$this->setOnUpdateError(db_error());
}
switch ($this->Group->getStorageAPI()) {
- case 'DB':
- $res = db_query_params ('UPDATE doc_data SET data = $1 where group_id = $2 and docid = $3',
- array(base64_encode($data),
- $this->Group->getID(),
- $this->getID()));
+ case 'DB': {
+ $res = db_query_params ('UPDATE doc_data SET data = $1 where group_id = $2 and docid = $3',
+ array(base64_encode($data),
+ $this->Group->getID(),
+ $this->getID())
+ );
- if (!$res || db_affected_rows($res) < 1) {
- $this->setOnUpdateError(db_error());
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setOnUpdateError(db_error());
+ return false;
+ }
+ break;
+ }
+ default: {
+ $this->setOnUpdateError(_('No Storage API'));
return false;
}
- break;
- default:
- $this->setOnUpdateError(_('No Storage API'));
- return false;
}
}
$body = _('Project:').' '.$this->Group->getPublicName()."\n";
$body .= _('Directory:').' '.$this->getDocGroupName()."\n";
$body .= _('Document title:').' '.$this->getName()."\n";
- $body .= _('Document description:').' '.util_unconvert_htmlspecialchars( $this->getDescription() )."\n";
+ $body .= _('Document description:').' '.util_unconvert_htmlspecialchars($this->getDescription())."\n";
$body .= _('Submitter:').' '.$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
$body .= "\n\n-------------------------------------------------------\n".
_('For more info, visit:').
"\n\n" . util_make_url('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
- util_send_message('',$subject,$body,'',$BCC);
+ util_send_message('', $subject, $body, '', $BCC);
}
return true;
}
-
+
/**
* delete - Delete this file
*
* @return boolean success
*/
function delete() {
- $perm =& $this->Group->getPermission ();
+ $perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
return false;
}
-
- $result = db_query_params ('DELETE FROM doc_data WHERE docid=$1',
- array ($this->getID())) ;
+
+ $result = db_query_params('DELETE FROM doc_data WHERE docid=$1',
+ array($this->getID()));
if (!$result) {
$this->setError(_('Error Deleting Document:').' '.db_error());
db_rollback();
return false;
}
-
+
switch ($this->Group->getStorageAPI()) {
- case 'DB':
- break;
- default:
- $this->setError(_('Error Deleting Document: No Storage API'));
- db_rollback();
- return false;
+ case 'DB': {
+ break;
+ }
+ default: {
+ $this->setError(_('Error Deleting Document: No Storage API'));
+ db_rollback();
+ return false;
+ }
}
// we should be able to send a notice that this doc has been deleted .... but we need to rewrite sendNotice
var $stateid;
var $docgroupid;
- var $sort='group_name, title';
/**
* Constructor.
* @param int The stateid from the doc_states table.
*/
function setStateID($stateid) {
- $this->stateid=$stateid;
+ $this->stateid = $stateid;
}
/**
* @param int The doc_group from the doc_groups table.
*/
function setDocGroupID($docgroupid) {
- $this->docgroupid=$docgroupid;
- }
-
- /**
- * setSort - call this before getDocuments() if you want to control the sorting.
- *
- * @param string The name of the field to sort on.
- */
- function setSort($sort) {
- $this->sort=$sort;
+ $this->docgroupid = $docgroupid;
}
/**
if (!$this->Documents) {
$this->getFromDB();
}
-
+
$return = array();
// If the document group is specified, we should only check that group in
// the Documents array. If not, we should check ALL the groups.
} else {
$keys = array_keys($this->Documents);
}
-
+
foreach ($keys as $key) {
- if (!array_key_exists($key, $this->Documents)) continue; // Should not happen
+ if (!array_key_exists($key, $this->Documents)) continue; // Should not happen
$count = count($this->Documents[$key]);
-
+
for ($i=0; $i < $count; $i++) {
- $valid = true; // do we need to return this document?
+ $valid = true; // do we need to return this document?
$doc =& $this->Documents[$key][$i];
-
+
if (!$this->stateid) {
if (session_loggedin()) {
- $perm =& $this->Group->getPermission ();
+ $perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isMember()) {
if ($doc->getStateID() != 1) { // non-active document?
$valid = false;
}
} else {
if ($doc->getStateID() != 1 && /* not active */
- $doc->getStateID() != 4 && /* not hidden */
- $doc->getStateID() != 5) { /* not private */
+ $doc->getStateID() != 4 && /* not hidden */
+ $doc->getStateID() != 5) { /* not private */
$valid = false;
}
}
} else {
- if ($doc->getStateID() != 1) { // non-active document?
+ if ($doc->getStateID() != 1) { // non-active document?
$valid = false;
}
}
*/
function getFromDB() {
$this->Documents = array();
- $result = db_query_params ('SELECT * FROM docdata_vw ORDER BY title',
- array());
+ $result = db_query_params('SELECT * FROM docdata_vw WHERE group_id = $1 ORDER BY title',
+ array($this->Group->getID()));
if (!$result) {
- exit_error(db_error(),'docman');
+ exit_error(db_error(), 'docman');
}
-
+
while ($arr = db_fetch_array($result)) {
$doc_group_id = $arr['doc_group'];
if (!is_array(@$this->Documents[$doc_group_id])) {
$this->Documents[$doc_group_id] = array();
}
-
$this->Documents[$doc_group_id][] = new Document($this->Group, $arr['docid'], $arr);
}
}
* getStates - Return an array of states that have documents associated to them
*/
function getUsedStates() {
- $result = db_query_params ('SELECT DISTINCT doc_states.stateid,doc_states.name
- FROM doc_states,doc_data
- WHERE doc_data.stateid=doc_states.stateid
- ORDER BY doc_states.name ASC',
- array());
+ $result = db_query_params('SELECT DISTINCT doc_states.stateid,doc_states.name
+ FROM doc_states,doc_data
+ WHERE doc_data.stateid=doc_states.stateid
+ ORDER BY doc_states.name ASC',
+ array());
if (!$result) {
- exit_error(db_error(),'docman');
+ exit_error(db_error(), 'docman');
}
-
+
$return = array();
while ($arr = db_fetch_array($result)) {
$return[] = $arr;
}
-
+
return $return;
}
*
* @var object $Group.
*/
- var $Group; //object
+ var $Group;
/**
* Array of data.
*
* @param object Group object.
* @param array (all fields from doc_groups) OR doc_group from database.
- * @return boolean success.
+ * @return boolean success.
*/
- function DocumentGroup(&$Group, $data=false) {
+ function DocumentGroup(&$Group, $data = false) {
$this->Error();
//was Group legit?
* @param string Item name.
* @return boolean on success / false on failure.
*/
- function create($name,$parent_doc_group=0) {
+ function create($name, $parent_doc_group = 0) {
//
// data validation
//
if ($parent_doc_group) {
// check if parent group exists
$res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
- array ($parent_doc_group,
- $this->Group->getID())) ;
+ array($parent_doc_group, $this->Group->getID())) ;
if (!$res || db_numrows($res) < 1) {
$this->setError(_('DocumentGroup: Invalid Document Directory parent ID'));
return false;
$parent_doc_group = 0;
}
- $perm =& $this->Group->getPermission ();
+ $perm =& $this->Group->getPermission();
if (!$perm || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
return false;
}
$res=db_query_params('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
- array($name,
- $parent_doc_group,
- $this->Group->getID()));
+ array($name,
+ $parent_doc_group,
+ $this->Group->getID())
+ );
if ($res && db_numrows($res) > 0) {
$this->setError(_('Directory name already exists'));
return false;
}
$result = db_query_params ('INSERT INTO doc_groups (group_id,groupname,parent_doc_group,stateid) VALUES ($1, $2, $3, $4)',
- array ($this->Group->getID(),
- htmlspecialchars($name),
- $parent_doc_group,
- '1')) ;
+ array ($this->Group->getID(),
+ htmlspecialchars($name),
+ $parent_doc_group,
+ '1')
+ );
if ($result && db_affected_rows($result) > 0) {
$this->clearError();
} else {
$doc_group = db_insertid($result, 'doc_groups', 'doc_group');
- // Now set up our internal data structures
+ // Now set up our internal data structures
if (!$this->fetchData($doc_group)) {
return false;
}
/**
* delete - delete a DocumentGroup.
- * delete is recursive and permanent
+ * WARNING delete is recursive and permanent
* @param int Document Group Id, integer Project Group Id
* @return boolean success
*/
}
db_begin();
/* delete documents in directory */
- $result = db_query_params ('DELETE FROM doc_data where doc_group = $1 and group_id = $2',
- array($doc_groupid,
- $project_group_id));
+ $result = db_query_params('DELETE FROM doc_data where doc_group = $1 and group_id = $2',
+ array($doc_groupid, $project_group_id));
/* delete directory */
- $result = db_query_params ('DELETE FROM doc_groups where doc_group = $1 and group_id = $2',
- array($doc_groupid,
- $project_group_id));
+ $result = db_query_params('DELETE FROM doc_groups where doc_group = $1 and group_id = $2',
+ array($doc_groupid, $project_group_id));
db_commit();
/* is there any subdir ? */
- $subdir = db_query_params ('select doc_group from doc_groups where parent_doc_group = $1 and group_id = $2',
- array($doc_groupid,
- $project_group_id));
+ $subdir = db_query_params('select doc_group from doc_groups where parent_doc_group = $1 and group_id = $2',
+ array($doc_groupid, $project_group_id));
/* make a recursive call */
while ($arr = db_fetch_array($subdir)) {
- $this->delete($arr['doc_group'],$project_group_id);
+ $this->delete($arr['doc_group'], $project_group_id);
}
if (!$result) {
* @return boolean success
*/
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',
+ array($id));
if (!$res || db_numrows($res) < 1) {
$this->setError(_('DocumentGroup: Invalid Document Directory ID'));
return false;
function getID() {
return $this->data_array['doc_group'];
}
-
+
/**
* getID - get parent DocumentGroup's id.
*
* @param string Name of the category.
* @return boolean.
*/
- function update($name,$parent_doc_group) {
+ function update($name, $parent_doc_group) {
$perm =& $this->Group->getPermission ();
if (!$perm || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
$this->setMissingParamsError();
return false;
}
-
+
if ($parent_doc_group) {
// check if parent group exists
- $res = db_query_params ('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
- array ($parent_doc_group,
- $this->Group->getID())) ;
+ $res = db_query_params('SELECT * FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
+ array($parent_doc_group,
+ $this->Group->getID())
+ );
if (!$res || db_numrows($res) < 1) {
$this->setError(_('DocumentGroup: Invalid Document Directory parent ID'));
return false;
}
} else {
- $parent_doc_group=0;
+ $parent_doc_group = 0;
}
- $res=db_query_params ('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
- array($name,
+ $res=db_query_params('SELECT * FROM doc_groups WHERE groupname=$1 AND parent_doc_group=$2 AND group_id=$3',
+ array($name,
$parent_doc_group,
- $this->Group->getID()));
+ $this->Group->getID())
+ );
if ($res && db_numrows($res) > 0) {
$this->setError(_('Directory name already exists'));
return false;
}
- $result = db_query_params ('UPDATE doc_groups SET groupname=$1, parent_doc_group=$2 WHERE doc_group=$3 AND group_id=$4',
- array(htmlspecialchars($name),
- $parent_doc_group,
- $this->getID(),
- $this->Group->getID())) ;
+ $result = db_query_params('UPDATE doc_groups SET groupname=$1, parent_doc_group=$2 WHERE doc_group=$3 AND group_id=$4',
+ array(htmlspecialchars($name),
+ $parent_doc_group,
+ $this->getID(),
+ $this->Group->getID())
+ );
if ($result && db_affected_rows($result) > 0) {
return true;
} else {
return false;
}
}
-
+
/**
* hasDocuments - Recursive function that checks if this group or any of it childs has documents associated to it
*
* @param int (optional) State of the documents
* @return boolean success
*/
- function hasDocuments(&$nested_groups, &$document_factory, $stateid=0) {
+ function hasDocuments(&$nested_groups, &$document_factory, $stateid = 0) {
$doc_group_id = $this->getID();
static $result = array(); // this function will probably be called several times so we better store results in order to speed things up
- if (!array_key_exists($stateid, $result) || !is_array($result[$stateid])) $result[$stateid] = array();
+ if (!array_key_exists($stateid, $result) || !is_array($result[$stateid]))
+ $result[$stateid] = array();
- if (array_key_exists($doc_group_id, $result[$stateid])) return $result[$stateid][$doc_group_id];
+ if (array_key_exists($doc_group_id, $result[$stateid]))
+ return $result[$stateid][$doc_group_id];
// check if it has documents
if ($stateid) {
$result[$stateid][$doc_group_id] = true;
return true;
}
-
+
// this group doesn't have documents... check recursively on the childs
- if (array_key_exists($doc_group_id,$nested_groups) && is_array($nested_groups[$doc_group_id])) {
+ if (array_key_exists($doc_group_id, $nested_groups) && is_array($nested_groups[$doc_group_id])) {
$count = count($nested_groups[$doc_group_id]);
for ($i=0; $i < $count; $i++) {
if ($nested_groups[$doc_group_id][$i]->hasDocuments($nested_groups, $document_factory, $stateid)) {
* hasSubgroup - Checks if this group has a specified subgroup associated to it
*
* @param array Array of nested groups information, fetched from DocumentGroupFactory class
- * @param int ID of the subgroup
+ * @param int ID of the subgroup
* @return boolean success
*/
function hasSubgroup(&$nested_groups, $doc_subgroup_id) {
/**
* setStateID - set the state id of this document group
*
- * @param int State ID
+ * @param int State ID
* @return boolean success
*/
function setStateID($stateid) {
- $res = db_query_params ('UPDATE doc_groups SET stateid=$1
- WHERE doc_group=$2
- AND group_id=$3',
- array ($stateid,$this->getID(),$this->Group->getID()));
+ $res = db_query_params('UPDATE doc_groups SET stateid=$1
+ WHERE doc_group=$2
+ AND group_id=$3',
+ array ($stateid,$this->getID(),$this->Group->getID())
+ );
if (!$res || db_affected_rows($res) < 1) {
$this->setOnUpdateError(_('DocumentGroup:').' '.db_error());
*/
function DocumentGroupFactory(&$Group) {
$this->Error();
-
+
if (!$Group || !is_object($Group)) {
- $this->setError(_("DocumentGroupFactory:: Invalid Project"));
+ $this->setError(_('DocumentGroupFactory:: Invalid Project'));
return false;
}
if ($Group->isError()) {
* @param int The stateid of DocumentGroup.
* @return array The array of DocumentGroup.
*/
- function &getNested($stateid=1) {
+ function &getNested($stateid = 1) {
if ($this->nested_groups) {
return $this->nested_groups;
}
-
- $result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
- array ($this->Group->getID(),$stateid));
+
+ $result = db_query_params('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
+ array($this->Group->getID(), $stateid));
$rows = db_numrows($result);
-
+
if (!$result) {
$this->setError(_('No Document Directory Found').' '.db_error());
return false;
$this->flat_groups[] = new DocumentGroup($this->Group, $arr);
}
}
-
+
// Build the nested array
$count = count($this->flat_groups);
for ($i=0; $i < $count; $i++) {
* @param int The stateid of DocumentGroups
* @return array The array of DocumentGroup.
*/
- function &getDocumentGroups($stateid=1) {
+ function &getDocumentGroups($stateid = 1) {
if ($this->flat_groups) {
return $this->flat_groups;
}
- $result = db_query_params ('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
- array ($this->Group->getID(),$stateid)) ;
+ $result = db_query_params('SELECT * FROM doc_groups WHERE group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
+ array($this->Group->getID(), $stateid));
$rows = db_numrows($result);
if (!$result || $rows < 1) {
return true;
}
- function get_parse_data ($data, $title, $description, $filetype) {
+ function get_parse_data($data, $title, $description, $filetype) {
$parser = "";
$rep = "";
$data1 = $data;
return preg_replace("/\n/", " ", "$rep $rep1");
}
- function print_debug ($text) {
+ function print_debug($text) {
echo "$text \n";
ob_flush();
}
}
-function get_parser_list ($parser_path) {
+function get_parser_list($parser_path) {
$file = $parser_path."parser_list.txt";
$rep = array();
$fp = fopen ($file, "r");
global $g; //group object
global $group_id; // id of group
-session_require_perm ('docman',$group_id,'submit');
+session_require_perm('docman', $group_id, 'submit');
-$upload_dir = forge_get_config('ftp_upload_dir') . "/" . $g->getUnixName();
+$upload_dir = forge_get_config('ftp_upload_dir') . '/' . $g->getUnixName();
$doc_group = getIntFromRequest('doc_group');
$title = getStringFromRequest('title');
$description = getStringFromRequest('description');
$file_url = getStringFromRequest('file_url');
-//$ftp_filename = getStringFromRequest('ftp_filename');
$uploaded_data = getUploadedFile('uploaded_data');
$type = getStringFromRequest('type');
$name = getStringFromRequest('name');
if (!$doc_group || $doc_group == 100) {
- //cannot add a doc unless an appropriate group is provided
- $return_msg= _('No valid Document Directory was selected.');
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+ //cannot add a doc unless an appropriate group is provided
+ $return_msg = _('No valid Document Directory was selected.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
}
-if (!$title || !$description || (!$uploaded_data && !$file_url && (!$editor && !$name ) )) {
- $missing_params = array();
- if (!$title)
- $missing_params[] = 'title';
+if (!$title || !$description || (!$uploaded_data && !$file_url && (!$editor && !$name))) {
+ $missing_params = array();
+ if (!$title)
+ $missing_params[] = 'title';
- if (!$description)
- $missing_params[] = 'description';
+ if (!$description)
+ $missing_params[] = 'description';
+ if (forge_get_config('use_ssl'))
+ $url = "https://";
+ else
+ $url = "http://";
- if (forge_get_config('use_ssl'))
- $url = "https://" ;
- else
- $url = "http://" ;
+ $url .= forge_get_config('web_host');
- $url .= forge_get_config('web_host') ;
-
- exit_missing_param(substr($_SERVER['HTTP_REFERER'],strlen($url)),$missing_params,'docman');
+ exit_missing_param(substr($_SERVER['HTTP_REFERER'], strlen($url)),$missing_params,'docman');
}
if (empty($gfcommon)) {
- $engine_dir = '../../common';
+ $engine_dir = '../../common';
} else {
- $engine_dir = $gfcommon;
+ $engine_dir = $gfcommon;
}
-$d = new Document($g, false, false,$engine_dir.'/docman/engine/');
-if (!$d || !is_object($d)) {
- $return_msg= _('Error getting blank document.');
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
-} elseif ($d->isError()) {
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
+
+$d = new Document($g, false, false, $engine_dir.'/docman/engine/');
+
+if (!$d || !is_object($d)) {
+ $return_msg= _('Error getting blank document.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+} elseif ($d->isError()) {
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
}
switch ($type) {
$sanitizer = new TextSanitizer();
$data = $sanitizer->SanitizeHtml($data);
if (strlen($data)<1) {
- $return_msg= _('Error getting blank document.');
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+ $return_msg = _('Error getting blank document.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
}
- $uploaded_data_type='text/html';
+ $uploaded_data_type = 'text/html';
break;
}
case 'pasteurl' : {
$data = '';
- $uploaded_data_name=$file_url;
- $uploaded_data_type='URL';
+ $uploaded_data_name = $file_url;
+ $uploaded_data_type = 'URL';
break;
}
case 'httpupload' : {
- if (!is_uploaded_file($uploaded_data['tmp_name'])) {
- $return_msg= _('Invalid file name.');
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
+ if (!is_uploaded_file($uploaded_data['tmp_name'])) {
+ $return_msg = _('Invalid file name.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
}
$data = fread(fopen($uploaded_data['tmp_name'], 'r'), $uploaded_data['size']);
- $file_url='';
- $uploaded_data_name=$uploaded_data['name'];
- $uploaded_data_type=$uploaded_data['type'];
+ $file_url = '';
+ $uploaded_data_name = $uploaded_data['name'];
+ $uploaded_data_type = $uploaded_data['type'];
break;
}
- /*
- case 'ftpupload' : {
- $uploaded_data_name=$upload_dir.'/'.$ftp_filename;
- $data = fread(fopen($uploaded_data_name, 'r'), filesize($uploaded_data_name));
+ default: {
+ $return_msg = _('Unknown type submission.');
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($return_msg));
}
- */
}
-if (!$d->create($uploaded_data_name,$uploaded_data_type,$data,$doc_group,$title,$description)) {
- if (forge_check_perm ('docman', $group_id, 'approve')) {
+if (!$d->create($uploaded_data_name, $uploaded_data_type, $data, $doc_group, $title, $description)) {
+ if (forge_check_perm('docman', $group_id, 'approve')) {
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'&error_msg='.urlencode($d->getErrorMessage()));
- } else {
+ } else {
session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($d->getErrorMessage()));
- }
+ }
} else {
if ($type == 'editor') {
//release the cookie for the document contents (should expire at the end of the session anyway)
- setcookie ("gforgecurrentdocdata", "", time() - 3600);
+ setcookie("gforgecurrentdocdata", "", time() - 3600);
}
// check if the user is docman's admin
- if (forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Document submitted successfully');
+ if (forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Document submitted successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'&feedback='.urlencode($return_msg));
- } else {
- $return_msg= _('Document submitted successfully : pending state (need validation)');
+ } else {
+ $return_msg = _('Document submitted successfully : pending state (need validation).');
session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
}
}
global $dirid; // id of doc_group
global $group_id; // id of group
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Document Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Document Action Denied.');
if ($dirid) {
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($dg->getErrorMessage()));
if ($dirid) {
- $return_msg = _('Document Sub Directory successfully created');
+ $return_msg = _('Document Sub Directory successfully created.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
} else {
- $return_msg = _('Document Directory successfully created');
+ $return_msg = _('Document Directory successfully created.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dg->getID().'&feedback='.urlencode($return_msg));
}
}
global $group_id; // id of group
if (!forge_check_perm('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
- $dg = new DocumentGroup($g,$dirid);
+ $dg = new DocumentGroup($g, $dirid);
if ($dg->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
- if (!$dg->delete($dirid,$group_id))
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+ if (!$dg->delete($dirid, $group_id))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
- $return_msg = _('Document Directory deleted successfully');
+ $return_msg = _('Document Directory deleted successfully.');
session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
}
?>
$groupname = getStringFromRequest('groupname');
$parent_dirid = getIntFromRequest('parent_dirid');
-$dg = new DocumentGroup($g,$dirid);
+$dg = new DocumentGroup($g, $dirid);
if ($dg->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
-if (!$dg->update($groupname,$parent_dirid))
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
+if (!$dg->update($groupname, $parent_dirid))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($dg->getErrorMessage()));
-$return_msg = _('Document Directory Updated successfully');
+$return_msg = _('Document Directory Updated successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
?>
global $group_id; // id of group
if (!forge_check_perm('docman', $group_id, 'approve')) {
- $return_msg = _('Document Action Denied');
+ $return_msg = _('Document Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$doc_group = getIntFromRequest('doc_group');
$description = getStringFromRequest('description');
$data = getStringFromRequest('details'.$docid);
$file_url = getStringFromRequest('file_url');
- //$ftp_filename = getStringFromRequest('ftp_filename');
$uploaded_data = getUploadedFile('uploaded_data');
$stateid = getIntFromRequest('stateid');
$filetype = getStringFromRequest('filetype');
$editor = getStringFromRequest('editor');
- $fromview = getStringFromRequest('fromview');
- if ( 'admin' == $fromview ) {
- $urlparam = '&view='.$fromview;
- } else {
- $urlparam = '&view=listfile&dirid='.$doc_group;
- }
+ $fromview = getStringFromRequest('fromview');
+ if ( 'admin' == $fromview ) {
+ $urlparam = '&view='.$fromview;
+ } else {
+ $urlparam = '&view=listfile&dirid='.$doc_group;
+ }
$d= new Document($g,$docid,false,$gfcommon.'docman/engine/');
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
$sanitizer = new TextSanitizer();
$data = $sanitizer->SanitizeHtml($data);
} elseif (!empty($uploaded_data) && $uploaded_data['name']) {
if (!is_uploaded_file($uploaded_data['tmp_name'])) {
- $return_msg = sprintf(_('Invalid file attack attempt %1$s'), $uploaded_data['name']);
- session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($return_msg));
- }
-
+ $return_msg = sprintf(_('Invalid file attack attempt %1$s.'), $uploaded_data['name']);
+ session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($return_msg));
+ }
$data = fread(fopen($uploaded_data['tmp_name'], 'r'), $uploaded_data['size']);
- $filename=$uploaded_data['name'];
- $filetype=$uploaded_data['type'];
+ $filename = $uploaded_data['name'];
+ $filetype = $uploaded_data['type'];
} elseif ($file_url) {
$data = '';
- $filename=$file_url;
- $filetype='URL';
- /*
- } elseif (forge_get_config('use_ftp_uploads') && $ftp_filename!=100) { //100==None
- $filename=$upload_dir.'/'.$ftp_filename;
- $data = fread(fopen($filename, 'r'), filesize($filename));
- $filetype=$uploaded_data_type;
- } elseif (forge_get_config('use_manual_uploads') && $uploaded_filename!=100 && util_is_valid_filename($uploaded_filename)) { //100==None
- $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
- $filename = $incoming.'/'.$uploaded_filename;
- $data = addslashes(fread(fopen($filename, 'r'), filesize($filename)));
- $finfo = finfo_open (FILEINFO_MIME_TYPE) ;
- $filetype = finfo_file($finfo, $filename) ;
- finfo_close ($finfo) ;
- */
+ $filename = $file_url;
+ $filetype = 'URL';
} else {
- $filename=$d->getFileName();
- $filetype=$d->getFileType();
+ $filename = $d->getFileName();
+ $filetype = $d->getFileType();
}
- if (!$d->update($filename,$filetype,$data,$doc_group,$title,$description,$stateid))
- session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
+ if (!$d->update($filename, $filetype, $data, $doc_group, $title, $description, $stateid))
+ session_redirect('/docman/?group_id='.$group_id.$urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
- $return_msg = _('Document Updated successfully');
+ $return_msg = _('Document Updated successfully.');
session_redirect('/docman/?group_id='.$group_id.$urlparam.'&feedback='.urlencode($return_msg));
}
?>
global $dirid; //id of doc_group
global $group_id; // id of group
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Docman Action Denied');
+if ( !forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
} else {
-
/* you must first delete files before dirs because of database constraints */
$emptyFile = db_query_params('DELETE FROM doc_data WHERE stateid=$1 and group_id=$2',array('2',$group_id));
if (!$emptyFile)
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
$emptyDir = db_query_params('DELETE FROM doc_groups WHERE stateid=$1 and group_id=$2',array('2',$group_id));
if (!$emptyDir)
- session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
+ session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode(db_error()));
- $return_msg = _('Emptied Trash successfully');
+ $return_msg = _('Emptied Trash successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
}
?>
global $dirid; //id of doc_group
global $group_id; // id of group
-if (!forge_check_perm ('docman', $group_id, 'admin')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'admin')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$fileid = getIntFromRequest('fileid');
- $d= new Document($g,$fileid);
+ $d = new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- if ( !$d->setReservedBy('0') )
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ if (!$d->setReservedBy('0'))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- $return_msg = _('Document reservation enforced successfully');
+ $return_msg = _('Document reservation enforced successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
}
?>
global $g; //group object
global $group_id; // id of group
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Docman Action Denied');
+if ( !forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied');
session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
} else {
if ($_POST['status']) {
$status = 1;
- $return_msg= _('Search Engine Reindex Forced : search results will be available within 24h');
+ $return_msg = _('Search Engine Reindex Forced : search results will be available within 24h.');
}
if (!$g->setDocmanForceReindexSearch($status))
- session_redirect('/docman/?group_id='.$group_id.'&view=admin&error_msg='.urlencode($g->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=admin&error_msg='.urlencode($g->getErrorMessage()));
session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
}
global $group_id; // id of group
global $LUSER; // User object
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$fileid = getIntFromRequest('fileid');
- $lock = getIntFromRequest('lock');
- $d= new Document($g,$fileid);
+ $lock = getIntFromRequest('lock');
+ $d = new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- if ($lock == 0) {
- echo $d->setLock($lock);
- } else {
- echo $d->setLock($lock,$LUSER->getID(),time());
- }
- exit;
+ if ($lock == 0) {
+ echo $d->setLock($lock);
+ } else {
+ echo $d->setLock($lock, $LUSER->getID(), time());
+ }
+ exit;
}
?>
global $group_id; // id of group
global $LUSER; // User object
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
-
$fileid = getIntFromRequest('fileid');
- $option = getStringFromRequest('option');
- $d= new Document($g,$fileid);
+ $option = getStringFromRequest('option');
+ $d = new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
switch ($option) {
- case "add":
- if (!$d->addMonitoredBy($LUSER->getID())) {
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- } else {
- $feedback = _('Monitoring started');
+ case "add": {
+ if (!$d->addMonitoredBy($LUSER->getID())) {
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ } else {
+ $feedback = _('Monitoring started.');
+ }
+ break;
+ }
+ case "remove": {
+ if (!$d->removeMonitoredBy($LUSER->getID())) {
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ } else {
+ $feedback = _('Monitoring stopped.');
+ }
+ break;
}
- break;
- case "remove":
- if (!$d->removeMonitoredBy($LUSER->getID())) {
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- } else {
- $feedback = _('Monitoring stopped');
+ default: {
+ $error_msg = _('Docman : monitoring action unknown.');
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($error_msg));
}
- break;
- default:
- $error_msg = _('Docman : monitoring action unknown');
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($error_msg));
}
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($feedback));
global $dirid; //id of doc_group
global $group_id; // id of group
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$fileid = getIntFromRequest('fileid');
- $d= new Document($g,$fileid);
+ $d= new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- if ( !$d->setReservedBy(0) )
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ if (!$d->setReservedBy(0))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- $return_msg = _('Document released successfully');
+ $return_msg = _('Document released successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
}
?>
global $group_id; // id of group
global $LUSER; // User object
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$fileid = getIntFromRequest('fileid');
- $d= new Document($g,$fileid);
+ $d = new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- if ( !$d->setReservedBy('1',$LUSER->getID()) )
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ if (!$d->setReservedBy('1', $LUSER->getID()))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- $return_msg = _('Document reserved successfully');
+ $return_msg = _('Document reserved successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
}
?>
global $dgf; // document group factory of this group
global $d_arr; // documents array of this group
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Document Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Document Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
/* when moving a document group to trash, it's recursive and it's applied to documents that belong to these document groups */
/* Get the document groups info */
$trashnested_groups =& $dgf->getNested();
- $trashnested_docs=array();
+ $trashnested_docs = array();
/* put the doc objects into an array keyed of the docgroup */
foreach ($d_arr as $doc) {
$trashnested_docs[$doc->getDocGroupID()][] = $doc;
}
/* set to trash content of this dirid */
- docman_recursive_stateid($dirid,$trashnested_groups,$trashnested_docs,2);
+ docman_recursive_stateid($dirid, $trashnested_groups, $trashnested_docs, 2);
/* set this dirid to trash */
- $dg = new DocumentGroup($g,$dirid);
+ $dg = new DocumentGroup($g, $dirid);
$dg->setStateID('2');
- $return_msg = _('Document Directory moved to trash successfully');
+ $return_msg = _('Document Directory moved to trash successfully.');
session_redirect('/docman/?group_id='.$group_id.'&feedback='.urlencode($return_msg));
}
?>
global $dirid; //id of doc_group
global $group_id; // id of group
-if (!forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg = _('Docman Action Denied');
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg = _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
} else {
$fileid = getIntFromRequest('fileid');
- $d= new Document($g,$fileid);
+ $d = new Document($g, $fileid);
if ($d->isError())
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- if ( !$d->setState('2') )
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
+ if (!$d->setState('2'))
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&error_msg='.urlencode($d->getErrorMessage()));
- $return_msg = _('Document moved to trash successfully');
+ $return_msg = _('Document moved to trash successfully.');
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&feedback='.urlencode($return_msg));
}
?>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg= _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
} else {
if ($_POST['status']) {
$status = 1;
- $return_msg= _('Create Online Documents Status updated successfully : Active');
+ $return_msg = _('Create Online Documents Status updated successfully : Active.');
} else {
$status = 0;
- $return_msg= _('Create Online Documents Status updated successfully : Off');
+ $return_msg = _('Create Online Documents Status updated successfully : Off.');
}
if (!$g->setDocmanCreateOnlineStatus($status))
- session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg= _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
} else {
if ($_POST['status']) {
$status = 1;
- $return_msg= _('Search Engine Status updated successfully : Active');
+ $return_msg = _('Search Engine Status updated successfully : Active.');
} else {
$status = 0;
- $return_msg= _('Search Engine Status updated successfully : Off');
+ $return_msg = _('Search Engine Status updated successfully : Off.');
}
if (!$g->setDocmanSearchStatus($status))
- session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-if ( !forge_check_perm ('docman', $group_id, 'approve')) {
- $return_msg= _('Docman Action Denied');
+/* please do not add require here : use www/docman/index.php to add require */
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $return_msg= _('Docman Action Denied.');
session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
} else {
if ($_POST['status']) {
$status = 1;
- $return_msg= _('Webdav Interface updated successfully : Active');
+ $return_msg = _('Webdav Interface updated successfully : Active.');
} else {
$status = 0;
- $return_msg= _('Webdav Interface updated successfully : Off');
+ $return_msg = _('Webdav Interface updated successfully : Off.');
}
if (!$g->setDocmanWebdav($status))
- session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
+ session_redirect('/docman/?group_id='.$group_id.'&view=admin&warning_msg='.urlencode($g->getErrorMessage()));
session_redirect('/docman/?group_id='.$group_id.'&view=admin&feedback='.urlencode($return_msg));
}
require_once $gfcommon.'docman/engine/parser_text.inc.php';
-if ($argc != 2)
-{
+if ($argc != 2) {
echo "Usage : parser_doc.php <filename>\n";
exit (1);
}
$fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+ exit (1);
+
$fichout = "/tmp/gfo".rand(10000, 99999).".tmp";
$cmd = "/usr/bin/antiword -i1 -t $fichin > $fichout";
$res = shell_exec($cmd);
-$rep = parser_text($fichout);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface les fichiers témporaires
+echo parser_text($fichout);
unlink ($fichout);
// Local Variables:
require_once $gfcommon.'docman/engine/parser_text.inc.php';
-if ($argc != 2)
-{
+if ($argc != 2) {
echo "Usage : parser_html.php <filename>\n";
exit (1);
}
+
$fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+ exit (1);
$fd = fopen($fichin, "r");
$contents = fread($fd, filesize($fichin));
fclose($fd);
$strip_content = strip_tags($contents);
-$filename = tempnam("/tmp","tmp");
+$filename = tempnam("/tmp", "tmp");
$fd = fopen($filename, "w");
-fwrite ( $fd , $strip_content );
+fwrite($fd , $strip_content);
fclose($fd);
-$rep = parser_text($filename);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface le fichier source
+echo parser_text($filename);
unlink ($fichin);
// Local Variables:
require_once $gfcommon.'docman/engine/parser_text.inc.php';
-if ($argc != 2)
-{
+if ($argc != 2) {
echo "Usage : parser_oo.php <filename>\n";
exit (1);
}
$fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+ exit (1);
+
$zip = new ZipArchive;
if ($zip->open($fichin) === TRUE) {
$output_dir = $fichin.".dir";
mkdir($output_dir);
- $zip->extractTo($output_dir,array('content.xml'));
+ $zip->extractTo($output_dir, array('content.xml'));
$zip->close();
} else {
exit (2);
}
+
// transformer le context.xml en fichier txt
$regexp_oo = "sed -e 's/<[^>]*>//g;s/</</g;s/>/>/g;s/'/'\"'\"'/g;s/"/\"/g;s/&/\&/g'";
$cmd = $regexp_oo." ".$output_dir."/content.xml > ".$output_dir."/content.xml.txt";
$res = shell_exec($cmd);
-$rep = parser_text($output_dir.'/content.xml.txt');
-echo "$rep";
+echo parser_text($output_dir.'/content.xml.txt');
unlink($output_dir.'/content.xml');
unlink($output_dir.'/content.xml.txt');
require_once $gfcommon.'docman/engine/parser_text.inc.php';
-if ($argc != 2)
-{
+if ($argc != 2) {
echo "Usage : parser_pdf.php <filename>\n";
exit (1);
}
$fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+ exit (1);
+
$fichout = tempnam("/tmp","tmp");
$cmd = "/usr/bin/pdftotext $fichin $fichout";
$res = shell_exec($cmd);
-$rep = parser_text($fichout);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface les fichiers témporaires
+echo parser_text($fichout);
unlink ($fichout);
// Local Variables:
* USA
*/
-function parser_text($fichin)
-{
+function parser_text($fichin) {
$tstart = microtime_float();
- if (!is_file($fichin)) return "";
+ if (!is_file($fichin))
+ return "";
+
$fp = fopen ($fichin, "r");
$buff = fread ($fp, filesize($fichin));
// tout en minuscules
$buff = suppression_diacritics($buff);
// tous les mots dans un tableau
$a = explode(" ", $buff);
- //sort($a);
// élimination des doublons
$a = array_unique($a);
// envoi du résultat sur stdout
return $rep;
}
-function print_list ($list)
-{
+function print_list($list) {
$rep = "";
- foreach ($list as $el)
- {
+ foreach ($list as $el) {
if (strlen($el) > 1) $rep .= "$el ";
}
return $rep;
}
-function suppression_diacritics($text)
-{
+function suppression_diacritics($text) {
$b = $text;
- $b = iconv ('UTF-8', 'US-ASCII//TRANSLIT', $b) ;
+ $b = iconv('UTF-8', 'US-ASCII//TRANSLIT', $b) ;
$b = strtr($b, "\t\r\n?.*'\":;,#![]()", " ");
return $b;
}
-function microtime_float()
-{
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
+function microtime_float() {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
}
-
-function print_debug ($text)
-{
+function print_debug ($text) {
echo "$text <br />\n";
ob_flush();
}
require_once $gfcommon.'docman/engine/parser_text.inc.php';
-if ($argc != 2)
-{
+if ($argc != 2) {
echo "Usage : parser_text.php <filename>\n";
exit (1);
}
+
$fichin = $argv[1];
-if (!is_file($fichin)) exit (1);
+if (!is_file($fichin))
+ exit (1);
-$rep = parser_text($fichin);
-// envoi du résultat sur stdout
-echo "$rep";
-// efface le fichier source
+echo parser_text($fichin);
unlink ($fichin);
// Local Variables:
?>
<script type="text/javascript" >
function displayRowFile() {
- document.getElementById('filerow').style.display = '';
- document.getElementById('urlrow').style.display = 'none';
- document.getElementById('editrow').style.display = 'none';
- document.getElementById('editnamerow').style.display = 'none';
+ document.getElementById('filerow').style.display = '';
+ document.getElementById('urlrow').style.display = 'none';
+ document.getElementById('editrow').style.display = 'none';
+ document.getElementById('editnamerow').style.display = 'none';
}
function displayRowUrl() {
- document.getElementById('filerow').style.display = 'none';
- document.getElementById('urlrow').style.display = '';
- document.getElementById('editrow').style.display = 'none';
- document.getElementById('editnamerow').style.display = 'none';
+ document.getElementById('filerow').style.display = 'none';
+ document.getElementById('urlrow').style.display = '';
+ document.getElementById('editrow').style.display = 'none';
+ document.getElementById('editnamerow').style.display = 'none';
}
function displayRowEditor() {
- document.getElementById('filerow').style.display = 'none';
- document.getElementById('urlrow').style.display = 'none';
- document.getElementById('editrow').style.display = '';
- document.getElementById('editnamerow').style.display = '';
+ document.getElementById('filerow').style.display = 'none';
+ document.getElementById('urlrow').style.display = 'none';
+ document.getElementById('editrow').style.display = '';
+ document.getElementById('editnamerow').style.display = '';
}
</script>
<?php
<tr>
<td style="text-align:right;">
<strong>'. _('Document Title').'</strong>'.utils_requiredField()
- .'</td><td>'
- .' <input type="text" name="title" size="40" maxlength="255" /> '
- .sprintf(_('(at least %1$s characters)'), 5)
+ .'</td><td>'
+ .' <input type="text" name="title" size="40" maxlength="255" /> '
+ .sprintf(_('(at least %1$s characters)'), 5)
.'</td>
</tr>
<tr>