new private custom fields visible only to certain users/groups, only used in addressbook at the moment, easy to add for other apps, only requires to modify the storage method to only save the available cfs, to not delete the hidden ones

This commit is contained in:
Ralf Becker 2008-01-19 05:32:51 +00:00
parent 4a800502fa
commit 5d4e591d19
3 changed files with 30 additions and 17 deletions

View File

@ -42,13 +42,20 @@
var $public_functions = array(
'edit' => True
);
/**
* Instance of the config class for the instancated applications
*
* @var config
*/
var $config;
function customfields($appname='')
{
$this->config =& CreateObject('phpgwapi.config',$this->appname=$appname);
$this->config =& new config($this->appname=$appname);
if ($appname)
{
$this->fields = $this->get_customfields();
$this->fields = $this->get_customfields(true);
$this->content_types = $this->get_content_types();
}
}
@ -73,7 +80,7 @@
// do we manage content-types?
if($this->tmpl->read($this->appname.'.admin.types')) $this->manage_content_types = true;
$this->fields = $this->get_customfields();
$this->fields = $this->get_customfields(true);
$this->tmpl->read('admin.customfields');
if($this->manage_content_types) $this->content_types = $this->get_content_types();
@ -126,6 +133,7 @@
$content_types = array_keys($this->content_types);
$this->content_type = $content_types[0];
}
$content['use_private'] = (boolean)$_GET['use_private'];
$referer = $GLOBALS['egw']->common->get_referer();
}
@ -151,7 +159,7 @@
}
//echo 'customfields=<pre style="text-align: left;">'; print_r($this->fields); echo "</pre>\n";
$content['fields'] = array();
$content['fields'] = array('use_private' => $content['use_private']);
$n = 0;
foreach($this->fields as $name => $data)
{
@ -178,6 +186,7 @@
}
$content['fields'][++$n] = array('name'=>'','order' => 10 * $n); // new line for create
if($this->manage_content_types) $content['fields']['type2'] = 'enable';
$readonlys['fields']["delete[]"] = True;
//echo '<p>uicustomfields.edit(content = <pre style="text-align: left;">'; print_r($content); echo "</pre>\n";
//echo 'readonlys = <pre style="text-align: left;">'; print_r($readonlys); echo "</pre>\n";
@ -188,6 +197,7 @@
'fields' => $preserv_fields,
'appname' => $this->appname,
'referer' => $referer,
'use_private' => $content['use_private'],
));
}
@ -236,8 +246,9 @@
'help' => $field['help'],
'values'=> $values,
'len' => $field['len'],
'rows' => intval($field['rows']),
'order' => intval($field['order'])
'rows' => (int)$field['rows'],
'order' => (int)$field['order'],
'private' => $field['private'],
);
if(!$this->fields[$name]['type2'] && $this->manage_content_types)
{
@ -345,29 +356,26 @@
/**
* get customfields of using application
*
* @deprecated use config::get_customfields() direct, no need to instanciate this UI class
* @author Cornelius Weiss
* @param boolean $all_private_too=false should all the private fields be returned too
* @return array with customfields
*/
function get_customfields()
function get_customfields($all_private_too=false)
{
$config = $this->config->read_repository();
//merge old config_name in phpgw_config table
$config_name = isset($config['customfields']) ? 'customfields' : 'custom_fields';
return is_array($config[$config_name]) ? $config[$config_name] : array();
return config::get_customfields($this->appname,$all_private_too);
}
/**
* get_content_types of using application
*
* @deprecated use config::get_content_types() direct, no need to instanciate this UI class
* @author Cornelius Weiss
* @return array with content-types
*/
function get_content_types()
{
$config = $this->config->read_repository();
return is_array($config['types']) ? $config['types'] : array();
return config::get_content_types($this->appname);
}
}

View File

