2019-02-08 13:44:52 -05:00
< ? php
/**
* This class will render the creation or editing of an LDAP entry .
*
* @ author The phpLDAPadmin development team
* @ package phpLDAPadmin
*/
/**
* TemplateRender class
*
* @ package phpLDAPadmin
* @ subpackage Templates
*/
class TemplateRender extends PageRender {
# Page number
private $pagelast ;
/** CORE FUNCTIONS **/
/**
* Initialise and Render the TemplateRender
2019-02-12 14:52:01 -05:00
* @ param bool $norender
2019-02-08 13:44:52 -05:00
*/
public function accept ( $norender = false ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s:%s</font><br />' , time (), __METHOD__ );
}
if ( DEBUGTMP || DEBUGTMPSUB )
{
printf ( '<font size=-2>* %s [Visit-Start:%s]</font><br />' , __METHOD__ , get_class ( $this ));
}
2019-02-08 13:44:52 -05:00
$tree = get_cached_item ( $this -> server_id , 'tree' );
if ( ! $tree )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$tree = Tree :: getInstance ( $this -> server_id );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$treeitem = $tree -> getEntry ( $this -> dn );
# If we have a DN, and no template_id, see if the tree has one from last time
if ( $this -> dn && is_null ( $this -> template_id ) && $treeitem && $treeitem -> getTemplate ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> template_id = $treeitem -> getTemplate ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
# Check that we have a valid template, or present a selection
# @todo change this so that the modification templates rendered are the ones for the objectclass of the dn.
if ( ! $this -> template_id )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> template_id = $this -> getTemplateChoice ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $treeitem )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$treeitem -> setTemplate ( $this -> template_id );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$this -> page = get_request ( 'page' , 'REQUEST' , false , 1 );
if ( $this -> template_id AND $this -> template_id != 'invalid' ) {
if ( ! $this -> template )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
parent :: accept ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$this -> url_base = sprintf ( 'server_id=%s&dn=%s' ,
$this -> getServerID (), $this -> template -> getDNEncode ());
$this -> layout [ 'hint' ] = sprintf ( '<td class="icon"><img src="%s/light.png" alt="%s" /></td><td colspan="3"><span class="hint">%%s</span></td>' ,
IMGDIR , _ ( 'Hint' ));
$this -> layout [ 'action' ] = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s">%s</a></td>' ;
$this -> layout [ 'actionajax' ] = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a></td>' ;
# If we dont want to render this template automatically, we'll return here.
if ( $norender )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$this -> visitStart ();
foreach ( $this -> template -> getAttributes ( true ) as $attribute ) {
# Evaluate our defaults
if ( $attribute -> getAutoValue ())
2019-02-12 14:57:50 -05:00
{
$this -> get ( 'Default' , $attribute ,
2019-02-12 15:34:47 -05:00
$this -> template -> getContainer () ? : $this -> getServer () -> getContainerPath ( $this -> template -> getDN ()),
2019-02-08 13:44:52 -05:00
'autovalue' );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
# If this is the default template, we should mark all our attributes to show().
if (( $this -> template -> getID () == 'none' ) && ( ! $attribute -> isInternal ())
&& (( $this -> template -> getContext () == 'edit' && $this -> template -> getID () == 'none' )
|| ( $this -> template -> getContext () == 'create' && $attribute -> getName () != 'objectclass' )))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$attribute -> show ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP || DEBUGTMPSUB )
{
printf ( '<font size=-2>* %s [Visit-End:%s]</font><br />' , __METHOD__ , get_class ( $this ));
}
2019-02-08 13:44:52 -05:00
$this -> visitEnd ();
}
}
protected function getDefaultAttribute ( $attribute , $container , $type ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
switch ( $type ) {
case 'autovalue' :
$autovalue = $attribute -> getAutoValue ();
break ;
case 'helpervalue' :
$autovalue = $attribute -> getHelperValue ();
break ;
default :
system_message ( array (
'title' => _ ( 'Unknown Default Attribute context' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'A call was made to getDefaultAttribute() with an unkown context' ), $type ),
'type' => 'warn' ));
return ;
}
$args = explode ( ';' , $autovalue [ 'args' ]);
$server = $this -> getServer ();
$vals = '' ;
switch ( $autovalue [ 'function' ]) {
/**
* Function enables normal PHP functions to be called to evaluate a value .
* eg : = php . Function ( date ; dmY )
*
* All arguments will be passed to the function , and its value returned .
* If this used used in a POST context , the attribute values can be used as arguments .
*
* Mandatory Arguments :
* * arg 0
* - php Function to call
*
* Additional arguments will be passed to the function .
*/
case 'Function' :
$function = array_shift ( $args );
if ( count ( $args ) && count ( $args ) > 1 ) {
system_message ( array (
'title' => _ ( 'Too many arguments' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'Function() only takes two arguments and more than two were specified' ), count ( $args )),
'type' => 'warn' ));
return ;
}
$function_args = explode ( ',' , $args [ 0 ]);
if ( function_exists ( $function ))
2019-02-12 14:57:50 -05:00
{
$vals = call_user_func_array ( $function , $function_args );
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
system_message ( array (
2019-02-12 14:57:50 -05:00
'title' => _ ( 'Function doesnt exist' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'An attempt was made to call a function that doesnt exist' ), $function ),
'type' => 'warn' ));
}
2019-02-08 13:44:52 -05:00
break ;
/**
* GetNextNumber will query the LDAP server and calculate the next number based on the query
* eg : <! [ CDATA [ = php . GetNextNumber ( / ; gidNumber ; false ;( & ( objectClass = posixGroup )); * 2 , + 1000 )]] >
*
* Mandatory Arguments :
* * arg 0
* - " $ " => 'auto_number' , 'search_base' in config file
* - " / " , " . " , " .. " => get container parent as usual
*
* * arg 1
* - attribute to query for
*
* Optional Arguments :
* * arg 2 ( pool mechanism only )
* - " true " increments attribute by 1
* - " false " do nothing
*
* * arg 3 ( pool mechanism only )
* - ldap filter ( must match one entry only in container )
*
* * arg 4
* - calculus on number , eg :
* - * 2 , + 1000 => number = ( 2 * number ) + 1000
*
* * arg 5
* - Min number
*/
case 'GetNextNumber' :
# If the attribute already has values, we'll return
if ( $type == 'autovalue' && $attribute -> getValues ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $args [ 0 ] == '$' )
2019-02-12 14:57:50 -05:00
{
$args [ 0 ] = $server -> getValue ( $this -> server_id , 'auto_number' , 'search_base' );
}
2019-02-08 13:44:52 -05:00
$container = $server -> getContainerPath ( $container , $args [ 0 ]);
$vals = get_next_number ( $container , $args [ 1 ],
( ! empty ( $args [ 2 ]) && ( $args [ 2 ] == 'false' )) ? false : true ,
( ! empty ( $args [ 3 ])) ? $args [ 3 ] : false ,
( ! empty ( $args [ 5 ])) ? $args [ 5 ] : null );
# Operate calculus on next number.
if ( ! empty ( $args [ 4 ])) {
$mod = explode ( ',' , $args [ 4 ]);
$next_number = $vals ;
foreach ( $mod as $calc ) {
$operand = $calc { 0 };
$operator = substr ( $calc , 1 );
switch ( $operand ) {
case '*' :
2019-02-12 14:57:50 -05:00
$next_number *= $operator ;
2019-02-08 13:44:52 -05:00
break ;
case '+' :
2019-02-12 14:57:50 -05:00
$next_number += $operator ;
2019-02-08 13:44:52 -05:00
break ;
case '-' :
2019-02-12 14:57:50 -05:00
$next_number -= $operator ;
2019-02-08 13:44:52 -05:00
break ;
case '/' :
2019-02-12 14:57:50 -05:00
$next_number /= $operator ;
2019-02-08 13:44:52 -05:00
break ;
}
}
$vals = $next_number ;
}
break ;
/**
* PickList will query the LDAP server and provide a select list of values
* MultiList will query the LDAP server and provide a multi select list of values
* eg : <! [ CDATA [ = php . MultiList ( / ;( objectClass = posixAccount ); uid )]] >
*
* eg : <! [ CDATA [ = php . MultiList ( / ;( & ( objectClass = posixAccount )( uid = groupA * )); uid ; % cn / U % ( % gidNumber % ); memberUid ; dmdName = users ; root => cn = root , nobody => cn = nobody ; gidNumber ; 10 )]] >
*
* Mandatory Arguments :
* * arg 0
* - container , to query from current position
* - " / " , " . " , " .. " => get container parent as usual
*
* * arg 1
* - LDAP filter . May include '%attr%' , it will be expanded .
*
* * arg2
* - list attribute key
*
* Optional Arguments :
* * arg3
* - select display ( plus modifier / C : Capitalize )
* - replaced by % arg 2 % if not given
*
* * arg 4
* - the value furnished in output - must be attribute id . replaced by arg 2 if not given
*
* * arg 5
* - container override
*
* * arg 6
* - csv list (, separator ) of added values . syntax : key => display_attribute = value , key ...
*
* * arg 7
* - csv list (, separator ) of sort attributes ( less to more important )
*
* * arg 8 ( for MultiList )
* - size of displayed list ( default : 10 lines )
*/
case 'MultiList' :
case 'PickList' :
# arg5 overrides our container
if ( empty ( $args [ 5 ]))
2019-02-12 14:57:50 -05:00
{
$container = $server -> getContainerPath ( $container , $args [ 0 ]);
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$container = $args [ 5 ];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
# Process filter (arg 1), eventually replace %attr% by it's value set in a previous page.
preg_match_all ( '/%(\w+)(\|.+)?(\/[lUC])?%/U' , $args [ 1 ], $filtermatchall );
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
if ( isset ( $_REQUEST [ 'form' ])) {
$formvalues = array_change_key_case ( $_REQUEST [ 'form' ]);
foreach ( $filtermatchall [ 1 ] as $arg ) {
$value = $formvalues [ strtolower ( $arg )];
$args [ 1 ] = preg_replace ( " /%( $arg )( \ |.+)?( \ /[lU])?%/U " , $value , $args [ 1 ]);
}
}
if ( empty ( $args [ 3 ]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$args [ 3 ] = " % { $args [ 2 ] } % " ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
preg_match_all ( '/%(\w+)(\|.+)?(\/[lUC])?%/U' , $args [ 3 ], $matchall );
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
$attrs = array_unique ( array_merge ( $matchall [ 1 ], array ( $args [ 2 ])));
# arg7 is sort attributes
if ( isset ( $args [ 7 ])) {
$sort_attrs = explode ( ',' , $args [ 7 ]);
$attrs = array_unique ( array_merge ( $attrs , $sort_attrs ));
}
$picklistvalues = return_ldap_hash ( $container , $args [ 1 ], $args [ 2 ], $attrs ,( isset ( $args [ 7 ]) && ( $args [ 7 ])) ? $sort_attrs : false );
# arg6 is a set of fixed values to add to search result
if ( isset ( $args [ 6 ])) {
$fixedvalues = explode ( ',' , $args [ 6 ]);
foreach ( $fixedvalues as $fixedvalue ) {
if ( empty ( $fixedvalue ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
continue ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$fixedvalue = preg_split ( '/=\>/' , $fixedvalue );
$displayvalue = explode ( '=' , $fixedvalue [ 1 ]);
$newvalue [ trim ( $fixedvalue [ 0 ])] = array ( $args [ 2 ] => trim ( $fixedvalue [ 0 ]), trim ( $displayvalue [ 0 ]) => trim ( $displayvalue [ 1 ]));
$picklistvalues = array_merge ( $picklistvalues , $newvalue );
}
}
$vals = array ();
foreach ( $picklistvalues as $key => $values ) {
$display = $args [ 3 ];
foreach ( $matchall [ 1 ] as $key => $arg ) {
if ( isset ( $values [ $arg ]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$disp_val = $values [ $arg ];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$disp_val = '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( is_array ( $disp_val ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$disp_val = $disp_val [ 0 ];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $matchall [ 3 ][ $key ])
2019-02-12 14:57:50 -05:00
{
switch ( $matchall [ 3 ][ $key ])
{
2019-02-08 13:44:52 -05:00
case '/l' :
2019-02-12 14:57:50 -05:00
# lowercase
2019-02-08 13:44:52 -05:00
if ( function_exists ( 'mb_convert_case' ))
2019-02-12 14:57:50 -05:00
{
$disp_val = mb_convert_case ( $disp_val , MB_CASE_LOWER , 'utf-8' );
} else
{
2019-02-08 13:44:52 -05:00
$disp_val = strtolower ( $disp_val );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
break ;
case '/U' :
2019-02-12 14:57:50 -05:00
# uppercase
2019-02-08 13:44:52 -05:00
if ( function_exists ( 'mb_convert_case' ))
2019-02-12 14:57:50 -05:00
{
$disp_val = mb_convert_case ( $disp_val , MB_CASE_UPPER , 'utf-8' );
} else
{
2019-02-08 13:44:52 -05:00
$disp_val = strtoupper ( $disp_val );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
break ;
2019-02-08 13:44:52 -05:00
case '/C' :
2019-02-12 14:57:50 -05:00
# capitalize
2019-02-08 13:44:52 -05:00
if ( function_exists ( 'mb_convert_case' ))
2019-02-12 14:57:50 -05:00
{
$disp_val = mb_convert_case ( $disp_val , MB_CASE_TITLE , 'utf-8' );
} else
{
2019-02-08 13:44:52 -05:00
$disp_val = ucfirst ( $disp_val );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
break ;
default :
break ;
}
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
# make value a substring of
preg_match_all ( '/^\|([0-9]*)-([0-9]*)$/' , trim ( $matchall [ 2 ][ $key ]), $substrarray );
if (( isset ( $substrarray [ 1 ][ 0 ]) && $substrarray [ 1 ][ 0 ]) || ( isset ( $substrarray [ 2 ][ 0 ]) && $substrarray [ 2 ][ 0 ])) {
$begin = $substrarray [ 1 ][ 0 ] ? $substrarray [ 1 ][ 0 ] : '0' ;
$end = $substrarray [ 2 ][ 0 ] ? $substrarray [ 2 ][ 0 ] : strlen ( $disp_val );
if ( function_exists ( 'mb_substr' ))
2019-02-12 14:57:50 -05:00
{
$disp_val = mb_substr ( $disp_val , $begin , $end , 'utf-8' );
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$disp_val = substr ( $disp_val , $begin , $end );
}
2019-02-08 13:44:52 -05:00
}
$display = preg_replace ( " /%( $arg )( \ |.+)?( \ /[lUC])?%/U " , $disp_val , $display );
}
if ( ! isset ( $picklist [ $values [ $args [ 2 ]]])) {
$vals [ $values [ $args [ 2 ]]] = $display ;
$picklist [ $values [ $args [ 2 ]]] = true ;
}
}
break ;
/**
* PasswordEncryptionTypes will return a list of our support password encryption types
* eg : = php . PasswordEncryptionTypes ()
*
* This function doesnt use any arguments
*/
case 'PasswordEncryptionTypes' :
$vals = password_types ();
break ;
/**
* RandomPassword will create a random password for the value .
* eg : = php . RandomPassword ()
*
* When calling the attribute Javascript it will generate a random password .
*
* This function doesnt use any arguments
*/
case 'RandomPassword' :
break ;
}
switch ( $type ) {
case 'autovalue' :
if ( ! is_array ( $vals ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$attribute -> autoValue ( array ( $vals ));
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$attribute -> autoValue ( $vals );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
break ;
case 'helpervalue' :
return $vals ;
}
}
/**
* Set the mode of the TemplateRender
* Applicable modes are " create " or " edit "
*/
protected function getMode () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
if ( $this -> dn )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return 'modification' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
elseif ( $this -> container )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return 'creation' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
elseif ( get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return 'creation' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
debug_dump_backtrace ( sprintf ( 'Unknown mode for %s' , __METHOD__ ), 1 );
}
2019-02-08 13:44:52 -05:00
}
/**
* Return the container for this mode
*/
protected function getModeContainer () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
switch ( $this -> getMode ()) {
case 'creation' :
return $this -> container ;
break ;
case 'modification' :
return $this -> dn ;
break ;
default :
return null ;
}
}
/**
* Is the default template enabled ?
*/
protected function haveDefaultTemplate () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'disable_default_template' ))
2019-02-12 14:57:50 -05:00
{
return FALSE ;
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return TRUE ;
}
2019-02-08 13:44:52 -05:00
}
/**
* Present a list of available templates for creating and editing LDAP entries
*/
protected function drawTemplateChoice () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> drawTitle ();
$this -> drawSubTitle ();
echo " \n " ;
switch ( $this -> getMode ()) {
case 'creation' :
$msg = _ ( 'Select a template for the creation process' );
break ;
case 'modification' :
$msg = _ ( 'Select a template to edit the entry' );
break ;
}
$avail_templates = $this -> getTemplates ();
$templates = $avail_templates -> getTemplates ( $this -> getMode (), $this -> getModeContainer ());
printf ( '<h3 style="text-align: center;">%s</h3>' , $msg );
$href_parms = array_to_query_string ( $_GET , array ( 'meth' ));
printf ( '<form id="template_choice_form" action="cmd.php?%s" method="post">' , htmlspecialchars ( $href_parms ));
echo " \n \n " ;
if ( count ( $_POST )) {
echo '<div>' ;
foreach ( $_POST as $p => $v )
2019-02-12 14:57:50 -05:00
{
printf ( '<input type="hidden" name="%s" value="%s" />' , $p , $v );
}
2019-02-08 13:44:52 -05:00
echo '</div>' ;
echo " \n \n " ;
}
echo '<table class="forminput" width="100%" border="0">' ;
echo '<tr>' ;
printf ( '<td class="heading" style="vertical-align: top">%s:</td>' , _ ( 'Templates' ));
echo '<td>' ;
echo '<table>' ;
$i = - 1 ;
$nb_templates = count ( $templates );
if ( $this -> haveDefaultTemplate ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$nb_templates ++ ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
foreach ( $templates as $name => $details ) {
$i ++ ;
$isInValid = $details -> isInValid ();
# Balance the columns properly
if (( $nb_templates % 2 == 0 && $i == intval ( $nb_templates / 2 )) ||
( $nb_templates % 2 == 1 && $i == intval ( $nb_templates / 2 ) + 1 )) {
echo '</table></td><td><table>' ;
}
echo " \n " ;
echo '<tr>' ;
if ( $isInValid )
2019-02-12 14:57:50 -05:00
{
printf ( '<td class="icon"><img src="%s/disabled.png" alt="Disabled" /></td>' , IMGDIR );
}
2019-02-08 13:44:52 -05:00
else {
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<td><input type="radio" name="template" value="%s" id="%s" onclick="return ajDISPLAY(\'BODY\',\'%s&template=%s\',\'%s\');" /></td>' ,
2019-02-12 14:57:50 -05:00
htmlspecialchars ( $details -> getID ()), htmlspecialchars ( $details -> getID ()), htmlspecialchars ( $href_parms ), $details -> getID (), str_replace ( '\'' , '\\\'' , _ ( 'Retrieving DN' )));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<td><input type="radio" name="template" value="%s" id="%s" onclick="document.getElementById(\'template_choice_form\').submit()" /></td>' ,
2019-02-12 14:57:50 -05:00
htmlspecialchars ( $details -> getID ()), htmlspecialchars ( $details -> getID ()));
}
2019-02-08 13:44:52 -05:00
}
printf ( '<td class="icon"><label for="%s"><img src="%s" alt="" /></label></td>' ,
htmlspecialchars ( $details -> getID ()), $details -> getIcon ());
printf ( '<td class="label"><label for="%s">' ,
htmlspecialchars ( $details -> getID ()));
if ( $isInValid )
2019-02-12 14:57:50 -05:00
{
printf ( '<span id="%s" style="color: gray"><acronym title="%s">' , htmlspecialchars ( $details -> getID ()), _ ( $isInValid ));
}
2019-02-08 13:44:52 -05:00
echo _ ( $details -> getTitle ());
if ( $isInValid )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '</acronym></span>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</label></td>' ;
echo '</tr>' ;
}
echo " \n " ;
# Default template
if ( $this -> haveDefaultTemplate ()) {
$i ++ ;
# Balance the columns properly
if (( $nb_templates % 2 == 0 && $i == intval ( $nb_templates / 2 )) ||
( $nb_templates % 2 == 1 && $i == intval ( $nb_templates / 2 ) + 1 )) {
echo '</table></td><td><table>' ;
}
echo '<tr>' ;
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<td><input type="radio" name="template" value="none" id="none" onclick="return ajDISPLAY(\'BODY\',\'%s&template=%s\',\'%s\');" /></td>' ,
2019-02-12 14:57:50 -05:00
htmlspecialchars ( $href_parms ), 'none' , str_replace ( '\'' , '\\\'' , _ ( 'Retrieving DN' )));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<td><input type="radio" name="template" value="none" id="none" onclick="document.getElementById(\'template_choice_form\').submit()" /></td>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
printf ( '<td class="icon"><label for="none"><img src="%s/ldap-default.png" alt="" /></label></td>' , IMGDIR );
printf ( '<td class="label"><label for="none">%s</label></td>' , _ ( 'Default' ));
echo '</tr>' ;
}
echo '</table>' ;
echo '</td></tr>' ;
echo '</table>' ;
echo '</form>' ;
}
/** VISIT METHODS **/
/**
* This function will setup our template object ( read LDAP for current values , read $_REQUEST for new values , etc )
* so that it can be rendered .
*/
private function visitStart () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# If we have a DN, then we are an editing template
if ( $this -> dn )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> template -> setDN ( $this -> dn );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
# Else if we have a container, we are a creating template
elseif ( $this -> container || get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> template -> setContainer ( $this -> container );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
debug_dump_backtrace ( 'Dont know what type of template we are - no DN or CONTAINER?' , 1 );
}
2019-02-08 13:44:52 -05:00
# Header
$this -> drawHeader ();
}
private function visitEnd () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
foreach ( $this -> template -> getAttributesShown () as $attribute )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
if ( $attribute -> getPage () > $this -> pagelast )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> pagelast = $attribute -> getPage ();
2019-02-12 14:57:50 -05:00
}
}
2019-02-08 13:44:52 -05:00
echo " \n \n " ;
if ( $this -> template -> getContext () == 'create' ) {
$this -> drawStepTitle ( $this -> page );
$this -> drawStepFormStart ( $this -> page );
$this -> drawStepForm ( $this -> page );
$this -> drawStepFormEnd ();
} elseif ( $this -> template -> getContext () == 'copyasnew' ) {
$this -> drawStepFormStart ( $this -> page );
printf ( '<input type="hidden" name="container" value="%s" />' , $this -> template -> getContainer ( false ));
echo '<div><table>' ;
$this -> drawRDNChooser ();
echo '</table></div>' ;
$this -> drawForm ( true );
$this -> drawStepFormSubmitButton ( $this -> page );
} else {
# Draw internal attributes
if ( get_request ( 'show_internal_attrs' , 'REQUEST' )) {
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">' ;
$this -> drawInternalAttributes ();
echo '</table><br/>' ;
echo " \n " ;
}
$this -> drawFormStart ();
# To support our AJAX add Attribute
printf ( '<div id="ajADD" style="display: %s"></div>' , 'none' );
$this -> drawForm ();
$this -> drawStepFormEnd ();
}
}
/** PAGE DRAWING METHODS **/
private function drawHeader () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# Title
$this -> drawTitle ();
if ( get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
$this -> drawSubTitle ( sprintf ( '<b>%s</b>: %s' , _ ( 'Creating Base DN' ), $this -> template -> getDN ()));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> drawSubTitle ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo " \n " ;
# Menu
$this -> drawMenu ();
}
public function drawTitle ( $title = null ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( is_null ( $title ))
2019-02-12 14:57:50 -05:00
{
switch ( $this -> getMode ())
{
2019-02-08 13:44:52 -05:00
case 'creation' :
$title = _ ( 'Create Object' );
break ;
case 'modification' :
$title = htmlspecialchars ( get_rdn ( $this -> dn ));
break ;
default :
$title = 'Title' ;
}
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
parent :: drawTitle ( $title );
}
public function drawSubTitle ( $subtitle = null ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( $subtitle )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return parent :: drawSubTitle ( $subtitle );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
switch ( $this -> getMode ()) {
case 'creation' :
$subtitle = sprintf ( '%s: <b>%s</b> %s: <b>%s</b>' ,
_ ( 'Server' ), $this -> getServer () -> getName (),
_ ( 'Container' ), htmlspecialchars ( $this -> container ));
if ( $this -> template_id ) {
$subtitle .= '<br />' ;
$subtitle .= sprintf ( '%s: <b>%s</b>' , _ ( 'Template' ), $this -> template -> getID () != 'none' ? $this -> template -> getTitle () : _ ( 'Default' ));
if ( $this -> template -> getName ())
2019-02-12 14:57:50 -05:00
{
$subtitle .= sprintf ( ' (<b>%s</b>)' , $this -> template -> getName ( FALSE ));
}
2019-02-08 13:44:52 -05:00
}
break ;
case 'modification' :
$subtitle = sprintf ( '%s: <b>%s</b> %s: <b>%s</b>' ,
_ ( 'Server' ), $this -> getServer () -> getName (),
_ ( 'Distinguished Name' ), htmlspecialchars ( $this -> dn ));
if ( $this -> template_id ) {
$subtitle .= '<br />' ;
$subtitle .= sprintf ( '%s: <b>%s</b>' , _ ( 'Template' ), $this -> template -> getID () != 'none' ? $this -> template -> getTitle () : _ ( 'Default' ));
if ( $this -> template -> getName ())
2019-02-12 14:57:50 -05:00
{
$subtitle .= sprintf ( ' (<b>%s</b>)' , $this -> template -> getName ( FALSE ));
}
2019-02-08 13:44:52 -05:00
}
break ;
}
parent :: drawSubTitle ( $subtitle );
}
/** PAGE ENTRY MENU **/
private function drawMenu () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# We only have a menu for editing entries.
if ( $this -> template -> getContext () == 'edit' ) {
echo '<table class="menu" width="100%" border="0">' ;
echo '<tr>' ;
$menuitem_number = 0 ;
foreach ( array ( 'entryrefresh' , 'showinternal' , 'switchtemplate' , 'entryexport' , 'entrycopy' , 'entrydelete' , 'entryrename' , 'entrycompare' , 'childcreate' , 'addattr' , 'msgdel' , 'childview' , 'childexport' , 'msgschema' , 'msgro' , 'msgmodattr' ) as $item ) {
$item = $this -> getMenuItem ( $item );
if ( $item ) {
$endofrow = false ;
$start = true ;
$it = '' ; // menu item
$ms = '' ; // item message
if ( is_array ( $item ) && count ( $item ) > 0 ) {
$it = $item [ 0 ];
if ( count ( $item ) > 1 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$ms = $item [ 1 ];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
} else {
$it = $item ;
}
if ( $it ) {
$menuitem_number ++ ;
echo $it ;
if ( $ms ) {
if (( $menuitem_number % 2 ) == 1 ) {
$menuitem_number ++ ;
echo '<td colspan="2"> </td>' ;
$endofrow = false ;
$start = false ;
}
if ( $endofrow )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
print $ms ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo " </tr><tr> $ms " ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</tr><tr>' ;
$endofrow = true ;
$start = false ;
} else {
if ( $menuitem_number > 1 && ( $menuitem_number % 2 ) == 0 ) {
echo '</tr><tr>' ;
$endofrow = true ;
$start = false ;
}
}
} elseif ( $ms ) {
if (( $menuitem_number % 2 ) == 1 ) {
$menuitem_number ++ ;
echo '<td colspan="2"> </td>' ;
$endofrow = false ;
$start = false ;
}
if ( $endofrow || $start )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
print $ms ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo " </tr><tr> $ms " ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</tr><tr>' ;
$endofrow = true ;
$start = false ;
}
echo " \n " ;
}
}
if (( $menuitem_number % 2 ) == 1 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<td> </td><td> </td>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<td> </td><td> </td><td> </td><td> </td>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</tr>' ;
echo '</table>' ;
}
}
2019-02-12 14:52:01 -05:00
/** PAGE ENTRY MENU ITEMS *
* @ param $i
* @ return array | bool
*/
2019-02-08 13:44:52 -05:00
private function getMenuItem ( $i ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s (%s)</font><br />' , __METHOD__ , $i );
}
2019-02-08 13:44:52 -05:00
switch ( $i ) {
case 'entryrefresh' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'cmd' , 'entry_refresh' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemRefresh ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'switchtemplate' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'cmd' , 'switch_template' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemSwitchTemplate ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'entryexport' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'export_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'export' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemExportBase ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'entrycopy' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'copy_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'copy' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemMove ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'showinternal' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'cmd' , 'entry_internal_attributes_show' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemInternalAttributes ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'entrydelete' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'delete_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'delete' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemDelete ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'entryrename' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'rename_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'rename' ) && ! $this -> template -> isReadOnly ()) {
# Check if any of the RDN's are read only.
$rdnro = false ;
foreach ( $this -> template -> getRDNAttributeName () as $attr ) {
$attribute = $this -> template -> getAttribute ( $attr );
if ( $attribute && $attribute -> isVisible () && ! $attribute -> isReadOnly ()) {
$rdnro = true ;
break ;
}
}
if ( ! $rdnro )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemRename ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
return '' ;
case 'msgdel' :
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'show_hints' )
&& $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'delete_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'delete' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
return array ( '' , $this -> getDeleteAttributeMessage ());
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'entrycompare' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'compare_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'compare' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemCompare ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'childcreate' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'create' ) && ! $this -> template -> isReadOnly () && ! $this -> template -> isNoLeaf ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemCreate ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'addattr' :
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'add_attr_form' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemAddAttribute ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'childview' :
case 'childexport' :
static $children_count = false ;
static $more_children = false ;
$tree = get_cached_item ( $this -> getServerID (), 'tree' );
$tree_item = $tree -> getEntry ( $this -> template -> getDN ());
if ( ! $tree_item ) {
$tree -> addEntry ( $this -> template -> getDN ());
$tree_item = $tree -> getEntry ( $this -> template -> getDN ());
}
if ( $children_count === false ) {
# Visible children in the tree
$children_count = count ( $tree_item -> getChildren ());
# Is there filtered children ?
$more_children = $tree_item -> isSizeLimited ();
if ( ! $children_count || ! $more_children ) {
# All children in ldap
$all_children = $this -> getServer () -> getContainerContents (
$this -> template -> getDN (), null , $children_count + 1 , '(objectClass=*)' , $_SESSION [ APPCONFIG ] -> getValue ( 'deref' , 'view' ), null );
$more_children = ( count ( $all_children ) > $children_count );
}
}
if ( $children_count > 0 || $more_children ) {
if ( $children_count <= 0 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$children_count = '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $more_children )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$children_count .= '+' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $i == 'childview' )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemShowChildren ( $children_count );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
elseif ( $i == 'childexport' && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'export_form' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'export' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return $this -> getMenuItemExportSub ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
} else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'msgschema' :
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'show_hints' ) && $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'schema' ))
2019-02-12 14:57:50 -05:00
{
return array ( '' , $this -> getViewSchemaMessage ());
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return array ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'msgro' :
if ( $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
return array ( '' , $this -> getReadOnlyMessage ());
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return array ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'msgmodattr' :
$modified_attrs = array ();
$modified = get_request ( 'modified_attrs' , 'REQUEST' , false , array ());
foreach ( $this -> template -> getAttributes ( true ) as $attribute )
2019-02-12 14:57:50 -05:00
{
if ( in_array ( $attribute -> getName (), $modified ))
{
2019-02-12 15:23:38 -05:00
$modified_attrs [] = $attribute -> getFriendlyName ();
2019-02-12 14:57:50 -05:00
}
}
2019-02-08 13:44:52 -05:00
if ( count ( $modified_attrs ))
2019-02-12 14:57:50 -05:00
{
return array ( '' , $this -> getModifiedAttributesMessage ( $modified_attrs ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return array ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
default :
return false ;
}
}
protected function getDeleteAttributeMessage () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'delete_attr' ) && ! $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'hint' ], _ ( 'Hint: To delete an attribute, empty the text field and click save.' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
protected function getModifiedAttributesMessage ( & $modified_attributes ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
return sprintf ( $this -> layout [ 'hint' ],
( count ( $modified_attributes ) == 1 ) ?
sprintf ( _ ( 'An attribute (%s) was modified and is highlighted below.' ), implode ( '' , $modified_attributes )) :
sprintf ( _ ( 'Some attributes (%s) were modified and are highlighted below.' ), implode ( ', ' , $modified_attributes )));
}
protected function getReadOnlyMessage () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
return sprintf ( $this -> layout [ 'hint' ], _ ( 'Viewing entry in read-only mode.' ));
}
protected function getViewSchemaMessage () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
return sprintf ( $this -> layout [ 'hint' ], _ ( 'Hint: To view the schema for an attribute, click the attribute name.' ));
}
/** PAGE ENTRY MENU ITEMS DETAILS **/
private function getMenuItemRefresh () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=template_engine&%s&junk=%s' , $this -> url_base , random_junk ());
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'refresh.png' , _ ( 'Refresh' ),
htmlspecialchars ( $href ), _ ( 'Refresh this entry' ), htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Reloading' )), _ ( 'Refresh' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'refresh.png' , _ ( 'Refresh' ),
htmlspecialchars ( $href ), _ ( 'Refresh this entry' ), _ ( 'Refresh' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemSwitchTemplate () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=template_engine&%s&template=' , $this -> url_base );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'switch.png' , _ ( 'Switch Template' ),
htmlspecialchars ( $href ), _ ( 'Change to another template' ), htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Switch Template' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'switch.png' , _ ( 'Switch Template' ),
htmlspecialchars ( $href ), _ ( 'Change to another template' ), _ ( 'Switch Template' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemExportBase () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=export_form&%s&scope=base' , $this -> url_base );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'export.png' , _ ( 'Export' ),
htmlspecialchars ( $href ), _ ( 'Save a dump of this object' ), htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Export' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'export.png' , _ ( 'Export' ),
htmlspecialchars ( $href ), _ ( 'Save a dump of this object' ), _ ( 'Export' ));
}
2019-02-08 13:44:52 -05:00
}
private function getMenuItemMove () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=copy_form&%s' , $this -> url_base );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'cut.png' , _ ( 'Cut' ),
htmlspecialchars ( $href ), _ ( 'Copy this object to another location, a new DN, or another server' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Copy or move this entry' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'cut.png' , _ ( 'Cut' ),
htmlspecialchars ( $href ), _ ( 'Copy this object to another location, a new DN, or another server' ),
2019-02-08 13:44:52 -05:00
_ ( 'Copy or move this entry' ));
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemInternalAttributes () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( get_request ( 'show_internal_attrs' , 'REQUEST' )) {
$href = sprintf ( 'cmd=template_engine&%s&junk=' , $this -> url_base , random_junk ());
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'tools-no.png' , _ ( 'Hide' ),
htmlspecialchars ( $href ), '' , _ ( 'Hide internal attributes' ));
} else {
$href = sprintf ( 'cmd=template_engine&show_internal_attrs=true&%s' , $this -> url_base );
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'tools.png' , _ ( 'Show' ),
htmlspecialchars ( $href ), '' , _ ( 'Show internal attributes' ));
}
}
private function getMenuItemDelete () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=delete_form&%s' , $this -> url_base );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'trash.png' , _ ( 'Trash' ),
htmlspecialchars ( $href ), _ ( 'You will be prompted to confirm this decision' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Delete this entry' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'trash.png' , _ ( 'Trash' ),
htmlspecialchars ( $href ), _ ( 'You will be prompted to confirm this decision' ), _ ( 'Delete this entry' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemRename () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=rename_form&%s&template=%s' , $this -> url_base , $this -> template -> getID ());
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'rename.png' , _ ( 'Rename' ),
htmlspecialchars ( $href ), _ ( 'Rename this entry' ), htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Rename' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'rename.png' , _ ( 'Rename' ),
htmlspecialchars ( $href ), _ ( 'Rename this entry' ), _ ( 'Rename' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemCompare () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=compare_form&%s' , $this -> url_base );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'compare.png' , _ ( 'Compare' ),
htmlspecialchars ( $href ), _ ( 'Compare this entry with another' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Compare with another entry' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'compare.png' , _ ( 'Compare' ),
htmlspecialchars ( $href ), _ ( 'Compare this entry with another' ), _ ( 'Compare with another entry' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemCreate () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=template_engine&server_id=%s&container=%s' , $this -> getServerID (), $this -> template -> getDNEncode ());
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'create.png' , _ ( 'Create' ),
htmlspecialchars ( $href ), _ ( 'Create a child entry' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Create a child entry' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'create.png' , _ ( 'Create' ),
htmlspecialchars ( $href ), _ ( 'Create a child entry' ), _ ( 'Create a child entry' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemAddAttribute () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( ! $this -> template -> getAvailAttrs ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=add_attr_form&%s' , $this -> url_base );
$layout = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s" onclick="getDiv(\'ADD\').style.display = \'block\';return ajDISPLAY(\'ADD\',\'%s\',\'%s\');">%s</a></td>' ;
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $layout , IMGDIR , 'add.png' , _ ( 'Add' ),
htmlspecialchars ( $href ), _ ( 'Add new attribute to this object' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Add new attribute' )), _ ( 'Add new attribute' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'add.png' , _ ( 'Add' ),
htmlspecialchars ( $href ), _ ( 'Add new attribute to this object' ), _ ( 'Add new attribute' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemShowChildren ( $children_count ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=query_engine&server_id=%s&filter=%s&base=%s&scope=one&query=none&size_limit=0&search=true' ,
$this -> getServerID (), rawurlencode ( 'objectClass=*' ), $this -> template -> getDNEncode ());
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'children.png' , _ ( 'Children' ),
htmlspecialchars ( $href ), _ ( 'View the children of this object' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )),
( $children_count == 1 ) ? _ ( 'View 1 child' ) : sprintf ( _ ( 'View %s children' ), $children_count ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'children.png' , _ ( 'Children' ),
htmlspecialchars ( $href ), _ ( 'View the children of this object' ),
( $children_count == 1 ) ? _ ( 'View 1 child' ) : sprintf ( _ ( 'View %s children' ), $children_count ));
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemExportSub () {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=export_form&%s&scope=%s' , $this -> url_base , 'sub' );
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'actionajax' ], IMGDIR , 'export.png' , _ ( 'Save' ),
htmlspecialchars ( $href ), _ ( 'Save a dump of this object and all of its children' ),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Loading' )), _ ( 'Export subtree' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
return sprintf ( $this -> layout [ 'action' ], IMGDIR , 'export.png' , _ ( 'Save' ),
htmlspecialchars ( $href ), _ ( 'Save a dump of this object and all of its children' ), _ ( 'Export subtree' ));
}
2019-02-08 13:44:52 -05:00
}
/** CHOOSERS **/
/**
* RDN Chooser
*/
protected function drawRDNChooser () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( ! count ( $this -> template -> getRDNAttrs ())) {
printf ( '<tr><th colspan="2">%s</th></tr>' , 'RDN' );
echo '<tr><td class="value" colspan="2" style="text-align: center;"><select name="rdn_attribute[]" id="rdn_attribute" />' ;
printf ( '<option value="">%s</option>' , _ ( 'select the rdn attribute' ));
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'rdn_all_attrs' ))
2019-02-12 14:57:50 -05:00
{
$allattrs = TRUE ;
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$allattrs = FALSE ;
}
2019-02-08 13:44:52 -05:00
foreach ( $this -> template -> getAttributes ( $allattrs ) as $attr ) {
$n = $attr -> getName ( false );
if ( $attr -> getName () != 'objectclass' ) {
$m = $attr -> getFriendlyName ();
$b = ' ' ;
printf ( '<option value="%s">%s%s(%s)</option>' , $n , $m , $b , $n );
}
}
echo '</select></td></tr>' ;
} else {
echo '<tr><td colspan="2">' ;
foreach ( $this -> template -> getRDNAttrs () as $rdn )
2019-02-12 14:57:50 -05:00
{
printf ( '<input type="hidden" name="rdn_attribute[]" value="%s" id="rdn_attribute"/>' , htmlspecialchars ( $rdn ));
}
2019-02-08 13:44:52 -05:00
if ( get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="create_base" value="true" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</td></tr>' ;
}
}
/**
* Container Chooser
2019-02-12 14:52:01 -05:00
* @ param $default_container
2019-02-08 13:44:52 -05:00
*/
protected function drawContainerChooser ( $default_container ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
echo '<tr>' ;
printf ( '<td class="heading">%s</td>' , _ ( 'Container' ));
echo '<td>' ;
if ( get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
printf ( '%s<input type="hidden" name="container" size="40" value="%s" />' , $default_container , htmlspecialchars ( $default_container ));
}
2019-02-08 13:44:52 -05:00
else {
printf ( '<input type="text" name="container" size="40" value="%s" />' , htmlspecialchars ( $default_container ));
draw_chooser_link ( 'entry_form' , 'container' );
}
echo '</td>' ;
echo '</tr>' ;
}
/**
* Object Class Chooser
*/
protected function drawObjectClassChooser () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$socs = $this -> getServer () -> SchemaObjectClasses ();
if ( ! $socs )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$socs = array ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '<tr>' ;
printf ( '<td class="heading">%s</td>' , _ ( 'ObjectClasses' ));
echo '<td><select name="new_values[objectclass][]" multiple="multiple" size="15">' ;
foreach ( $socs as $name => $oclass ) {
if ( ! strcasecmp ( 'top' , $name ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
continue ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
printf ( '<option %s value="%s">%s</option>' ,
( $oclass -> getType () == 'structural' ) ? 'style="font-weight: bold" ' : '' ,
htmlspecialchars ( $oclass -> getName ( false )), $oclass -> getName ( false ));
}
echo '</select>' ;
echo '</td>' ;
echo '</tr>' ;
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'show_hints' )) {
printf ( '<tr><td> </td><td><small><img src="%s/light.png" alt="Hint" /><span class="hint">' , IMGDIR );
echo _ ( 'Hint: You must choose exactly one structural objectClass (shown in bold above)' );
echo '</span></small><br /></td></tr>' ;
}
}
/** INTERNAL ATTRIBUTES **/
protected function drawInternalAttributes () {
if ( $this -> template -> getAttributesInternal ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
foreach ( $this -> template -> getAttributesInternal () as $attribute )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Internal' , $attribute );
}
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<tr><td>(%s)<br/></td></tr>' , _ ( 'No internal attributes' ));
}
2019-02-08 13:44:52 -05:00
echo " \n " ;
}
protected function drawInternalAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> draw ( 'Template' , $attribute );
}
/** FORM METHODS **/
public function drawFormStart () {
echo '<form action="cmd.php" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">' ;
echo '<div>' ;
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'confirm' , 'update' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="cmd" value="update_confirm" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="cmd" value="update" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</div>' ;
}
protected function drawForm ( $nosubmit = false ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
echo '<div>' ;
printf ( '<input type="hidden" name="server_id" value="%s" />' , $this -> getServerID ());
printf ( '<input type="hidden" name="dn" value="%s" />' , $this -> template -> getDNEncode ( false ));
printf ( '<input type="hidden" name="template" value="%s" />' , $this -> template -> getID ());
echo '</div>' ;
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">' ;
$this -> drawShownAttributes ();
if ( ! $nosubmit )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> drawFormSubmitButton ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</table>' ;
echo '<div> ' ;
$this -> drawHiddenAttributes ();
echo '</div>' ;
}
public function drawFormEnd () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# Include the RDN details to support creating the base
if ( get_request ( 'create_base' )) {
if ( get_request ( 'rdn' )) {
$rdn = explode ( '=' , get_request ( 'rdn' ));
echo '<div>' ;
printf ( '<input type="hidden" name="new_values[%s][]" value="%s" />' , $rdn [ 0 ], $rdn [ 1 ]);
printf ( '<input type="hidden" name="rdn_attribute[]" value="%s" />' , $rdn [ 0 ]);
echo '</div>' ;
}
}
echo '</form>' ;
# Javascript
$this -> drawJavascript ();
# For debugging, show the template object.
if ( ! $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'hide_debug_info' ) && get_request ( 'debug' , 'GET' )) {
echo " \n \n " ;
printf ( '<img src="%s/plus.png" alt="Plus" onclick="if (document.getElementById(\'DEBUGtemplate\').style.display == \'none\') { document.getElementById(\'DEBUGtemplate\').style.display = \'block\' } else { document.getElementById(\'DEBUGtemplate\').style.display = \'none\' };"/>' , IMGDIR );
echo '<div id="DEBUGtemplate" style="display: none">' ;
echo '<fieldset>' ;
printf ( '<legend>DEBUG: %s</legend>' , $this -> template -> getDescription ());
echo '<textarea cols="120" rows="20">' ;
debug_dump ( $this );
echo '</textarea>' ;
echo '</fieldset>' ;
echo '</div>' ;
}
}
public function drawFormSubmitButton () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( ! $this -> template -> isReadOnly ())
// @todo cant use AJAX here, it affects file uploads.
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<tr><td colspan="2" style="text-align: center;"><input type="submit" id="create_button" name="submit" value="%s" /></td></tr>' ,
_ ( 'Update Object' ));
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
2019-02-12 14:52:01 -05:00
/** STEP FORM METHODS *
* @ param $page
*/
2019-02-08 13:44:52 -05:00
private function drawStepTitle ( $page ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
if ( DEBUGTMP || DEBUGTMPSUB )
{
printf ( '<font size=-2>* %s [templateNAME:%s]</font><br />' , __METHOD__ , $this -> template -> getName ());
}
2019-02-08 13:44:52 -05:00
# The default template needs to ask the user for objectClasses.
if ( $this -> template -> isType ( 'default' )) {
# The default template only uses 2 pages
$this -> pagelast = 2 ;
echo '<h4 style="text-align: center;">' ;
printf ( '%s: ' , sprintf ( _ ( 'Step %s of %s' ), $page , $this -> pagelast ));
if ( $page == 1 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo _ ( 'Container and ObjectClass(es)' );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo _ ( 'Specify attributes and values' );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</h4>' ;
} elseif ( $this -> template -> getDescription ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<h4 style="text-align: center;">%s (%s)</h4>' ,
_ ( $this -> template -> getDescription ()),
2019-02-12 14:57:50 -05:00
sprintf ( _ ( 'Step %s of %s' ), $page , $this -> pagelast ));
}
2019-02-08 13:44:52 -05:00
}
private function drawStepFormStart ( $page ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if (( $this -> template -> isType ( 'default' ) && $this -> template -> getContext () == 'create' && $page == 1 ) || $page < $this -> pagelast ) {
echo '<form action="cmd.php?cmd=template_engine" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">' ;
echo '<div>' ;
} else {
echo '<form action="cmd.php" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">' ;
echo '<div>' ;
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'confirm' , 'create' ) && ! get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="cmd" value="create_confirm" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="cmd" value="create" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
}
protected function drawStepForm ( $page ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
printf ( '<input type="hidden" name="server_id" value="%s" />' , $this -> getServerID ());
printf ( '<input type="hidden" name="template" value="%s" />' , $this -> template -> getID ());
printf ( '<input type="hidden" name="page" value="%s" />' , $page + 1 );
if ( get_request ( 'create_base' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<input type="hidden" name="create_base" value="true" />' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$this -> drawHiddenAttributes ();
if ( $this -> template -> isType ( 'default' ) && $page == 1 ) {
echo '</div>' ;
echo '<table class="forminput" border="0" style="margin-left: auto; margin-right: auto;">' ;
$this -> drawContainerChooser ( $this -> template -> getContainer ());
$this -> drawObjectClassChooser ();
} else {
printf ( '<input type="hidden" name="container" value="%s" />' , $this -> template -> getContainerEncode ( false ));
echo '</div>' ;
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">' ;
$this -> drawRDNChooser ();
if ( $this -> template -> isType ( 'default' ) && $this -> template -> getContext () == 'create' )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> drawStepFormDefaultAttributes ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$this -> drawShownAttributes ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
$this -> drawStepFormSubmitButton ( $page );
echo '</table>' ;
}
private function drawStepFormEnd () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> drawFormEnd ();
}
private function drawStepFormSubmitButton ( $page ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
echo '<tr>' ;
if ( $page < $this -> pagelast )
2019-02-12 14:57:50 -05:00
{
printf ( '<td> </td><td><input type="submit" id="create_button" value="%s" /></td>' , _ ( 'Proceed >>' ));
}
2019-02-08 13:44:52 -05:00
else
// @todo cant use AJAX here, it affects file uploads.
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<td style="text-align: center;"><input type="submit" id="create_button" name="submit" value="%s" /></td>' ,
_ ( 'Create Object' ));
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '</tr>' ;
}
/**
* Given our known objectClass in the template , this will render the required MAY and optional MUST attributes
*/
private function drawStepFormDefaultAttributes () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# Put required attributes first
$attrs = array ();
$attrs [ 'required' ] = array ();
$attrs [ 'optional' ] = array ();
foreach ( $this -> template -> getAttributes ( true ) as $attribute ) {
# Skip the objectclass attribute, we already know it in a default creation form.
if ( $attribute -> getName () == 'objectclass' )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
continue ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $attribute -> isRequired ())
2019-02-12 14:57:50 -05:00
{
2019-02-12 15:23:38 -05:00
$attrs [ 'required' ][] = $attribute ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
elseif ( ! $attribute -> getValues ())
2019-02-12 14:57:50 -05:00
{
2019-02-12 15:23:38 -05:00
$attrs [ 'optional' ][] = $attribute ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
printf ( '<tr><th colspan="2">%s</th></tr>' , _ ( 'Required Attributes' ));
if ( count ( $attrs [ 'required' ]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
foreach ( $attrs [ 'required' ] as $attribute )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Template' , $attribute );
}
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<tr class="noinput"><td colspan="2" style="text-align: center;">(%s)</td></tr>' , _ ( 'none' ));
}
2019-02-08 13:44:52 -05:00
printf ( '<tr><th colspan="2">%s</th></tr>' , _ ( 'Optional Attributes' ));
if ( count ( $attrs [ 'optional' ]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
foreach ( $attrs [ 'optional' ] as $attribute )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Template' , $attribute );
}
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<tr class="noinput"><td colspan="2" style="text-align: center;">(%s)</td></tr>' , _ ( 'none' ));
}
2019-02-08 13:44:52 -05:00
echo " \n " ;
}
/** DRAW ATTRIBUTES **/
private function drawShownAttributes () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
foreach ( $this -> template -> getAttributesShown () as $attribute )
2019-02-12 14:57:50 -05:00
{
if (( $attribute -> getPage () == $this -> page ) && ( $attribute -> isRequired () || $attribute -> isMay ()))
{
$this -> draw ( 'Template' , $attribute );
2019-02-08 13:44:52 -05:00
echo " \n " ;
}
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
/** DRAW PAGE JAVACRIPT */
protected function drawJavascript () {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
echo " \n " ;
printf ( '<!-- START: %s -->' , __METHOD__ );
echo " \n " ;
printf ( '<script type="text/javascript" src="%sTemplateRender.js"></script>' , JSDIR );
printf ( '<script type="text/javascript" src="%stoAscii.js"></script>' , JSDIR );
printf ( '<script type="text/javascript" src="%sdnChooserPopup.js"></script>' , JSDIR );
echo " \n " ;
printf ( '<!-- START: MAIN FORM VALIDATION: %s -->' , __METHOD__ );
echo '
< script type = " text/javascript " >
function validateForm ( silence ) {
var i = 0 ;
var valid = true ;
var components = null ; ' . " \n " ;
foreach ( $this -> template -> getAttributes ( true ) as $attribute ) {
if ( $attribute -> isVisible () && ( $attribute -> getOnchange ()) || $attribute -> isRequired ()) {
echo '
components = getAttributeComponents ( " new " , " '. $attribute->getName ().' " );
for ( i = 0 ; i < components . length ; i ++ ) {
if ( window . validate_ '.$attribute->getName().' ) {
valid = ( ! validate_ '.$attribute->getName().' ( components [ i ], silence ) || ! valid ) ? false : true ;
}
} ' ;
echo " \n " ;
}
}
# If we displayed the RDN chooser...
if ( ! count ( $this -> template -> getRDNAttrs ()))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo ' valid = (!document.getElementById(\'rdn_attribute\').value || !valid) ? false : true;' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '
return valid ;
}
</ script > ' ;
echo " \n " ;
printf ( '<!-- END: MAIN FORM VALIDATION: %s -->' , __METHOD__ );
echo " \n " ;
$this -> drawTemplateJavascript ();
# For DateAttributes, we need to set some defaults for the js_calendar.
echo '<!-- START: GLOBAL SETTINGS FOR THE js_calendar -->' . " \n " ;
echo '<script type="text/javascript">' . " \n " ;
echo 'var defaults = new Array();' . " \n " ;
printf ( 'var default_date_format = "%s";' , $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'date' ));
echo " \n " ;
echo '</script>' . " \n " ;
echo '<!-- END: GLOBAL SETTINGS FOR THE js_calendar -->' . " \n " ;
echo " \n " ;
foreach ( $this -> template -> getAttributesShown () as $attribute )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Javascript' , $attribute );
}
2019-02-08 13:44:52 -05:00
// @todo We need to sleep here a little bit, because our JS may not have loaded yet.
echo ' < script type = " text/javascript " >
if ( typeof getAttributeComponents == " undefined " )
setTimeout ( " isJSComplete() " , 1000 );
else
validateForm ( true );
function isJSComplete () {
if ( typeof getAttributeComponents == " undefined " ) {
alert ( " Our Javascript didnt load in time, you may need to reload this page " );
// Sometimes the alert gives us enough time!
if ( typeof getAttributeComponents != " undefined " )
alert ( " Dont bother, our JS is loaded now! " );
}
validateForm ( true );
}
</ script > ' . " \n " ;
printf ( '<!-- END: %s -->' , __METHOD__ );
echo " \n " ;
}
/**
* Javascript Functions
*/
private function drawTemplateJavascript () {
printf ( '<!-- START: ONCHANGE PROCESSING %s -->' , __METHOD__ );
echo " \n " ;
foreach ( $this -> template -> getAttributes ( true ) as $attribute )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
if ( $onchange = $attribute -> getOnChange ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
if ( is_array ( $onchange ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
foreach ( $onchange as $value )
2019-02-12 14:57:50 -05:00
{
$this -> template -> OnChangeAdd ( $attribute -> getName (), $value );
}
} else
{
$this -> template -> OnChangeAdd ( $attribute -> getName (), $onchange );
}
}
}
2019-02-08 13:44:52 -05:00
printf ( '<!-- END: ONCHANGE PROCESSING %s -->' , __METHOD__ );
echo " \n " ;
printf ( '<!-- START: %s -->' , __METHOD__ );
echo '
< script type = " text/javascript " >
var attrTrace ;
function fill ( id , value ) {
attrTrace = new Array ();
fillRec ( id , value );
}
function fillRec ( id , value ) {
if ( attrTrace [ id ] == 1 ) {
return ;
} else {
var pre = " " ;
var suf = " " ;
var i ;
attrTrace [ id ] = 1 ;
pla_setComponentValue ( pla_getComponentById ( id ), value );
// here comes template-specific implementation,generated by php
if ( false ) {} ' ;
foreach ( $this -> template -> getAttributes ( true ) as $attribute ) {
if ( $attribute -> isVisible () && ( $attribute -> getOnchange ()) || $attribute -> isRequired ()) {
$attr = $attribute -> getName ();
printf ( "
else if (( i = id . indexOf ( '_%s_' )) >= 0 ) { " , $attr );
echo "
pre = id . substring ( 0 , i + 1 ); " ;
printf ( "
suf = id . substring ( i + 1 + '%s' . length , id . length ); \n " , $attr );
$this -> draw ( 'FillJavascript' , $attribute , 'id' , 'value' );
if ( isset ( $attribute -> js [ 'autoFill' ]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo $attribute -> js [ 'autoFill' ];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo "
} \n " ;
}
}
echo ' }
}
</ script > ' ;
echo " \n " ;
printf ( '<!-- END: %s -->' , __METHOD__ );
echo " \n " ;
}
2019-02-12 14:52:01 -05:00
/** ATTRIBUTE TITLE *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawTitleAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if (( $this -> template -> getContext () == 'edit' )
&& ( $attribute -> hasBeenModified () || in_array ( $attribute -> getName (), get_request ( 'modified_attrs' , 'REQUEST' , false , array ()))))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr class="updated">' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '<td class="title">' ;
$this -> draw ( 'Name' , $attribute );
echo '</td>' ;
echo '<td class="note">' ;
# Setup the $attr_note, which will be displayed to the right of the attr name (if any)
if ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'show_attribute_notes' ))
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Notes' , $attribute );
}
2019-02-08 13:44:52 -05:00
echo '</td>' ;
echo '</tr>' ;
}
2019-02-12 14:52:01 -05:00
/** ATTRIBUTE LINE *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawStartValueLineAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if (( $this -> template -> getContext () == 'edit' )
&& ( $attribute -> hasBeenModified () || in_array ( $attribute -> getName (), get_request ( 'modified_attrs' , 'REQUEST' , false , array ()))))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr class="updated">' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '<td class="value" colspan="2">' ;
}
protected function drawEndValueLineAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
echo '</td>' ;
echo '</tr>' ;
if ( $attribute -> getSpacer ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr class="spacer"><td colspan="3"> </td></tr>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if (( $this -> template -> getContext () == 'edit' )
&& ( $attribute -> hasBeenModified () || in_array ( $attribute -> getName (), get_request ( 'modified_attrs' , 'REQUEST' , false , array ()))))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '<tr class="updated"><td class="bottom" colspan="2"></td></tr>' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
protected function drawTemplateAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> draw ( 'Title' , $attribute );
$this -> draw ( 'TemplateValues' , $attribute );
}
protected function drawTemplateValuesAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s:%s</font><br />' , time (), __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> draw ( 'StartValueLine' , $attribute );
# Draws values
$value_count = $attribute -> getValueCount ();
for ( $i = 0 ; $i < $value_count ; $i ++ )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Value' , $attribute , $i );
}
2019-02-08 13:44:52 -05:00
if ( ! $attribute -> isInternal ()) {
$blankvalue_count = $attribute -> getMaxValueCount ();
if ( $blankvalue_count < 0 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$blankvalue_count = 1 ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$blankvalue_count -= $value_count ;
for ( $j = 0 ; $j < $blankvalue_count ; $j ++ )
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Value' , $attribute , $i + $j );
}
2019-02-08 13:44:52 -05:00
if (( $value_count == $blankvalue_count ) || ( $value_count && $blankvalue_count < 1 ))
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'Menu' , $attribute );
}
2019-02-08 13:44:52 -05:00
}
$this -> draw ( 'EndValueLine' , $attribute );
echo " \n " ;
}
2019-02-12 14:52:01 -05:00
/** DRAW ICONS FOR ATTRIBUTES VALUES *
* @ param $attribute
* @ param $val
*/
2019-02-08 13:44:52 -05:00
protected function drawIconAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( is_dn_string ( $val ) || $this -> getServer () -> isDNAttr ( $attribute -> getName ()))
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'DnValueIcon' , $attribute , $val );
}
2019-02-08 13:44:52 -05:00
elseif ( is_mail_string ( $val ))
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'MailValueIcon' , $attribute , $val );
}
2019-02-08 13:44:52 -05:00
elseif ( is_url_string ( $val ))
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'UrlValueIcon' , $attribute , $val );
}
2019-02-08 13:44:52 -05:00
else {
if ( $icon = $attribute -> getIcon ())
2019-02-12 14:57:50 -05:00
{
printf ( '<img src="%s" alt="Icon" style="float: right;" /> ' , $icon );
}
2019-02-08 13:44:52 -05:00
}
}
protected function drawDnValueIconAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( strlen ( $val ) <= 0 )
2019-02-12 14:57:50 -05:00
{
printf ( '<img src="%s/ldap-alias.png" alt="Go" style="float: right;" /> ' , IMGDIR );
}
2019-02-08 13:44:52 -05:00
elseif ( $this -> getServer () -> dnExists ( $val ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
printf ( '<a href="cmd.php?cmd=template_engine&server_id=%s&dn=%s" title="%s %s"><img src="%s/ldap-alias.png" alt="Go" /></a> ' ,
2019-02-12 14:57:50 -05:00
$this -> getServerID (), rawurlencode ( $val ), _ ( 'Go to' ), $val , IMGDIR );
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<a title="%s %s"><img src="%s/nogo.png" alt="Go" /></a> ' , _ ( 'DN not available' ), $val , IMGDIR );
}
2019-02-08 13:44:52 -05:00
}
protected function drawMailValueIconAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$img = sprintf ( '<img src="%s/mail.png" alt="%s" style="float: right;" />' , IMGDIR , _ ( 'Mail' ));
if ( strlen ( $val ) <= 0 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo $img ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<a href="mailto:%s">%s</a>' , htmlspecialchars ( $val ), $img );
}
2019-02-08 13:44:52 -05:00
echo ' ' ;
}
protected function drawUrlValueIconAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$img = sprintf ( '<img src="%s/ldap-dc.png" alt="%s" style="float: right;" />' , IMGDIR , _ ( 'URL' ));
$url = explode ( ' +' , $val , 2 );
if ( strlen ( $val ) <= 0 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo $img ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
printf ( '<a href="%s" onclick="target=\'new\';">%s</a>' , htmlspecialchars ( $url [ 0 ]), $img );
}
2019-02-08 13:44:52 -05:00
echo ' ' ;
}
/** DEFAULT ATTRIBUTE RENDERING **/
2019-02-12 14:52:01 -05:00
/** javacript
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawJavascriptAttribute ( $attribute ) {
if ( ! $attribute -> needJS ()) {
printf ( '<!-- NO JS REQUIRED FOR %s -->' , $attribute -> getName ());
echo " \n " ;
return ;
}
printf ( '<!-- START: ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
echo '<script type="text/javascript">' . " \n " ;
echo '// focus' . " \n " ;
if ( $attribute -> needJS ( 'focus' )) {
printf ( 'function focus_%s(component) {' , $attribute -> getName ());
echo " \n " ;
$this -> draw ( 'FocusJavascript' , $attribute , 'component' );
echo " }; \n " ;
}
echo '// blur' . " \n " ;
if ( $attribute -> needJS ( 'blur' )) {
printf ( 'function blur_%s(component) {' , $attribute -> getName ());
echo " \n " ;
$this -> draw ( 'BlurJavascript' , $attribute , 'component' );
echo " }; \n " ;
}
echo '// validate' . " \n " ;
printf ( 'function validate_%s(component,silence) {' , $attribute -> getName ());
echo " \n " ;
if ( $attribute -> needJS ( 'validate' )) {
echo ' var valid = true;' ;
echo " \n " ;
$this -> draw ( 'ValidateJavascript' , $attribute , 'component' , 'silence' , 'valid' );
echo " \n " ;
echo ' if (valid) { component.style.backgroundColor = "white"; component.style.color = "black"; }' ;
echo ' else { component.style.backgroundColor = \'#FFFFA0\'; component.style.color = "black"; }' ;
echo ' return valid;' ;
} else {
echo ' return true;' . " \n " ;
}
echo '}' . " \n " ;
echo '</script>' . " \n " ;
printf ( '<!-- END: ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
}
protected function getFocusJavascriptAttribute ( $attribute , $component ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
return '' ;
}
protected function getBlurJavascriptAttribute ( $attribute , $component ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$j = " \t " . 'fill(' . $component . '.id,pla_getComponentValue(' . $component . '));' . " \n " ;
$j .= " \t " . 'validate_' . $attribute -> getName () . '(' . $component . ',false);' . " \n " ;
return $j ;
}
protected function drawFocusJavascriptAttribute ( $attribute , $component ) {
echo $this -> get ( 'FocusJavascript' , $attribute , $component );
}
protected function drawBlurJavascriptAttribute ( $attribute , $component ) {
echo $this -> get ( 'BlurJavascript' , $attribute , $component );
}
protected function drawFillJavascriptAttribute ( $attribute , $component_id , $component_value ) {
if ( $attribute -> needJS ( 'validate' ))
2019-02-12 14:57:50 -05:00
{
printf ( " \t validate_%s(pla_getComponentById(%s),true); \n " , $attribute -> getName (), $component_id );
}
2019-02-08 13:44:52 -05:00
}
protected function drawValidateJavascriptAttribute ( $attribute , $component , $silence , $var_valid ) {
printf ( 'var vals = getAttributeValues("new","%s");' , $attribute -> getName ());
echo 'if (vals.length <= 0) {' ;
printf ( '%s = false;' , $var_valid );
printf ( 'alertError("%s: %s",%s);' , _ ( 'This attribute is required' ), $attribute -> getFriendlyName (), $silence );
echo '}' ;
echo " \n " ;
printf ( 'var comp = getAttributeComponents("new","%s");' , $attribute -> getName ());
echo 'for (var i = 0; i < comp.length; i++) {' ;
printf ( 'comp[i].style.backgroundColor = "%s";' , $var_valid ? 'white' : '#FFFFA0' );
echo '}' ;
}
2019-02-12 14:52:01 -05:00
/** ATTRIBUTE MENU *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawMenuAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$result = '' ;
$item = '' ;
foreach ( array ( 'add' , 'modify' , 'rename' ) as $action )
2019-02-12 14:57:50 -05:00
{
if ( $item = $this -> get ( 'MenuItem' , $attribute , $action ))
{
$result .= sprintf ( '<div class="add_value">%s</div>' , $item );
}
}
2019-02-08 13:44:52 -05:00
if ( ! $result )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
echo '<table class="entry" border="0"><tr><td style="width: 25px;"> </td>' ;
printf ( '<td>%s</td>' , $result );
echo '</td>' ;
echo '</tr></table>' ;
}
protected function getMenuItemAttribute ( $attribute , $action ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
# If there is no DN, then this is a creating entry.
if (( $this -> template -> getContext () == 'create' ) || $this -> template -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
return FALSE ;
}
2019-02-08 13:44:52 -05:00
switch ( $action ) {
case 'add' :
if ( $attribute -> isVisible () && ! $attribute -> isReadOnly ()
&& $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'add_value_form' )) {
if ( $attribute -> haveMoreValues ())
2019-02-12 14:57:50 -05:00
{
return $this -> get ( 'AddValueMenuItem' , $attribute );
}
2019-02-08 13:44:52 -05:00
}
return '' ;
case 'modify' :
if ( in_array ( $attribute -> getName (), arrayLower ( $_SESSION [ APPCONFIG ] -> getValue ( 'modify_member' , 'groupattr' )))) {
if ( $attribute -> isVisible () && ! $attribute -> isReadOnly () && ! $attribute -> isRDN ()
&& $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'modify_member_form' ))
2019-02-12 14:57:50 -05:00
{
return $this -> get ( 'ModifyMemberMenuItem' , $attribute );
}
2019-02-08 13:44:52 -05:00
}
return '' ;
case 'rename' :
if ( $attribute -> isVisible () && $attribute -> isRDN () && ! $attribute -> isReadOnly ()
&& $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'rename_form' )
&& $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'rename' ))
2019-02-12 14:57:50 -05:00
{
return $this -> get ( 'RenameMenuItem' , $attribute );
}
2019-02-08 13:44:52 -05:00
return '' ;
default :
return false ;
}
}
protected function getAddValueMenuItemAttribute ( $attribute ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href_parm = htmlspecialchars ( sprintf ( 'cmd=add_value_form&server_id=%s&dn=%s&attr=%s' ,
$this -> getServerID (), $this -> template -> getDNEncode (), rawurlencode ( $attribute -> getName ( false ))));
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s %s" onclick="return ajDISPLAY(\'ADDVALUE%s\',\'%s&raw=1\',\'%s\',1);">%s</a>)' ,
2019-02-12 14:57:50 -05:00
$href_parm , _ ( 'Add an additional value to attribute' ), $attribute -> getName ( FALSE ), $attribute -> getName (),
$href_parm , str_replace ( '\'' , '\\\'' , _ ( 'Add Value to Attribute' )), _ ( 'add value' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s %s">%s</a>)' ,
2019-02-12 14:57:50 -05:00
$href_parm , _ ( 'Add an additional value to attribute' ), $attribute -> getName ( FALSE ), _ ( 'add value' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getAddValueMenuItemObjectClassAttribute ( $attribute ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href_parm = htmlspecialchars ( sprintf ( 'cmd=add_value_form&server_id=%s&dn=%s&attr=%s' ,
$this -> getServerID (), $this -> template -> getDNEncode (), rawurlencode ( $attribute -> getName ( false ))));
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s %s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>)' ,
2019-02-12 14:57:50 -05:00
$href_parm , _ ( 'Add an additional value to attribute' ), $attribute -> getName ( FALSE ),
$href_parm , str_replace ( '\'' , '\\\'' , _ ( 'Add Value to Attribute' )), _ ( 'add value' ));
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s %s">%s</a>)' ,
2019-02-12 14:57:50 -05:00
$href_parm , _ ( 'Add an additional value to attribute' ), $attribute -> getName ( FALSE ), _ ( 'add value' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getModifyMemberMenuItemAttribute ( $attribute ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd=modify_member_form&server_id=%s&dn=%s&attr=%s' ,
$this -> getServerID (), $this -> template -> getDNEncode (), rawurlencode ( $attribute -> getName ()));
if ( isAjaxEnabled ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s: %s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>)' ,
2019-02-12 14:57:50 -05:00
htmlspecialchars ( $href ), _ ( 'Modify members for' ), $this -> template -> getDN (),
htmlspecialchars ( $href ), str_replace ( '\'' , '\\\'' , _ ( 'Modify group membership' )),
2019-02-08 13:44:52 -05:00
_ ( 'modify group members' ));
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return sprintf ( '(<a href="cmd.php?%s" title="%s: %s">%s</a>)' ,
2019-02-12 14:57:50 -05:00
htmlspecialchars ( $href ), _ ( 'Modify members for' ), $this -> template -> getDN (), _ ( 'modify group members' ));
}
2019-02-08 13:44:52 -05:00
}
protected function getRenameMenuItemAttribute ( $attribute ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$href = sprintf ( 'cmd.php?cmd=rename_form&server_id=%s&dn=%s&template=%s' ,
$this -> getServerID (), $this -> template -> getDNEncode (), $this -> template -> getID ());
return sprintf ( '<small>(<a href="%s">%s</a>)</small>' , htmlspecialchars ( $href ), _ ( 'rename' ));
}
2019-02-12 14:52:01 -05:00
/** values *
* @ param $attribute
* @ param $i
*/
2019-02-08 13:44:52 -05:00
protected function drawValueAttribute ( $attribute , $i ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( $attribute -> isMultiple () && $i > 0 )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
$val = $attribute -> getValue ( $i );
if ( $attribute -> isVisible ()) {
echo '<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td class="icon" style="width: 25px;">' ;
$this -> draw ( 'Icon' , $attribute , $val );
echo '</td>' ;
echo '<td valign="top">' ;
}
if ( $attribute -> isInternal ())
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'FormReadOnlyValue' , $attribute , $i );
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$this -> draw ( 'FormValue' , $attribute , $i );
}
2019-02-08 13:44:52 -05:00
if ( $attribute -> isVisible ()) {
echo '</td>' ;
echo '<td valign="top" style="text-align: right;">' ;
$this -> draw ( 'RequiredSymbol' , $attribute );
echo '</td></tr></table>' ;
}
echo " \n " ;
}
# @todo for userPasswords, we need to capture the default value of select lists, without specifying <default>
protected function drawHelperAttribute ( $attribute , $i ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$params = $attribute -> getHelper ();
# We take the first <id> only
$id = isset ( $params [ 'id' ]) ? $params [ 'id' ] : '' ;
if ( is_array ( $id )) {
system_message ( array (
'title' => _ ( 'Too many arguments' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'Helper attribute has too many ID values, only the first one is used' ), count ( $id )),
'type' => 'warn' ));
$id = $id [ 0 ];
}
# We take the first <display> only
$display = isset ( $params [ 'display' ]) ? $params [ 'display' ] : '' ;
if ( is_array ( $display )) {
system_message ( array (
'title' => _ ( 'Too many arguments' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'Helper attribute has too many DISPLAY values, only the first one is used' ), count ( $display )),
'type' => 'warn' ));
$display = $display [ 0 ];
}
# We take the first <default> only
$default = isset ( $params [ 'default' ]) ? $params [ 'default' ] : '' ;
if ( is_array ( $default )) {
system_message ( array (
'title' => _ ( 'Too many arguments' ),
'body' => sprintf ( '%s (<b>%s</b>)' , _ ( 'Helper attribute has too many DISPLAY values, only the first one is used' ), count ( $default )),
'type' => 'warn' ));
$default = $default [ 0 ];
}
if ( $attribute -> getHelperValue ())
2019-02-12 14:57:50 -05:00
{
$vals = $this -> get ( 'Default' , $attribute ,
2019-02-08 13:44:52 -05:00
$this -> template -> getContainer () ? $this -> template -> getContainer () : $this -> getServer () -> getContainerPath ( $this -> template -> getDN ()),
'helpervalue' );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$vals = isset ( $params [ 'value' ]) ? $params [ 'value' ] : '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( $this -> template -> getContext () == 'create' )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$dn = $this -> template -> getContainer ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$dn = $this -> template -> getDN ();
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( is_array ( $vals ) && count ( $vals ) > 0 ) {
$found = false ;
printf ( '<select name="%s[%s][%s]" id="%s_%s_%s">' ,
$id , htmlspecialchars ( $attribute -> getName ()), $i ,
$id , htmlspecialchars ( $attribute -> getName ()), $i );
foreach ( $vals as $v ) {
printf ( '<option value="%s" %s>%s</option>' , $v ,( $v == $default ) ? 'selected="selected"' : '' , $v );
if ( $v == $default )
2019-02-12 14:57:50 -05:00
{
$found = TRUE ;
}
2019-02-08 13:44:52 -05:00
}
if ( ! $found )
2019-02-12 14:57:50 -05:00
{
printf ( '<option value="%s" selected="selected">%s</option>' , $default , $default ? $default : ' ' );
}
2019-02-08 13:44:52 -05:00
echo '</select>' ;
} else {
# Vals must be an empty array.
if ( is_array ( $vals ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$vals = '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
printf ( '<input type="text" name="%s[%s][%s]" id="%s_%s_%s" value="%s" size="4" />' ,
$id , htmlspecialchars ( $attribute -> getName ()), $i ,
$id , htmlspecialchars ( $attribute -> getName ()), $i ,
htmlspecialchars ( $vals ));
}
if ( $display ) {
echo '<div class="helper">' ;
printf ( '<span class="hint">%s</span>' , $display );
echo '</div>' ;
}
}
protected function drawRequiredSymbolAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( $attribute -> isRequired () && ! $attribute -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
echo '*' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
}
2019-02-12 14:52:01 -05:00
/** BINARY ATTRIBUTE RENDERING *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
#@todo do we need a $this->drawJavascriptAttribute($attribute) here too ?
protected function drawJavascriptBinaryAttribute ( $attribute ) {
# If there are no values, then this javascript doesnt need to be drawn.
if ( ! $attribute -> getValues ())
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
static $drawn = false ;
# This JS may have been rendered by multiple Binary attributes
if ( $drawn )
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$drawn = TRUE ;
}
2019-02-08 13:44:52 -05:00
printf ( '<!-- START: BINARY ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
echo '<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->' ;
echo '<form id="delete_attribute_form" action="cmd.php?cmd=delete_attr" method="post">' ;
printf ( '<input type="hidden" name="server_id" value="%s" />' , $this -> getServerID ());
printf ( '<input type="hidden" name="dn" value="%s" />' , $this -> template -> getDNEncode ( false ));
printf ( '<input type="hidden" name="template" value="%s" />' , $this -> template -> getID ());
echo '<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />' ;
echo '<input type="hidden" name="index" value="FILLED IN BY JAVASCRIPT" />' ;
echo '</form>' ;
echo '
< script type = " text/javascript " >
function deleteAttribute ( attrName , friendlyName , i )
{
if ( confirm ( " '._('Really delete value from attribute').' \ ' " + friendlyName + " \ '? " )) {
document . getElementById ( \ ' delete_attribute_form\ ' ) . attr . value = attrName ;
document . getElementById ( \ ' delete_attribute_form\ ' ) . index . value = i ;
document . getElementById ( \ ' delete_attribute_form\ ' ) . submit ();
}
}
</ script > ' ;
echo " \n " ;
printf ( '<!-- END: BINARY ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
}
2019-02-12 14:52:01 -05:00
/** DATE ATTRIBUTE RENDERING *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawJavaScriptDateAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
printf ( '<!-- START: DATE ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
2019-02-12 14:52:01 -05:00
$this -> drawJavascriptAttribute ( $attribute );
2019-02-08 13:44:52 -05:00
static $drawn = false ;
# This JS may have been rendered by multiple Date attributes
if ( ! $drawn ) {
printf ( '<script type="text/javascript" src="%sjscalendar/lang/calendar-en.js"></script>' , JSDIR );
printf ( '<script type="text/javascript" src="%sjscalendar/calendar-setup.js"></script>' , JSDIR );
printf ( '<script type="text/javascript" src="%sdate_selector.js"></script>' , JSDIR );
$drawn = true ;
}
$config = array ();
$config [ 'date' ] = array_change_key_case ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'date_attrs' ));
$config [ 'time' ] = array_change_key_case ( $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'date_attrs_showtime' ));
$config [ 'format' ] = $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'date' );
if ( isset ( $config [ 'date' ][ $attribute -> getName ()]))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$config [ 'format' ] = $config [ 'date' ][ $attribute -> getName ()];
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
for ( $i = 0 ; $i <= $attribute -> getValueCount (); $i ++ ) {
printf ( '<script type="text/javascript">defaults[\'new_values_%s_%s\'] = \'%s\';</script>' , $attribute -> getName (), $i , $config [ 'format' ]);
if ( in_array_ignore_case ( $attribute -> getName (), array_keys ( $config [ 'time' ])) && ( $config [ 'time' ][ $attribute -> getName ()]))
2019-02-12 14:57:50 -05:00
{
printf ( '<script type="text/javascript">defaults[\'f_time_%s_%s\'] = \'%s\';</script>' , $attribute -> getName (), $i , 'true' );
}
2019-02-08 13:44:52 -05:00
echo " \n " ;
}
printf ( '<!-- END: DATE ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
}
/**
* Draws an HTML date selector button which , when clicked , pops up a date selector dialog .
2019-02-12 14:52:01 -05:00
* @ param $attribute
* @ param $i
2019-02-08 13:44:52 -05:00
*/
protected function drawSelectorPopupDateAttribute ( $attribute , $i ) {
printf ( '<a href="javascript:dateSelector(\'%s_%s\');" title="%s"><img src="%s/calendar.png" alt="Calendar" class="chooser" id="f_trigger_%s_%s" style="cursor: pointer;" /></a>' ,
$attribute -> getName (), $i , _ ( 'Click to popup a dialog to select a date graphically' ), IMGDIR , $attribute -> getName (), $i );
}
2019-02-12 14:52:01 -05:00
/** DN ATTRIBUTES *
* @ param $attribute
* @ param $val
*/
2019-02-08 13:44:52 -05:00
protected function drawIconDnAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
$this -> draw ( 'DnValueIcon' , $attribute , $val );
}
2019-02-12 14:52:01 -05:00
/** OBJECT CLASS ATTRIBUTE *
* @ param $attribute
* @ param $val
*/
2019-02-08 13:44:52 -05:00
protected function drawIconObjectClassAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( ! $_SESSION [ APPCONFIG ] -> getValue ( 'appearance' , 'show_schema_link' ) || ! $_SESSION [ APPCONFIG ] -> isCommandAvailable ( 'script' , 'schema' ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
if ( strlen ( $val ) > 0 ) {
$href = sprintf ( 'cmd.php?cmd=schema&server_id=%s&view=objectclasses&viewvalue=%s' ,
$this -> getServerID (), $val );
printf ( '<a href="%s" title="%s"><img src="%s/info.png" alt="Info" /></a> ' ,
htmlspecialchars ( $href ), _ ( 'View the schema description for this objectClass' ), IMGDIR );
}
}
2019-02-12 14:52:01 -05:00
/** PASSWORD ATTRIBUTES *
* @ param $attribute
*/
2019-02-08 13:44:52 -05:00
protected function drawJavascriptPasswordAttribute ( $attribute ) {
static $drawn = array ();
# This JS may have been rendered by multiple Binary attributes
if ( isset ( $drawn [ $attribute -> getName ()]) && $drawn [ $attribute -> getName ()])
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$drawn [ $attribute -> getName ()] = TRUE ;
}
2019-02-08 13:44:52 -05:00
printf ( '<!-- START: PASSWORD ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
$this -> drawJavascriptAttribute ( $attribute );
# Add the javascript so we can call check password later.
echo '
< script type = " text/javascript " >
function passwordComparePopup ( component_id , attr ) {
mywindow = open ( \ ' password_checker . php\ ' , \ ' myname\ ' , \ ' resizable = no , width = 500 , height = 200 , scrollbars = 1 \ ' );
mywindow . location . href = \ ' password_checker . php ? componentid = \ ' + component_id + \ ' & attr = \ ' + attr ;
if ( mywindow . opener == null ) mywindow . opener = self ;
}
</ script > ' ;
echo " \n " ;
printf ( '<!-- END: PASSWORD ATTRIBUTE %s (%s)-->' , __METHOD__ , $attribute -> getName ());
echo " \n " ;
}
protected function drawCheckLinkPasswordAttribute ( $attribute , $component_id ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
printf ( '<small><a href="javascript:passwordComparePopup(\'%s\',\'%s\')">%s...</a></small><br />' ,
$component_id , $attribute -> getName (), _ ( 'Check password' ));
}
/** RANDOM PASSWORD **/
/**
* This will draw the javascript that displays to the user the random password generated
*
* @ todo This function doesnt work well if there are more than 1 RandomPasswordAttributes on the form for the same attribute ( unlikely situation )
2019-02-12 14:52:01 -05:00
* @ param $attribute
2019-02-08 13:44:52 -05:00
*/
protected function drawJavascriptRandomPasswordAttribute ( $attribute ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
printf ( " \n <!-- START: %s --> \n " , __METHOD__ );
$this -> drawJavascriptPasswordAttribute ( $attribute );
$pwd = password_generate ();
$pwd = str_replace ( " \\ " , " \\ \\ " , $pwd );
$pwd = str_replace ( " ' " , " \\ ' " , $pwd );
printf ( " \n <!-- %s --> \n " , __METHOD__ );
echo '<script type="text/javascript">' . " \n " ;
echo 'var i = 0;' . " \n " ;
printf ( 'var component = document.getElementById(\'new_values_%s_\'+i);' , $attribute -> getName ());
echo " \n " ;
echo 'while (component) {' . " \n " ;
echo ' if (!component.value) {' . " \n " ;
printf ( ' component.value = \'%s\';' , $pwd );
echo " \n " ;
printf ( ' alert(\'%s:\n%s\');' , _ ( 'A random password was generated for you' ), $pwd );
echo " \n " ;
echo ' };' . " \n " ;
echo ' i++;' . " \n " ;
printf ( ' component = document.getElementById(\'new_values_%s_\'+i);' , $attribute -> getName ());
echo " \n " ;
# It seems that JS gets stuck in a loop if there isnt a command here? - normally this alert isnt shown.
printf ( 'alert("It seems another element was found, PLA hasnt been configured for this situation Component: "+component.value+" I:"+i);' , $attribute -> getName ());
echo " \n " ;
echo '}' . " \n " ;
echo '</script>' ;
printf ( " \n <!-- END: %s --> \n " , __METHOD__ );
}
protected function drawDefaultHelperPasswordAttribute ( $attribute , $i ) {
$id = 'enc' ;
if ( $val = $attribute -> getValue ( $i ))
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
$default = get_enc_type ( $val );
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
$default = $this -> getServer () -> getValue ( 'appearance' , 'password_hash' );
}
2019-02-08 13:44:52 -05:00
if ( ! $attribute -> getPostValue ())
2019-02-12 14:57:50 -05:00
{
printf ( '<input type="hidden" name="post_value[%s][]" value="%s" />' , $attribute -> getName (), $i );
}
2019-02-08 13:44:52 -05:00
printf ( '<select name="%s[%s][%s]" id="%s_%s_%s">' ,
$id , htmlspecialchars ( $attribute -> getName ()), $i ,
$id , htmlspecialchars ( $attribute -> getName ()), $i );
foreach ( password_types () as $v => $display )
2019-02-12 14:57:50 -05:00
{
printf ( '<option value="%s" %s>%s</option>' , $v , ( $v == $default ) ? 'selected="selected"' : '' , $display );
}
2019-02-08 13:44:52 -05:00
echo '</select>' ;
}
protected function drawDefaultHelperSambaPasswordAttribute ( $attribute , $i ) {
$id = 'enc' ;
if ( ! $attribute -> getPostValue ())
2019-02-12 14:57:50 -05:00
{
printf ( '<input type="hidden" name="post_value[%s][]" value="%s" />' , $attribute -> getName (), $i );
}
2019-02-08 13:44:52 -05:00
switch ( $attribute -> getName ()) {
case 'sambalmpassword' : $enc = 'lm' ; break ;
case 'sambantpassword' : $enc = 'nt' ; break ;
default :
return '' ;
}
printf ( '<input type="hidden" name="%s[%s][%s]" id="%s_%s_%s" value="%s" />' ,
$id , htmlspecialchars ( $attribute -> getName ()), $i ,
$id , htmlspecialchars ( $attribute -> getName ()), $i , $enc );
}
2019-02-12 14:52:01 -05:00
/** SELECTION ATTRIBUTE RENDERING *
* @ param $attribute
* @ param $val
*/
2019-02-08 13:44:52 -05:00
protected function drawIconSelectionAttribute ( $attribute , $val ) {
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
if ( ! $attribute -> isMultiple () || $attribute -> isReadOnly ())
2019-02-12 14:57:50 -05:00
{
$this -> drawIconAttribute ( $attribute , $val );
}
2019-02-08 13:44:52 -05:00
}
protected function getMenuItemSelectionAttribute ( $attribute , $i ) {
if ( DEBUG_ENABLED && (( $fargs = func_get_args ()) || $fargs = 'NOARGS' ))
2019-02-12 14:57:50 -05:00
{
debug_log ( 'Entered (%%)' , 129 , 0 , __FILE__ , __LINE__ , __METHOD__ , $fargs );
}
2019-02-08 13:44:52 -05:00
2019-02-12 14:57:50 -05:00
if ( DEBUGTMP )
{
printf ( '<font size=-2>%s</font><br />' , __METHOD__ );
}
2019-02-08 13:44:52 -05:00
switch ( $i ) {
case 'add' :
if ( ! $attribute -> isMultiple ())
2019-02-12 14:57:50 -05:00
{
return $this -> getMenuItemAttribute ( $attribute , $i );
}
2019-02-08 13:44:52 -05:00
else
2019-02-12 14:57:50 -05:00
{
2019-02-08 13:44:52 -05:00
return '' ;
2019-02-12 14:57:50 -05:00
}
2019-02-08 13:44:52 -05:00
case 'modify' :
return '' ;
default :
return $this -> getMenuItemAttribute ( $attribute , $i );
}
}
}
2019-02-12 14:52:01 -05:00