source: contrib/Dms/inc/class.uimydms.inc.php @ 3526

Revision 3526, 44.8 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado modulos Timesheet e DMS para a comunidade.

  • Property svn:executable set to *
Line 
1<?php
2        /***************************************************************************\
3        * eGroupWare - mydms                                                        *
4        * http://www.linux-at-work.de                                               *
5        * http://www.phpgw.de                                                       *
6        * http://www.egroupware.org                                                 *
7        * Written by : Lars Kneschke [lkneschke@linux-at-work.de]                   *
8        * -------------------------------------------------                         *
9        * This program is free software; you can redistribute it and/or modify it   *
10        * under the terms of the GNU General Public License as published by the     *
11        * Free Software Foundation; version 2 of the License.                       *
12        \***************************************************************************/
13       
14        /* $Id: class.uimydms.inc.php 22794 2006-11-06 05:53:11Z lkneschke $ */
15
16        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.Settings.php');
17        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.DBAccess.php');
18        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.AccessUtils.php');
19        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassAccess.php');
20        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassUser.php');
21        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassGroup.php');
22        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassFolder.php');
23        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassDocument.php');
24
25        class uimydms
26        {
27                var $icons = array(
28                        'txt'   => 'txt.png',
29                        'doc'   => 'word.png',
30                        'rtf'   => 'document.png',
31                        'xls'   => 'excel.png',
32                        'ppt'   => 'powerpoint.png',
33                        'exe'   => 'binary.png',
34                        'html'  => 'html.png',
35                        'htm'   => 'html.png',
36                        'gif'   => 'image.png',
37                        'jpg'   => 'image.png',
38                        'bmp'   => 'image.png',
39                        'png'   => 'image.png',
40                        'log'   => 'log.png',
41                        'midi'  => 'midi.png',
42                        'pdf'   => 'pdf.png',
43                        'wav'   => 'sound.png',
44                        'mp3'   => 'sound.png',
45                        'c'     => 'source_c.png',
46                        'cpp'   => 'source_cpp.png',
47                        'h'     => 'source_h.png',
48                        'java'  => 'source_java.png',
49                        'py'    => 'source_py.png',
50                        'tar'   => 'tar.png',
51                        'gz'    => 'gz.png',
52                        'zip'   => 'gz.png',
53                        'mpg'   => 'video.png',
54                        'avi'   => 'video.png',
55                        'tex'   => 'tex.png',
56                        'default' => 'default.png',
57                );
58
59                var $public_functions = array
60                (
61                        'addACL'                => 'true',
62                        'addNotification'       => 'true',
63                        'deleteACL'             => 'true',
64                        'deleteDocument'        => 'true',
65                        'deleteFile'            => 'true',
66                        'deleteNotification'    => 'true',
67                        'folderChooser'         => 'true',
68                        'inheritACL'            => 'true',
69                        'setDefaultAccess'      => 'true',
70                        'updateACL'             => 'true',
71                        'updateDocument'        => 'true',
72                        'updateFile'            => 'true',
73                        'setOwner'              => 'true',
74                        'viewDocument'          => 'true',
75                );
76               
77                function uimydms()
78                {
79                        $this->t                =& CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
80                        $this->bomydms          =& CreateObject('mydms.bomydms');
81
82                        if (!is_object($GLOBALS['phpgw']->jscalendar))
83                        {
84                                $GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar');
85                        }
86                }
87
88                function addACL()
89                {
90                        $userID         = (int)$_POST['userid'];
91                        $groupID        = (int)$_POST['groupid'];
92                        $access         = (int)$_POST['access'];
93                       
94                        $documentID     = (int)$_GET['documentid'];
95
96                        if($documentID)
97                        {
98                                $this->bomydms->addACL($documentID, ($userID == 'unselected' ? false : (int)$userID), ($groupID == 'unselected' ? false : (int)$groupID), $access);
99                                $this->viewDocument($documentID);
100                        }
101                }
102
103                function addNotification()
104                {
105                        $userID         = $_POST['userid'];
106                        $groupID        = $_POST['groupid'];
107                       
108                        $documentID     = (int)$_GET['documentid'];
109
110                        if($documentID)
111                        {
112                                $this->bomydms->addNotification($documentID, ($userID == 'unselected' ? false : (int)$userID), ($groupID == 'unselected' ? false : (int)$groupID));
113                                $this->viewDocument($documentID);
114                        }
115                }
116
117                function folderChooser($_folderID=false)
118                {
119                        $folderID = ($_folderID === false ? (int)$_GET['folderid'] : $_folderID);
120                        $formName = $_GET['form'];
121                       
122                        $folder = getFolder($folderID);
123
124                        $this->display_app_header();
125               
126                        $this->t->set_file(array("folderChooser" => "folderChooser.tpl"));
127                        $this->t->set_block('folderChooser', 'main', 'main');
128
129                        $this->t->set_var('folderTree',$this->getFolderTree($folder->getPathNew(), 0, $folder, true));
130                        $this->t->set_var('formName',$formName);
131
132                        $this->t->parse("out","main");
133                       
134                        print $this->t->get('out','main');
135                }
136
137                /**
138                * create a folder tree
139                *
140                * this function will create a foldertree based on javascript
141                * on click the sorounding form gets submitted
142                *
143                * @param _folders array containing the list of folders
144                * @param _selected string containing the selected folder
145                * @param _topFolderName string containing the top folder name
146                * @param _topFolderDescription string containing the description for the top folder
147                * @param _formName string name of the sorounding form
148                * @param _hiddenVar string hidden form value, transports the selected folder
149                *
150                * @return string the html code, to be added into the template
151                */
152                function createHTMLFolder($_folders, $_selected, $_divName, $_displayCheckBox=false)
153                {
154                       
155
156?>
157<table border=0 padding=0 valign=top width=250px><tr><td valign=top>
158<div id=NAVTREE style="position:static">NAVTREE</div>
159</td></tr></table>
160<style>.navs_action {font-size: 8pt; font-family: Arial, Helvetica}.navs_tree {font-size: 8pt; font-family: Arial, Helvetica}.navs_content {border: 2 groove; padding: 5; font-size: 8pt; font-family: Arial, Helvetica}</style>
161
162
163<script language="JavaScript" type="text/javascript">
164
165// variables
166var nodes_array = new Array();
167var current_document = -1;
168
169var nav_div_id='NAVTREE';
170var nav_root = 0;
171var nav_tree = new Array();   // nav_tree
172var nav_type = new Array();
173
174var outmsg="";
175// var indentation
176var indent_width = 20;
177var indent_height = 10
178// image file
179var img_hsize = 40;
180var img_vsize = 20;
181var img_plus   = "../images/nav_plus.gif";
182var img_minus  = "../images/nav_minus.gif";
183var img_spacer  = "../images/nav_spacer.gif";
184var img_box  = "../images/nav_box.gif";
185
186//--------------------------------------------------------------
187// Define type of node
188
189function DefineType(tname, img_prefix)
190{   this.name = tname;
191    this.img_prefix = img_prefix;
192    // preload image
193    var temp_image = new Image(img_hsize, img_vsize);
194    temp_image.src = img_prefix + "_collapse.gif";
195    var temp_image = new Image(img_hsize, img_vsize);
196    temp_image.src = img_prefix + "_expand.gif";
197    var temp_image = new Image(img_hsize, img_vsize);
198    temp_image.src = img_prefix + "_open.gif";
199    var temp_image = new Image(img_hsize, img_vsize);
200    temp_image.src = img_prefix + "_close.gif";
201
202}
203
204function CreateType(tname, img_prefix)
205{   var tid = nav_type.length;
206    nav_type[tid] = new DefineType(tname, img_prefix);
207    return tid;
208}
209
210//--------------------------------------------------------------
211// This function creates a node in the tree with the following arguments:
212//    parent - parent node number
213//    Type   -  F: folder    D: document
214//    state - O: Open    C: Close
215//    header -  header to be displayed when closed
216//    content   -  detail data to be displayed when opened
217function DefineNode(parent, type, state, header, content)
218{   this.parent = parent;
219    this.state = state;
220    this.type = type;
221    this.header = header;
222    this.content = content;
223    this.child = 0;
224}
225
226function CreateNode(parent, type, state, header, content)
227{   var id = nav_tree.length;
228    nav_tree[id] = new DefineNode(parent, type, state, header, content);
229    if ( parent >= 0)
230        nav_tree[parent].child ++;
231    return id;
232}
233
234//--------------------------------------------------------------
235function output(msg)
236{   outmsg += msg;
237}
238
239//--------------------------------------------------------------
240function WriteActionAll(nav_root, nav_root_level, nav_div_id)
241{
242    outmsg="";
243    // Display collapse all, expand all icon
244    output('<span class=navs_action>');
245    output('<a href=\'javascript:change_all("open",'
246            + nav_root+ ',' + nav_root_level + ',"'+nav_div_id+'")\'>');
247    output('<img src='+img_plus+' border="0"></a>Expand All&nbsp;');
248    output('<a href=\'javascript:change_all("close",'
249            + nav_root+ ',' + nav_root_level + ',"'+nav_div_id+'")\'>');
250    output('<img src='+img_minus+' border="0"></a>Collapse All<p>');
251    output('<\/span>');
252    // now print it out
253    element = document.all[nav_div_id];
254    element.innerHTML = outmsg;
255}
256
257
258
259//--------------------------------------------------------------
260function WriteMenu(nav_root, nav_root_level, nav_div_id)
261{
262    outmsg="";
263    // Create a table for each node
264    WriteSubTree(nav_root, nav_root_level, nav_root, nav_root_level, nav_div_id);
265    // now print it out
266    element = document.all[nav_div_id];
267
268    element.innerHTML = outmsg;
269}
270
271//----------------------------------------------------------------
272// This function writes all the child node for whatever
273// parent node is specified as the argument. Note that
274// this function is called recursively whenever any
275// child node has children of its own.
276function WriteSubTree(id, level, nav_root, nav_root_level, nav_div_id)
277{
278    var child_id;
279    var indent_space;
280
281    // Write this node data first, don't write main node
282    if ( level >= 0 )
283    {   // use table for breaking up column
284        output('<table class=navs_tree border="0" cellspacing="0" cellpadding="0" width=100%>');
285        //--- determine indentation level
286        indent = level* indent_width + 1;
287        output('<tr><td width='+indent+'><img src='+img_spacer+
288           ' width=' +indent +
289           ' height='+indent_height+'>');
290        //--- display open/collapse action icon
291        output('<td width='+indent_width+'>');
292        if ( nav_tree[id].child == 0 )
293        {   output('<img src='+img_spacer+
294                   ' width=' + indent_width +
295                   ' height='+indent_height+'>');
296        }
297        else
298        {   // determine action
299            if (nav_tree[id].state == "open")
300                img_src = "_collapse.gif";
301            else
302                img_src = "_expand.gif";
303            // extract image node type
304            node_type = nav_tree[id].type;
305            img_src = nav_type[node_type].img_prefix + img_src;
306            // display it
307            output('<a href=\'javascript:toggle_state('
308                   + id + ',' + nav_root + "," + nav_root_level +
309                   ',"' + nav_div_id+ '")\'>');
310            output('<img src="'+img_src+'" border=0><\/a>')
311        }
312        //--- display item state
313        output('<td width='+indent_width+'>');
314        node_type = nav_tree[id].type;
315        img_src=nav_type[node_type].img_prefix + "_"+nav_tree[id].state+".gif";
316        output('<a href=\'javascript:toggle_state('
317                   + id + ',' + nav_root + "," + nav_root_level +
318                   ',"' + nav_div_id+ '")\'>');
319        output('<img src="'+img_src+'" border=0><\/a>')
320        //--- display header and detail
321        output("<td><b>"+nav_tree[id].header+"<\/b>");
322        if (nav_tree[id].state == "open" && nav_tree[id].content != "")
323        {   output("<tr><td colspan=3><td class=navs_content>"+nav_tree[id].content);
324        }
325        output("<\/table>");
326    }
327    //--- Run through all of the parent's child nodes
328    if (nav_tree[id].state == "open" || level < 0)
329    {   for (child_id = 0; child_id < nav_tree.length; child_id++)
330        {   // skip if the parent is different >
331            if ( nav_tree[child_id].parent == id && child_id != id )
332                WriteSubTree(child_id, level+1, nav_root, nav_root_level, nav_div_id);
333        } // for each node
334    }
335} // function WriteSubTree
336
337function toggle_state(id, root, root_level, nav_div_id)
338{   // toggle the state
339    current_state = nav_tree[id].state;
340    if (current_state == "open")
341        nav_tree[id].state = "close";
342    else
343        nav_tree[id].state = "open";
344    // Rewrite the menu
345    timeout_id = setTimeout('WriteMenu('+root+','+root_level+',"'+nav_div_id+'")', 50)
346}
347
348function change_all(new_state, root, root_level, nav_div_id)
349{   var current_node;
350    // change current nod
351    nav_tree[root].state = new_state;
352    // Run through the global nodes_array
353    for (counter = 0; counter < nav_tree.length; counter++)
354    {   if (nav_tree[counter].parent == root)
355            change_all(new_state, counter, 0, "")
356    }
357    // Rewrite the menu
358    if ( nav_div_id != "")
359        timeout_id = setTimeout('WriteMenu('+root+','+root_level+',"'+nav_div_id+'")', 50)
360}
361
362</script>
363
364
365
366<?php
367
368  // Menu01 -- This is from the original example
369
370$this->db = clone($GLOBALS['phpgw']->db);
371                $this->db->set_app('mydms');
372
373
374//$queryStr0 = "SELECT distinct parent FROM phpgw_mydms_Folders";
375$queryStr0 ="select parent,id,SEQUENCE,name  FROM phpgw_mydms_Folders ORDER BY parent,sequence";
376
377
378
379
380$resArr0 = $GLOBALS['mydms']->db->getResultArray($queryStr0);
381
382//$node0 = new HTML_TreeNode($resArr[$i]["name"], "mydms/out/out.ViewFolder.php?menuaction=dummy&folderid=1", $icon);
383
384
385$txt="<script language=\"JavaScript\" type=\"text/javascript\">nav_type0=CreateType('Folder', '../images/folder');";   
386
387$txt=$txt." "."nav_type1=CreateType('Document', '../images/document');";
388
389
390//$txt=$txt." "."nav_tree0=CreateNode(-1, 0, 'close', 'Carpetas Compartidas', '');";
391
392for ($i = 0; $i < count($resArr0); $i++)
393{
394
395//$n=$i-1;
396//$defaultpos[$i]=$n;
397$defaultposicion=$i;
398$defaultparent[$resArr0[$i]["id"]]=$resArr0[$i]["parent"];
399$defaultid[$resArr0[$i]["id"]]=$resArr0[$i]["id"];
400$defaultnombre[$resArr0[$i]["id"]]=$defaultposicion;
401if($i==0){
402        $defaultvalor[$resArr0[$i]["id"]]="-1";
403}else{
404
405$defaultvalor[$resArr0[$i]["id"]]=$defaultnombre[$resArr0[$i]["parent"]];
406}
407
408//echo $resArr0[$i]["name"]." , ".$defaultvalor[$i]." , ".$defaultparent[$i]." , ".$defaultid[$i]."   ".$defaultvalor[$resArr0[$i]["id"]]."<br>";
409
410}
411
412
413
414$queryStr0 = "SELECT distinct parent FROM phpgw_mydms_Folders";
415
416
417$resArr0 = $GLOBALS['mydms']->db->getResultArray($queryStr0);
418
419//$node0 = new HTML_TreeNode($resArr[$i]["name"], "mydms/out/out.ViewFolder.php?menuaction=dummy&folderid=1", $icon);
420
421
422$txt="<script language=\"JavaScript\" type=\"text/javascript\">nav_type0=CreateType('Folder', '../images/folder');";   
423
424$txt=$txt." "."nav_type1=CreateType('Document', '../images/document');";
425
426
427//$txt=$txt." "."nav_tree0=CreateNode(-1, 0, 'close', 'Carpetas Compartidas', '');";
428
429for ($i = 0; $i < count($resArr0); $i++)
430{
431
432
433if($valores=='')
434{
435$valores=$resArr0[$i]["parent"];
436}else
437{
438$valores=$valores.",".$resArr0[$i]["parent"];
439}
440
441}
442
443//$txt=$txt." "."nav_tree0=CreateNode(".$n.", 0, 'close', '".$resArr[$i]["name"]."', '');";
444//echo $resArr[$i]["parent"]."<br>";
445
446$queryStr = "SELECT * FROM phpgw_mydms_Folders WHERE parent in (".$valores.") ORDER BY parent,sequence";
447
448
449                        $resArr = $GLOBALS['mydms']->db->getResultArray($queryStr);
450       
451
452       
453                        //$this->_subFolders = array();
454                        for ($ii = 0; $ii < count($resArr); $ii++)
455                        {
456                               
457$valor0=$ii+1;
458
459$valor1="node";
460
461
462
463$valor2=$valor1.$ii;
464
465
466//echo "JJJJJJ".$_GET['folderid']."<br>";
467
468
469$Activo="close";
470if(($resArr[$ii]["id"]==$_GET['folderid'] )||($resArr[$ii]["id"]==1))
471{
472$Activo="open";
473}
474$ver=$_GET['folderid'];
475while ($ver!=''&&$ver!=1){
476
477//echo $ver."<br>";
478if($resArr[$ii]["id"]==$defaultparent[$ver]){
479$Activo="open";
480}
481$ver=$defaultparent[$ver];
482
483}
484
485
486
487$txt=$txt." "."nav_tree1=CreateNode(".$defaultvalor[$resArr[$ii]["id"]].",0, '".$Activo."', '<a href=out.ViewFolder.php?menuaction=dummy&folderid=".$resArr[$ii]["id"]." >".$resArr[$ii]["name"]."</a>', '');";
488
489
490
491
492//$txt=$txt." $".$valor1.$valor0."= $".$valor2."->addItem(new HTML_TreeNode(\"".$resArr[$ii]["name"]."\",\"mydms/out///out.ViewFolder.php?menuaction=dummy&folderid=".$resArr[$ii]["id"]."\",\"".$icon."\"));";
493
494
495
496//$valor2=$node0->addItem(new HTML_TreeNode($resArr[$ii]["name"], "mydms/out/out.ViewFolder.php?menuaction=dummy&folderid=".$resArr[$ii]["id"], $icon));
497//echo $resArr[$ii]["id"]."   ".$resArr[$ii]["name"]."  ". $n."_".$i. "<br>  ";
498
499
500                        }       
501
502
503//}
504//$txt=$txt." "."$menu02  = new HTML_TreeMenu(\"menuLayer02\", '../imagesAlt', '_self');";
505
506
507 /* $node1 = new HTML_TreeNode("INBOX", "test.php", $icon);
508  $foo   = &$node1->addItem(new HTML_TreeNode("deleted-items", "test.php", $icon));
509  $bar   = &$foo->addItem(new HTML_TreeNode("deleted-items", "test.php", $icon));
510  $blaat = &$bar->addItem(new HTML_TreeNode("deleted-items", "test.php", $icon));
511  $blaat1 = $blaat->addItem(new HTML_TreeNode("deleted-itemswww", "test.php", $icon));
512  $blaat1->addItem(new HTML_TreeNode("deleted-items", "test.php", $icon));
513
514  $node1->addItem(new HTML_TreeNode("sent-items",    "test.php", $icon));
515  $node1->addItem(new HTML_TreeNode("drafts",        "test.php", $icon));       */
516
517
518  // Menu02 -- This uses the "alternate" image directory
519
520        //echo "<script language=\"JavaScript\">.$txt."</script>";
521
522
523 
524$txt=$txt." "."</script><script language=\"JavaScript\" type=\"text/javascript\">WriteMenu(0, 0, 'NAVTREE');</script>";
525//$txt=$txt." "."</script><script language=\"JavaScript\" type=\"text/javascript\">WriteMenu(7, 0, 'NAVDATA');
526 
527echo $txt;
528
529 ?>
530
531
532
533
534<?php
535return "";
536
537
538                }
539
540/*              function createHTMLFolder_old($_folders, $_selected, $_divName, $_displayCheckBox=false)
541                {
542                        $allFolders = $_folders;
543                       
544                        $folderImageDir = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/templates/default/images/';
545                       
546                        $folder_tree_new  = '<link rel="STYLESHEET" type="text/css" href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js/dhtmlxtree/css/dhtmlXTree.css">';
547                        $folder_tree_new .= "<script type='text/javascript'>";
548                        $folder_tree_new .= "tree=new dhtmlXTreeObject('$_divName','100%','100%',0);";
549                        $folder_tree_new .= "tree.setImagePath('$folderImageDir/dhtmlxtree/');";
550                        $folder_tree_new .= "tree.setOnClickHandler('onNodeSelect');";
551
552                        $linkData = array
553                        (
554                                'menuaction'    => 'mydms.uifolder.getSubFolder',
555                        );
556                        $xmlAutoLoadURL = $GLOBALS['phpgw']->link('/index.php',$linkData);
557
558                        $folder_tree_new .= "tree.setXMLAutoLoading('$xmlAutoLoadURL');";
559                        if($_displayCheckBox)
560                        {
561                                $folder_tree_new .= "tree.enableCheckBoxes(1);";
562                                $folder_tree_new .= "tree.setOnCheckHandler('onCheckHandler');";
563                        }
564
565                        #foreach($allFolders as $folderID => $folderObject)
566                        #{
567                                $folderObject = array_shift($allFolders);
568                                $image1 = "'folderClosed.gif'";
569                                $image2 = "0";
570                                $image3 = "0";
571
572                        $linkData = array
573                        (
574                                'menuaction'    => 'mydms.uifolder.getInitialFolderView',
575                                'id'            => $folderObject->getID(),
576                        );
577                        $xmlAutoLoadURL = $GLOBALS['phpgw']->link('/index.php',$linkData);
578                               
579                                if(empty($parentName)) $parentName = '--topfolder--';
580                               
581                                $entryOptions = 'CHILD,CHECKED';
582
583                                // highlight currently selected mailbox
584                                if ($folderObject->getID() == $_selected->getID())
585                                {
586                                        $entryOptions .= ',SELECT';
587                                }
588                               
589                                $folderID       = $folderObject->getID();
590                                $folderName     = $folderObject->getName();
591                                $parentID       = ($folderObject->_parentID ? $folderObject->_parentID : 0);
592
593                                $folder_tree_new .= "tree.insertNewItem('$parentID','$folderID','$folderName',onNodeSelect,$image1,$image2,$image3,'$entryOptions');\n";
594                                $folder_tree_new .= "tree.openItem('$folderID');";
595                                $folder_tree_new .= "tree.loadXML('$xmlAutoLoadURL&id=1');";
596                                $folder_tree_new .= "tree.openItem(1);";
597                                #$folder_tree_new .= "tree.loadXML('$xmlAutoLoadURL&id=6');";
598                                #if($_displayCheckBox)
599                                #       $folder_tree_new .= "tree.setCheck('$longName','".(int)$obj->subscribed."');";
600                        #}
601       
602       
603#                       foreach($allFolders as $folderID => $folderObject)
604#                       {
605#                               $folder_tree_new .= "tree.loadXML('$xmlAutoLoadURL&id=".$folderObject->getID()."');";
606#                               $folder_tree_new .= "tree.openItem('".$folderObject->getID()."');";
607#                       }
608                       
609
610                        #$selectedID = $_selected->getID();
611                        #$folder_tree_new.= "tree.closeAllItems(0);tree.openItem('$selectedID');"
612                        $folder_tree_new.= '</script><a href="#" onclick="javascript:tree.openItem(1); return false;">test</a><a href="#" onclick="javascript:tree.closeItem(1); return false;">test b</a>';
613
614                        return $folder_tree_new;
615                }
616*/
617                function deleteACL()
618                {
619                        $userID         = (int)$_GET['userid'];
620                        $groupID        = (int)$_GET['groupid'];
621                       
622                        $documentID     = (int)$_GET['documentid'];
623
624                        if($documentID)
625                        {
626                                $this->bomydms->deleteACL($documentID, ($userID == 'unselected' ? false : (int)$userID), ($groupID == 'unselected' ? false : (int)$groupID));
627                                $this->viewDocument($documentID);
628                        }
629                }
630
631                function deleteDocument()
632                {
633                        $documentID     = (int)$_GET['documentid'];
634
635                        if($documentID)
636                        {
637                                $this->bomydms->deleteDocument($documentID);
638                        }
639                        print '<script language="JavaScript">window.close();</script>';
640                }
641
642                function deleteFile()
643                {
644                        $documentID     = (int)$_GET['documentid'];
645                        $version        = (int)$_GET['version'];
646
647                        if($documentID && $version)
648                        {
649                                $this->bomydms->deleteFile($documentID, $version);
650                                $this->viewDocument($documentID);
651                        }
652                }
653
654                function deleteNotification()
655                {
656                        $documentID     = (int)$_GET['documentid'];
657                        $userID         = (int)$_GET['userid'];
658                        $groupID        = (int)$_GET['groupid'];
659
660                        if($documentID && ($userID || $groupID))
661                        {
662                                $this->bomydms->deleteNotification($documentID, (!$userID ? false : $userID), (!$groupID ? false : $groupID));
663                                $this->viewDocument($documentID);
664                        }
665                }
666
667                function display_app_header()
668                {
669                        if(!@is_object($GLOBALS['phpgw']->js))
670                        {
671                                $GLOBALS['phpgw']->js =& CreateObject('phpgwapi.javascript');
672                        }
673                        if (!is_object($GLOBALS['phpgw']->jscalendar))
674                        {
675                                $GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar');
676                        }
677                        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
678                        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
679                        switch($_GET['menuaction'])
680                        {
681                                case 'mydms.uimydms.addACL':
682                                case 'mydms.uimydms.addNotification':
683                                case 'mydms.uimydms.deleteACL':
684                                case 'mydms.uimydms.deleteFile':
685                                case 'mydms.uimydms.deleteNotification':
686                                case 'mydms.uimydms.setDefaultAccess':
687                                case 'mydms.uimydms.setOwner':
688                                case 'mydms.uimydms.updateACL':
689                                case 'mydms.uimydms.updateFile':
690                                case 'mydms.uimydms.viewDocument':
691                                case 'mydms.uimydms.inheritACL':
692                                        $GLOBALS['phpgw']->js->validate_file('tabs','tabs');
693                                        $GLOBALS['phpgw']->js->validate_file('jscode','viewDocument','mydms');
694                                        $GLOBALS['phpgw']->js->validate_file('jscode','mydms','mydms');
695
696                                        $GLOBALS['phpgw']->js->set_onload('javascript:initTabs();');
697                                        break;
698                                case 'mydms.uimydms.folderChooser':
699                                        $GLOBALS['phpgw']->js->validate_file('jscode','mydms','mydms');
700                                        $GLOBALS['phpgw']->js->validate_file('jscode','folderChooser','mydms');
701                                        break;
702                        }
703
704                        $GLOBALS['phpgw_info']['flags']['include_xajax'] = True;
705
706                        $GLOBALS['phpgw']->common->phpgw_header();
707                        #if(!$this->mailPreferences['messageNewWindow'])
708                        #       echo parse_navbar();
709                }
710
711                function getFolderTree($path, $level = 0, $_activeObj, $isFolder)
712                {
713                        return $this->createHTMLFolder($path, $_activeObj, 'mydmstreebox');                     
714                }
715               
716                function inheritACL()
717                {
718                        $documentID     = (int)$_GET['documentid'];
719                        $action         = $_GET['action'];
720                        $mode           = $_GET['mode'];
721
722                        if($documentID && $action)
723                        {
724                                $this->bomydms->inheritACL($documentID, $action, $mode);
725                                $this->viewDocument($documentID);
726                        }
727                }
728               
729                function setDefaultAccess()
730                {
731                        $documentID     = (int)$_GET['documentid'];
732                        $mode           = $_POST['defaultAccess'];
733
734                        if($documentID && $mode)
735                        {
736                                $this->bomydms->setDefaultAccess($documentID, $mode);
737                                $this->viewDocument($documentID);
738                        }
739                }
740
741                function setOwner()
742                {
743                        $documentID     = (int)$_GET['documentid'];
744                        $owner          = (int)$_POST['owner'];
745
746                        if($documentID && $owner)
747                        {
748                                $this->bomydms->setOwner($documentID, $owner);
749                                $this->viewDocument($documentID);
750                        }
751                }
752
753                function translate()
754                {
755                        $this->t->set_var('lang_informations',lang('informations'));
756                        $this->t->set_var('lang_all_versions',lang('all versions'));
757                        $this->t->set_var('lang_linked_documents',lang('linked documents'));
758                        $this->t->set_var('lang_owner',lang('owner'));
759                        $this->t->set_var('lang_comment',lang('comment'));
760                        $this->t->set_var('lang_keywords',lang('keywords'));
761                        $this->t->set_var('lang_download',lang('download'));
762                        $this->t->set_var('lang_last_update',lang('last update'));
763                        $this->t->set_var('lang_current_version',lang('current version'));
764                        $this->t->set_var('lang_uploaded_by',lang('uploaded by'));
765                        $this->t->set_var('lang_file_size',lang('file size'));
766                        $this->t->set_var('lang_filename',lang('filename'));
767                        $this->t->set_var('lang_mime_type',lang('mime type'));
768                        $this->t->set_var('lang_comment_for_current_version',lang('comment for current version'));
769                        $this->t->set_var('lang_creation_date',lang('creation date'));
770                        $this->t->set_var('lang_lock_status',lang('lock status'));
771                        $this->t->set_var('lang_expires',lang('expires'));
772                        $this->t->set_var('lang_version',lang('version'));
773                        $this->t->set_var('lang_upload_date',lang('upload date'));
774                        $this->t->set_var('lang_save',lang('save'));
775                        $this->t->set_var('lang_cancel',lang('cancel'));
776                        $this->t->set_var('lang_delete',lang('delete'));
777                        $this->t->set_var('lang_view_online',lang('view online'));
778                        $this->t->set_var('lang_confirm_delete',lang('Do you really want to delete this document?'));
779                        $this->t->set_var('lang_update_document',lang('update document'));
780                        $this->t->set_var('lang_update',lang('update'));
781                        $this->t->set_var('lang_acl',lang('acl'));
782                        $this->t->set_var('lang_name',lang('name'));
783                        $this->t->set_var('lang_move_document',lang('move document'));
784                        $this->t->set_var('lang_folder',lang('folder'));
785                        $this->t->set_var('lang_user',lang('user'));
786                        $this->t->set_var('lang_group',lang('group'));
787                        $this->t->set_var('lang_acl',lang('acl'));
788                        $this->t->set_var('lang_acl_get_inherited',lang('acl get inherited'));
789                        $this->t->set_var('lang_notifications',lang('notifications'));
790                        $this->t->set_var('lang_file_gets_unlocked',lang('this document gets unlocked by you.'));
791                        $this->t->set_var('lang_file_gets_locked',lang('this document gets locked by you!'));
792                        $this->t->set_var('lang_delete_this_notification',lang('delete this notification'));
793                        $this->t->set_var('lang_add_notification',lang('add notification'));
794                        $this->t->set_var('lang_information_about_last_update',lang('information about last update'));
795                        $this->t->set_var('lang_general_information',lang('general information'));
796                        $this->t->set_var('lang_copy_acl',lang('copy acl'));
797                        $this->t->set_var('lang_create_empty_acl',lang('create empty acl'));
798                        $this->t->set_var('lang_inherit_acl_again',lang('inherit acl again'));
799                        $this->t->set_var('lang_default_access',lang('default access'));
800                        $this->t->set_var('lang_permission',lang('permission'));
801                        $this->t->set_var('lang_add_acl',lang('add acl'));
802                        $this->t->set_var('lang_current_acl',lang('current acl'));
803                        $this->t->set_var('lang_access_mode',lang('access mode'));
804                        $this->t->set_var('lang_confirm_acl_delete',lang('Do you really want to delete this acl?'));
805                }
806               
807                function updateACL()
808                {
809                        $userID         = (int)$_GET['userid'];
810                        $groupID        = (int)$_GET['groupid'];
811                        $access         = (int)$_POST['mode'];
812                       
813                        $documentID     = (int)$_GET['documentid'];
814
815                        if($documentID)
816                        {
817                                $this->bomydms->updateACL($documentID, ($userID == 'unselected' ? false : (int)$userID), ($groupID == 'unselected' ? false : (int)$groupID), $access);
818                                $this->viewDocument($documentID);
819                        }
820                }
821
822                function updateDocument()
823                {
824                        $fileName       = $_POST['fname'];
825                        $comment        = $_POST['comment'];
826                        $keywords       = $_POST['keywords'];
827                        $expire         = $_POST['expire'];
828                        $expire_date    = $GLOBALS['phpgw']->jscalendar->input2date($_POST['expire_date']);
829                        $lockStatus     = $_POST['lockStatus'];
830                        $targetID       = $_POST['targetid'];
831                       
832                        $documentID     = (int)$_GET['documentid'];
833
834                        if($documentID)
835                        {
836                                $this->bomydms->updateDocument($documentID,$fileName,$comment,$keywords,($expire ? $expire_date['raw'] : 0));
837                                if($lockStatus != 'unchanged')
838                                {
839                                        $this->bomydms->updateLockStatus($documentID, $lockStatus);
840                                }
841                                if($targetID != 'unchanged')
842                                {
843                                        $this->bomydms->moveDocument($documentID, (int)$targetID);
844                                }
845                        }
846                        print '<script language="JavaScript">window.close();</script>';
847                }
848
849                function updateFile()
850                {
851                        $comment        = $_POST['comment'];
852                        $expire         = $_POST['expire'];
853                        $expire_date    = $GLOBALS['phpgw']->jscalendar->input2date($_POST['expire_date_update']);
854                        $documentID     = (int)$_GET['documentid'];
855                        $userfile       = $_FILES['userfile'];
856
857                        if($documentID && is_uploaded_file($userfile['tmp_name']))
858                        {
859                                $this->bomydms->updateFile($documentID, $userfile, $comment, ($expire ? $expire_date['raw'] : 0));
860                                $this->viewDocument($documentID);
861                        }
862                }
863
864                function viewDocument($_documentID=false)
865                {
866                        $documentID = ($_documentID === false ? (int)$_GET['documentid'] : $_documentID);
867
868                        if(!$document   = getDocument($documentID))
869                        {
870                                print "Access denied!"; exit;
871                        }
872                        $user           = getUser($GLOBALS['phpgw_info']['user']['account_id']);
873                        $accessMode     = $document->getAccessMode($user);
874                        $owner          = $document->getOwner();
875                        $folder         = $document->getFolder();
876                        $latestContent  = $document->getLatestContent();
877                        $versions       = $document->getContent();
878                        $notifyList     = $document->getNotifyList();
879                        $accessList     = $document->getAccessList();
880                        $updatingUser   = $latestContent->getUser();
881                       
882                        #_debug_array($document);
883                       
884                        $this->display_app_header();
885               
886                        $this->t->set_file(array("viewDocument" => "viewDocument.tpl"));
887                        $this->t->set_block('viewDocument', 'main', 'main');
888                        $this->t->set_block('viewDocument', 'acl_row', 'acl_row');
889                        $this->t->set_block('viewDocument', 'lock_row', 'lock_row');
890                        $this->t->set_block('viewDocument', 'version_row', 'version_row');
891                        $this->t->set_block('viewDocument', 'notification_row', 'notification_row');
892                        $this->t->set_block('viewDocument', 'information_ro', 'information_ro');
893                        $this->t->set_block('viewDocument', 'information_rw', 'information_rw');
894                        $this->t->set_block('viewDocument', 'block_download', 'block_download');
895                        $this->t->set_block('viewDocument', 'block_view_online', 'block_view_online');
896                        $this->t->set_block('viewDocument', 'block_delete', 'block_delete');
897                        $this->t->set_block('viewDocument', 'block_change_owner', 'block_change_owner');
898                        $this->t->set_block('viewDocument', 'block_acl_inherite', 'block_acl_inherite');
899                        $this->t->set_block('viewDocument', 'block_acl_notinherite', 'block_acl_notinherite');
900
901                        $downloadImage  = $GLOBALS['phpgw']->common->image('mydms','download');
902                        $viewImage      = $GLOBALS['phpgw']->common->image('mydms','view');
903                        $deleteImage    = $GLOBALS['phpgw']->common->image('mydms','del');
904                        $groupImage     = $GLOBALS['phpgw']->common->image('mydms','groupicon');
905                        $userImage      = $GLOBALS['phpgw']->common->image('mydms','usericon');
906                        $saveImage      = $GLOBALS['phpgw']->common->image('mydms','save');
907                        $this->t->set_var('download_image',$downloadImage);
908                        $this->t->set_var('view_image',$viewImage);
909                        $this->t->set_var('delete_image',$deleteImage);
910                        $this->t->set_var('save_image',$saveImage);
911
912
913                        $this->translate();
914                       
915                        $linkData = array
916                        (
917                                'menuaction'    => 'mydms.uimydms.folderChooser',
918                        );
919                        $this->t->set_var('folderChooserURL', $GLOBALS['phpgw']->link('/index.php',$linkData));
920
921                        $linkData = array
922                        (
923                                'menuaction'    => 'mydms.uimydms.updateDocument',
924                                'documentid'    => $documentID,
925                        );
926                        $this->t->set_var('action_informations', $GLOBALS['phpgw']->link('/index.php',$linkData));
927
928                        // download link
929                        $linkData = array
930                        (
931                                'documentid'    => $documentID,
932                                'version'       => $latestContent->getVersion(),
933                        );
934                        $this->t->set_var('download_link', $GLOBALS['phpgw']->link('/mydms/op/op.Download.php',$linkData));
935                        $this->t->parse('download','block_download',True);
936
937                        // view Online
938                        if ($latestContent->viewOnline())
939                        {
940                                $linkData = array
941                                (
942                                        'documentid'    => $documentID,
943                                        'version'       => $latestContent->getVersion()
944                                );
945                                $this->t->set_var('view_link', $GLOBALS['phpgw']->link('/mydms/op/op.ViewOnline.php',$linkData));
946                                $this->t->parse('view_online','block_view_online',True);
947                        }
948
949                        // delete link
950                        if ($accessMode == M_ALL)
951                        {
952                                $linkData = array
953                                (
954                                        'menuaction'    => 'mydms.uimydms.deleteDocument',
955                                        'documentid'    => $documentID,
956                                );
957                                $this->t->set_var('delete_link', $GLOBALS['phpgw']->link('/index.php',$linkData));
958                                $this->t->parse('delete','block_delete',True);
959                        }
960
961                        $this->t->set_var('owner_fullname',     $owner->getFullName());
962                        $this->t->set_var('owner_email',        $owner->getEmail());
963
964                        $this->t->set_var('updater_fullname',   $updatingUser->getFullName());
965                        $this->t->set_var('updater_email',      $updatingUser->getEmail());
966
967                        $this->t->set_var('filename',           $document->getName());
968                        $this->t->set_var('comment',            $document->getComment());
969                        $this->t->set_var('keywords',           $document->getKeywords());
970                        $this->t->set_var('creation_date',      date("d.m.Y - H:i:s",$document->getDate()));
971
972                        $this->t->set_var('foldername',         $folder->getName());
973                        $this->t->set_var('current_folder_id',  $folder->getID());
974                       
975                        // lock status
976                        // lock select box
977                       
978                        if ($document->isLocked())
979                        {
980                                $lockingUser = $document->getLockingUser();
981
982                                $this->t->set_var('lang_current_status', lang('this document is locked by <a href="mailto:%1">%2</a>.',$lockingUser->getEmail(),$lockingUser->getFullName()));
983                                $this->t->set_var('checked_lock_status', 'checked');
984                                $this->t->parse('locking','lock_row',True);
985                        }
986                        else
987                        {
988                                $this->t->set_var('lang_current_status', lang('this document is currently not locked.'));
989                               
990                                $this->t->parse('locking','lock_row', True);
991                        }
992
993if (!is_object($GLOBALS['phpgw']->html))
994                        {
995                                $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
996                        }
997
998                       
999                        // expire select box
1000                        $selectOptions = array('0' => lang('does not expire'), '1' => lang('expires after'));
1001                        $this->t->set_var('select_expire',$GLOBALS['phpgw']->html->select('expire',(!$document->getExpires() ? 0 : 1),$selectOptions,true,"onchange=\"toggleJSCal(this);\""));
1002                        #$this->t->set_var('select_expire',$GLOBALS['phpgw']->html->select('expire',(!$document->getExpires() ? 0 : 1),$selectOptions,true,"onchange=\"alert('test')\""));
1003                       
1004                        if (!$document->getExpires())
1005                        {
1006                                $this->t->set_var('expire_date_ro',lang('does not expire'));
1007                                $this->t->set_var('expire_date',$GLOBALS['phpgw']->jscalendar->input('expire_date',''));
1008                                $this->t->set_var('expire_class', 'inactive');
1009                        }
1010                        else
1011                        {
1012                                $this->t->set_var('expire_date_ro',lang('expires after').' '.date("d.m.Y",$document->getExpires()));
1013                                $this->t->set_var('expire_date',$GLOBALS['phpgw']->jscalendar->input('expire_date',$document->getExpires()));
1014                                $this->t->set_var('expire_class', 'active');
1015                        }
1016                               
1017                        $this->t->set_var('current_version',    $latestContent->getVersion());
1018                        $this->t->set_var('current_comment',    $latestContent->getComment());
1019                        $this->t->set_var('mime_type',          $latestContent->getMimeType());
1020                        $this->t->set_var('file_size',          filesize($GLOBALS['phpgw_info']['server']['files_dir'] . '/mydms/' . $latestContent->getPath()));
1021                        $this->t->set_var('last_update',        date("d.m.Y - H:i:s",$latestContent->getDate()));
1022
1023                        $this->t->set_var('rownum',             count($versions)+1);
1024
1025                        if (($accessMode >= M_READWRITE))
1026                        {
1027                                $this->t->parse('informations','information_rw',True);
1028                        }
1029                        else
1030                        {
1031                                $this->t->parse('informations','information_ro',True);
1032                        }
1033
1034                        for ($i = count($versions)-1; $i >= 0; $i--)
1035                        {
1036                                $version = $versions[$i];
1037                                $uploadingUser = $version->getUser();
1038                                $comment = $version->getComment();
1039                                //if (strlen($comment) > 25) $comment = substr($comment, 0, 22) . "...";
1040
1041                                $this->t->set_var('version_version',            $version->getVersion());
1042                                $this->t->set_var('version_comment',            $version->getComment());
1043                                $this->t->set_var('version_uploadingUser',      $uploadingUser->getFullName());
1044                                $this->t->set_var('version_date',               date("d.m.Y - H:i:s",$version->getDate()));
1045                                if ($version->viewOnline())
1046                                        $this->t->set_var('url_view_online', "<a target=\"_blank\" href=\"../op/viewonline" . $version->getURL()."\"><img src=\"images/view.gif\" width=18 height=18 border=0 title=\"".lang('view online')."\"></a>");
1047                                else
1048                                        $this->t->set_var('url_view_online',    '');
1049                               
1050                                $linkData = array
1051                                (
1052                                        'documentid'    => $documentID,
1053                                        'version'       => $version->getVersion()
1054                                );
1055                                $this->t->set_var('url_download_file', $GLOBALS['phpgw']->link('/mydms/op/op.Download.php',$linkData));
1056                               
1057                                if (($accessMode == M_ALL) && (count($versions) > 1))
1058                                {
1059                                        $linkData = array
1060                                        (
1061                                                'menuaction'    => 'mydms.uimydms.deleteFile',
1062                                                'documentid'    => $documentID,
1063                                                'version'       => $version->getVersion(),
1064                                                'tabpage'       => 2,
1065                                        );
1066                                        $this->t->set_var('url_delete_file',
1067                                                "<a href=\"".$GLOBALS['phpgw']->link('/index.php',$linkData).
1068                                                        "\" onClick=\"return confirm('".lang('do you really want to delete this version of the document?').
1069                                                        "');\"><img src=\"$deleteImage\" width=15 height=15 border=0 title=\"".
1070                                                        lang("delete")."\"></a>");
1071                                }
1072                               
1073                                $this->t->parse('versions','version_row',True);
1074                        }
1075                       
1076                        // div 4 notifications
1077                        $linkData = array
1078                        (
1079                                'menuaction'    => 'mydms.uimydms.addNotification',
1080                                'documentid'    => $documentID,
1081                                'tabpage'       => 4,
1082                        );
1083                        $this->t->set_var('notify_form_action', $GLOBALS['phpgw']->link('/index.php',$linkData));
1084
1085                        foreach ((array)$notifyList["users"] as $userNotify)
1086                        {
1087                                $this->t->set_var('notify_username',$userNotify->getFullName());
1088                                $this->t->set_var('notify_image',$userImage);
1089                               
1090                                $linkData = array
1091                                (
1092                                        'menuaction'    => 'mydms.uimydms.deleteNotification',
1093                                        'documentid'    => $documentID,
1094                                        'userid'        => $userNotify->getID(),
1095                                        'tabpage'       => 4,
1096                                );
1097                                $this->t->set_var('link_notify_delete', $GLOBALS['phpgw']->link('/index.php',$linkData));
1098
1099                                $this->t->parse('notifications','notification_row',True);
1100                        }
1101                       
1102                        foreach ((array)$notifyList["groups"] as $groupNotify)
1103                        {
1104                                $this->t->set_var('notify_username',$groupNotify->getName());
1105                                $this->t->set_var('notify_image',$groupImage);
1106                               
1107                                $linkData = array
1108                                (
1109                                        'menuaction'    => 'mydms.uimydms.deleteNotification',
1110                                        'documentid'    => $documentID,
1111                                        'groupid'       => $groupNotify->getID(),
1112                                        'tabpage'       => 4,
1113                                );
1114                                $this->t->set_var('link_notify_delete', $GLOBALS['phpgw']->link('/index.php',$linkData));
1115
1116                                $this->t->parse('notifications','notification_row',True);
1117                        }
1118                       
1119                        $allUsers = getAllUsers();
1120                        $allUsersOptions = array('unselected' => lang('please select').'...');
1121                        foreach ($allUsers as $userObj)
1122                        {
1123                                $allUsersOptions[$userObj->getID()] = $userObj->getFullName();
1124                        }
1125                        $this->t->set_var('select_userid',$GLOBALS['phpgw']->html->select('userid',0,$allUsersOptions,true,"style=\"width: 300px;\" onchange=\"javascript:document.notify_form.submit();\""));
1126                       
1127                        $allGroups = getAllGroups();
1128                        $allGroupsOptions = array('unselected' => lang('please select').'...');
1129                        foreach ($allGroups as $groupObj)
1130                        {
1131                                $allGroupsOptions[$groupObj->getID()] = $groupObj->getName();
1132                        }
1133                        $this->t->set_var('select_groupid',$GLOBALS['phpgw']->html->select('groupid',0,$allGroupsOptions,true,"style=\"width: 300px;\" onchange=\"javascript:document.notify_form.submit();\""));
1134                       
1135        // div 5 ACL
1136                        if ($accessMode == M_ALL)
1137                        {
1138                                if ($user->isAdmin())
1139                                {
1140                                        $linkData = array
1141                                        (
1142                                                'menuaction'    => 'mydms.uimydms.setOwner',
1143                                                'documentid'    => $documentID,
1144                                                'tabpage'       => 5,
1145                                        );
1146                                        $this->t->set_var('action_change_owner', $GLOBALS['phpgw']->link('/index.php',$linkData));
1147
1148                                        $allUsers = getAllUsers();
1149                                        $allUsersOptions = array();
1150                                        foreach ($allUsers as $userObj)
1151                                        {
1152                                                $allUsersOptions[$userObj->getID()] = $userObj->getFullName();
1153                                        }
1154                                        $this->t->set_var('select_ownerid',$GLOBALS['phpgw']->html->select('owner',$owner->getID(),$allUsersOptions,true,"style=\"width: 300px;\" onchange=\"javascript:document.change_owner.submit();\""));
1155                                       
1156                                        $this->t->parse('change_owner','block_change_owner',True);
1157                                }
1158                               
1159                                if ($document->inheritsAccess())
1160                                {
1161                                        $linkData = array
1162                                        (
1163                                                'menuaction'    => 'mydms.uimydms.inheritACL',
1164                                                'documentid'    => $documentID,
1165                                                'action'        => 'notinherit',
1166                                                'mode'          => 'copy',
1167                                                'tabpage'       => 5,
1168                                        );
1169                                        $this->t->set_var('link_acl_copy', $GLOBALS['phpgw']->link('/index.php',$linkData));
1170                                       
1171                                        $linkData = array
1172                                        (
1173                                                'menuaction'    => 'mydms.uimydms.inheritACL',
1174                                                'documentid'    => $documentID,
1175                                                'action'        => 'notinherit',
1176                                                'mode'          => 'empty',
1177                                                'tabpage'       => 5,
1178                                        );
1179                                        $this->t->set_var('link_acl_empty', $GLOBALS['phpgw']->link('/index.php',$linkData));
1180
1181                                        $this->t->parse('display_acl','block_acl_inherite',True);
1182                                }
1183                                else
1184                                {
1185                                        $linkData = array
1186                                        (
1187                                                'menuaction'    => 'mydms.uimydms.inheritACL',
1188                                                'documentid'    => $documentID,
1189                                                'action'        => 'inherit',
1190                                                'tabpage'       => 5,
1191                                        );
1192                                        $this->t->set_var('link_acl_inherit_again', $GLOBALS['phpgw']->link('/index.php',$linkData));
1193
1194                                        $linkData = array
1195                                        (
1196                                                'menuaction'    => 'mydms.uimydms.setDefaultAccess',
1197                                                'documentid'    => $documentID,
1198                                                'tabpage'       => 5,
1199                                        );
1200                                        $this->t->set_var('action_change_default_access', $GLOBALS['phpgw']->link('/index.php',$linkData));
1201
1202                                        $linkData = array
1203                                        (
1204                                                'menuaction'    => 'mydms.uimydms.addACL',
1205                                                'documentid'    => $documentID,
1206                                                'tabpage'       => 5,
1207                                        );
1208                                        $this->t->set_var('action_add_acl', $GLOBALS['phpgw']->link('/index.php',$linkData));
1209
1210                                       
1211                                        $defaultACL = array
1212                                        (
1213                                                M_NONE          => 'access_mode_none',
1214                                                M_READ          => 'access_mode_read',
1215                                                M_READWRITE     => 'access_mode_readwrite',
1216                                                M_ALL           => 'access_mode_all',
1217                                        );
1218                                        $this->t->set_var('select_default_access',$GLOBALS['phpgw']->html->select('defaultAccess',$document->getDefaultAccess(),$defaultACL,false,"style=\"width: 300px;\" onchange=\"javascript:document.change_default_access.submit();\""));
1219
1220                                        foreach ((array)$accessList["users"] as $userAccess)
1221                                        {
1222                                                $userObj        = $userAccess->getUser();
1223                                                $userMode       = $userAccess->getMode();
1224
1225                                                $this->t->set_var('acl_username',$userObj->getFullName());
1226                                                $this->t->set_var('acl_image',$userImage);
1227
1228                                                $linkData = array
1229                                                (
1230                                                        'menuaction'    => 'mydms.uimydms.updateACL',
1231                                                        'documentid'    => $documentID,
1232                                                        'userid'        => $userObj->getID(),
1233                                                        'tabpage'       => 5,
1234                                                );
1235                                                $this->t->set_var('action_acl_row', $GLOBALS['phpgw']->link('/index.php',$linkData));
1236
1237                                                $linkData = array
1238                                                (
1239                                                        'menuaction'    => 'mydms.uimydms.deleteACL',
1240                                                        'documentid'    => $documentID,
1241                                                        'userid'        => $userObj->getID(),
1242                                                        'tabpage'       => 5,
1243                                                );
1244                                                $this->t->set_var('link_acl_delete', $GLOBALS['phpgw']->link('/index.php',$linkData));
1245
1246                                                $this->t->set_var('acl_selectbox',$GLOBALS['phpgw']->html->select('mode',$userAccess->getMode(),$defaultACL,false,"style=\"width: 300px;\""));
1247                               
1248                                                $this->t->parse('acls','acl_row',True);
1249                                        }
1250                                       
1251                                        foreach ((array)$accessList["groups"] as $groupAccess)
1252                                        {
1253                                                $groupObj       = $groupAccess->getGroup();
1254                                                $groupMode      = $groupAccess->getMode();
1255
1256                                                $this->t->set_var('acl_username',$groupObj->getName());
1257                                                $this->t->set_var('acl_image',$groupImage);
1258
1259                                                $linkData = array
1260                                                (
1261                                                        'menuaction'    => 'mydms.uimydms.updateACL',
1262                                                        'documentid'    => $documentID,
1263                                                        'groupid'       => $groupObj->getID(),
1264                                                        'tabpage'       => 5,
1265                                                );
1266                                                $this->t->set_var('action_acl_row', $GLOBALS['phpgw']->link('/index.php',$linkData));
1267
1268                                                $linkData = array
1269                                                (
1270                                                        'menuaction'    => 'mydms.uimydms.deleteACL',
1271                                                        'documentid'    => $documentID,
1272                                                        'groupid'       => $groupObj->getID(),
1273                                                        'tabpage'       => 5,
1274                                                );
1275                                                $this->t->set_var('link_acl_delete', $GLOBALS['phpgw']->link('/index.php',$linkData));
1276
1277                                                $this->t->set_var('acl_selectbox',$GLOBALS['phpgw']->html->select('mode',$groupAccess->getMode(),$defaultACL,false,"style=\"width: 300px;\""));
1278
1279                                                $this->t->parse('acls','acl_row',True);
1280                                        }
1281
1282
1283                                        $allUsers = getAllUsers();
1284                                        $allUsersOptions = array('unselected' => lang('please select').'...');
1285                                        foreach ($allUsers as $userObj)
1286                                        {
1287                                                $allUsersOptions[$userObj->getID()] = $userObj->getFullName();
1288                                        }
1289                                        $this->t->set_var('select_add_acl_userid',$GLOBALS['phpgw']->html->select('userid',0,$allUsersOptions,true,"style=\"width: 300px;\" oonchange=\"javascript:document.notify_form.submit();\""));
1290                       
1291                                        $allGroups = getAllGroups();
1292                                        $allGroupsOptions = array('unselected' => lang('please select').'...');
1293                                        foreach ($allGroups as $groupObj)
1294                                        {
1295                                                $allGroupsOptions[$groupObj->getID()] = $groupObj->getName();
1296                                        }
1297                                        $this->t->set_var('select_add_acl_groupid',$GLOBALS['phpgw']->html->select('groupid',0,$allGroupsOptions,true,"style=\"width: 300px;\" oonchange=\"javascript:document.notify_form.submit();\""));
1298
1299                                        $this->t->set_var('select_add_acl_permission',$GLOBALS['phpgw']->html->select('access',M_READ,$defaultACL,false,"style=\"width: 300px;\" oonchange=\"javascript:document.change_default_access.submit();\""));
1300
1301                                        $this->t->parse('display_acl','block_acl_notinherite',True);
1302                                }
1303                        }
1304                       
1305        // div 6 update file
1306                       
1307                        $linkData = array
1308                        (
1309                                'menuaction'    => 'mydms.uimydms.updateFile',
1310                                'documentid'    => $documentID,
1311                        );
1312                        $this->t->set_var('action_update_file', $GLOBALS['phpgw']->link('/index.php',$linkData));
1313
1314                        // expire select box
1315                        $this->t->set_var('select_expire_update',$GLOBALS['phpgw']->html->select('expire',0,$selectOptions,true,"onchange=\"toggleJSCalUpdate(this);\""));
1316                       
1317                        $this->t->set_var('expire_date_update',$GLOBALS['phpgw']->jscalendar->input('expire_date_update',''));
1318                        $this->t->set_var('expire_class_update', 'inactive');
1319                       
1320                       
1321                        $this->t->parse("out","main");
1322                       
1323                        print $this->t->get('out','main');
1324                }
1325
1326        }
1327
1328?>
Note: See TracBrowser for help on using the repository browser.