3 * GForge Documentaion Manager
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 by Quentin Cregan, SourceForge 06/2000
34 function display_groups_option($group_id=false,$checkedval='xzxz') {
39 $query = "select doc_group, groupname "
41 ."where group_id = '$group_id' "
42 ."order by groupname";
43 $result = db_query($query);
45 echo html_build_select_box ($result,'doc_group',$checkedval,false);
49 } //end display_groups_option
52 function docman_header($title,$pagehead,$style='xyz') {
54 global $group_id, $Language, $HTML, $sys_use_docman;
56 if (!$sys_use_docman) {
60 $project =& group_get_object($group_id);
61 if (!$project || !is_object($project)) {
65 if (!$project->usesDocman()) {
66 exit_error($Language->getText('general','error'),$Language->getText('docman','turned_off'));
69 site_project_header(array('title'=>$title,'group'=>$group_id,'toptab'=>'docman'));
74 $menu_text[]=$Language->getText('docman','submit_new');
75 $menu_links[]='/docman/new.php?group_id='.$group_id;
76 $menu_text[]=$Language->getText('docman','view_doc');
77 $menu_links[]='/docman/index.php?group_id='.$group_id;
78 $menu_text[]=$Language->getText('docman_search','search_title');
79 $menu_links[]='/docman/search.php?group_id='.$group_id;
82 if (session_loggedin()) {
83 $perm =& $project->getPermission(session_get_user());
84 if ($perm && is_object($perm) && !$perm->isError() && $perm->isDocEditor()) {
85 $menu_text[]=$Language->getText('docman','admin');
86 $menu_links[]='/docman/admin/index.php?group_id='.$group_id;
95 function doc_droplist_count($l_group_id, $language_id, $g) {
98 if (session_loggedin()) {
99 $perm =& $g->getPermission( session_get_user() );
100 if (!$perm || !is_object($perm) || !$perm->isMember()) {
101 $public_flag='AND dd.stateid=1';
103 $public_flag='AND dd.stateid IN (1,4,5)';
106 $public_flag='AND dd.stateid=1';
109 $query = "select dd.language_id, sl.name, count(*) as count
110 from doc_groups as dg, doc_data as dd, supported_languages as sl
111 where dg.doc_group = dd.doc_group
112 and dg.group_id = '$l_group_id'
114 and sl.language_id = dd.language_id
115 group by dd.language_id,sl.name";
117 $gresult = db_query($query);
120 if (db_numrows($gresult) >= 1) {
122 print "<form name=\"langchoice\" action=\"index.php?group_id=".$l_group_id."\" method=\"post\"><table border=\"0\">"
123 ." <tr><td valign=\"middle\"><strong>".$Language->getText('general','language')." </strong></td>"
124 ." <td valign=\"middle\"><select name=\"language_id\">\n\n";
125 print "<option value=\"*\">".$Language->getText('docman_display_doc','all_languages')." </option>";
126 while($grow = db_fetch_array($gresult)) {
128 if ($language_id == $grow['language_id']) {
130 print "<option value=\"".$grow['language_id']."\" selected=\"selected\">".$grow['name']." (".$grow['count'].") </option>";
132 print "<option value=\"".$grow['language_id']."\">".$grow['name']." (".$grow['count'].") </option>";
135 print "</select></td><td valign=\"middle\"><input type=\"submit\" value=\"".$Language->getText('general','go')."\" /></td></tr></table></form>";
143 function doc_get_state_box($checkedval='xzxz') {
144 $res_states=db_query("select * from doc_states;");
145 echo html_build_select_box ($res_states,'stateid',$checkedval,false);
149 function docman_footer($params) {
150 site_project_footer($params);
154 * docman_display_documents - Recursive function to show the documents inside the groups tree
156 function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid=0, $from_admin=false, $parent_group=0) {
157 global $selected_doc_group_id,$Language,$sys_datefmt;
159 $selected_doc_group_id=getIntFromRequest('selected_doc_group_id');
164 if (!is_array($nested_groups["$parent_group"])) {
168 echo "<ul style='list-style-type: none'>";
169 $child_count = count($nested_groups["$parent_group"]);
171 for ($i=0; $i < $child_count; $i++) {
172 $doc_group =& $nested_groups["$parent_group"][$i];
174 // Display group and subgroups only if it has associated documents
175 if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
177 if (($doc_group->getID() == $selected_doc_group_id || $doc_group->hasSubgroup($nested_groups, $selected_doc_group_id)) && (!$stateid || $stateid == $selected_stateid)) {
178 $icon = 'ofolder15.png';
180 $icon = 'cfolder15.png';
182 echo "<li>".html_image('ic/'.$icon,"15","13",array("border"=>"0"))." <a href='index.php?group_id=".$doc_group->Group->getID()."&selected_doc_group_id=".$doc_group->getID()."&language_id=".$GLOBALS['selected_language'];
183 if ($from_admin && $stateid) { // if we're sorting by the state, pass the state as a variable
184 echo "&selected_stateid=".$stateid;
186 echo "'>".$doc_group->getName()."</a>";
188 // display link to add a document to the current group
189 echo " <a href='".($from_admin ? "../" : "")."new.php?group_id=".$doc_group->Group->getID()."&selected_doc_group=".$doc_group->getID()."'>";
190 echo html_image('ic/adddoc12.png',"12","14",array("border"=>"0"))." ";
191 echo $Language->getText('docman_admin', 'add_docs');
193 if (($doc_group->getID() == $selected_doc_group_id || $doc_group->hasSubgroup($nested_groups, $selected_doc_group_id)) && (!$stateid || $stateid == $selected_stateid)) {
194 docman_display_documents($nested_groups, $document_factory, $is_editor, $stateid, $from_admin, $doc_group->getID());
198 // Display this group's documents
199 if (($doc_group->hasSubgroup($nested_groups, $selected_doc_group_id) || $selected_doc_group_id == $doc_group->getID()) && (!$stateid || $stateid == $GLOBALS['selected_stateid'])) {
200 // Retrieve all the docs from this category
202 $document_factory->setStateID($stateid);
204 $document_factory->setDocGroupID($doc_group->getID());
205 $docs = $document_factory->getDocuments();
206 if (is_array($docs)) {
207 $docs_count = count($docs);
209 echo "<ul style='list-style-type: none'>";
210 for ($j=0; $j < $docs_count; $j++) {
212 $link = "index.php?editdoc=1&docid=".$docs[$j]->getID()."&group_id=".$docs[$j]->Group->getID();
214 $link = (( $docs[$j]->isURL() ) ? $docs[$j]->getFileName() : "view.php/".$docs[$j]->Group->getID()."/".$docs[$j]->getID()."/".$docs[$j]->getFileName() );
216 $tooltip = $docs[$j]->getFileName() . " (" .
217 ($docs[$j]->getUpdated() ?
218 date($sys_datefmt, $docs[$j]->getUpdated()) :
219 date($sys_datefmt,$docs[$j]->getCreated())) .
221 if ($docs[$j]->getFilesize() > 1024) {
222 $tooltip .= floor($docs[$j]->getFilesize()/1024) . "KB";
224 $tooltip .= $docs[$j]->getFilesize() . "B";
226 $tooltip = htmlspecialchars($tooltip);
228 html_image('ic/docman16b.png',"20","20",array("border"=>"0")).
230 "<a href=\"".$link."\" title=\"$tooltip\">".
231 $docs[$j]->getName().
232 "</a> - " . $tooltip . "</li>".
233 "(".$docs[$j]->getFileSize()." ".$Language->getText("docman", "bytes").")";
235 echo "<br /> ";
236 echo "<i>".$docs[$j]->getDescription()."</i>";