+2003-01-02 Tim Perdue <tim@gforge.org>
+
+ * Complete rewrite of doc mgr in GForge coding guidelines.
+
2002-12-24 Tim Perdue <tim@gforge.org>
* Gantt charting added and more debugging of new Project Manager.
/*
$perm =& $this->Group->getPermission( session_get_user() );
- if (!$perm || !is_object($perm) || !$perm->isDocumentAdmin()) {
+ if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
$this->setError('Permission Denied');
return false;
}
*/
$user_id = ((session_loggedin()) ? user_getid() : 100);
- $sql="INSERT INTO doc_data (group_id,title,description,createdate,
+ $sql="INSERT INTO doc_data (group_id,title,description,createdate,doc_group,
stateid,language_id,filename,filetype,data,created_by)
VALUES ('".$this->Group->getId()."',
'". htmlspecialchars($title) ."',
'". htmlspecialchars($description) ."',
'". time() ."',
+ '$doc_group',
'3',
'$language_id',
'$filename',
'$filetype',
- '". base64_encode($data) ."',
+ '". base64_encode(stripslashes($data)) ."',
'$user_id')";
db_begin();
$result=db_query($sql);
if (!$result) {
- db_rollback();
$this->setError('Error Adding Document: '.db_error());
+ db_rollback();
return false;
}
$docid=db_insertid($result,'doc_data','docid');
* @return string The name of this document.
*/
function getName() {
- return $this->data_array['filename'];
+ return $this->data_array['title'];
}
/**
return $this->data_array['state_name'];
}
+ /**
+ * getLanguageID - get this language_id.
+ *
+ * @return int The language_id.
+ */
+ function getLanguageID() {
+ return $this->data_array['language_id'];
+ }
+
+ /**
+ * getLanguageName - the language_name of this document.
+ *
+ * @return string The language_name.
+ */
+ function getLanguageName() {
+ return $this->data_array['language_name'];
+ }
+
/**
* getDocGroupID - get this doc_group_id.
*
$perm =& $this->Group->getPermission( session_get_user() );
- if (!$perm || !is_object($perm) || !$perm->isDocAdmin()) {
+ if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
$this->setError('Permission Denied');
return false;
}
+ if ($data) {
+ $datastr="data='". base64_encode(stripslashes($data)) ."',";
+ }
$res=db_query("UPDATE doc_data SET
title='". htmlspecialchars($title) ."',
doc_group='$doc_group',
filetype='$filetype',
filename='$filename',
- data='$data',
+ $datastr
language_id='$language_id',
updatedate='". time() ."'
WHERE group_id='".$this->Group->getID()."'
--- /dev/null
+<?php
+/**
+ * GForge Doc Mgr Facility
+ *
+ * Copyright 2002 GForge, LLC
+ * http://gforge.org/
+ *
+ * @version $Id$
+ */
+
+
+/*
+ Document Manager
+
+ by Quentin Cregan, SourceForge 06/2000
+
+ Complete OO rewrite by Tim Perdue 1/2003
+*/
+
+require_once('common/include/Error.class');
+require_once('common/docman/Document.class');
+
+class DocumentFactory extends Error {
+
+ /**
+ * The Group object
+ *
+ * @var object $Group
+ */
+ var $Group;
+
+ /**
+ * The Documents array.
+ *
+ * @var array Documents
+ */
+ var $Documents;
+ var $stateid;
+ var $languageid;
+ var $docgroupid;
+ var $sort='doc_group';
+
+ /**
+ * Constructor.
+ *
+ * @param object The Group object to which this forum is associated
+ */
+ function DocumentFactory(&$Group) {
+ $this->Error();
+ if (!$Group || !is_object($Group)) {
+ $this->setError('ProjectGroup:: No Valid Group Object');
+ return false;
+ }
+ if ($Group->isError()) {
+ $this->setError('ProjectGroup:: '.$Group->getErrorMessage());
+ return false;
+ }
+ $this->Group =& $Group;
+
+ return true;
+ }
+
+ /**
+ * getGroup() - get the Group object this ArtifactType is associated with
+ *
+ * @return the Group object
+ */
+ function &getGroup() {
+ return $this->Group;
+ }
+
+ function setStateID($stateid) {
+ $this->stateid=$stateid;
+ }
+
+ function setLanguageID($languageid) {
+ $this->languageid=$languageid;
+ }
+
+ function setDocGroupID($docgroupid) {
+ $this->docgroupid=$docgroupid;
+ }
+
+ function setSort($sort) {
+ $this->sort=$sort;
+ }
+
+ function &getDocuments() {
+ if ($this->Documents) {
+ return $this->Documents;
+ }
+
+ if (!$this->stateid) {
+ if (session_loggedin()) {
+ $perm =& $this->Group->getPermission( session_get_user() );
+ if (!$perm || !is_object($perm) || !$perm->isMember()) {
+ $public_flag='AND stateid=1';
+ } else {
+ $public_flag='AND stateid IN (1,4,5)';
+ }
+ } else {
+ $public_flag='AND stateid=1';
+ }
+ } else {
+ if ($this->stateid =='ALL') {
+
+ } else {
+ $public_flag='AND stateid =\''.$this->stateid.'\'';
+ }
+ }
+
+ if ($this->docgroupid) {
+ $docgroupsql="AND doc_group='".$this->docgroupid."'";
+ }
+ if ($this->languageid) {
+ $languagesql="AND language_id='".$this->languageid."'";
+ }
+
+ $sql="SELECT *
+ FROM docdata_vw
+ WHERE group_id='". $this->Group->getID() ."'
+ $public_flag
+ $docgroupsql
+ $languagesql
+ ORDER BY ".$this->sort;
+
+ $result = db_query ($sql);
+
+//echo "$sql<br>".db_error();
+
+ $rows = db_numrows($result);
+
+ if (!$result || $rows < 1) {
+ $this->setError('No Documents Found '.db_error());
+ return false;
+ } else {
+ while ($arr =& db_fetch_array($result)) {
+ $this->Documents[] = new Document($this->Group, $arr['docid'], $arr);
+ }
+ }
+ return $this->Documents;
+ }
+
+}
+
+?>
require_once('common/include/Error.class');
-class DocumentCategory extends Error {
+class DocumentGroup extends Error {
/**
* The artifact type object
var $data_array;
/**
- * DocumentCategory - constructor.
+ * DocumentGroup - constructor.
*
* Use this constructor if you are modifying an existing doc_group.
*
* @param array (all fields from doc_groups) OR doc_group from database.
* @return boolean.
*/
- function DocumentCategory(&$Group, $data=false) {
+ function DocumentGroup(&$Group, $data=false) {
$this->Error();
//was Group legit?
if (!$Group || !is_object($Group)) {
- $this->setError('DocumentCategory: No Valid Group');
+ $this->setError('DocumentGroup: No Valid Group');
return false;
}
//did Group have an error?
if ($Group->isError()) {
- $this->setError('DocumentCategory: '.$Group->getErrorMessage());
+ $this->setError('DocumentGroup: '.$Group->getErrorMessage());
return false;
}
$this->Group =& $Group;
// data validation
//
if (!$name) {
- $this->setError('DocumentCategory: name is Required');
+ $this->setError('DocumentGroup: name is Required');
return false;
}
$perm =& $this->Group->getPermission (session_get_user());
- if (!$perm || !$perm->isPMAdmin()) {
+ if (!$perm || !$perm->isDocEditor()) {
$this->setError('Permission Denied');
return false;
}
}
/**
- * fetchData() - re-fetch the data for this DocumentCategory from the database
+ * fetchData() - re-fetch the data for this DocumentGroup from the database
*
* @param int ID of the category
* @return true/false
function fetchData($id) {
$res=db_query("SELECT * FROM doc_groups WHERE doc_group='$id'");
if (!$res || db_numrows($res) < 1) {
- $this->setError('DocumentCategory: Invalid DocumentCategory ID');
+ $this->setError('DocumentGroup: Invalid DocumentGroup ID');
return false;
}
$this->data_array =& db_fetch_array($res);
}
/**
- * getGroup - get the Group Object this DocumentCategory is associated with.
+ * getGroup - get the Group Object this DocumentGroup is associated with.
*
* @return Object Group.
*/
}
/**
- * getID - get this DocumentCategory's ID.
+ * getID - get this DocumentGroup's ID.
*
* @return int The id #.
*/
}
/**
- * update - update an DocumentCategory.
+ * update - update a DocumentGroup.
*
* @param string Name of the category.
* @return boolean.
*/
function update($name) {
$perm =& $this->Group->getPermission (session_get_user());
- if (!$perm || !$perm->isDocAdmin()) {
+ if (!$perm || !$perm->isDocEditor()) {
$this->setError('Permission Denied');
return false;
}
require_once('common/tracker/ArtifactTypes.class');
require_once('common/forum/Forum.class');
require_once('common/frs/FRSPackage.class');
+require_once('common/docman/DocumentGroup.class');
require_once('www/include/BaseLanguage.class');
$GROUP_OBJ=array();
*/
function update(&$user, $group_name,$homepage,$short_description,$use_mail,$use_survey,$use_forum,
$use_pm,$use_pm_depend_box,$use_cvs,$use_news,$use_docman,
- $new_task_address,$send_all_tasks,$logo_image_id,
+ $new_doc_address,$send_all_docs,$logo_image_id,
$enable_pserver,$enable_anoncvs,
$use_ftp,$use_tracker,$use_frs,$use_stats) {
global $Language;
return false;
}
- if ($new_task_address && !validate_email($new_task_address)) {
- $this->setError('Task Address Appeared Invalid');
+ if ($new_doc_address && !validate_email($new_doc_address)) {
+ $this->setError('New Doc Address Appeared Invalid');
return false;
}
use_cvs='$use_cvs',
use_news='$use_news',
use_docman='$use_docman',
- new_task_address='$new_task_address',
- send_all_tasks='$send_all_tasks',
+ new_doc_address='$new_doc_address',
+ send_all_docs='$send_all_docs',
enable_pserver='$enable_pserver',
enable_anoncvs='$enable_anoncvs',
use_ftp='$use_ftp',
use_tracker='$use_tracker',
use_frs='$use_frs',
- use_stats='$use_stats'".
- "
+ use_stats='$use_stats'
WHERE group_id='".$this->getID()."'
");
// consistent with trackers code
/**
- * PMEmailAddress() - get email address to send PM notifications to
+ * getDocEmailAddress() - get email address to send doc notifications to.
*
- * @return true/false
+ * @return string email address.
*/
- function PMEmailAddress() {
- return $this->data_array['new_task_address'];
+ function getDocEmailAddress() {
+ return $this->data_array['new_doc_address'];
}
/**
- * PMEmailAll() - whether or not this group has opted to use task dependencies
+ * DocEmailAll() - whether or not this group has opted to use receive notices on all doc updates.
*
- * @return true/false
+ * @return true/false.
*/
- function PMEmailAll() {
- return $this->data_array['send_all_tasks'];
+ function docEmailAll() {
+ return $this->data_array['send_all_docs'];
}
/**
- * getHomePage() - The URL for this project's home page
+ * getHomePage() - The URL for this project's home page.
*
- * @return text homepage URL
+ * @return string homepage URL.
*/
function getHomePage() {
return $this->data_array['homepage'];
return false;
}
- // Step 3: Setup default DocManager doc_group
- db_query("
- INSERT INTO doc_groups(groupname,group_id)
- VALUES ('Uncategorized Submissions',".$this->getID().")
- ");
+ $dg = new DocumentGroup($this);
+ if (!$dg->create('Uncategorized Submissions')) {
+ $this->setError($dg->getErrorMessage());
+ db_rollback();
+ return false;
+ }
// Step 4: Setup default filerelease package
$frs = new FRSPackage($this);
--
-- Create a convenience view for selecting from docman
--
+DROP VIEW docdata_vw;
CREATE VIEW docdata_vw AS
-SELECT users.user_name,users.realname,users.email,doc_data.*,
- doc_states.name AS state_name,doc_groups.groupname AS group_name
-FROM doc_data
+SELECT users.user_name,users.realname,users.email,
+ d.group_id,d.docid,d.stateid,d.title,d.updatedate,d.createdate,d.created_by,
+ d.doc_group,d.description,d.language_id,d.filename,d.filetype,
+ doc_states.name AS state_name,
+ doc_groups.groupname AS group_name,
+ sl.name as language_name
+FROM doc_data d
NATURAL JOIN doc_states
NATURAL JOIN doc_groups
-JOIN users ON (users.user_id=doc_data.created_by);
+JOIN supported_languages sl ON (sl.language_id=d.language_id)
+JOIN users ON (users.user_id=d.created_by);
<?php
/**
- *
- * SourceForge Documentaion Manager
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- *
- */
+ * GForge Doc Mgr Facility
+ *
+ * Copyright 2002 GForge, LLC
+ * http://gforge.org/
+ *
+ * @version $Id$
+ */
/*
- Docmentation Manager
- by Quentin Cregan, SourceForge 06/2000
-*/
+ Document Manager
+
+ by Quentin Cregan, SourceForge 06/2000
+ Complete OO rewrite by Tim Perdue 1/2003
+*/
-require_once('../doc_utils.php');
require_once('pre.php');
+require_once('www/docman/include/doc_utils.php');
+require_once('common/docman/DocumentFactory.class');
+require_once('common/docman/DocumentGroup.class');
-if (!($group_id)) {
+if (!$group_id) {
exit_no_group();
}
-if (!(user_ismember($group_id,"D1"))) {
+$g =& group_get_object($group_id);
+if (!$g || !is_object($g) || $g->isError()) {
+ exit_no_group();
+}
+
+$perm =& $g->getPermission( session_get_user() );
+if (!$perm || $perm->isError() || !$perm->isDocEditor()) {
exit_permission_denied();
}
-function main_page($group_id) {
- docman_header('Document Admin Page','Document Manager Admin','docman_admin','admin',group_getname($group_id),'admin');
- echo '<p><b>Pending Submissions:</b> <p>';
- display_docs('3',$group_id);
- // doc_group 3 == pending
- echo '<p>';
- echo '<b>Active Submissions:</b> <p>';
- display_docs('1',$group_id);
- //doc_group 1 == active
- docman_footer($params);
-
-}//end function main_page($group_id);
-
-//begin to seek out what this page has been called to do.
-
- if (strstr($mode,"docedit")) {
- $query = "select * from doc_data,doc_groups "
- ."where docid='$docid' "
- ."and doc_groups.doc_group = doc_data.doc_group "
- ."and doc_groups.group_id = '$group_id'";
- $result = db_query($query);
- $row = db_fetch_array($result);
-
- docman_header('Edit Document','Edit Document','docman_admin_docedit','admin',group_getname($group_id),'');
+//
+//
+// Submit the changes to the database
+//
+//
+if ($submit) {
+
+ if ($editdoc) {
+
+ $d= new Document($g,$docid);
+ if ($d->isError()) {
+ exit_error('Error',$d->getErrorMessage());
+ }
+ if ($uploaded_data_name) {
+ if (!is_uploaded_file($uploaded_data)) {
+ exit_error("Error","Invalid file attack attempt $uploaded_data");
+ }
+ $data = addslashes(fread(fopen($uploaded_data, 'r'), filesize($uploaded_data)));
+ $filename=$uploaded_data_name;
+ $filetype=$uploaded_data_type;
+ } else {
+ $filename=$d->getFileName();
+ $filetype=$d->getFileType();
+ }
+ if (!$d->update($filename,$filetype,$data,$doc_group,$title,$language_id,$description,$stateid)) {
+ exit_error('Error',$d->getErrorMessage());
+ }
+ $feedback = "Successfully Updated";
+
+ } elseif ($editgroup) {
- echo '
+ $dg = new DocumentGroup($g,$doc_group);
+ if ($dg->isError()) {
+ exit_error('Error',$dg->getErrorMessage());
+ }
+ if (!$dg->update($groupname)) {
+ exit_error('Error',$dg->getErrorMessage());
+ }
+ $feedback = "Successfully Updated";
+
+ } elseif ($addgroup) {
+
+ $dg = new DocumentGroup($g);
+ if ($dg->isError()) {
+ exit_error('Error',$dg->getErrorMessage());
+ }
+ if (!$dg->create($groupname)) {
+ exit_error('Error',$dg->getErrorMessage());
+ }
+ $feedback = "Successfully Created";
+
+ }
+
+}
+
+//
+//
+// Edit a specific document
+//
+//
+if ($editdoc && $docid) {
- <form name="editdata" action="index.php?mode=docdoedit&group_id='.$group_id.'" method="POST" enctype="multipart/form-data">
-
- <table border="0" width="75%">
-
- <tr>
- <th>Document Title:</th>
- <td><input type="text" name="title" size="40" maxlength="255" value="'.$row['title'].'"></td>
- <td class="example">(e.g. How to use the download server)</td>
-
- </tr>
- <tr>
- </tr>
- <tr>
- <th>Short Description:</td>
- <td><input type="text" name="description" size="20" maxlength="255" value="'.$row['description'].'"></td>
- <td class="example">(e.g. http://www.linux.com/)</td>
-
- </tr>
- <tr>
- <th>File:</th>
- <td><a target="_blank" href="../display_doc.php/'.$row['docid'].'/'.$row['filename'].'">'.$row['title'].'</A>
- </tr>
- <tr>
- <th>Language:</th>
- <td>';
-
- echo html_get_language_popup($Language,'language_id',$row['language_id']);
+ $d= new Document($g,$docid);
+ if ($d->isError()) {
+ exit_error('Error',$d->getErrorMessage());
+ }
- echo '
- <tr>
- <th>Group doc belongs in:</th>
- <td>';
+ docman_header('Edit Document','Edit Document','docman_admin_docedit','admin',$g->getPublicName(),'');
- display_groups_option($group_id,$row['doc_group']);
+ ?>
+ <form name="editdata" action="index.php?editdoc=1&group_id=<?php echo $group_id; ?>" method="POST" enctype="multipart/form-data">
- echo ' </td>
- </tr>
+ <table border="0">
- <tr>
- <th>State:</th>
- <td>';
+ <tr>
+ <td>
+ <b>Document Title:</b><br>
+ <input type="text" name="title" size="40" maxlength="255" value="<?php echo $d->getName(); ?>">
+ <br>(e.g. How to use the download server)</td>
+ </tr>
- doc_get_state_box($row['stateid']);
+ <tr>
+ <td>
+ <b>Short Description:</b><br>
+ <input type="text" name="description" size="20" maxlength="255" value="<?php echo $d->getDescription(); ?>">
+ <br>(e.g. http://www.linux.com/)</td>
+ </tr>
- echo '
- </td>
- </tr>';
+ <tr>
+ <td>
+ <b>File:</b><br>
+ <a target="_blank" href="../view.php/<?php echo $group_id.'/'.$d->getID().'/'.$d->getFileName() ?>"><?php echo $d->getName(); ?></a>
+ </td>
+ </tr>
- // if this is a text/html doc, display an edit box
- if (strstr($row['filetype'],'ext')) {
+ <tr>
+ <td>
+ <b>Language:</b><br>
+ <?php
- echo '
- <tr>
- <th>Document Contents:</th>
- <td><textarea cols="80" rows="20" name="data">'. htmlspecialchars(base64_decode($row['data'])).'</textarea></td>
- </tr>';
- }
+ echo html_get_language_popup($Language,'language_id',$d->getLanguageID());
- echo '
- <tr>
- <th>OPTIONAL: Upload New File:</th>
- <td><input type="file" name="uploaded_data" size="30"></td>
- </tr>
- </table>
-
- <input type="hidden" name="docid" value="'.$row['docid'].'">
- <input type="submit" value="Submit Edit">
-
- </form>';
-
- docman_footer($params);
- } elseif (strstr($mode,"groupdelete")) {
- $query = "select docid "
- ."from doc_data "
- ."where doc_group = '$doc_group'";
- $result = db_query($query);
- if (db_numrows($result) < 1) {
- $query = "delete from doc_groups "
- ."where doc_group = '$doc_group' "
- ."and group_id = '$group_id'";
- db_query($query);
- docman_header("Group Delete","Group Delete",'docman_admin_groupdelete','admin',group_getname($group_id),'');
- print "<p><b>Group deleted. (GroupID : ".$doc_group.")</b>";
- docman_footer($params);
+ ?></td>
+ </tr>
- } else {
-
- docman_header("Group Delete","Group Delete Failed",'docman_admin_groupdelete','admin',group_getname($group_id),'');
- print "Group was not deleted. Cannot delete groups that still have documents grouped under them.";
- docman_footer($params);
- }
-
- } elseif (strstr($mode,"groupedit")) {
- docman_header('Group Edit','Group Edit','docman_admin_groupedit','admin',group_getname($group_id),'');
- $query = "select * "
- ."from doc_groups "
- ."where doc_group = '$doc_group' "
- ."and group_id='$group_id'";
- $result = db_query($query);
- $row = db_fetch_array($result);
- echo '
- <b> Edit a group:</b>
-
- <form name="editgroup" action="index.php?mode=groupdoedit&group_id='.$group_id.'" method="POST">
- <table>
- <tr><th>Name:</th> <td><input type="text" name="groupname" value="'.$row['groupname'].'"></td></tr>
- <input type="hidden" name="doc_group" value="'.$row['doc_group'].'">
- <tr><td> <input type="submit"></td></tr></table>
- </form>
- ';
- docman_footer($params);
-
- } elseif (strstr($mode,"groupdoedit")) {
- $query = "update doc_groups "
- ."set groupname='".htmlspecialchars($groupname)."' "
- ."where doc_group='$doc_group' "
- ."and group_id = '$group_id'";
- db_query($query);
- $feedback .= "Document Group Edited.";
- main_page($group_id);
-
- } elseif (strstr($mode,"docdoedit")) {
- //Page security - checks someone isnt updating a doc
- //that isnt theirs.
-
- $query = "select dd.docid "
- ."from doc_data dd, doc_groups dg "
- ."where dd.doc_group = dg.doc_group "
- ."and dg.group_id = '$group_id' "
- ."and dd.docid = '$docid'";
-
- $result = db_query($query);
-
- if (db_numrows($result) == 1) {
+ <tr>
+ <td>
+ <b>Group doc belongs in:</b><br>
+ <?php
- if ($data) {
- $datastring = "data = '". base64_encode($data) ."',";
- }
- if ($uploaded_data_name) {
- if (!is_uploaded_file($uploaded_data)) {
- exit_error("Error","Invalid file attack attempt $uploaded_data");
- }
- $data = fread(fopen($uploaded_data, 'r'), filesize($uploaded_data));
- $datastring = "data = '". base64_encode($data) ."',
- filename='$uploaded_data_name',
- filetype='$uploaded_data_type',";
- }
- // data in DB stored in htmlspecialchars()-encoded form
- $query = "update doc_data "
- ."set title = '".htmlspecialchars($title)."', "
- .$datastring
- ."updatedate = '".time()."', "
- ."doc_group = '".$doc_group."', "
- ."stateid = '".$stateid."', "
- ."language_id = '".$language_id."', "
- ."description = '".htmlspecialchars($description)."' "
- ."where docid = '$docid'";
-
- $res = db_query($query);
- if (!$res || db_affected_rows($res)<1) {
- $feedback .= 'Could not update document<br>';
- } else {
- $feedback .= "Document \" ".htmlspecialchars($title)." \" updated";
- }
- main_page($group_id);
+ echo display_groups_option($group_id,$d->getDocGroupID());
- } else {
+ ?></td>
+ </tr>
+
+ <tr>
+ <td>
+ <br>State:</b><br>
+ <?php
+
+ doc_get_state_box($d->getStateID());
+
+ ?></td>
+ </tr>
+
+ <?php
- exit_error("Error","Unable to update - Document does not exist, or document's group not the same as that to which your account belongs.");
+ // if this is a text/html doc, display an edit box
+ if (strstr($d->getFileType(),'ext')) {
+ echo '
+ <tr>
+ <td>
+ <b>Document Contents:</b><br>
+ <textarea cols="80" rows="20" name="data">'. htmlspecialchars( $d->getFileData() ).'</textarea>
+ </td>
+ </tr>';
+ }
+
+ ?>
+ <tr>
+ <td>
+ <b>OPTIONAL: Upload New File:</b><br>
+ <input type="file" name="uploaded_data" size="30">
+ </td>
+ </tr>
+ </table>
+
+ <input type="hidden" name="docid" value="<?php echo $d->getID(); ?>">
+ <input type="submit" value="Submit Edit" name="submit">
+
+ </form>
+ <?php
+
+ docman_footer(array());
+
+//
+//
+// Add a document group / view existing groups list
+//
+//
+} elseif ($addgroup) {
+
+ docman_header('Group Edit', 'Group Edit','docman_admin_editgroups','admin',$g->getPublicName(),'');
+
+ echo "<h1>Add Document Groups</h1>";
+
+ /*
+ List of possible categories for this ArtifactType
+ */
+ $result=db_query("SELECT * FROM doc_groups WHERE group_id='$group_id'");
+ echo "<p>";
+ $rows=db_numrows($result);
+ if ($result && $rows > 0) {
+ $title_arr=array();
+ $title_arr[]='ID';
+ $title_arr[]='Title';
+
+ echo $GLOBALS['HTML']->listTableTop ($title_arr);
+
+ for ($i=0; $i < $rows; $i++) {
+ echo '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
+ '<td>'.db_result($result, $i, 'doc_group').'</td>'.
+ '<td><a href="index.php?editgroup=1&doc_group='.
+ db_result($result, $i, 'doc_group').'&group_id='.$group_id.'">'.
+ db_result($result, $i, 'groupname').'</a></td></tr>';
}
- } elseif (strstr($mode,"groupadd")) {
- $query = "insert into doc_groups(groupname,group_id) "
- ."values ('"
- ."".htmlspecialchars($groupname)."',"
- ."'$group_id')";
-
- db_query($query);
- $feedback .= "Group ".htmlspecialchars($groupname)." added.";
- main_page($group_id);
-
- } elseif (strstr($mode,"editgroups")) {
- docman_header('Group Edit', 'Group Edit','docman_admin_editgroups','admin',group_getname($group_id),'');
- echo '
- <p><b> Add a group:</b>
- <form name="addgroup" action="index.php?mode=groupadd&group_id='.$group_id.'" method="POST">
- <table>
- <tr><th>New Group Name:</th> <td><input type="text" name="groupname"></td><td><input type="submit" value="Add"></td></tr></table>
- <p>
- Group name will be used as a title, so it should be
- formatted correspondingly.
- </p>
- </form>
- ';
- display_groups($group_id);
-
- } elseif (strstr($mode,"editdocs")) {
-
- docman_header('Edit documents list','Edit documents','docman_admin_editdocs','admin',group_getname($group_id),'');
-
- print "<p><b>Active Documents:</b><p>";
- display_docs('1',$group_id);
- print "<p><b>Pending Documents:</b><p>";
- display_docs('3',$group_id);
- print "<p><b>Hidden Documents:</b><p>";
- display_docs('4',$group_id);
- print "<p><b>Deleted Documents:</b><p>";
- display_docs('2',$group_id);
- print "<p><b>Private Documents:</b><p>";
- display_docs('5',$group_id);
- docman_footer($params);
+ echo $GLOBALS['HTML']->listTableBottom();
+
+ } else {
+ echo "\n<h1>No Document Groups Defined</h1>";
+ }
+ ?>
+ <p><b> Add a group:</b>
+ <form name="addgroup" action="index.php?addgroup=1&group_id=<?php echo $group_id; ?>" method="POST">
+ <table>
+ <tr>
+ <th>New Group Name:</th>
+ <td><input type="text" name="groupname"></td>
+ <td><input type="submit" value="Add" name="submit"></td>
+ </tr>
+ </table>
+ <p>
+ Group name will be used as a title, so it should be
+ formatted correspondingly.
+ </p>
+ </form>
+ <?php
+
+ docman_footer(array());
+
+//
+//
+// Edit a specific doc group
+//
+//
+} elseif ($editgroup && $doc_group) {
+
+ $dg = new DocumentGroup($g,$doc_group);
+ if ($dg->isError()) {
+ exit_error('Error',$dg->getErrorMessage());
+ }
+
+ docman_header('Group Edit', 'Group Edit','docman_admin_editgroups','admin',$g->getPublicName(),'');
+ ?>
+ <p><b>Edit a group:</b>
+ <form name="editgroup" action="index.php?editgroup=1&group_id=<?php echo $group_id; ?>" method="POST">
+ <input type="hidden" name="doc_group" value="<?php echo $doc_group; ?>">
+ <table>
+ <tr>
+ <th>Group Name:</th>
+ <td><input type="text" name="groupname" value="<?php echo $dg->getName(); ?>"></td>
+ <td><input type="submit" value="Edit" name="submit"></td>
+ </tr>
+ </table>
+ <p>
+ Group name will be used as a title, so it should be
+ formatted correspondingly.
+ </p>
+ </form>
+ <?php
+ docman_footer(array());
+
+//
+//
+// Display the main admin page
+//
+//
+} else {
+
+ $df = new DocumentFactory($g);
+ if ($df->isError()) {
+ exit_error('Error',$df->getErrorMessage());
+ }
+ $df->setStateID('ALL');
+ $df->setSort('stateid');
+ $d_arr =& $df->getDocuments();
+
+ docman_header('Document Admin Page','Document Manager Admin','docman_admin','admin',$g->getPublicName(),'admin');
+
+ ?>
+ <h3>Doc Manager Administration</h3>
+ <p>
+ <a href="index.php?group_id=<?php echo $group_id; ?>&addgroup=1">Add/Edit Document Groups</a>
+ <p>
+ <?php
+
+ if (!$d_arr || count($d_arr) < 1) {
+ print "<b>This project has no visible documents.</b><p>";
} else {
- main_page($group_id);
- } //end else
+ // doc_droplist_count($group_id, $language_id);
+
+ print "\n<ul>";
+ for ($i=0; $i<count($d_arr); $i++) {
+
+ //
+ // If we're starting a new "group" of docs, put in the
+ // docGroupName and start a new <ul>
+ //
+ if ($d_arr[$i]->getStateID() != $last_state) {
+ print (($i==0) ? '' : '</ul>');
+ print "\n\n<li><b>". $d_arr[$i]->getStateName() ."</b></li><ul>";
+ $last_state=$d_arr[$i]->getStateID();
+ }
+ print "\n<li><a href=\"index.php?editdoc=1&docid=".$d_arr[$i]->getID()."&group_id=$group_id\">".
+ $d_arr[$i]->getName()." [ ".$d_arr[$i]->getFileName()." ]</a>".
+ "\n<BR><i>Description:</i> ".$d_arr[$i]->getDescription();
+
+ }
+ print "\n</ul>\n";
+ }
+
+ docman_footer(array());
+
+}
?>
+++ /dev/null
-<?php
-/**
- * SourceForge Documentaion Manager
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- */
-
-/*
- by Quentin Cregan, SourceForge 06/2000
-*/
-
-
-require_once('doc_utils.php');
-require_once('pre.php');
-
-$arr=explode('/',$REQUEST_URI);
-$docid=$arr[3];
-
-if ($docid) {
- $query = "select data,doc_group,filetype,filename
- from doc_data
- where docid = '$docid'";
- //and stateid = '1'";
- // stateid = 1 == active
- $result = db_query($query);
- if (db_numrows($result) < 1) {
- exit_error('Document unavailable','Document is not available.');
- } else {
- $row = db_fetch_array($result);
- }
- $g =& group_get_object($row['doc_group']);
- if (!$g || !is_object($g)) {
- exit_no_group();
- } elseif ($g->isError()) {
- exit_error('Error',$g->getErrorMessage());
- }
-
- Header ("Content-disposition: filename=$row[filename]");
- if (strstr($row['filetype'],'app')) {
- Header ("Content-type: application/binary");
- } else {
- Header ("Content-type: $row[filetype]");
- }
- echo base64_decode($row['data']);
-
-} else {
- exit_error("No document data.","No document to display - invalid or inactive document number.");
-}
-
-?>
+++ /dev/null
-<?php
-/**
- *
- * SourceForge Documentaion Manager
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id: doc_utils.php,v 1.72 2001/07/11 00:51:18 dbellizzi Exp $
- *
- */
-
-
-/*
- by Quentin Cregan, SourceForge 06/2000
-*/
-
-
-function display_groups_option($group_id=false,$checkedval='xzxz') {
-
- if (!$group_id) {
- exit_no_group();
- } else {
- $query = "select doc_group, groupname "
- ."from doc_groups "
- ."where group_id = '$group_id' "
- ."order by groupname";
- $result = db_query($query);
-
- echo html_build_select_box ($result,'doc_group',$checkedval,false);
-
- } //end else
-
-} //end display_groups_option
-
-
-function display_groups($group_id) {
- // show list of groups to edit.
- $query = "select * "
- ."from doc_groups "
- ."where group_id = '$group_id'";
- $result = db_query($query);
-
- if (db_numrows($result) < 1) {
- print "<p>No groups currently exist.";
- } else {
-
- $title_arr=array();
- $title_arr[]='Group ID';
- $title_arr[]='Group Name';
- $title_arr[]='Controls';
-
- echo $GLOBALS['HTML']->listTableTop ($title_arr);
-
- $i = 0;
- while ($row = db_fetch_array($result)) {
- $output = "<tr ".$GLOBALS['HTML']->boxGetAltRowStyle($i).">".
- "<td>".$row['doc_group']."</td>\n".
- "<td>".$row['groupname']."</td>\n".
- "<td>[ <a href=\"index.php?mode=groupdelete&doc_group=".$row['doc_group']."&group_id=".$group_id."\">Delete</A> ] [ <a href=\"index.php?mode=groupedit&doc_group=".$row['doc_group']."&group_id=".$group_id."\">Change Name</a> ]\n</td>".
- "</tr>\n";
-
- print "$output";
- $i++;
- }
-
- echo $GLOBALS['HTML']->listTableBottom();
-
- }
-
- docman_footer($params);
-
-}
-
-/**
- * get_group_count returns the number of document cateogries that the project has.
- *
- * @author Dominick Bellizzi (dbellizzi@valinux.com)
- * @param $group_id The project group ID
- * @return int The number of document groups for the specified project, or false on an error
- */
-function get_group_count($group_id){
- // show list of groups to edit.
- $query = "select count(*) "
- ."from doc_groups "
- ."where group_id = '$group_id'";
- $result = db_query($query);
-
- if (list($count) = db_fetch_array($result)){
- return $count;
- }
- else {
- return false;
- }
-}// end function get_group_count
-
-function display_docs($style,$group_id) {
- global $sys_datefmt;
-
- $query = "select * "
- ."from doc_data as d1, doc_groups as d2 "
- ."where d1.stateid = '".$style."' "
- ."and d2.group_id = '".$group_id."' "
- ."and d1.doc_group = d2.doc_group";
- $result = db_query($query);
-
- if (db_numrows($result) < 1) {
-
- $query = "select name"
- ."from doc_states "
- ."where stateid = '$style'";
- $result = db_query($query);
- $row = db_fetch_array($result);
- echo 'No '.$row['name'].' docs available <p>';
-
- } else {
-
- $title_arr=array();
- $title_arr[]='Document ID';
- $title_arr[]='Name';
- $title_arr[]='Create Date';
-
- echo $GLOBALS['HTML']->listTableTop ($title_arr);
-
- $i = 0;
- while ($row = db_fetch_array($result)) {
- print "<tr ".$GLOBALS['HTML']->boxGetAltRowStyle($i).">"
- ."<td>".$row['docid']."</td>"
- ."<td><a href=\"index.php?docid=".$row['docid']."&mode=docedit&group_id=".$group_id."\">".$row['title']."</a></td>"
- ."<td>".date($sys_datefmt,$row['createdate'])."</td></tr>";
- $i++;
- }
-
- echo $GLOBALS['HTML']->listTableBottom();
-
- }//end else
-
-} //end function display_docs($style)
-
-function docman_header($title,$pagehead,$pagename,$titleval,$sectionval,$style='xyz') {
-
- global $group_id;
-
- $project =& group_get_object($group_id);
- if (!$project || !is_object($project)) {
- exit_no_group();
- }
-
- if (!$project->usesDocman()) {
- exit_error('Error','This Project Has Turned Off The Doc Manager');
- }
-
- site_project_header(array('title'=>$title,'group'=>$group_id,'toptab'=>'docman','pagename'=>$pagename,'titlevals'=>array($titleval),'sectionvals'=>array($sectionval)));
-
- print "<p><b><a href=\"/docman/new.php?group_id=".$group_id."\">Submit new documentation</a> | ".
- "<a href=\"/docman/index.php?group_id=".$group_id."\">View Documentation</a> | ".
- "<a href=\"/docman/admin/index.php?group_id=".$group_id."\">Admin</a></b>";
-
- if ($style == 'admin') {
- print "<b> | <a href=\"/docman/admin/index.php?mode=editdocs&group_id=".$group_id."\">Edit Documents</a> | ".
- "<a href=\"/docman/admin/index.php?mode=editgroups&group_id=".$group_id." \">Edit Document Groups</a></b>";
-
- }
- print("<BR>");
-}
-
-function doc_droplist_count($l_group_id, $language_id) {
-
- $query = "select dd.language_id, sl.name, count(*) as count
- from doc_groups as dg, doc_data as dd, supported_languages as sl
- where dg.doc_group = dd.doc_group
- and dg.group_id = '$l_group_id'
- and dd.stateid = '1'
- and sl.language_id = dd.language_id
- group by dd.language_id,sl.name";
-
- $gresult = db_query($query);
-
-
- if (db_numrows($gresult) >= 1) {
-
- print "<form name=\"langchoice\" action=\"index.php?group_id=".$l_group_id."\" method=\"POST\"><table border=\"0\">"
- ." <tr><td valign=\"center\"><b>Language:</b></td>"
- ." <td valign=\"center\"><select name=\"language_id\">\n\n";
- while($grow = db_fetch_array($gresult)) {
-
- if ($language_id == $grow['language_id']) {
-
- print "<option value=\"".$grow['language_id']."\" selected>".$grow['name']." (".$grow['count'].") </option>";
- } else {
- print "<option value=\"".$grow['language_id']."\">".$grow['name']." (".$grow['count'].") </option>";
- }
- }
- print "</select></td><td valign=\"center\"><input type=\"submit\" value=\"Go\"></td></tr></table></form>";
- } else {
- echo db_error();
- }
-
-
-}
-
-
-function doc_get_state_box($checkedval='xzxz') {
- $res_states=db_query("select * from doc_states;");
- echo html_build_select_box ($res_states,'stateid',$checkedval,false);
-
-}
-
-function docman_footer($params) {
- site_project_footer($params);
-
-}
-
-?>
--- /dev/null
+<?php
+/**
+ * SourceForge Documentaion Manager
+ *
+ * SourceForge: Breaking Down the Barriers to Open Source Development
+ * Copyright 1999-2001 (c) VA Linux Systems
+ * http://sourceforge.net
+ *
+ * @version $Id$
+ */
+
+
+/*
+ by Quentin Cregan, SourceForge 06/2000
+*/
+
+
+function display_groups_option($group_id=false,$checkedval='xzxz') {
+
+ if (!$group_id) {
+ exit_no_group();
+ } else {
+ $query = "select doc_group, groupname "
+ ."from doc_groups "
+ ."where group_id = '$group_id' "
+ ."order by groupname";
+ $result = db_query($query);
+
+ echo html_build_select_box ($result,'doc_group',$checkedval,false);
+
+ } //end else
+
+} //end display_groups_option
+
+
+function docman_header($title,$pagehead,$pagename,$titleval,$sectionval,$style='xyz') {
+
+ global $group_id;
+
+ $project =& group_get_object($group_id);
+ if (!$project || !is_object($project)) {
+ exit_no_group();
+ }
+
+ if (!$project->usesDocman()) {
+ exit_error('Error','This Project Has Turned Off The Doc Manager');
+ }
+
+ site_project_header(array('title'=>$title,'group'=>$group_id,'toptab'=>'docman','pagename'=>$pagename,'titlevals'=>array($titleval),'sectionvals'=>array($sectionval)));
+
+ print "<p><b><a href=\"/docman/new.php?group_id=".$group_id."\">Submit new documentation</a> | ".
+ "<a href=\"/docman/index.php?group_id=".$group_id."\">View Documentation</a> | ".
+ "<a href=\"/docman/admin/index.php?group_id=".$group_id."\">Admin</a></b>";
+
+ print("<BR>");
+}
+
+function doc_droplist_count($l_group_id, $language_id) {
+
+ $query = "select dd.language_id, sl.name, count(*) as count
+ from doc_groups as dg, doc_data as dd, supported_languages as sl
+ where dg.doc_group = dd.doc_group
+ and dg.group_id = '$l_group_id'
+ and dd.stateid = '1'
+ and sl.language_id = dd.language_id
+ group by dd.language_id,sl.name";
+
+ $gresult = db_query($query);
+
+
+ if (db_numrows($gresult) >= 1) {
+
+ print "<form name=\"langchoice\" action=\"index.php?group_id=".$l_group_id."\" method=\"POST\"><table border=\"0\">"
+ ." <tr><td valign=\"center\"><b>Language:</b></td>"
+ ." <td valign=\"center\"><select name=\"language_id\">\n\n";
+ while($grow = db_fetch_array($gresult)) {
+
+ if ($language_id == $grow['language_id']) {
+
+ print "<option value=\"".$grow['language_id']."\" selected>".$grow['name']." (".$grow['count'].") </option>";
+ } else {
+ print "<option value=\"".$grow['language_id']."\">".$grow['name']." (".$grow['count'].") </option>";
+ }
+ }
+ print "</select></td><td valign=\"center\"><input type=\"submit\" value=\"Go\"></td></tr></table></form>";
+ } else {
+ echo db_error();
+ }
+
+
+}
+
+function doc_get_state_box($checkedval='xzxz') {
+ $res_states=db_query("select * from doc_states;");
+ echo html_build_select_box ($res_states,'stateid',$checkedval,false);
+
+}
+
+function docman_footer($params) {
+ site_project_footer($params);
+}
+
+?>
<?php
/**
- *
- * SourceForge Documentaion Manager
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- *
- */
+ * GForge Doc Mgr Facility
+ *
+ * Copyright 2002 GForge, LLC
+ * http://gforge.org/
+ *
+ * @version $Id$
+ */
/*
- by Quentin Cregan, SourceForge 06/2000
+ Document Manager
+
+ by Quentin Cregan, SourceForge 06/2000
+
+ Complete OO rewrite by Tim Perdue 1/2003
*/
-require_once('doc_utils.php');
require_once('pre.php');
+require_once('include/doc_utils.php');
+require_once('common/docman/DocumentFactory.class');
-if ($group_id) {
+if (!$group_id) {
+ exit_no_group();
+}
+$g =& group_get_object($group_id);
+if (!$g || !is_object($g) || $g->isError()) {
+ exit_no_group();
+}
- if (!$language_id) {
- if (session_loggedin()) {
- $language_id = $LUSER->getLanguage();
- } else {
- $language_id = 1;
- }
- }
+$df = new DocumentFactory($g);
+if ($df->isError()) {
+ exit_error('Error',$df->getErrorMessage());
+}
- $usermem = user_ismember($group_id);
- docman_header('Project Documentation','Project Documentation','docman','',group_getname($group_id));
- //get a list of group numbers that this project owns
- $query = "select * "
- ."from doc_groups "
- ."where group_id = '$group_id' "
- ."order by groupname";
- $result = db_query($query);
-
- //otherwise, throw up an error
- if (db_numrows($result) < 1) {
- print "<b>This project has no categorized data.</b><p>";
- } else {
- doc_droplist_count($group_id, $language_id);
- print "<hr>";
- // get the groupings and display them with their members.
- while ($row = db_fetch_array($result)) {
- $query = "select description, docid, title, doc_group, filename "
- ."from doc_data "
- ."where doc_group = '".$row['doc_group']."' "
- ."and stateid='1' "
- ."and language_id='$language_id'";
-
- //state 1 == 'active'
- if ($usermem == true) {
- $query .= " or stateid = '5' "
- ." and doc_group = '".$row['doc_group']."' ";
- } //state 5 == 'private'
-
- $query .= " order by title" ;
-
- $subresult = db_query($query);
-
- if (!(db_numrows($subresult) < 1)) {
- print "<p><b>".$row['groupname']."</b>\n<ul>\n";
- while ($subrow = db_fetch_array($subresult)) {
- print "<li><a href=\"display_doc.php/$subrow[docid]/$subrow[filename]\">$subrow[title]</a>".
- "<BR><i>Description:</i> ".$subrow['description'];
- }
- print "</ul>\n\n";
-
- }
- }
+if (!$language_id) {
+ if (session_loggedin()) {
+ $language_id = $LUSER->getLanguage();
+ } else {
+ $language_id = 1;
}
+}
+
+$df->setLanguageID($language_id);
+$d_arr =& $df->getDocuments();
+
+docman_header('Project Documentation','Project Documentation','docman','',$g->getPublicName());
+
+if (!$d_arr || count($d_arr) < 1) {
+ print "<b>This project has no visible documents.</b><p>";
+} else {
+// doc_droplist_count($group_id, $language_id);
- docman_footer($params);
+ print "\n<ul>";
+ for ($i=0; $i<count($d_arr); $i++) {
-} else {
- exit_no_group();
+ //
+ // If we're starting a new "group" of docs, put in the
+ // docGroupName and start a new <ul>
+ //
+ if ($d_arr[$i]->getDocGroupID() != $last_group) {
+ print (($i==0) ? '' : '</ul>');
+ print "\n\n<li><b>". $d_arr[$i]->getDocGroupName() ."</b></li><ul>";
+ $last_group=$d_arr[$i]->getDocGroupID();
+ }
+ print "\n<li><a href=\"view.php/$group_id/".$d_arr[$i]->getID()."/".$d_arr[$i]->getFileName()."\">".
+ $d_arr[$i]->getName()." [ ".$d_arr[$i]->getFileName()." ]</a>".
+ "\n<BR><i>Description:</i> ".$d_arr[$i]->getDescription();
+
+ }
+ print "\n</ul>\n";
}
+docman_footer(array());
+
?>
<?php
/**
- *
- * SourceForge Documentaion Manager
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- *
- */
+ * GForge Doc Mgr Facility
+ *
+ * Copyright 2002 GForge, LLC
+ * http://gforge.org/
+ *
+ * @version $Id$
+ */
/*
+ Document Manager
+
by Quentin Cregan, SourceForge 06/2000
+
+ Complete OO rewrite by Tim Perdue 1/2003
*/
-require_once('doc_utils.php');
require_once('pre.php');
+require_once('common/docman/Document.class');
+require_once('include/doc_utils.php');
-if($group_id) {
-
- if ($mode == "add"){
-
- if (!$doc_group || $doc_group ==100) {
- //cannot add a doc unless an appropriate group is provided
- exit_error('Error','No Valid Document Group Was Selected');
- }
-
- if (!$title || !$description) {
- exit_missing_param();
- }
-
- if (!$uploaded_data) {
- exit_missing_param();
- }
-
- if (!session_loggedin()) {
- $user_id=100;
- } else {
- $user_id=user_getid();
- }
-
- if (!util_check_fileupload($uploaded_data)) {
- exit_error("Error","Invalid filename");
- }
- $data = fread(fopen($uploaded_data, 'r'), filesize($uploaded_data));
-
- docman_header('Documentation - Add Information - Processing','Documentation - New submission','docman_new','',group_getname($group_id));
-
- $query = "insert into doc_data(stateid,title,data,filename,filetype,createdate,
- updatedate,created_by,doc_group,description,language_id)
- values('3','". htmlspecialchars($title). "','". base64_encode($data) ."','$uploaded_data_name','$uploaded_data_type','".time()."',
- '".time()."', '$user_id', '$doc_group', '".htmlspecialchars($description)."', '$lang_id')";
-
- $res = db_query($query);
-
- if (!$res || db_affected_rows($res)<1) {
- print '<p><b><font color="red">Error adding new document: '.db_error().'</font></b></p>';
- } else {
- print "<p><b>Thank You! Your submission has been placed in the database for review before posting.</b> \n\n<p>\n <a href=\"/docman/index.php?group_id=".$group_id."\">Back</a>";
- }
-
- docman_footer($params);
- } else {
- docman_header('Add documentation','Add documentation','docman_new','',group_getname($group_id));
- if (get_group_count($group_id) > 0){
- if ($user == 100) {
- print "<p>You are not logged in, and will not be given credit for this.<p>";
- }
-
- echo '
- <p>
-
- <b> Document Title: </b> Refers to the relatively brief title of the document (e.g. How to use the download server)
- <br>
- <b> Description: </b> A brief description to be placed just under the title.<br>
-
- <form name="adddata" action="new.php?mode=add&group_id='.$group_id.'" method="POST" enctype="multipart/form-data">
-
- <table border="0" width="75%">
-
- <tr>
- <th>Document Title:</th>
- <td><input type="text" name="title" size="40" maxlength="255"></td>
-
- </tr>
- <tr>
- <th>Description:</th>
- <td><input type="text" name="description" size="50" maxlength="255"></td>
- </tr>
-
- <tr>
- <th><B>Upload File:</B></th>
- <td> <input type="file" name="uploaded_data" size="30"></td>
- </tr>
-
- <tr>
- <th> Language:</th>
- <td>';
-
- echo html_get_language_popup($Language,'lang_id',1);
-
- echo '</td>
- </tr>
-
- <tr>
- <th>Group that document belongs in:</th>
- <td>';
-
- display_groups_option($group_id);
-
- echo ' </td> </tr> </table>
-
- <input type="submit" value="Submit Information">
-
- </form> ';
- } // end if (project has doc categories)
- else {
- echo("At least one documentation category must be defined before you can submit a document.<BR>");
-
- $group = new Group($group_id);
- $perm =& $group->getPermission( session_get_user() );
+if (!$group_id) {
+ exit_no_group();
+}
+$g =& group_get_object($group_id);
+if (!$g || !is_object($g) || $g->isError()) {
+ exit_no_group();
+}
- // if an admin, prompt for adding a category
- if ( $perm->isDocEditor() || $perm->isAdmin() ) {
- echo("<a href=\"/docman/admin/index.php?mode=editgroups&group_id=" . $group_id . "\">Add a document group</a>");
- }
- }
- docman_footer($params);
- } // end else.
+if ($submit){
+
+ if (!$doc_group || $doc_group ==100) {
+ //cannot add a doc unless an appropriate group is provided
+ exit_error('Error','No Valid Document Group Was Selected');
+ }
+
+ if (!$title || !$description) {
+ exit_missing_param();
+ }
+
+ if (!$uploaded_data) {
+ exit_missing_param();
+ }
+
+ if (!is_uploaded_file($uploaded_data)) {
+ exit_error("Error","Invalid filename");
+ }
+ $d = new Document($g);
+ if (!$d || !is_object($d)) {
+ exit_error('Error','Error getting blank document');
+ } elseif ($d->isError()) {
+ exit_error('Error',$d->getErrorMessage());
+ }
+
+ $data = addslashes(fread(fopen($uploaded_data, 'r'), filesize($uploaded_data)));
+ if (!$d->create($uploaded_data_name,$uploaded_data_type,$data,$doc_group,$title,$language_id,$description)) {
+ exit_error('Error',$d->getErrorMessage());
+ } else {
+ Header("Location: /docman/?group_id=$group_id&feedback=Document+Submitted+Successfully");
+ exit;
+ }
} else {
- exit_no_group();
+ docman_header('Add documentation','Add documentation','docman_new','',$g->getPublicName());
+ ?>
+ <p>
+ <b> Document Title: </b> Refers to the relatively brief title of the document
+ (e.g. How to use the download server)
+ <br>
+ <b> Description: </b> A brief description to be placed just under the title.<br>
+
+ <form name="adddata" action="<?php echo "$PHP_SELF?group_id=$group_id"; ?>" method="POST" enctype="multipart/form-data">
+
+ <table border="0" width="75%">
+
+ <tr>
+ <td>
+ <b>Document Title:</b><br>
+ <input type="text" name="title" size="40" maxlength="255">
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Description:</b><br>
+ <input type="text" name="description" size="50" maxlength="255">
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Upload File:</b><br>
+ <input type="file" name="uploaded_data" size="30">
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Language:</b><br>
+ <?php
+ echo html_get_language_popup($Language,'language_id',1);
+ ?>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Group that document belongs in:</b><br>
+ <?php
+ display_groups_option($group_id);
+ ?>
+ </td>
+ </tr>
+
+ </table>
+ <input type="submit" name="submit" value="Submit Information">
+ </form>
+ <?php
+ docman_footer(array());
}
?>
--- /dev/null
+<?php
+/**
+ * GForge Doc Mgr Facility
+ *
+ * Copyright 2002 GForge, LLC
+ * http://gforge.org/
+ *
+ * @version $Id$
+ */
+
+
+/*
+ Document Manager
+
+ by Quentin Cregan, SourceForge 06/2000
+
+ Complete OO rewrite by Tim Perdue 1/2003
+*/
+
+require_once('pre.php');
+require_once('include/doc_utils.php');
+require_once('common/docman/Document.class');
+
+$arr=explode('/',$REQUEST_URI);
+$group_id=$arr[3];
+$docid=$arr[4];
+
+if ($docid) {
+
+ $g =& group_get_object($group_id);
+ if (!$g || !is_object($g)) {
+ exit_no_group();
+ } elseif ($g->isError()) {
+ exit_error('Error',$g->getErrorMessage());
+ }
+
+ $d = new Document($g,$docid);
+ if (!$d || !is_object($d)) {
+ exit_error('Document unavailable','Document is not available.');
+ } elseif ($d->isError()) {
+ exit_error('Error',$d->getErrorMessage());
+ }
+
+ Header ("Content-disposition: filename=".$d->getFileName());
+
+ if (strstr($d->getFileType(),'app')) {
+ Header ("Content-type: application/binary");
+ } else {
+ Header ("Content-type: ".$d->getFileType());
+ }
+
+ echo $d->getFileData();
+
+} else {
+ exit_error("No document data.","No document to display - invalid or inactive document number.");
+}
+
+?>
$use_cvs,
$use_news,
$use_docman,
- $new_task_address,
- $send_all_tasks,
+ $new_doc_address,
+ $send_all_docs,
100,
$enable_pserver,
$enable_anoncvs,
<P>
If you wish, you can provide default email addresses to which new submissions will be sent.<BR>
-<B>New Task Assignments:</B><BR><INPUT TYPE="TEXT" NAME="new_task_address" VALUE="<?php echo $group->PMEmailAddress(); ?>" SIZE="25" MAXLENGTH="250">
+<B>New Document Submissions:</B><BR><INPUT TYPE="TEXT" NAME="new_doc_address" VALUE="<?php echo $group->getDocEmailAddress(); ?>" SIZE="25" MAXLENGTH="250">
(send on all updates)
-<INPUT TYPE="CHECKBOX" NAME="send_all_tasks" VALUE="1" <?php echo c($group->PMEmailAll()); ?> ><BR>
+<INPUT TYPE="CHECKBOX" NAME="send_all_docs" VALUE="1" <?php echo c($group->docEmailAll()); ?> ><BR>
<HR>
<P><INPUT type="submit" name="submit" value="Update">