From 01e92100c4633d241744709db1dd280c57c2d265 Mon Sep 17 00:00:00 2001 From: Ralf Becker <ralfbecker@outdoor-training.de> Date: Thu, 13 Oct 2011 06:21:46 +0000 Subject: [PATCH] ability to mark resource-categories to be used for locations or rooms, destinction is required for CalDAV --- resources/inc/class.resources_bo.inc.php | 2 +- resources/inc/class.ui_acl.inc.php | 51 ++++++++++++++---------- resources/lang/egw_de.lang | 4 +- resources/lang/egw_en.lang | 1 + resources/setup/default_records.inc.php | 10 +++-- resources/templates/default/acl.tpl | 5 ++- 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index a26124f366..f9cef05ad1 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -24,7 +24,7 @@ class resources_bo /** * Instance of resources so object * - * @var so_resources + * @var resources_so */ var $so; /** diff --git a/resources/inc/class.ui_acl.inc.php b/resources/inc/class.ui_acl.inc.php index 6e85b49958..f9050cf2e3 100755 --- a/resources/inc/class.ui_acl.inc.php +++ b/resources/inc/class.ui_acl.inc.php @@ -28,8 +28,8 @@ class ui_acl function ui_acl() { - $this->bo =& createobject('resources.bo_acl',True); - $this->nextmatchs =& createobject('phpgwapi.nextmatchs'); + $this->bo = createobject('resources.bo_acl',True); + $this->nextmatchs = createobject('phpgwapi.nextmatchs'); $this->start = $this->bo->start; $this->query = $this->bo->query; $this->order = $this->bo->order; @@ -46,10 +46,10 @@ class ui_acl if ($_POST['btnDone']) { - $GLOBALS['egw']->redirect_link('/admin/index.php'); + egw::redirect_link('/admin/index.php'); } - $GLOBALS['egw']->common->egw_header(); + common::egw_header(); echo parse_navbar(); if ($_POST['btnSave']) @@ -59,6 +59,7 @@ class ui_acl $this->bo->set_rights($cat_id,$_POST['inputread'][$cat_id],$_POST['inputwrite'][$cat_id], $_POST['inputcalread'][$cat_id],$_POST['inputcalbook'][$cat_id],$_POST['inputadmin'][$cat_id]); } + config::save_value('location_cats', implode(',', $_POST['location_cats']), 'resources'); } $template =& CreateObject('phpgwapi.Template',EGW_APP_TPL); $template->set_file(array('acl' => 'acl.tpl')); @@ -74,7 +75,8 @@ class ui_acl 'lang_calread' => lang('Read Calendar permissions'), 'lang_calbook' => lang('Direct booking permissions'), 'lang_implies_book' => lang('implies booking permission'), - 'lang_cat_admin' => lang('Categories admin') + 'lang_cat_admin' => lang('Categories admin'), + 'lang_locations_rooms' => lang('Locations / rooms'), )); $left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->catbo->total_records,'menuaction=resources.ui_acl.acllist'); @@ -91,23 +93,28 @@ class ui_acl 'query' => $this->query, )); - @reset($this->bo->cats); - while (list(,$cat) = @each($this->bo->cats)) + if ($this->bo->cats) { - $this->rights = $this->bo->get_rights($cat['id']); + $config = config::read('resources'); + $location_cats = $config['location_cats'] ? explode(',', $config['location_cats']) : array(); + foreach($this->bo->cats as $cat) + { + $this->rights = $this->bo->get_rights($cat['id']); - $tr_color = $this->nextmatchs->alternate_row_color($tr_color); - $template->set_var(array( - 'tr_color' => $tr_color, - 'catname' => $cat['name'], - 'catid' => $cat['id'], - 'read' => $this->selectlist(EGW_ACL_READ), - 'write' => $this->selectlist(EGW_ACL_ADD), - 'calread' => $this->selectlist(EGW_ACL_CALREAD), - 'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING), - 'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true) - )); - $template->parse('Cblock','cat_list',True); + $tr_color = $this->nextmatchs->alternate_row_color($tr_color); + $template->set_var(array( + 'tr_color' => $tr_color, + 'catname' => $cat['name'], + 'catid' => $cat['id'], + 'read' => $this->selectlist(EGW_ACL_READ), + 'write' => $this->selectlist(EGW_ACL_ADD), + 'calread' => $this->selectlist(EGW_ACL_CALREAD), + 'calbook' =>$this->selectlist(EGW_ACL_DIRECT_BOOKING), + 'admin' => '<option value="" selected="1">'.lang('choose categories admin').'</option>'.$this->selectlist(EGW_ACL_CAT_ADMIN,true), + 'location_checked' => in_array($cat['id'], $location_cats) ? 'checked="1"' : '', + )); + $template->parse('Cblock','cat_list',True); + } } $template->pfp('out','acl',True); } @@ -140,7 +147,7 @@ class ui_acl { $selectlist .= ' selected="selected"'; } - $selectlist .= '>' . $GLOBALS['egw']->common->display_fullname($account['account_lid'],$account['account_firstname'], + $selectlist .= '>' . common::display_fullname($account['account_lid'],$account['account_firstname'], $account['account_lastname'],$account['account_id']) . '</option>' . "\n"; } } @@ -150,6 +157,6 @@ class ui_acl function deny() { echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; - $GLOBALS['egw']->common->egw_exit(True); + common::egw_exit(True); } } diff --git a/resources/lang/egw_de.lang b/resources/lang/egw_de.lang index 46bf3f5a50..a24e62208d 100644 --- a/resources/lang/egw_de.lang +++ b/resources/lang/egw_de.lang @@ -18,7 +18,7 @@ category: resources de Kategorie check all resources de Alle auswählen choose categories admin resources de Wählen Sie einen Verwalter für diese Kategorie clear selection resources de Auswahl löschen -configure access permissions resources de Zugangseinstellungen konfigurieren +configure access permissions admin de Zugangseinstellungen konfigurieren create new accessory for this resource resources de Neues Zubehör zu dieser Ressource hinzufügen create new links resources de Neue Verknüpfung erstellen delete selected resources resources de Ausgewählte Ressourcen löschen @@ -49,6 +49,7 @@ links resources de Verknüpfungen location resources de Lagerort location of resource resources de Lagerort der Ressource location: resources de Lagerort: +locations / rooms resources de Orte / Räume name of resource resources de Name der Ressource name: resources de Name: no description available resources de Keine Beschreibung vorhanden @@ -95,6 +96,5 @@ web-site for this resource resources de Ausführliche Beschreibung der Ressource where to find this resource? resources de Wo findet man diese Ressource? which category does this resource belong to? resources de Zu welcher Kategorie gehört diese Ressource? write permissions resources de Schreiberechtigung -you are not permitted to edit this reource! resources de Sie haben keine Erlaubnis diese Ressource zu bearbeiten you are not permitted to get information about this resource! resources de Sie haben keine Erlaubnis sich informationen über diese Ressource anzuschauen you chose more resources than available resources de Sie haben mehr Ressourcen ausgewählt als verfügbar sind diff --git a/resources/lang/egw_en.lang b/resources/lang/egw_en.lang index 28708708b6..953c9d02ee 100644 --- a/resources/lang/egw_en.lang +++ b/resources/lang/egw_en.lang @@ -60,6 +60,7 @@ links resources en Links location resources en Location location of resource resources en Location of resource location: resources en Location: +locations / rooms resources en Locations / rooms long description resources en Long description manage mapping resources en Manage mapping name of resource resources en Name of resource diff --git a/resources/setup/default_records.inc.php b/resources/setup/default_records.inc.php index 46a0f23beb..0498986407 100644 --- a/resources/setup/default_records.inc.php +++ b/resources/setup/default_records.inc.php @@ -1,7 +1,7 @@ <?php /** * eGroupWare - resources - * http://www.egroupware.org + * http://www.egroupware.org * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package resources @@ -14,6 +14,9 @@ $resources_table_prefix = 'egw_resources'; // Add a general category for resources $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'General resources','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__); $cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); +$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__); +$locations_cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); +config::save_value('location_cats', $locations_cat_id, 'resources'); // Give default group all rights to this general cat $defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); @@ -21,8 +24,7 @@ $GLOBALS['egw_setup']->add_acl('resources','run',$defaultgroup); $GLOBALS['egw_setup']->add_acl('resources',"L$cat_id",$defaultgroup,399); // Add two rooms to give user an idea of what resources is... -$oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 1',$cat_id,1,'cat_src',-1)"); -$oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 2',$cat_id,1,'cat_src',-1)"); +$oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 1',$locations_cat_id,1,'cat_src',-1)"); +$oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 2',$locations_cat_id,1,'cat_src',-1)"); $res_id = $oProc->m_odb->get_last_insert_id($resources_table_prefix,'res_id'); $oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Fixed Beamer',$cat_id,0,'cat_src',$res_id)"); - \ No newline at end of file diff --git a/resources/templates/default/acl.tpl b/resources/templates/default/acl.tpl index a9448d5f7d..6fd763642a 100755 --- a/resources/templates/default/acl.tpl +++ b/resources/templates/default/acl.tpl @@ -33,8 +33,9 @@ <!-- BEGIN cat_list --> <tr bgcolor="{tr_color}"> <td> - {catname}<input type="hidden" name="catids[]" value="{catid}" /><br> - <select name="inputadmin[{catid}][]">{admin}</select> + {catname}<input type="hidden" name="catids[]" value="{catid}" /><br> + <select name="inputadmin[{catid}][]">{admin}</select><br> + <label><input type="checkbox" value="{catid}" name="location_cats[]" {location_checked} /> {lang_locations_rooms}</label> </td> <td align="center"><select multiple="multiple" size="5" name="inputread[{catid}][]">{read}</select></td> <td align="center"><select multiple="multiple" size="5" name="inputwrite[{catid}][]">{write}</select></td>