@ -2,7 +2,7 @@
/**
* eGroupWare - eTemplates for Application admin
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2007-11-24 20:46
* generated by soetemplate::dump4setup() 2008-01-17 01:59
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -31,6 +31,8 @@ $templ_data[] = array('name' => 'admin.customfields.fields','template' => '','la
$templ_data[] = array('name' => 'admin.customfields.fields','template' => '','lang' => '','group' => '0','version' => '1.4.001','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:3:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";s:1:"C";s:8:",!@type2";}i:1;a:8:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Label";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Subtype";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";}s:1:"E";a:3:{s:4:"type";s:5:"label";s:5:"label";s:7:"Options";s:4:"help";s:40:"each value is a line like <id>[=<label>]";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"Length<br>Rows";}s:1:"G";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Order";}s:1:"H";a:4:{s:4:"type";s:5:"label";s:5:"label";s:6:"Action";s:5:"align";s:6:"center";s:4:"help";s:18:"deletes this field";}}i:2;a:8:{s:1:"A";a:4:{s:4:"type";s:4:"text";s:4:"size";s:5:"20,32";s:4:"name";s:12:"${row}[name]";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:",255";s:4:"name";s:13:"${row}[label]";s:4:"help";s:30:"the text displayed to the user";}i:2;a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[label]";}}s:1:"C";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"All";s:4:"name";s:13:"${row}[type2]";s:7:"no_lang";s:1:"1";}s:1:"D";a:3:{s:4:"type";s:18:"customfields-types";s:4:"name";s:12:"{$row}[type]";s:4:"help";s:19:"Type of customfield";}s:1:"E";a:4:{s:4:"type";s:8:"textarea";s:4:"size";s:4:"2,30";s:4:"name";s:14:"${row}[values]";s:4:"help";s:36:"each value is a line like id[=label]";}s:1:"F";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:1:"5";s:4:"name";s:11:"${row}[len]";s:4:"help";s:63:"max length of the input [, length of the inputfield (optional)]";}i:2;a:5:{s:4:"type";s:3:"int";s:4:"size";s:6:"0,10,2";s:4:"name";s:12:"${row}[rows]";s:4:"help";s:70:"number of row for a multiline inputfield or line of a multi-select-box";s:4:"blur";s:1:"1";}}s:1:"G";a:4:{s:4:"type";s:3:"int";s:4:"size";s:4:"1,,3";s:4:"name";s:13:"${row}[order]";s:4:"help";s:45:"determines the order the fields are displayed";}s:1:"H";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:23:"delete[$row_cont[name]]";s:4:"help";s:18:"deletes this field";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:21:"create$row_cont[name]";s:4:"help";s:19:"creates a new field";}}}}s:4:"rows";i:2;s:4:"cols";i:8;s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1131454776',);
$templ_data[] = array('name' => 'admin.customfields.fields','template' => '','lang' => '','group' => '0','version' => '1.5.001','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:4:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";s:1:"C";s:8:",!@type2";s:1:"E";s:14:",!@use_private";}i:1;a:9:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Label";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Subtype";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Private";}s:1:"F";a:3:{s:4:"type";s:5:"label";s:5:"label";s:7:"Options";s:4:"help";s:40:"each value is a line like <id>[=<label>]";}s:1:"G";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"Length<br>Rows";}s:1:"H";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Order";}s:1:"I";a:4:{s:4:"type";s:5:"label";s:5:"label";s:6:"Action";s:5:"align";s:6:"center";s:4:"help";s:18:"deletes this field";}}i:2;a:9:{s:1:"A";a:4:{s:4:"type";s:4:"text";s:4:"size";s:5:"20,32";s:4:"name";s:12:"${row}[name]";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:",255";s:4:"name";s:13:"${row}[label]";s:4:"help";s:30:"the text displayed to the user";}i:2;a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[label]";}}s:1:"C";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"All";s:4:"name";s:13:"${row}[type2]";s:7:"no_lang";s:1:"1";}s:1:"D";a:3:{s:4:"type";s:18:"customfields-types";s:4:"name";s:12:"{$row}[type]";s:4:"help";s:19:"Type of customfield";}s:1:"E";a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:15:"${row}[private]";s:4:"help";s:69:"Should this custom field only be available if you have private rights";s:5:"align";s:6:"center";}s:1:"F";a:4:{s:4:"type";s:8:"textarea";s:4:"size";s:4:"2,30";s:4:"name";s:14:"${row}[values]";s:4:"help";s:36:"each value is a line like id[=label]";}s:1:"G";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:1:"5";s:4:"name";s:11:"${row}[len]";s:4:"help";s:63:"max length of the input [, length of the inputfield (optional)]";}i:2;a:5:{s:4:"type";s:3:"int";s:4:"size";s:6:"0,10,2";s:4:"name";s:12:"${row}[rows]";s:4:"help";s:70:"number of row for a multiline inputfield or line of a multi-select-box";s:4:"blur";s:1:"1";}}s:1:"H";a:4:{s:4:"type";s:3:"int";s:4:"size";s:4:"1,,3";s:4:"name";s:13:"${row}[order]";s:4:"help";s:45:"determines the order the fields are displayed";}s:1:"I";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:23:"delete[$row_cont[name]]";s:4:"help";s:18:"deletes this field";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:21:"create$row_cont[name]";s:4:"help";s:19:"creates a new field";}}}}s:4:"rows";i:2;s:4:"cols";i:9;s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1131454776',);
$templ_data[] = array('name' => 'admin.customfields.types','template' => '','lang' => '','group' => '0','version' => '1.2','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:1:{s:1:"D";s:15:",@non_deletable";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:8:"app-name";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"- type";}s:1:"C";a:4:{s:4:"type";s:6:"select";s:4:"name";s:5:"types";s:8:"onchange";s:1:"1";s:7:"no_lang";s:1:"1";}s:1:"D";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:6:"delete";s:7:"onclick";s:110:"return confirm(\'WARNING: You are about to delete this type. Entries of this type won\\\'t be accessable then.\');";}s:1:"E";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"name";s:4:"blur";s:8:"new name";}s:1:"F";a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:6:"create";}}}s:4:"rows";i:1;s:4:"cols";i:6;}}','size' => '','style' => '','modified' => '1139823458',);
$templ_data[] = array('name' => 'admin.remotes','template' => '','lang' => '','group' => '0','version' => '1.5.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:3:{s:2:"h2";s:9:",!@remote";s:2:"h1";s:6:",!@msg";s:2:"h3";s:2:",1";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:4:"name";s:3:"msg";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"remote";s:4:"span";s:10:"all,border";s:4:"name";s:18:"admin.remotes.edit";}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:26:"admin.remotes.header_right";}}i:4;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:18:"admin.remotes.rows";}}}s:4:"rows";i:4;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.border { border: black solid 2px; }','modified' => '1195926693',);

View File

@ -25,13 +25,14 @@
</rows>
</grid>
</template>
<template id="admin.customfields.fields" template="" lang="" group="0" version="1.4.001">
<template id="admin.customfields.fields" template="" lang="" group="0" version="1.5.001">
<grid>
<columns>
<column/>
<column/>
<column disabled="!@type2"/>
<column/>
<column disabled="!@use_private"/>
<column/>
<column/>
<column/>
@ -43,6 +44,7 @@
<description value="Label"/>
<description value="Subtype"/>
<description value="Type"/>
<description value="Private"/>
<description value="Options" statustext="each value is a line like &lt;id&gt;[=&lt;label&gt;]"/>
<description value="Length&lt;br&gt;Rows"/>
<description value="Order"/>
@ -58,6 +60,7 @@
<menupopup options="All" id="${row}[type2]" no_lang="1"/>
</menulist>
<customfields-types id="{$row}[type]" statustext="Type of customfield"/>
<checkbox id="${row}[private]" statustext="Should this custom field only be available if you have private rights" align="center"/>
<textbox multiline="true" rows="2" cols="30" id="${row}[values]" statustext="each value is a line like id[=label]"/>
<vbox>
<textbox size="5" id="${row}[len]" statustext="max length of the input [, length of the inputfield (optional)]"/>