* Add ability for users to define their own definitions

- Permissions set by admin in the Site configuration
This commit is contained in:
Nathan Gray 2011-02-22 17:13:03 +00:00
parent 68e369cdd7
commit 838f4664f1
5 changed files with 96 additions and 4 deletions

View File

@ -39,6 +39,12 @@ class importexport_admin_prefs_sidebox_hooks
'icon' => 'export'
),
);
if($GLOBALS['egw']->acl->check('definition', EGW_ACL_EDIT, $appname))
{
$file['Define imports|exports'] = egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_definitions_ui.index',
));
}
if ($location == 'preferences')
{
display_section($appname,$file);
@ -52,6 +58,7 @@ class importexport_admin_prefs_sidebox_hooks
if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences')
{
$file = Array(
'Site Configuration' => egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'),
'Import definitions' => egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'),
'Define imports|exports' => egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_definitions_ui.index',

View File

@ -88,7 +88,7 @@ class importexport_definitions_bo {
$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
$this_membership[] = $this_user_id;
$alluser = array_intersect($allowed_user,$this_membership);
return count($alluser) > 0 ? true : false;
return ($this_user_id == $_definition['owner'] || count($alluser) > 0);
}
/**

View File

@ -26,6 +26,7 @@ class importexport_definitions_ui
'index' => true,
'wizard' => true,
'import_definition' => true,
'site_config' => true,
);
/**
@ -77,7 +78,16 @@ class importexport_definitions_ui
*/
function index($content = null,$msg='')
{
$bodefinitions = new importexport_definitions_bo(array('name' => '*'), true);
$filter = array('name' => '*');
// Filter private definitions
if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
$filter['owner'] = $GLOBALS['egw_info']['user']['account_id'];
} else {
$filter[] = '!owner || owner IS NULL';
}
$bodefinitions = new importexport_definitions_bo($filter, true);
if (is_array($content))
{
if (isset($content['delete']))
@ -140,6 +150,7 @@ class importexport_definitions_ui
$definition = array('name' => $_definition);
$bodefinitions = new importexport_definitions_bo();
$definition = $bodefinitions->read($definition);
$definition['edit'] = true;
$this->wizard($definition);
}
@ -338,7 +349,12 @@ class importexport_definitions_ui
else
{
$content['msg'] = $this->steps['wizard_step10'];
foreach ($this->plugins as $appname => $options) $sel_options['application'][$appname] = lang($appname);
foreach ($this->plugins as $appname => $options)
{
if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
$sel_options['application'][$appname] = lang($appname);
}
}
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][previous]');");
$content['step'] = 'wizard_step10';
$preserv = $content;
@ -475,6 +491,10 @@ class importexport_definitions_ui
unset($content['button']);
$bodefinitions = new importexport_definitions_bo();
// Set owner for non-admins
if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
$content['owner'] = $GLOBALS['egw_info']['user']['account_id'];
}
$bodefinitions->save($content);
// This message is displayed if browser cant close window
$content['msg'] = lang('ImportExport wizard finished successfully!');
@ -497,4 +517,44 @@ class importexport_definitions_ui
return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv);
}
}
/**
* Site configuration
*/
public function site_config($content = array())
{
if(!$GLOBALS['egw_info']['user']['apps']['admin'])
{
egw::redirect_link('/home');
}
if($content['save'])
{
unset($content['save']);
// ACL
$GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false);
if($content['create_definition_users'])
{
$GLOBALS['egw']->acl->add_repository(self::_appname, 'definition', $content['create_definition_users'],
EGW_ACL_ADD | EGW_ACL_EDIT
);
}
unset($content['create_definition_users']);
// Other config
foreach($content as $key=>$value)
{
config::save_value($key, $value, 'importexport');
}
} elseif (isset($content['cancel'])) {
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
$data = config::read(self::_appname);
$data['create_definition_users'] = $GLOBALS['egw']->acl->get_ids_for_location('definition', EGW_ACL_ADD | EGW_ACL_EDIT, self::_appname);
$GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname);
$etpl = new etemplate(self::_appname.'.config');
$etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv);
}
}

View File

