28b3e16d1b50cd4118533c6cddf97b3345bb9765
[acontent.git] / docs / themes / default / user / user_group.tmpl.php
1 <?php\r
2 /************************************************************************/\r
3 /* AContent                                                             */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2010                                                   */\r
6 /* Inclusive Design Institute                                           */\r
7 /*                                                                      */\r
8 /* This program is free software. You can redistribute it and/or        */\r
9 /* modify it under the terms of the GNU General Public License          */\r
10 /* as published by the Free Software Foundation.                        */\r
11 /************************************************************************/\r
12 \r
13 global $_custom_css;\r
14 $_custom_css = TR_BASE_HREF."include/jscripts/infusion/components/inlineEdit/css/InlineEdit.css";\r
15 \r
16 include(TR_INCLUDE_PATH.'header.inc.php');\r
17 ?>\r
18 \r
19 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
20 \r
21 <table summary="<?php echo _AT("user_group"); ?>" class="data" rules="rows" id="editable_table">\r
22         <thead>\r
23         <tr>\r
24                 <th scope="col" align="left"><input type="checkbox" value="<?php echo _AT('select_all'); ?>" id="all" title="<?php echo _AT('select_all'); ?>" name="selectall" onclick="CheckAll();" /></th>\r
25         \r
26                 <th scope="col"><?php echo _AT('title'); ?></th>\r
27                 <th scope="col"><?php echo _AT('description'); ?></th>\r
28                 <th scope="col"><?php echo _AT('privileges'); ?></th>\r
29         </tr>\r
30         \r
31         </thead>\r
32 <?php if (is_array($this->user_group_rows)): ?>\r
33         <tfoot>\r
34         <tr>\r
35                 <td colspan="4">\r
36                         <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> \r
37                         <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />\r
38                 </td>\r
39         </tr>\r
40         </tfoot>\r
41         <tbody>\r
42                 <?php foreach ($this->user_group_rows as $row) \r
43                         {\r
44                         // get privileges\r
45                         $privileges = $this->privilegesDAO->getUserGroupPrivileges($row['user_group_id']);\r
46                         \r
47                         if (is_array($privileges))\r
48                         {\r
49                                 $priv_str = '<ul>';\r
50                                 foreach ($privileges as $priv)  $priv_str .= '<li>'. $priv['privilege_desc'].'</li>';\r
51                                 $priv_str .= '</ul>';\r
52                         }\r
53                 ?>\r
54                         <tr onmousedown="document.form['m<?php echo $row['user_group_id']; ?>'].checked = !document.form['m<?php echo $row['user_group_id']; ?>'].checked; togglerowhighlight(this, 'm<?php echo $row['user_group_id']; ?>');" \r
55                             onkeydown="document.form['m<?php echo $row['user_group_id']; ?>'].checked = !document.form['m<?php echo $row['user_group_id']; ?>'].checked; togglerowhighlight(this, 'm<?php echo $row['user_group_id']; ?>');"\r
56                             id="rm<?php echo $row['user_group_id']; ?>">\r
57                                 <td><input type="checkbox" name="id[]" value="<?php echo $row['user_group_id']; ?>" id="m<?php echo $row['user_group_id']; ?>" \r
58                                            onmouseup="this.checked=!this.checked" onkeyup="this.checked=!this.checked" /></td>\r
59                                 <td width='20%'><label for="m<?php echo $row['user_group_id']; ?>"><span id="<?php echo 'title-'.$row['user_group_id']?>" class="inlineEdits"><?php echo $row['title']; ?></span></label></td>\r
60                                 <td width='30%'><span id="<?php echo 'description-'.$row['user_group_id']?>" class="inlineEdits"><?php echo $row['description']; ?></span></td>\r
61                                 <td><?php echo $priv_str; ?></td>\r
62                         </tr>\r
63                 <?php } ?>\r
64         </tbody>\r
65 <?php else: ?>\r
66         <tr>\r
67                 <td colspan="4"><?php echo _AT('none_found'); ?></td>\r
68         </tr>\r
69 <?php endif; ?>\r
70 </table>\r
71 </form>\r
72 <br/><br/>\r
73 \r
74 <script language="JavaScript" type="text/javascript">\r
75 //<!--\r
76 function CheckAll() {\r
77         for (var i=0;i<document.form.elements.length;i++)       {\r
78                 var e = document.form.elements[i];\r
79                 if ((e.name == 'id[]') && (e.type=='checkbox')) {\r
80                         e.checked = document.form.selectall.checked;\r
81                         togglerowhighlight(document.getElementById("r" + e.id), e.id);\r
82                 }\r
83         }\r
84 }\r
85 \r
86 function togglerowhighlight(obj, boxid) {\r
87         if (document.getElementById(boxid).checked) {\r
88                 obj.className = 'selected';\r
89         } else {\r
90                 obj.className = '';\r
91         }\r
92 }\r
93 \r
94 jQuery(document).ready(function () {\r
95         var tableEdit = fluid.inlineEdits("#editable_table", {\r
96                 selectors : {\r
97                         text : "span",\r
98                         editables : "td:has(span.inlineEdits)"\r
99                 },\r
100                 defaultViewText: "",\r
101                 useTooltip: true,\r
102                 listeners: {\r
103                         afterFinishEdit : function (newValue, oldValue, editNode, viewNode) \r
104                         {\r
105                                 if (newValue != oldValue)\r
106                                 {\r
107                                         rtn = jQuery.post("<?php echo TR_BASE_HREF; ?>user/user_group_inline_editor_submit.php", { "field":viewNode.id, "value":newValue }, \r
108                                           function(data) \r
109                                           {\r
110                                                 if (data.status=="fail")\r
111                                                 {\r
112                                                   for (var i = 0; i < tableEdit.length; i++) \r
113                                                       {\r
114                                                     if(tableEdit[i].editField[0] == editNode) \r
115                                                       tableEdit[i].updateModelValue(oldValue);\r
116                                                   }\r
117                                                     }\r
118                                                 \r
119                                         handleAjaxResponse(data); \r
120                                           }, "json");\r
121                                 }\r
122                         }\r
123                 }\r
124         });\r
125 });\r
126 //-->\r
127 </script>\r
128 <?php require(TR_INCLUDE_PATH.'footer.inc.php'); ?>