30 static function plInfo (): array
33 'plShortName' =>
'SnapshotCreateDialog',
37 static function getAttributesInfo (): array
41 'name' => _(
'Creating an object snapshot'),
44 _(
'Object'), _(
'DN of the object you are creating a snapshot of'),
48 _(
'Timestamp'), _(
'Timestamp of this snapshot creation'),
52 _(
'Reason'), _(
'Reason for creating this snapshot'),
60 'name' => _(
'dataSource - only available via web-service.'),
63 'Data source', _(
'Origin / Source of the data'),
64 'snapshotSource', FALSE,
73 parent::__construct(NULL, NULL, $parent);
75 $this->attributesAccess[
'description']->setInLdap(FALSE);
76 $this->attributesAccess[
'snapshotSource']->setInLdap(FALSE);
77 $this->attributesAccess[
'snapshotSource']->setVisible(FALSE);
79 $recordedDataSources = $this->getLdapRecordedDataSources();
80 if (!empty($recordedDataSources)) {
81 $this->attributesAccess[
'snapshotSource']->setChoices($recordedDataSources);
84 $this->object_dn =
$dn;
85 $this->aclCategory = $aclCategory;
91 public function getLdapRecordedDataSources () : array
95 $recordedDataSources = [];
96 if (isset($config->current[
'SNAPSHOTSOURCEDATA']) && !empty($config->current[
'SNAPSHOTSOURCEDATA'])) {
97 $recordedDataSources = $config->current[
'SNAPSHOTSOURCEDATA'];
100 return $recordedDataSources;
108 return $this->object_dn;
119 if (!is_object($attr)) {
120 $attr = $this->attributesAccess[$attr];
122 if ($attr->getLdapName() ==
'description') {
123 return in_array(
'c', $ui->get_snapshot_permissions($this->object_dn, $this->aclCategory));
125 return parent::attrIsWriteable($attr);
129 function renderAttributes (
bool $readOnly = FALSE)
134 $permissions = $ui->get_snapshot_permissions($this->object_dn, $this->aclCategory);
136 if (in_array(
'c', $permissions)) {
139 $smarty->assign(
'SnapshotHandlerACL', $acl);
141 return parent::renderAttributes($readOnly);
146 $this->timestamp = date(_(
'Y-m-d, H:i:s'));
147 return parent::update();
153 if (empty($this->snapshotSource)) {
154 $this->snapshotSource =
'FD';
156 $this->parent->createSnapshot($this->object_dn, $this->description, $this->snapshotSource);
162 parent::fillHookAttrs($addAttrs);
163 foreach (array_keys($this->attributesAccess) as $attr) {
164 if (!isset($addAttrs[$attr])) {
165 $addAttrs[$attr] = $this->$attr;
This class allow to handle easily a Select LDAP attribute with a set of choices.
$parent
Reference to parent object.
Snapshot creation dialog.
$dn
dn of the opened object
attrIsWriteable($attr)
Check if logged in user have enough right to write this attribute value.
update()
Update state and return FALSE if the dialog was closed.
& get_smarty()
Get global smarty object.
fillHookAttrs(array &$addAttrs)
Fill attributes which may be used in hooks.
This class allow to display a text in front of an attribute.
This class allow to handle easily a String LDAP attribute that appears as a text area.
save()
Save data to the LDAP and return errors.
getAclBase(bool $callParent=TRUE)
Get LDAP base to use for ACL checks.