FusionDirectory
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions | Protected Attributes
simplePlugin Class Reference

This class is made for easy plugin creation for editing LDAP attributes. More...

Inheritance diagram for simplePlugin:
Inheritance graph
[legend]

Public Member Functions

 __construct (string $dn=NULL, $object=NULL, $parent=NULL, bool $mainTab=FALSE, array $attributesInfo=NULL)
 constructor More...
 
 setTemplate (bool $bool)
 Sets whether the opened objet is a template. More...
 
 getObjectClassFilter ()
 This function returns an LDAP filter for this plugin object classes.
 
 __get ($name)
 This function allows to use the syntax $plugin->attributeName to get attributes values. More...
 
 __set ($name, $value)
 This function allows to use the syntax $plugin->attributeName to set attributes values. More...
 
 __isset ($name)
 This function allows to use the syntax isset($plugin->attributeName) More...
 
 compute_dn ()
 This function returns the dn this object should have.
 
 get_allowed_bases ()
 Returns a list of all available departments for this object. More...
 
 set_acl_category (string $category)
 Set acl category. More...
 
 move (string $src_dn, string $dst_dn)
 Move ldap entries from one place to another. More...
 
 getRequiredAttributes ()
 Returns list of required LDAP attributes. More...
 
 readOnly ()
 Indicates if this object is opened as read-only (because of locks)
 
 update ()
 Update state and return FALSE if the dialog was closed.
 
 render ()
 This function display the plugin and return the html code.
 
 show_header (string $buttonHtmlText, string $htmlText, bool $plugin_enabled, bool $button_disabled=FALSE, string $name='modify_state')
 Show header message for tab dialogs. More...
 
 isActive ()
 Test whether a tab is active.
 
 isActivatable ()
 Test whether a tab can be deactivated.
 
 attrIsReadable ($attr)
 Check if logged in user have enough right to read this attribute value. More...
 
 attrIsWriteable ($attr)
 Check if logged in user have enough right to write this attribute value. More...
 
 getAclBase (bool $callParent=TRUE)
 Get LDAP base to use for ACL checks.
 
 openDialog (FusionDirectoryDialog $dialog)
 This function allows you to open a dialog. More...
 
 closeDialog ()
 This function closes the dialog.
 
 setNeedEditMode (bool $bool)
 Sets whether the opened objet has an edit button. More...
 
 acl_is_writeable ($attribute, bool $skipWrite=FALSE)
 Can we write the attribute.
 
 acl_is_readable ($attribute)
 Can we read the acl. More...
 
 acl_is_createable (string $base=NULL)
 Can we create the object. More...
 
 acl_is_removeable (string $base=NULL)
 Can we delete the object. More...
 
 acl_is_moveable (string $base=NULL)
 Can we move the object. More...
 
 aclHasPermissions ()
 Test if there are ACLs for this plugin.
 
 aclGetPermissions ($attribute='0', string $base=NULL, bool $skipWrite=FALSE)
 Get the acl permissions for an attribute or the plugin itself.
 
 remove (bool $fulldelete=FALSE)
 This function removes the object from LDAP.
 
 save_object ()
 This function handle $_POST informations.
 
 readPost ()
 This function handle $_POST informations.
 
 cleanup ()
 Remove attributes, empty arrays, arrays single attributes that do not differ.
 
 save ()
 This function saves the object in the LDAP.
 
 mergeObjectClasses (array $oc)
 Merge in objectClasses needed by this tab. More...
 
 handle_post_events (string $mode, array $addAttrs=[])
 Forward command execution requests to the post hook execution method.
 
 handle_pre_events (string $mode, array $addAttrs=[])
 Forward command execution requests to the pre hook execution method.
 
 fillHookAttrs (array &$addAttrs)
 Fill attributes which may be used in hooks. More...
 
 callHook ($cmd, array $addAttrs=[], &$returnOutput=[], &$returnCode=NULL)
 Calls external hooks which are defined for this plugin (fusiondirectory.conf) Replaces placeholder by class values of this plugin instance. Allows to a add special replacements.
 
 check ()
 This function checks the attributes values and yell if something is wrong.
 
 create_unique_dn (string $attribute, string $base)
 Create unique DN. More...
 
 adapt_from_template (array $attrs, array $skip=[])
 Adapt from template. More...
 
 resetCopyInfos ()
 This function is called on the copied object to set its dn to where it will be saved.
 
 deserializeValues (array $values, bool $checkAcl=TRUE)
 Deserialize values. More...
 
 showInTemplate (string $attr, array $templateAttrs)
 Returns TRUE if this attribute should be asked in the creation by template dialog. More...
 
 is_modal_dialog ()
 Is there a modal dialog opened.
 

Static Public Member Functions

static plInfo ()
 Return plugin informations for acl handling. More...
 