@ -2,7 +2,7 @@
/**
* eGroupWare - eTemplates for Application importexport
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2011-01-27 09:40
* generated by soetemplate::dump4setup() 2011-02-22 10:10
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
@ -12,6 +12,8 @@
$templ_version=1;
$templ_data[] = array('name' => 'importexport.config','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:45:"Users allowed to create their own definitions";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"size";s:6:"5,both";s:4:"name";s:23:"create_definition_users";}}i:2;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:4:"span";s:3:"all";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1298390222',);
$templ_data[] = array('name' => 'importexport.definition_index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:1:{s:1:"A";a:4:{s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"type";s:5:"label";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";}i:1;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";s:4:"span";s:11:",lr_padding";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";s:4:"span";s:11:",lr_padding";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";s:4:"span";s:11:",lr_padding";}s:1:"D";a:4:{s:5:"align";s:6:"center";s:4:"type";s:5:"label";s:5:"label";s:13:"Allowed users";s:4:"span";s:11:",lr_padding";}s:1:"E";a:5:{s:5:"label";s:3:"Add";s:5:"align";s:6:"center";s:4:"type";s:6:"button";s:4:"span";s:11:",lr_padding";s:7:"onclick";s:226:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.importexport_definitions_ui.wizard\'),\'\',\'dependent=yes,width=500,height=500,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";}s:1:"F";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:6:{s:5:"label";s:6:"Delete";s:4:"name";s:15:"delete_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"delete ALL selected definitions";s:4:"size";s:6:"delete";s:7:"onclick";s:65:"return confirm(\'Do you really want to DELETE this definitions?\');";}i:2;a:5:{s:5:"label";s:6:"Export";s:4:"name";s:15:"export_selected";s:4:"type";s:6:"button";s:4:"help";s:31:"export ALL selected definitions";s:4:"size";s:10:"fileexport";}}}i:2;a:6:{s:1:"A";a:5:{s:7:"no_lang";s:1:"1";s:4:"type";s:5:"image";s:4:"span";s:18:",lr_padding button";s:4:"name";s:12:"${row}[type]";s:7:"onclick";s:222:"window.open(egw::link(\'/index.php\',\'menuaction=${row_cont[menuaction]}&appname=${row_cont[application]}&definition=${row_cont[name]}\'),\'_blank\',\'dependent=yes,width=850,height=440,scrollbars=yes,status=yes\'); return false;";}s:1:"B";a:5:{s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";s:4:"size";s:1:",";}s:1:"C";a:4:{s:7:"no_lang";s:1:"1";s:4:"name";s:19:"${row}[application]";s:4:"type";s:5:"label";s:4:"span";s:11:",lr_padding";}s:1:"D";a:6:{s:7:"no_lang";s:1:"1";s:4:"type";s:14:"select-account";s:4:"span";s:11:",lr_padding";s:8:"readonly";s:1:"1";s:4:"name";s:21:"${row}[allowed_users]";s:4:"size";s:6:"5,both";}s:1:"E";a:5:{s:5:"align";s:6:"center";s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:5:"label";s:4:"Edit";s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:7:"onclick";s:263:"window.open(egw::link(\'/index.php\',\'menuaction=importexport.importexport_definitions_ui.edit&definition=$row_cont[name]\'),\'\',\'dependent=yes,width=500,height=500,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=1,status=yes\'); return false; return false;";}i:2;a:6:{s:5:"label";s:6:"Delete";s:7:"onclick";s:41:"return confirm(\'Delete this definition\');";s:4:"name";s:32:"delete[$row_cont[definition_id]]";s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:4:"help";s:21:"Delete this eTemplate";}}s:1:"F";a:4:{s:5:"align";s:6:"center";s:4:"name";s:34:"selected[$row_cont[definition_id]]";s:4:"type";s:8:"checkbox";s:4:"help";s:34:"select this eTemplate to delete it";}}}s:4:"cols";i:6;s:4:"rows";i:2;}}}s:4:"cols";i:1;s:4:"rows";i:2;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.redItalic { color:red; font-style:italic;} td.lr_padding { padding-left: 5px; padding-right: 5px; }
.button {

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="importexport.config" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row>
<description value="Users allowed to create their own definitions"/>
<listbox type="select-account" rows="5" options="both" id="create_definition_users"/>
</row>
<row>
<hbox span="all">
<button span="all" label="Save" id="save"/>
</hbox>
</row>
</rows>
</grid>
</template>
</overlay>