Enable control of creating children in templates

This commit is contained in:
Deon George 2009-09-20 10:21:44 +10:00
parent d062308f32
commit f0a6d312ab
5 changed files with 19 additions and 7 deletions

View File

@ -36,9 +36,6 @@ if (! $request['container'])
$request['container'] = $tree->getEntry($request['template']->getContainer()); $request['container'] = $tree->getEntry($request['template']->getContainer());
if ($request['container']->isLeaf())
error(sprintf(_('The container (%s) is a leaf.'),$request['template']->getContainer()),'error','index.php');
# Check our RDN # Check our RDN
if (! count($request['template']->getRDNAttrs())) if (! count($request['template']->getRDNAttrs()))
error(_('The were no attributes marked as an RDN attribute.'),'error','index.php'); error(_('The were no attributes marked as an RDN attribute.'),'error','index.php');

View File

@ -30,9 +30,6 @@ if (! $request['container'])
$request['container'] = $tree->getEntry($request['template']->getContainer()); $request['container'] = $tree->getEntry($request['template']->getContainer());
if ($request['container']->isLeaf())
error(sprintf(_('The container (%s) is a leaf.'),$request['template']->getContainer()),'error','index.php');
# Check our RDN # Check our RDN
if (! count($request['template']->getRDNAttrs())) if (! count($request['template']->getRDNAttrs()))
error(_('The were no attributes marked as an RDN attribute.'),'error','index.php'); error(_('The were no attributes marked as an RDN attribute.'),'error','index.php');

View File

@ -45,6 +45,8 @@ class Template extends xmlTemplate {
private $dn; private $dn;
# Where this template will store its data # Where this template will store its data
protected $container; protected $container;
# Does this template prohibit children being created
private $noleaf = false;
# A regexp that determines if this template is valid in the container. # A regexp that determines if this template is valid in the container.
private $regexp; private $regexp;
# Template Title # Template Title
@ -54,6 +56,14 @@ class Template extends xmlTemplate {
# Template RDN attributes # Template RDN attributes
private $rdn; private $rdn;
public function __construct($server_id,$name=null,$filename=null,$type=null,$id=null) {
parent::__construct($server_id,$name,$filename,$type,$id);
# If this is the default template, we might disable leafs by default.
if (is_null($filename))
$this->noleaf = $_SESSION[APPCONFIG]->getValue('appearance','disable_default_leaf');
}
public function __clone() { public function __clone() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
@ -1501,5 +1511,9 @@ class Template extends xmlTemplate {
masort($attributes,'name'); masort($attributes,'name');
return $attributes; return $attributes;
} }
public function isNoLeaf() {
return $this->noleaf;
}
} }
?> ?>

View File

@ -902,7 +902,7 @@ class TemplateRender extends PageRender {
return ''; return '';
case 'childcreate': case 'childcreate':
if ($_SESSION[APPCONFIG]->isCommandAvailable('script','create') && ! $this->template->isReadOnly()) if ($_SESSION[APPCONFIG]->isCommandAvailable('script','create') && ! $this->template->isReadOnly() && ! $this->template->isNoLeaf())
return $this->getMenuItemCreate(); return $this->getMenuItemCreate();
else else
return ''; return '';

View File

@ -87,6 +87,10 @@ class Config {
'desc'=>'Disabled the Default Template', 'desc'=>'Disabled the Default Template',
'default'=>false); 'default'=>false);
$this->default->appearance['disable_default_leaf'] = array(
'desc'=>'Disabled creating leaf entries in the Default Template',
'default'=>false);
$this->default->appearance['friendly_attrs'] = array( $this->default->appearance['friendly_attrs'] = array(
'desc'=>'Friendly names for attributes', 'desc'=>'Friendly names for attributes',
'default'=>array()); 'default'=>array());