static generatePlProvidedAcls (array $attributesInfo, bool $operationalAttributes=NULL)
 This function generate the needed ACLs for a given attribtues array. More...
 
static mainInc ($classname=NULL, $entry_dn=NULL, $tabs=FALSE, $edit_mode=TRUE, $objectType=FALSE)
 This function is the needed main.inc for plugins that are not used inside a management class. More...
 

Data Fields

 $attributesInfo
 This attribute store all information about attributes.
 
 $attributesAccess = []
 This attribute store references toward attributes. More...
 
 $is_account = FALSE
 Mark plugin as account. More...
 
 $dn = ''
 dn of the opened object
 
 $orig_dn = ''
 original dn of the opened object
 
 $parent = NULL
 Reference to parent object. More...
 
 $is_template = FALSE
 Mark plugin as template. More...
 
 $attrs = []
 Represent temporary LDAP data. More...
 

Protected Member Functions

 post_save ()
 This function is called after LDAP save to do some post operations and logging. More...
 
 getAuditAttributesListFromConf ()
 
 handle_hooks (string $when, string $mode, array $addAttrs=[])
 Forward command execution requests to the pre/post hook execution method. More...
 

Static Protected Member Functions

static passwordProtect (string $hookCommand=NULL)
 This function protect the clear string password by replacing char.
 

Protected Attributes

 $objectclasses = []
 The objectClasses set by this tab.
 
 $saved_attributes = []
 The state of the attributes when we opened the object.
 
 $displayHeader = FALSE
 Do we want a header allowing to able/disable this plugin.
 
 $mainTab = FALSE
 Is this plugin the main tab, the one that handle the object itself.
 
 $needEditMode = FALSE
 Are we executed in a edit-mode environment? (this is FALSE if we're called from management, TRUE if we're called from a main.inc)
 
 $preInitAttributes = []
 Attributes that needs to be initialized before the others.
 
 $inheritance = FALSE
 FALSE to disable inheritance. Array like array ('objectClass' => 'attribute') to specify oc of the groups it might be inherited from.
 
 $read_only = FALSE
 Used when the entry is opened as "readonly" due to locks.
 
 $ldap_error
 Last LDAP error (used by logging calls from post_* methods)
 
 $entryCSN = ''
 Object entry CSN. More...
 

Detailed Description

This class is made for easy plugin creation for editing LDAP attributes.

Definition at line 31 of file class_simplePlugin.inc.

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $dn = NULL,
  $object = NULL,
  $parent = NULL,
bool  $mainTab = FALSE,
array  $attributesInfo = NULL 
)

constructor

Parameters
string$dnThe dn of this instance
Object$objectAn object to copy values from
Object$parentA parent instance, usually a simpleTabs instance.
boolean$mainTabWhether or not this is the main tab
array$attributesInfoAn attributesInfo array, if NULL, getAttributesInfo will be used.

Definition at line 155 of file class_simplePlugin.inc.

References $attributesInfo, $attrs, $dn, $mainTab, $parent, logging\debug(), session\get(), getEntryCSN(), in_array_ics(), session\is_set(), and setTemplate().

Member Function Documentation

◆ __get()

__get (   $name)

This function allows to use the syntax $plugin->attributeName to get attributes values.

It calls the getValue method on the concerned attribute It also adds the $plugin->attribtues syntax to get attributes list

Definition at line 437 of file class_simplePlugin.inc.

◆ __isset()

__isset (   $name)

This function allows to use the syntax isset($plugin->attributeName)

It returns FALSE if the attribute has an empty value.

Definition at line 474 of file class_simplePlugin.inc.

◆ __set()

__set (   $name,
  $value 
)

This function allows to use the syntax $plugin->attributeName to set attributes values.

It calls the setValue method on the concerned attribute

Definition at line 458 of file class_simplePlugin.inc.

◆ acl_is_createable()

acl_is_createable ( string  $base = NULL)

Can we create the object.

Parameters
string$baseEmpty string

Definition at line 1005 of file class_simplePlugin.inc.

References aclGetPermissions().

Referenced by get_allowed_bases(), and show_header().

◆ acl_is_moveable()

acl_is_moveable ( string  $base = NULL)

Can we move the object.

Parameters
string$baseEmpty string

Definition at line 1025 of file class_simplePlugin.inc.

References aclGetPermissions().

Referenced by attrIsWriteable(), and get_allowed_bases().

◆ acl_is_readable()

acl_is_readable (   $attribute)

Can we read the acl.

Parameters
string$attribute

Definition at line 995 of file class_simplePlugin.inc.

References aclGetPermissions().

Referenced by attrIsReadable(), and simpleService\getListEntry().

◆ acl_is_removeable()

acl_is_removeable ( string  $base = NULL)

Can we delete the object.

Parameters
string$baseEmpty string

Implements SimpleTab.

Definition at line 1015 of file class_simplePlugin.inc.

References aclGetPermissions().

Referenced by attrIsWriteable(), simpleService\getListEntry(), remove(), and show_header().

◆ adapt_from_template()

adapt_from_template ( array  $attrs,
array  $skip = [] 
)

Adapt from template.

Adapts fields to the values from a template. Should not empty any fields, only take values for the ones provided by the caller.

Parameters
array$attrsLDAP attributes values for template-modified attributes
array$skipattributes to leave untouched

Implements SimpleTab.

Definition at line 2092 of file class_simplePlugin.inc.

◆ attrIsReadable()

attrIsReadable (   $attr)

Check if logged in user have enough right to read this attribute value.

Parameters
mixed$attrAttribute object or name (in this case it will be fetched from attributesAccess)

Implements SimpleTab.

Definition at line 829 of file class_simplePlugin.inc.

References acl_is_readable().

◆ attrIsWriteable()

attrIsWriteable (   $attr)

Check if logged in user have enough right to write this attribute value.

Parameters
mixed$attrAttribute object or name (in this case it will be fetched from attributesAccess)

Implements SimpleTab.

Definition at line 847 of file class_simplePlugin.inc.

References acl_is_moveable(), acl_is_removeable(), and acl_is_writeable().

Referenced by deserializeValues().

◆ create_unique_dn()

create_unique_dn ( string  $attribute,
string  $base 
)

Create unique DN.

Parameters
string$attribute
string$base

Definition at line 2047 of file class_simplePlugin.inc.

References $dn.

◆ deserializeValues()

deserializeValues ( array  $values,
bool  $checkAcl = TRUE 
)

Deserialize values.

Returns TRUE or error

Implements SimpleTab.

Definition at line 2177 of file class_simplePlugin.inc.

References attrIsWriteable(), htmlescape(), and msgPool\permModify().

◆ fillHookAttrs()

fillHookAttrs ( array &  $addAttrs)

Fill attributes which may be used in hooks.

Used by simplePlugin::callHook

Implements SimpleTab.

Definition at line 1619 of file class_simplePlugin.inc.

Referenced by callHook().

◆ generatePlProvidedAcls()

static generatePlProvidedAcls ( array  $attributesInfo,
bool  $operationalAttributes = NULL 
)
static

This function generate the needed ACLs for a given attribtues array.

Parameters
array$attributesInfothe attribute array
bool?$operationalAttributes Whether to add ACLs for operational attributes. Use NULL for autodetection (default)

Definition at line 2272 of file class_simplePlugin.inc.

◆ get_allowed_bases()

get_allowed_bases ( )

Returns a list of all available departments for this object.

If this object is new, all departments we are allowed to create a new object in are returned. If this is an existing object, return all deps we are allowed to move this object to. Used by BaseSelectorAttribute

Returns
array [dn] => "..name" // All deps. we are allowed to act on.

Definition at line 544 of file class_simplePlugin.inc.

References $dn, acl_is_createable(), and acl_is_moveable().

◆ getAuditAttributesListFromConf()

getAuditAttributesListFromConf ( )
protected
Returns
array Note: This method is required because setAttribute can contain one value STRING or multiple ARRAY but, selectAttribute only accepts arrays. Its usage is to get audit attributes listed in backend, allowing to hide values from set attributes.

Definition at line 1506 of file class_simplePlugin.inc.

References class_available().

Referenced by post_save().

◆ getRequiredAttributes()

getRequiredAttributes ( )

Returns list of required LDAP attributes.

Used by template

Implements SimpleTab.

Definition at line 629 of file class_simplePlugin.inc.

◆ handle_hooks()

handle_hooks ( string  $when,
string  $mode,
array  $addAttrs = [] 
)
protected

Forward command execution requests to the pre/post hook execution method.

Parameters
string$whenmust be PRE or POST
string$modeadd, remove or modify
array$addAttrs

Definition at line 1568 of file class_simplePlugin.inc.

References callHook().

Referenced by handle_post_events(), and handle_pre_events().

◆ mainInc()

static mainInc (   $classname = NULL,
  $entry_dn = NULL,
  $tabs = FALSE,
  $edit_mode = TRUE,
  $objectType = FALSE 
)
static

This function is the needed main.inc for plugins that are not used inside a management class.

Parameters
array$classnamethe class name to read plInfo from. (plIcon, plTitle, plShortname and plObjectType may be used)
string$entry_dnthe dn of the object to show/edit
boolean$tabsTRUE to use tabs, FALSE to show directly the plugin class
boolean$edit_modewether or not this plugin can be edited
string$objectTypeThe objectType to use (will be taken in the plInfo if FALSE)

Definition at line 2308 of file class_simplePlugin.inc.

◆ mergeObjectClasses()

mergeObjectClasses ( array  $oc)

Merge in objectClasses needed by this tab.

Used by prepare_save and template::apply

Implements SimpleTab.

Definition at line 1347 of file class_simplePlugin.inc.

References array_merge_unique(), handle_pre_events(), and htmlescape().

◆ move()

move ( string  $src_dn,
string  $dst_dn 
)

Move ldap entries from one place to another.

Parameters
string$src_dnthe source DN.
string$dst_dnthe destination DN.
Returns
TRUE on success, error string on failure

Definition at line 588 of file class_simplePlugin.inc.

References logging\debug(), DEBUG_LDAP, and logging\log().

◆ openDialog()

openDialog ( FusionDirectoryDialog  $dialog)

This function allows you to open a dialog.

Parameters
FusionDirectoryDialog$dialogThe dialog object

Definition at line 962 of file class_simplePlugin.inc.

◆ plInfo()

static plInfo ( )
static

Return plugin informations for acl handling.

Returns
an array

Implements SimpleTab.

Definition at line 2261 of file class_simplePlugin.inc.

◆ post_save()

post_save ( )
protected

This function is called after LDAP save to do some post operations and logging.

This function calls hooks, update foreign keys and log modification

Definition at line 1471 of file class_simplePlugin.inc.

References getAuditAttributesListFromConf(), handle_post_events(), and logging\log().

◆ set_acl_category()

set_acl_category ( string  $category)

Set acl category.

Parameters
string$category

Implements SimpleTab.

Definition at line 574 of file class_simplePlugin.inc.

◆ setNeedEditMode()

setNeedEditMode ( bool  $needEditMode)

Sets whether the opened objet has an edit button.

Parameters
bool$needEditMode

Implements SimpleTab.

Definition at line 974 of file class_simplePlugin.inc.

References session\is_set().

◆ setTemplate()

setTemplate ( bool  $isTemplate)

Sets whether the opened objet is a template.

Parameters
bool$isTemplate

Implements SimpleTab.

Definition at line 360 of file class_simplePlugin.inc.

References templateHandling\fieldsFromLDAP(), and templateHandling\fieldsToLDAP().

Referenced by __construct().

◆ show_header()

show_header ( string  $buttonHtmlText,
string  $htmlText,
bool  $plugin_enabled,
bool  $button_disabled = FALSE,
string  $name = 'modify_state' 
)

Show header message for tab dialogs.

Parameters
string$buttonHtmlTextThe button text, escaped for HTML output
string$htmlTextThe text to show, as HTML code
boolean$plugin_enabledIs the plugin/tab activated
boolean$button_disabledIs the button disabled
string$nameThe html name of the input, defaults to modify_state

Definition at line 796 of file class_simplePlugin.inc.

References acl_is_createable(), and acl_is_removeable().

◆ showInTemplate()

showInTemplate ( string  $attr,
array  $templateAttrs 
)

Returns TRUE if this attribute should be asked in the creation by template dialog.

Returns
bool whether this attribute should be asked

Implements SimpleTab.

Definition at line 2203 of file class_simplePlugin.inc.

Field Documentation

◆ $attributesAccess

$attributesAccess = []

This attribute store references toward attributes.

associative array that stores attributeLdapName => reference on object

Definition at line 40 of file class_simplePlugin.inc.

◆ $attrs

$attrs = []

Represent temporary LDAP data.

This should only be used internally.

Definition at line 93 of file class_simplePlugin.inc.

Referenced by __construct(), and is_modal_dialog().

◆ $entryCSN

$entryCSN = ''
protected

Object entry CSN.

If an entry was edited while we have edited the entry too, an error message will be shown. To configure this check correctly read the FAQ.

Definition at line 142 of file class_simplePlugin.inc.

◆ $is_account

$is_account = FALSE

Mark plugin as account.

Defines whether this plugin is defined as an account or not. This has consequences for the plugin to be saved from tab mode. If it is set to 'FALSE' the tab will call the delete function, else the save function. Should be set to 'TRUE' if the construtor detects a valid LDAP object.

See also
simplePlugin::is_this_account()

Definition at line 55 of file class_simplePlugin.inc.

◆ $is_template

$is_template = FALSE

Mark plugin as template.

Defines whether we are editing a template or a normal object. Has consequences on the way execute() shows the formular and how save() puts the data to LDAP.

Definition at line 86 of file class_simplePlugin.inc.

◆ $parent

$parent = NULL

Reference to parent object.

This variable is used when the plugin is included in tabs and keeps reference to the tab class. Communication to other tabs is possible by 'name'. So the 'fax' plugin can ask the 'userinfo' plugin for the fax number.

See also
simpleTabs

Definition at line 77 of file class_simplePlugin.inc.

Referenced by simpleService\__construct(), and __construct().


The documentation for this class was generated from the following file: