42 private static $user_locked = FALSE;
56 public $initially_was_account = FALSE;
57 protected $ignore_account = FALSE;
59 public $acl_category =
'';
101 protected $beforeLdapChangeAttributes = [];
109 protected $header =
"";
111 protected $templatePath;
113 protected $dialog = FALSE;
125 protected $member_of_group = FALSE;
126 protected $editing_group = NULL;
127 protected $group_attrs = [];
144 private $hadSubobjects = FALSE;
164 if (self::$user_locked) {
165 $this->read_only = TRUE;
169 $plInfo = pluglist::pluginInfos(get_class($this));
175 if (empty($this->objectclasses) && isset($plInfo[
'plObjectClass'])) {
176 $this->objectclasses = $plInfo[
'plObjectClass'];
182 if (!$this->displayHeader) {
184 $this->ignore_account = TRUE;
187 $this->attributesInfo = [];
190 foreach ($sectionInfo[
'attrs'] as $attr) {
191 $name = $attr->getLdapName();
192 if (isset(
$attrs[$name])) {
194 trigger_error(
"Duplicated attribute LDAP name '$name' in a simplePlugin subclass");
200 $sectionInfo[
'attrs'] =
$attrs;
201 $this->attributesInfo[$section] = $sectionInfo;
202 foreach ($this->attributesInfo[$section][
'attrs'] as $name => $attr) {
203 if (isset($this->attributesAccess[$name])) {
205 trigger_error(
"Duplicated attribute LDAP name '$name' in a simplePlugin subclass");
207 $this->attributesAccess[$name] =& $this->attributesInfo[$section][
'attrs'][$name];
213 if (empty($this->acl_category) && isset($plInfo[
'plCategory'])) {
214 $c = key($plInfo[
'plCategory']);
215 if (is_numeric($c)) {
216 $c = $plInfo[
'plCategory'][$c];
218 $this->acl_category = $c .
'/';
222 if (($this->dn !=
'new') &&
223 isset($_POST[
'open_readonly']) &&
227 if (isset($cache[
'READ_ONLY'][$this->dn])) {
228 $this->read_only = TRUE;
233 if (($this->dn !=
'new' && $this->dn !== NULL) || ($object !== NULL)) {
235 if ($object !== NULL) {
237 $this->attrs = $object->attrs;
238 if (isset($object->is_template)) {
243 $ldap = $config->get_ldap_link();
244 $ldap->cat($this->dn);
245 $this->attrs = $ldap->fetch(TRUE);
246 if (empty($this->attrs)) {
249 if ($this->mainTab) {
253 $this->is_account = TRUE;
258 if (isset($this->attrs[
'objectClass']) &&
in_array_ics(
'fdTemplate', $this->attrs[
'objectClass'])) {
259 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
'found',
'Template check');
261 $this->templateLoadAttrs($this->attrs);
265 if ($this->is_this_account($this->attrs)) {
266 $this->is_account = TRUE;
267 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, get_class($this),
'Tab active');
271 if (is_array($this->inheritance)) {
273 $ldap = $config->get_ldap_link();
274 $ldap->cd($config->current[
'BASE']);
275 foreach ($this->inheritance as $oc => $at) {
276 if ($this->mainTab) {
277 $filter =
'(&(objectClass=' . $oc .
')(' . $at .
'=' . ldap_escape_f($this->dn) .
'))';
279 $filter =
'(&(objectClass=' . $oc .
')' . static::getLdapFilter() .
'(' . $at .
'=' . ldap_escape_f($this->dn) .
'))';
281 $ldap->search($filter, $this->attributes);
282 if ($ldap->count() == 1) {
283 $this->member_of_group = TRUE;
285 $this->group_attrs =
$attrs;
294 $this->loadAttributes();
296 $this->prepareSavedAttributes();
298 $this->orig_dn =
$dn;
300 if ($this->mainTab) {
301 $this->is_account = TRUE;
304 if (!isset($this->templatePath)) {
310 public static function setUserLocked (
bool $locked):
void 312 self::$user_locked = $locked;
315 protected function loadAttributes ()
319 foreach ($this->preInitAttributes as $attr) {
320 $this->attributesAccess[$attr]->setParent($this);
321 $this->attributesAccess[$attr]->loadValue($this->attrs);
324 foreach ($this->attributesInfo as &$sectionInfo) {
325 foreach ($sectionInfo[
'attrs'] as $name => &$attr) {
326 if (in_array($name, $this->preInitAttributes)) {
330 $attr->setParent($this);
331 $attr->loadValue($this->attrs);
338 function is_this_account (
$attrs)
340 $result = static::isAccount(
$attrs);
341 if ($result === NULL) {
342 if (!empty($this->objectclasses)) {
343 trigger_error(
'Deprecated fallback was used for ' . get_called_class() .
'::is_this_account');
346 foreach ($this->objectclasses as $obj) {
347 if (preg_match(
'/^top$/i', $obj)) {
362 $this->is_template = $bool;
363 if ($this->is_template && $this->mainTab) {
365 $this->attributesInfo = array_merge(
368 'class' => [
'fullwidth'],
369 'name' => _(
'Template settings'),
372 _(
'Template name'), _(
'This is the name of the template'),
373 '_template_cn', TRUE,
378 '_template_dummy' => [
379 'class' => [
'invisible'],
380 'name' =>
'_template_dummy',
384 $this->attributesInfo
386 $this->attributesAccess[
'_template_cn'] =& $this->attributesInfo[
'_template'][
'attrs'][
'_template_cn'];
387 $this->attributesAccess[
'_template_cn']->setInLdap(FALSE);
388 $this->attributesAccess[
'_template_cn']->setValue($this->_template_cn);
389 $this->attributesAccess[
'_template_cn']->setParent($this);
390 unset($this->_template_cn);
394 protected function templateLoadAttrs (array $template_attrs)
396 if ($this->mainTab) {
397 $this->_template_cn = $template_attrs[
'cn'][0];
402 protected function templateSaveAttrs ()
405 $ldap = $config->get_ldap_link();
406 $ldap->cat($this->dn);
407 $template_attrs = $ldap->fetch(TRUE);
408 if (!$template_attrs) {
409 if (!$this->mainTab) {
410 trigger_error(
'It seems main tab has not been saved.');
413 'objectClass' => [
'fdTemplate'],
414 'fdTemplateField' => []
418 if ($this->mainTab) {
419 $template_attrs[
'cn'] = $this->_template_cn;
421 return $template_attrs;
428 trigger_error(
'Deprecated');
429 return static::getLdapFilter();
439 if ($name ==
'attributes') {
441 return array_filter(array_keys($this->attributesAccess),
442 function ($a) use ($plugin) {
443 return $plugin->attributesAccess[$a]->isInLdap();
446 } elseif (isset($this->attributesAccess[$name])) {
447 return $this->attributesAccess[$name]->getValue();
458 public function __set ($name, $value)
460 if ($name ==
'attributes') {
461 trigger_error(
'Tried to set obsolete attribute "attributes" (it is now dynamic)');
462 } elseif (isset($this->attributesAccess[$name])) {
463 $this->attributesAccess[$name]->setValue($value);
466 $this->$name = $value;
476 if ($name ==
'attributes') {
479 return isset($this->attributesAccess[$name]);
487 if (!$this->mainTab) {
490 if (!isset($this->parent) || !($this->parent instanceof
simpleTabs)) {
493 _(
'Could not compute dn: no parent tab class for "%s"'),
498 $infos = $this->parent->objectInfos();
499 if ($infos === FALSE) {
502 _(
'Could not compute dn: could not find objectType info from tab class "%s"'),
503 get_class($this->parent)
507 $attr = $infos[
'mainAttr'];
509 if (isset($this->base)) {
512 $base = $config->current[
'BASE'];
514 if ($this->is_template) {
515 return 'cn=' . ldap_escape_dn($this->_template_cn) .
',ou=templates,' . $ou . $base;
517 return $attr .
'=' . ldap_escape_dn($this->attributesAccess[$attr]->computeLdapValue()) .
',' . $ou . $base;
520 protected function addAttribute (
string $section, \
FusionDirectory\Core\SimplePlugin\Attribute $attr)
522 $name = $attr->getLdapName();
523 $this->attributesInfo[$section][
'attrs'][$name] = $attr;
524 $this->attributesAccess[$name] =& $this->attributesInfo[$section][
'attrs'][$name];
525 $this->attributesAccess[$name]->setParent($this);
529 protected function removeAttribute (
string $section,
string $id)
531 unset($this->attributesInfo[$section][
'attrs'][$id]);
532 unset($this->attributesAccess[$id]);
550 $departmentTree = $config->getDepartmentTree();
551 foreach ($departmentTree as
$dn => $name) {
561 if (isset($this->base) && isset($departmentTree[$this->base])) {
562 $deps[$this->base] = $departmentTree[$this->base];
563 } elseif (strtolower($this->dn) != strtolower($config->current[
'BASE'])) {
564 trigger_error(
'Cannot return list of departments, no default base found in class ' . get_class($this) .
'. (base is "' . $this->base .
'")');
576 $this->acl_category =
"$category/";
588 function move (
string $src_dn,
string $dst_dn)
593 if (strtolower($src_dn) == strtolower($dst_dn)) {
598 $ldap = $config->get_ldap_link();
599 $ldap->cd($config->current[
'BASE']);
601 $ldap->create_missing_trees(preg_replace(
'/^[^,]+,/',
'', $dst_dn));
605 if (!$ldap->rename_dn($src_dn, $dst_dn)) {
606 logging::log(
'error',
'ldap',
"FROM: $src_dn -- TO: $dst_dn", [],
'Ldap Protocol v3 implementation error, ldap_rename failed: ' . $ldap->get_error());
608 'Ldap Protocol v3 implementation error. Error:' . $ldap->get_error());
609 return $ldap->get_error();
613 if (preg_match(
'/' . preg_quote($src_dn,
'/') .
'$/i', $ui->dn)) {
614 $ui->dn = preg_replace(
'/' . preg_quote($src_dn,
'/') .
'$/i', $dst_dn, $ui->dn);
619 $ldap->search(
'(objectClass=gosaDepartment)', [
'dn']);
620 if ($ldap->count()) {
621 $config->resetDepartmentCache();
622 $ui->reset_acl_cache();
625 $this->handleForeignKeys($src_dn, $dst_dn);
632 foreach ($this->attributesAccess as $attr) {
633 if ($attr->isRequired()) {
634 $tmp[] = $attr->getLdapName();
640 function editing_group ()
642 if ($this->editing_group == NULL) {
643 if (isset($this->parent)) {
644 $this->editing_group = (get_class($this->parent->getBaseObject()) ==
'ogroup');
649 return $this->editing_group;
658 function execute ():
string 660 trigger_error(
'obsolete');
667 if (is_object($this->dialog)) {
668 $dialogState = $this->dialog->update();
669 if ($dialogState === FALSE) {
681 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn,
'render');
689 $this->displayPlugin = TRUE;
692 if (is_object($this->dialog)) {
693 $this->header = $this->dialog->render();
694 $this->displayPlugin = FALSE;
695 return $this->header;
698 if ($this->displayHeader) {
700 if ($this->parent !== NULL) {
701 list($disabled, $buttonHtmlText, $htmlText) = $this->getDisplayHeaderInfos();
707 get_class($this) .
'_modify_state' 709 if (!$this->is_account) {
710 $this->displayPlugin = FALSE;
711 return $this->header . $this->inheritanceDisplay();
713 } elseif (!$this->is_account) {
714 $plInfo = pluglist::pluginInfos(get_class($this));
715 $this->header =
'<img alt="' .
htmlescape(_(
'Error')) .
'" src="geticon.php?context=status&icon=dialog-error&size=16" align="middle"/> <b>' .
717 $this->displayPlugin = FALSE;
718 return $this->header . $this->inheritanceDisplay();
724 $this->renderAttributes(FALSE);
725 $smarty->assign(
"hiddenPostedInput", get_class($this) .
"_posted");
726 if (isset($this->focusedField)) {
727 $smarty->assign(
"focusedField", $this->focusedField);
728 unset($this->focusedField);
730 $smarty->assign(
"focusedField", key($this->attributesAccess));
733 return $this->header . $smarty->fetch($this->templatePath);
736 public function getDisplayHeaderInfos (): array
738 $plInfo = pluglist::pluginInfos(get_class($this));
739 $disabled = $this->acl_skip_write();
740 if ($this->is_account) {
742 if (isset($plInfo[
'plDepending'])) {
743 foreach ($plInfo[
'plDepending'] as $plugin) {
744 if (isset($this->parent->by_object[$plugin]) &&
745 $this->parent->by_object[$plugin]->is_account) {
747 $dependPlInfos = pluglist::pluginInfos($plugin);
748 $depends[] = $dependPlInfos[
'plShortName'];
757 if (isset($plInfo[
'plDepends'])) {
758 foreach ($plInfo[
'plDepends'] as $plugin) {
759 if (isset($this->parent->by_object[$plugin]) &&
760 !$this->parent->by_object[$plugin]->is_account) {
762 $dependPlInfos = pluglist::pluginInfos($plugin);
763 $depends[] = $dependPlInfos[
'plShortName'];
767 if (isset($plInfo[
'plConflicts'])) {
768 foreach ($plInfo[
'plConflicts'] as $plugin) {
769 if (isset($this->parent->by_object[$plugin]) &&
770 $this->parent->by_object[$plugin]->is_account) {
772 $conflictPlInfos = pluglist::pluginInfos($plugin);
773 $conflicts[] = $conflictPlInfos[
'plShortName'];
780 return [$disabled, $buttonHtmlText, $htmlText];
796 function show_header (
string $buttonHtmlText,
string $htmlText,
bool $plugin_enabled,
bool $button_disabled = FALSE,
string $name =
'modify_state'): string
799 $state =
'disabled="disabled"';
803 $display =
'<div width="100%"><p><b>' . $htmlText .
'</b><br/>' .
"\n";
804 $display .=
'<input type="submit" formnovalidate="formnovalidate" value="' . $buttonHtmlText .
'" name="' . $name .
'" ' . $state .
'></p></div><hr class="separator"/>';
814 return ($this->is_account || $this->ignore_account);
831 if (!is_object($attr)) {
832 $attr = $this->attributesAccess[$attr];
834 if ($attr->getLdapName() ==
'base') {
837 if ($attr->getAcl() ==
'noacl') {
849 if (!is_object($attr)) {
850 $attr = $this->attributesAccess[$attr];
852 if ($attr->getLdapName() ==
'base') {
854 !$this->acl_skip_write() &&
858 if ($attr->getAcl() ==
'noacl') {
871 if (($this->parent instanceof
simpleTabs) && $callParent) {
872 return $this->parent->getAclBase();
874 if (isset($this->dn) && ($this->dn !=
'new')) {
877 if (isset($this->base)) {
878 return 'new,' . $this->base;
881 return $config->current[
'BASE'];
884 function renderAttributes (
bool $readOnly = FALSE)
889 if ($this->is_template) {
890 $smarty->assign(
'template_cnACL', $ui->get_permissions($this->getAclBase(), $this->acl_category .
'template',
'template_cn', $this->acl_skip_write()));
894 if (isset($this->attributesAccess[
'base'])) {
896 $smarty->assign(
'baseACL',
'rw');
898 $smarty->assign(
'baseACL',
'r');
903 foreach ($this->attributesInfo as $section => $sectionInfo) {
904 $smarty->assign(
'section', $sectionInfo[
'name']);
905 $smarty->assign(
'sectionIcon', ($sectionInfo[
'icon'] ?? NULL));
906 $smarty->assign(
'sectionId', $section);
907 $sectionClasses =
'';
908 if (isset($sectionInfo[
'class'])) {
909 $sectionClasses .=
' ' . join(
' ', $sectionInfo[
'class']);
912 $readableSection = FALSE;
913 foreach ($sectionInfo[
'attrs'] as $attr) {
914 if ($attr->getAclInfo() !== FALSE) {
916 $smarty->assign($attr->getAcl() .
'ACL', $this->
aclGetPermissions($attr->getAcl(), NULL, $this->acl_skip_write()));
920 if (!$readableSection && ($readable || $writable)) {
921 $readableSection = TRUE;
923 $attr->renderAttribute($attributes, $readOnly, $readable, $writable);
925 $smarty->assign(
'attributes', $attributes);
926 if (!$readableSection) {
927 $sectionClasses .=
' nonreadable';
929 $smarty->assign(
'sectionClasses', $sectionClasses);
931 if (isset($sectionInfo[
'template'])) {
932 $displaySection = $smarty->fetch($sectionInfo[
'template']);
936 $sections[$section] = $displaySection;
938 $smarty->assign(
"sections", $sections);
941 function inheritanceDisplay ():
string 943 if (!$this->member_of_group) {
946 $class = get_class($this);
947 $attrsWrapper =
new stdClass();
948 $attrsWrapper->attrs = $this->group_attrs;
949 $group =
new $class($this->group_attrs[
'dn'], $attrsWrapper, $this->parent, $this->mainTab);
952 $group->renderAttributes(TRUE);
953 $smarty->assign(
"hiddenPostedInput", get_class($this) .
"_posted");
955 return "<h1>Inherited information:</h1><div></div>\n" . $smarty->fetch($this->templatePath);
964 $this->dialog = $dialog;
971 $this->dialog = NULL;
976 $this->needEditMode = $bool;
979 protected function acl_skip_write ():
bool 987 return (strpos($this->
aclGetPermissions($attribute, NULL, $skipWrite),
'w') !== FALSE);
1035 return in_array(get_class($this), $config->data[
'CATEGORIES'][rtrim($this->acl_category,
'/')][
'classes']);
1041 if (isset($this->parent) && isset($this->parent->ignoreAcls) && $this->parent->ignoreAcls) {
1042 return 'cdmr' . ($skipWrite ?
'' :
'w');
1046 if ($base === NULL) {
1049 return $ui->get_permissions($base, $this->acl_category . get_class($this), $attribute, $skipWrite);
1054 function remove (
bool $fulldelete = FALSE): array
1056 if (!$this->initially_was_account) {
1061 trigger_error(
'remove was called on a tab without enough ACL rights');
1065 $this->prepare_remove();
1066 if ($this->is_template) {
1067 $this->attrs = $this->templateSaveAttrs();
1068 $this->saved_attributes = [];
1071 $errors = $this->pre_remove();
1072 if (!empty($errors)) {
1075 $errors = $this->ldap_remove();
1076 if (!empty($errors)) {
1079 $this->post_remove();
1084 protected function prepare_remove ()
1089 if (!$this->mainTab) {
1091 $ldap = $config->get_ldap_link();
1094 $ldap->cat($this->dn, [
'fdTemplateField',
'objectClass']);
1095 $tmp = $ldap->fetch();
1097 if ($this->is_template) {
1098 if (isset($tmp[
'fdTemplateField'])) {
1099 foreach ($tmp[
'fdTemplateField'] as $tpl_field) {
1100 if (preg_match(
'/^objectClass:(.+)$/', $tpl_field, $m)) {
1106 if (isset($tmp[
'objectClass'])) {
1107 $oc = $tmp[
'objectClass'];
1108 unset($oc[
'count']);
1116 foreach ($this->attributes as $val) {
1117 $this->attrs[
"$val"] = [];
1122 protected function pre_remove ()
1124 if ($this->initially_was_account) {
1125 return $this->
handle_pre_events(
'remove', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1129 protected function ldap_remove (): array
1132 $ldap = $config->get_ldap_link();
1133 if ($this->mainTab) {
1134 $ldap->rmdir_recursive($this->dn);
1137 $ldap->cd($this->dn);
1138 $ldap->modify($this->attrs);
1140 $this->ldap_error = $ldap->get_error();
1142 if ($ldap->success()) {
1149 ($this->mainTab ? LDAP_DEL : LDAP_MOD),
1157 protected function post_remove ()
1159 logging::log(
'remove',
'plugin/' . get_class($this), $this->dn, array_keys($this->attrs), $this->ldap_error);
1162 $errors = $this->
handle_post_events(
'remove', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1163 if (!empty($errors)) {
1164 msg_dialog::displayChecks($errors);
1172 trigger_error(
'obsolete');
1180 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn,
'readPost');
1182 if ($this->displayHeader && isset($_POST[get_class($this) .
'_modify_state'])) {
1184 $this->is_account = FALSE;
1186 $this->is_account = TRUE;
1189 if (is_object($this->dialog)) {
1190 $this->dialog->readPost();
1192 if (isset($_POST[get_class($this) .
'_posted'])) {
1195 foreach ($this->attributesInfo as $sectionInfo) {
1196 foreach ($sectionInfo[
'attrs'] as $attr) {
1199 $attr->loadPostValue();
1204 foreach ($this->attributesInfo as $sectionInfo) {
1205 foreach ($sectionInfo[
'attrs'] as $attr) {
1208 $attr->applyPostValue();
1215 protected function prepareSavedAttributes ()
1222 foreach (array_keys($this->saved_attributes) as $index) {
1223 if (is_numeric($index)) {
1224 unset($this->saved_attributes[$index]);
1228 list($attribute,) = explode(
';', $index, 2);
1229 if (!
in_array_ics($index, $this->attributes) && !
in_array_ics($attribute, $this->attributes) && strcasecmp(
'objectClass', $attribute)) {
1230 unset($this->saved_attributes[$index]);
1234 if (isset($this->saved_attributes[$index][0])) {
1235 if (!isset($this->saved_attributes[$index][
'count'])) {
1236 $this->saved_attributes[$index][
'count'] = count($this->saved_attributes[$index]);
1238 if ($this->saved_attributes[$index][
'count'] == 1) {
1239 $tmp = $this->saved_attributes[$index][0];
1240 unset($this->saved_attributes[$index]);
1241 $this->saved_attributes[$index] = $tmp;
1245 unset($this->saved_attributes[$index][
'count']);
1255 foreach ($this->attrs as $index => $value) {
1258 if (is_array($this->attrs[$index]) &&
1259 (count($this->attrs[$index]) == 1) &&
1260 isset($this->saved_attributes[$index]) &&
1261 !is_array($this->saved_attributes[$index])) {
1262 $this->attrs[$index] = $this->attrs[$index][0];
1266 if (is_array($this->attrs[$index]) &&
1267 (count($this->attrs[$index]) == 0) &&
1268 !isset($this->saved_attributes[$index])) {
1269 unset($this->attrs[$index]);
1274 if (!is_array($this->attrs[$index]) &&
1275 isset($this->saved_attributes[$index]) &&
1276 !is_array($this->saved_attributes[$index]) &&
1277 ($this->attrs[$index] == $this->saved_attributes[$index])) {
1278 unset($this->attrs[$index]);
1283 if (is_array($this->attrs[$index]) &&
1284 isset($this->saved_attributes[$index]) &&
1285 is_array($this->saved_attributes[$index]) &&
1286 !
array_differs($this->attrs[$index], $this->saved_attributes[$index])) {
1287 unset($this->attrs[$index]);
1293 function prepareNextCleanup ()
1296 foreach ($this->attrs as $name => $value) {
1297 $this->saved_attributes[$name] = $value;
1305 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn,
"save");
1306 $errors = $this->prepare_save();
1307 if (!empty($errors)) {
1310 if ($this->is_template) {
1312 if (!empty($errors)) {
1315 $this->attrs = $this->templateSaveAttrs();
1316 $this->saved_attributes = [];
1319 if (!$this->shouldSave()) {
1323 $errors = $this->pre_save();
1324 if (!empty($errors)) {
1328 $errors = $this->ldap_save();
1329 if (!empty($errors)) {
1332 $this->prepareNextCleanup();
1338 protected function shouldSave ():
bool 1340 if ($this->mainTab && !$this->initially_was_account) {
1343 return !empty($this->attrs);
1353 protected function prepare_save (): array
1357 $this->entryCSN =
'';
1363 if (!$this->mainTab || $this->initially_was_account) {
1365 $ldap = $config->get_ldap_link();
1366 $ldap->cat($this->dn, [
'fdTemplateField',
'objectClass']);
1368 $tmp = $ldap->fetch();
1370 if ($this->is_template) {
1371 if (isset($tmp[
'fdTemplateField'])) {
1372 foreach ($tmp[
'fdTemplateField'] as $tpl_field) {
1373 if (preg_match(
'/^objectClass:(.+)$/', $tpl_field, $m)) {
1379 if (isset($tmp[
'objectClass'])) {
1380 $oc = $tmp[
'objectClass'];
1381 unset($oc[
'count']);
1389 foreach ($this->attributesInfo as $sectionInfo) {
1390 foreach ($sectionInfo[
'attrs'] as $attr) {
1391 $attr->fillLdapValue($this->attrs);
1395 foreach ($this->attributesInfo as $sectionInfo) {
1396 foreach ($sectionInfo[
'attrs'] as $attr) {
1397 $attr->fillLdapValueHook($this->attrs);
1404 protected function pre_save (): array
1406 if ($this->initially_was_account) {
1407 return $this->
handle_pre_events(
'modify', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1409 return $this->
handle_pre_events(
'add', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1414 protected function ldap_save (): array
1419 $ldap = $config->get_ldap_link();
1420 if ($this->mainTab && !$this->initially_was_account) {
1421 if ($ldap->dn_exists($this->dn)) {
1425 htmlescape(sprintf(_(
'There is already an entry with the same dn: %s'), $this->dn))
1429 $ldap->cd($config->current[
'BASE']);
1431 $ldap->create_missing_trees(preg_replace(
'/^[^,]+,/',
'', $this->dn));
1437 if (!$ldap->dn_exists($this->dn)) {
1441 htmlescape(sprintf(_(
'The entry %s is not existing'), $this->dn))
1448 $ldap->cd($this->dn);
1449 $ldap->$action($this->attrs);
1450 $this->ldap_error = $ldap->get_error();
1453 if (!$ldap->success()) {
1458 ($action ==
'modify' ? LDAP_MOD : LDAP_ADD),
1475 if (!empty($auditAttributesValuesToBeHidden)) {
1476 foreach ($auditAttributesValuesToBeHidden as $key) {
1477 if (key_exists($key, $this->attrs)) {
1478 $this->attrs[$key] =
'Value not stored by policy';
1484 if ($this->initially_was_account) {
1485 $errors = $this->
handle_post_events(
'modify', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1487 $modifiedAttrs = $this->getModifiedAttributesValues();
1489 logging::log(
'modify',
'plugin/' . get_class($this), $this->dn, [json_encode($modifiedAttrs)], $this->ldap_error);
1492 $errors = $this->
handle_post_events(
'add', [
'modifiedLdapAttrs' => array_keys($this->attrs)]);
1493 logging::log(
'create',
'plugin/' . get_class($this), $this->dn, array_keys($this->attrs), $this->ldap_error);
1496 if (!empty($errors)) {
1497 msg_dialog::displayChecks($errors);
1513 if (!empty($config->current[
'AUDITCONFHIDDENATTRVALUES'])) {
1514 if (is_string($config->current[
'AUDITCONFHIDDENATTRVALUES'])) {
1515 $result[] = $config->current[
'AUDITCONFHIDDENATTRVALUES'];
1517 $result = $config->current[
'AUDITCONFHIDDENATTRVALUES'];
1525 private function getModifiedAttributesValues (): array
1531 $commonKeys = array_intersect_key($this->attrs, $this->beforeLdapChangeAttributes);
1534 foreach ($commonKeys as $key => $value) {
1536 if ($this->attrs[$key] !== $this->beforeLdapChangeAttributes[$key]) {
1537 $newValues = $this->attrs[$key];
1538 $oldValues = $this->beforeLdapChangeAttributes[$key];
1541 if (is_array($newValues) && is_array($oldValues)) {
1543 $diffValues = array_diff($newValues, $oldValues);
1546 if (!empty($diffValues)) {
1547 $result[$key] = $diffValues;
1551 $result[$key] = $newValues;
1568 protected function handle_hooks (
string $when,
string $mode, array $addAttrs = []): array
1572 return $this->
callHook($when .
'CREATE', $addAttrs);
1575 return $this->
callHook($when .
'MODIFY', $addAttrs);
1578 return $this->
callHook($when .
'REMOVE', $addAttrs);
1581 trigger_error(sprintf(
'Invalid %s event type given: "%s"! Valid types are: add, modify, remove.', strtolower($when), $mode));
1592 if ($mode ==
'remove') {
1593 $this->handleForeignKeys($this->dn, NULL);
1594 } elseif ($mode ==
'modify') {
1595 $this->handleForeignKeys();
1608 $this->ldap_error =
'';
1609 if ($this->mainTab && ($mode ==
'remove')) {
1611 $ldap = $config->get_ldap_link();
1612 $ldap->cd($this->dn);
1613 $ldap->search(
'(objectClass=*)', [
'dn'],
'one');
1614 $this->hadSubobjects = ($ldap->count() > 0);
1622 foreach ($this->attributes as $attr) {
1623 if (!isset($addAttrs[$attr])) {
1624 $addAttrs[$attr] = $this->$attr;
1634 function callHook ($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL): array
1636 if ($this->is_template) {
1641 $commands = $config->searchHooks(get_class($this), $cmd);
1644 foreach ($commands as $command) {
1649 $addAttrs[
'callerDN'] = $ui->dn;
1650 $addAttrs[
'callerCN'] = $ui->cn;
1651 $addAttrs[
'callerUID'] = $ui->uid;
1652 $addAttrs[
'callerSN'] = $ui->sn;
1653 $addAttrs[
'callerGIVENNAME'] = $ui->givenName;
1654 $addAttrs[
'callerMAIL'] = $ui->mail;
1657 $addAttrs[
'location'] = $config->current[
'NAME'];
1659 if (isset($this->parent->by_object)) {
1660 foreach ($this->parent->by_object as $class => $object) {
1661 if ($class != get_class($this)) {
1662 $object->fillHookAttrs($addAttrs);
1667 if (!isset($addAttrs[
'base']) && isset($this->base)) {
1668 $addAttrs[
'base'] = $this->base;
1673 exec($command, $arr, $returnCode);
1675 $command = static::passwordProtect($command);
1677 $returnOutput = $arr;
1679 if ($returnCode != 0) {
1680 $str = implode(
"\n", $arr);
1681 $str = static::passwordProtect($str);
1690 } elseif (is_array($arr)) {
1691 $str = implode(
"\n", $arr);
1692 $str = static::passwordProtect($str);
1694 if (!empty($str) && $config->get_cfg_value(
'displayHookOutput',
'FALSE') ==
'TRUE') {
1698 unset($arr, $command, $returnCode);
1707 if (isset($_POST[
"userPassword_password"]) && !empty($_POST[
"userPassword_password"])) {
1708 if (strpos($hookCommand, $_POST[
"userPassword_password"]) !== FALSE) {
1709 $hookCommand = str_replace($_POST[
"userPassword_password"],
'*******', $hookCommand);
1712 return $hookCommand;
1719 logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn,
'check');
1722 foreach ($this->attributesInfo as $sectionInfo) {
1723 foreach ($sectionInfo[
'attrs'] as $attr) {
1724 $error = $attr->check();
1725 if (!empty($error)) {
1726 if (is_array($error)) {
1727 $messages = array_merge($messages, $error);
1729 $messages[] = $error;
1735 $error = $this->
callHook(
'CHECK', [
'nbCheckErrors' => count($messages)], $returnOutput);
1736 if (!empty($error)) {
1737 $messages = array_merge($messages, $error);
1738 } elseif (!empty($returnOutput)) {
1739 $messages[] = join(
"\n", $returnOutput);
1743 if (!empty($this->entryCSN)) {
1745 if (($current_csn != $this->entryCSN) && !empty($current_csn)) {
1746 $this->entryCSN = $current_csn;
1747 $messages[] = _(
'The object has changed since being opened in FusionDirectory. All changes that may be done by others will get lost if you save this entry!');
1754 function handleForeignKeys (
string $olddn = NULL,
string $newdn = NULL,
string $mode =
'move')
1756 if (($olddn !== NULL) && ($olddn == $newdn)) {
1759 if ($this->is_template) {
1762 $this->browseForeignKeys(
1769 function browseForeignKeys (
string $mode, $param1 = NULL, $param2 = NULL)
1771 global $config, $plist;
1773 $subobjects = FALSE;
1774 if (preg_match(
'/^handle_/', $mode)) {
1777 $classes = [get_class($this)];
1778 if (($olddn != $newdn) && $this->mainTab) {
1779 if ($newdn === NULL) {
1780 $subobjects = $this->hadSubobjects;
1782 $ldap = $config->get_ldap_link();
1784 $ldap->search(
'(objectClass=*)', [
'dn'],
'one');
1785 $subobjects = ($ldap->count() > 0);
1788 } elseif ($mode ==
'references') {
1789 $classes = array_keys($this->parent->by_object);
1797 foreach ($plist->dnForeignRefs as $ref) {
1801 $filtersub = $ref[3];
1802 if ($filtersub ==
'*') {
1803 if ($config->get_cfg_value(
'wildcardForeignKeys',
'TRUE') ==
'TRUE') {
1804 $filtersub = $ofield .
'=*';
1809 if ($class ==
'aclAssignment') {
1811 $objectTypes = [
'ACLASSIGNMENT'];
1812 } elseif (is_subclass_of($class,
'simpleService')) {
1813 $objectTypes = [
'SERVER'];
1816 $cinfos = pluglist::pluginInfos($class);
1817 foreach ($cinfos[
'plObjectType'] as $key => $objectType) {
1818 if (!is_numeric($key)) {
1821 if (preg_match(
'/^ogroup-/i', $objectType)) {
1822 $objectType =
'OGROUP';
1824 $objectTypes[] = strtoupper($objectType);
1826 $objectTypes = array_unique($objectTypes);
1828 foreach ($objectTypes as $objectType) {
1832 $foreignRefs[$objectType][
'refs'][$class][$ofield][$field]
1834 'tab' => $classes[0],
1836 'oldvalue' => $oldvalue,
1837 'newvalue' => $newvalue,
1840 if (!preg_match(
'/^\(.*\)$/', $filter)) {
1841 $filter =
'(' . $filter .
')';
1843 $foreignRefs[$objectType][
'filters'][$filter] = $filter;
1847 foreach ($classes as $tabclass) {
1849 $infos = pluglist::pluginInfos($tabclass);
1850 foreach ($infos[
'plForeignRefs'] as $field => $refs) {
1851 if (preg_match(
'/^handle_/', $mode)) {
1853 (($newdn !== NULL) && ($field !=
'dn') && ($mode ==
'handle_move')) ||
1854 (($newdn === NULL) && ($olddn === NULL) && (($field ==
'dn') || (!$this->attributeHaveChanged($field))))
1862 foreach ($refs as $ref) {
1866 $cinfos = pluglist::pluginInfos($class);
1867 if ($class ==
'aclAssignment') {
1869 $objectTypes = [
'ACLASSIGNMENT'];
1870 } elseif (is_subclass_of($class,
'simpleService')) {
1871 $objectTypes = [
'SERVER'];
1874 foreach ($cinfos[
'plObjectType'] as $key => $objectType) {
1875 if (!is_numeric($key)) {
1878 if (preg_match(
'/^ogroup-/i', $objectType)) {
1879 $objectType =
'OGROUP';
1881 $objectTypes[] = $objectType;
1883 $objectTypes = array_unique($objectTypes);
1885 foreach ($objectTypes as $objectType) {
1886 if (preg_match(
'/^handle_/', $mode)) {
1887 if ($field ==
'dn') {
1890 } elseif (($olddn !== NULL) && ($newdn === NULL)) {
1891 $oldvalue = $this->attributeInitialValue($field);
1894 $oldvalue = $this->attributeInitialValue($field);
1895 $newvalue = $this->attributeValue($field);
1897 $foreignRefs[$objectType][
'refs'][$class][$ofield][$field]
1901 'oldvalue' => $oldvalue,
1902 'newvalue' => $newvalue,
1905 } elseif ($mode ==
'references') {
1906 $foreignRefs[$objectType][
'refs'][$class][
'name'] = $cinfos[
'plShortName'];
1908 $foreignRefs[$objectType][
'refs'][$class][
'fields'][$ofield][$field]
1912 'tabname' => $this->parent->by_name[$tabclass],
1913 'value' => $this->parent->by_object[$tabclass]->$field,
1917 if (!preg_match(
'/^\(.*\)$/', $filter)) {
1918 $filter =
'(' . $filter .
')';
1920 $foreignRefs[$objectType][
'filters'][$filter] = $filter;
1931 $SAVED_POST = $_POST;
1934 foreach ($foreignRefs as $objectType => $tabRefs) {
1936 $filters = array_values($tabRefs[
'filters']);
1937 $filter =
'(|' . join($filters) .
')';
1940 $objects =
objects::ls($objectType, [
'dn' =>
'raw'], NULL, $filter);
1947 foreach (array_keys($objects) as
$dn) {
1950 if (preg_match(
'/^handle_/', $mode)) {
1952 foreach ($tabRefs[
'refs'] as $tab => $fieldRefs) {
1954 $pluginobject = $tabobject->getTabOrServiceObject($tab);
1955 if ($pluginobject !== FALSE) {
1957 foreach ($fieldRefs as $ofield => $fields) {
1958 foreach ($fields as $field) {
1960 $pluginobject->foreignKeyUpdate(
1965 'CLASS' => $field[
'tab'],
1966 'FIELD' => $field[
'field'],
1967 'MODE' => preg_replace(
'/^handle_/',
'', $mode),
1973 $pluginobject->update();
1976 $errors = $tabobject->save();
1977 msg_dialog::displayChecks($errors);
1978 } elseif ($mode ==
'references') {
1980 foreach ($tabRefs[
'refs'] as $tab => $tab_infos) {
1982 $pluginobject = $tabobject->getTabOrServiceObject($tab);
1983 if ($pluginobject !== FALSE) {
1985 foreach ($tab_infos[
'fields'] as $ofield => $fields) {
1986 foreach ($fields as $field) {
1987 if ($pluginobject->foreignKeyCheck(
1991 'CLASS' => $field[
'tab'],
1992 'FIELD' => $field[
'field'],
1996 if (!isset($refs[$dn])) {
2004 trigger_error(
"Could not create link to $dn: " . $e->getMessage());
2005 $refs[
$dn][
'link'] =
$dn;
2008 if (!isset($refs[$dn][
'tabs'][$tab])) {
2009 $refs[
$dn][
'tabs'][$tab] = [
2014 if (is_subclass_of($tab,
'simpleService')) {
2015 $refs[
$dn][
'tabs'][$tab][
'link'] =
objects::link($dn, $objectType,
"service_$tab", sprintf(_(
'Service "%s"'), $tab_infos[
'name']));
2017 $refs[
$dn][
'tabs'][$tab][
'link'] =
objects::link($dn, $objectType,
"tab_$tab", sprintf(_(
'Tab "%s"'), $tab_infos[
'name']));
2020 trigger_error(
"Could not create link to $dn $tab: " . $e->getMessage());
2021 $refs[
$dn][
'tabs'][$tab][
'link'] = $tab;
2024 $refs[
$dn][
'tabs'][$tab][
'fields'][$ofield] = $field;
2034 $_POST = $SAVED_POST;
2035 if ($mode ==
'references') {
2050 $ldap = $config->get_ldap_link();
2051 $base = preg_replace(
'/^,*/',
'', $base);
2054 $dn = $attribute .
'=' . ldap_escape_dn($this->$attribute) .
',' . $base;
2055 if ((
$dn == $this->orig_dn) || !$ldap->dn_exists(
$dn)) {
2060 $usableAttributes = [];
2061 foreach ($this->attributes as $attr) {
2062 if (($attr != $attribute) && is_scalar($this->$attr) && ($this->$attr !=
'')) {
2063 $usableAttributes[] = (string)$attr;
2066 for ($i = 1; $i < count($usableAttributes); $i++) {
2068 $dn = $attribute .
'=' . ldap_escape_dn($this->$attribute);
2069 foreach (
$attrs as $attr) {
2070 $dn .=
'+' . $attr .
'=' . ldap_escape_dn($this->$attr);
2073 if ((
$dn == $this->orig_dn) || !$ldap->dn_exists(
$dn)) {
2094 $this->attrs = array_merge($this->attrs, $attrs);
2097 foreach ($this->attributesAccess as $ldapName => &$attr) {
2099 if (in_array($ldapName, $skip)) {
2103 $attr->loadValue($attrs);
2108 $this->is_account = $this->is_this_account($this->attrs);
2119 $this->saved_attributes = [];
2120 $this->initially_was_account = FALSE;
2123 protected function attributeHaveChanged (
string $field):
bool 2125 return $this->attributesAccess[$field]->hasChanged();
2128 protected function attributeValue (
string $field)
2130 return $this->attributesAccess[$field]->getValue();
2133 protected function attributeInitialValue (
string $field)
2135 return $this->attributesAccess[$field]->getInitialValue();
2138 function foreignKeyUpdate (
string $field, $oldvalue, $newvalue, array $source)
2140 if (!isset($source[
'MODE'])) {
2141 $source[
'MODE'] =
'move';
2145 if (is_array($oldvalue) && isset($oldvalue[0])) {
2147 $oldvalue = $oldvalue[0];
2149 if (is_array($newvalue) && isset($newvalue[0])) {
2151 $newvalue = $newvalue[0];
2154 $this->attributesAccess[$field]->foreignKeyUpdate($oldvalue, $newvalue, $source);
2167 function foreignKeyCheck (
string $field, $value, array $source)
2170 if (is_array($value) && isset($value[0])) {
2174 return $this->attributesAccess[$field]->foreignKeyCheck($value, $source);
2179 foreach ($values as $name => $value) {
2180 if (isset($this->attributesAccess[$name])) {
2182 $error = $this->attributesAccess[$name]->deserializeValue($value);
2183 if (!empty($error)) {
2192 htmlescape(sprintf(_(
'Unknown field "%s"'), $name))
2205 if (isset($templateAttrs[$attr])) {
2213 return (isset($this->dialog) && $this->dialog);
2216 static function fillAccountAttrsNeeded (&$needed)
2218 $infos = pluglist::pluginInfos(get_called_class());
2219 if (isset($infos[
'plFilterObject'])) {
2220 $attrs = $infos[
'plFilterObject']->listUsedAttributes();
2221 foreach (
$attrs as $attr) {
2222 if (!isset($needed[$attr])) {
2223 $needed[$attr] =
'*';
2229 static function isAccount (
$attrs)
2231 $infos = pluglist::pluginInfos(get_called_class());
2232 if (isset($infos[
'plFilterObject'])) {
2233 return $infos[
'plFilterObject'](
$attrs);
2238 static function getLdapFilter ()
2240 $infos = pluglist::pluginInfos(get_called_class());
2241 if (isset($infos[
'plFilter'])) {
2242 return $infos[
'plFilter'];
2247 static function getLdapFilterObject ()
2249 $infos = pluglist::pluginInfos(get_called_class());
2250 if (isset($infos[
'plFilterObject'])) {
2251 return $infos[
'plFilterObject'];
2274 $plProvidedAcls = [];
2275 foreach ($attributesInfo as $sectionInfo) {
2276 foreach ($sectionInfo[
'attrs'] as $attr) {
2277 if (($attr->getLdapName() ===
'base') && ($operationalAttributes === NULL)) {
2279 $operationalAttributes = TRUE;
2281 $aclInfo = $attr->getAclInfo();
2282 if ($aclInfo !== FALSE) {
2283 $plProvidedAcls[$aclInfo[
'name']] = $aclInfo[
'desc'];
2287 if ($operationalAttributes) {
2288 $plProvidedAcls[
'createTimestamp'] = _(
'The time the entry was added');
2289 $plProvidedAcls[
'modifyTimestamp'] = _(
'The time the entry was last modified');
2292 return $plProvidedAcls;
2308 static function mainInc ($classname = NULL, $entry_dn = NULL, $tabs = FALSE, $edit_mode = TRUE, $objectType = FALSE)
2310 global $remove_lock, $cleanup, $display, $config, $plug, $ui, $smarty;
2312 if ($classname === NULL) {
2313 $classname = get_called_class();
2316 if ($entry_dn === NULL) {
2317 $entry_dn = $ui->dn;
2320 $plInfo = pluglist::pluginInfos($classname);
2321 $plIcon = (isset($plInfo[
'plIcon']) ? $plInfo[
'plIcon'] :
'plugin.png');
2322 $plHeadline = $plInfo[
'plTitle'];
2323 if ($objectType === FALSE) {
2324 $key = key($plInfo[
'plObjectType']);
2325 if (is_numeric($key)) {
2326 $key = $plInfo[
'plObjectType'][$key];
2333 && ($remove_lock || (isset($_POST[
'edit_cancel']) &&
session::is_set(
'edit')))
2345 if ($edit_mode && isset($_POST[
'edit_cancel'])) {
2351 if (!
session::is_set($classname) || (isset($_GET[
'reset']) && $_GET[
'reset'] == 1)) {
2358 $tabObject->setNeedEditMode(TRUE);
2361 $tabObject->current = $classname;
2369 $tabObject->readPost();
2370 $tabObject->update();
2373 $tabObject->readPostTabChange();
2381 session::set(
'LOCK_VARS_TO_USE', [
'/^edit$/',
'/^plug$/']);
2391 if (isset($_POST[
'edit_finish'])) {
2393 $errors = $tabObject->save();
2396 if (count($errors) == 0) {
2404 msg_dialog::displayChecks($errors);
2410 if ($edit_mode && $lock_msg) {
2411 $display = $lock_msg;
2414 $display .= $tabObject->render();
2416 $display .= $tabObject->by_object[$classname]->render();
2426 $info = $entry_dn .
' ';
2427 if ($edit_mode && (!$tabObject->dialogOpened()) && empty($lock_msg)) {
2430 $display .=
'<p class="plugbottom">' .
"\n";
2431 $display .=
'<input type="submit" name="edit_finish" style="width:80px" value="' .
msgPool::okButton() .
'"/>' .
"\n";
2432 $display .=
' ';
2433 $display .=
'<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="' .
msgPool::cancelButton() .
'"/>' .
"\n";
2434 $display .=
"</p>\n";
2435 } elseif (strpos($tabObject->by_object[$tabObject->current]->aclGetPermissions(
''),
'w') !== FALSE) {
2437 $display .=
'<p class="plugbottom">' .
"\n";
2438 $info .=
'<div style="float:left;" class="optional"><img class="center" alt="information" ' .
2439 'src="geticon.php?context=status&icon=dialog-information&size=16"> ' .
2441 $display .=
'<input type="submit" name="edit" value="' .
msgPool::editButton() .
'"/>' .
"\n";
2442 $display .=
"</p>\n";
2447 if (!preg_match(
'/^geticon/', $plIcon)) {
2450 $smarty->assign(
'headline', $plHeadline);
2451 $smarty->assign(
'headline_image', $plIcon);
2452 $display =
'<div class="pluginfo">' . $info .
"</div>\n" . $display;
$parent
Reference to parent object.
$saved_attributes
The state of the attributes when we opened the object.
htmlescape(string $str)
Escape string for HTML output.
handle_post_events(string $mode, array $addAttrs=[])
Forward command execution requests to the post hook execution method.
This class is made for easy plugin creation for editing LDAP attributes.
setNeedEditMode(bool $bool)
Sets whether the opened objet has an edit button.
in_array_ics($value, array $items)
Check if a value exists in an array (case-insensitive)
getEntryCSN(string $dn)
Get the Change Sequence Number of a certain DN.
$inheritance
FALSE to disable inheritance. Array like array ('objectClass' => 'attribute') to specify oc of the gr...
callHook($cmd, array $addAttrs=[], &$returnOutput=[], &$returnCode=NULL)
Calls external hooks which are defined for this plugin (fusiondirectory.conf) Replaces placeholder by...
get_template_path($filename='', $plugin=FALSE, $path='')
Return themed path for specified base file.
static get($name)
Accessor of a session var.
This interface should be implemented by all dialog classes in FusionDirectory.
acl_is_readable($attribute)
Can we read the acl.
acl_is_createable(string $base=NULL)
Can we create the object.
$objectclasses
The objectClasses set by this tab.
get_allowed_bases()
Returns a list of all available departments for this object.
update()
Update state and return FALSE if the dialog was closed.
handle_hooks(string $when, string $mode, array $addAttrs=[])
Forward command execution requests to the pre/post hook execution method.
static featuresEnabled($name, $depends='')
List the features settings enabled.
This class contains all function to manage tabs classes.
isActivatable()
Test whether a tab can be deactivated.
compute_dn()
This function returns the dn this object should have.
__set($name, $value)
This function allows to use the syntax $plugin->attributeName to set attributes values.
$dn
dn of the opened object
save()
This function saves the object in the LDAP.
$mainTab
Is this plugin the main tab, the one that handle the object itself.
static genLockedMessage(array $locks, bool $allowReadonly=FALSE, string $action=NULL)
Generate a lock message.
& get_userinfo()
Return the current userinfo object.
create_unique_dn(string $attribute, string $base)
Create unique DN.
move(string $src_dn, string $dst_dn)
Move ldap entries from one place to another.
getAclBase(bool $callParent=TRUE)
Get LDAP base to use for ACL checks.
static editButton($escape=TRUE)
Text for an edit button.
static get($objects, bool $allow_readonly=FALSE)
Get locks for objects.
static log(string $action, string $objecttype, string $object, array $changes=[], string $result='')
logging method
static plInfo()
Return plugin informations for acl handling.
static display($title, string $message, int $type=INFO_DIALOG, array $trace=[])
Display a message dialog.
Error returned by any method of SimplePlugin.
static addFeaturesButton($name)
Display Add features button.
static set($name, $value)
Set a value in a session.
acl_is_writeable($attribute, bool $skipWrite=FALSE)
Can we write the attribute.
save_object()
This function handle $_POST informations.
Error returned by a hook called from SimplePlugin.
cleanup()
Remove attributes, empty arrays, arrays single attributes that do not differ.
$ldap_error
Last LDAP error (used by logging calls from post_* methods)
static passwordProtect(string $hookCommand=NULL)
This function protect the clear string password by replacing char.
static ls($types, $attrs=NULL, string $ou=NULL, string $filter='', bool $checkAcl=FALSE, string $scope='subtree', bool $templateSearch=FALSE, bool $sizeLimit=FALSE)
Get list of object of objectTypes from $types in $ou.
static add($object, string $user=NULL)
Add a lock for object(s)
__construct(string $dn=NULL, $object=NULL, $parent=NULL, bool $mainTab=FALSE, array $attributesInfo=NULL)
constructor
& get_smarty()
Get global smarty object.
$attributesAccess
This attribute store references toward attributes.
static generatePlProvidedAcls(array $attributesInfo, bool $operationalAttributes=NULL)
This function generate the needed ACLs for a given attribtues array.
openDialog(FusionDirectoryDialog $dialog)
This function allows you to open a dialog.
__get($name)
This function allows to use the syntax $plugin->attributeName to get attributes values.
$preInitAttributes
Attributes that needs to be initialized before the others.
static featuresDisabled($name, array $depends=[], array $conflicts=[])
List the features settings disabled.
isActive()
Test whether a tab is active.
__isset($name)
This function allows to use the syntax isset($plugin->attributeName)
Error returned by an LDAP operation called from SimplePlugin.
set_acl_category(string $category)
Set acl category.
static open(string $dn, string $type)
Create the tab object for the given dn.
static debug(int $level, int $line, string $function, string $file, $data, string $info='')
Debug output method.
show_header(string $buttonHtmlText, string $htmlText, bool $plugin_enabled, bool $button_disabled=FALSE, string $name='modify_state')
Show header message for tab dialogs.
Parent class for all exceptions thrown in FusionDirectory.
array_differs(array $src, array $dst)
getObjectClassFilter()
This function returns an LDAP filter for this plugin object classes.
static deleteByObject($object)
Remove a lock for object(s)
setTemplate(bool $bool)
Sets whether the opened objet is a template.
acl_is_moveable(string $base=NULL)
Can we move the object.
$read_only
Used when the entry is opened as "readonly" due to locks.
fillHookAttrs(array &$addAttrs)
Fill attributes which may be used in hooks.
$is_account
Mark plugin as account.
static fieldsFromLDAP(array $template_attrs)
Translate template attrs into $attrs as if taken from LDAP.
Fatal error class. Does not extend FusionDirectoryError.
$needEditMode
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)
$orig_dn
original dn of the opened object
static fieldsToLDAP(array $template_attrs, array $attrs)
Translate $attrs into template attrs.
static un_set($name)
Unset a session.
closeDialog()
This function closes the dialog.
getAuditAttributesListFromConf()
static cancelButton($escape=TRUE)
Text for a cancel button.
readPost()
This function handle $_POST informations.
acl_is_removeable(string $base=NULL)
Can we delete the object.
static noValidExtension($name)
Display error about invalid extension from account.
$is_template
Mark plugin as template.
render()
This function display the plugin and return the html code.
mergeObjectClasses(array $oc)
Merge in objectClasses needed by this tab.
attrIsReadable($attr)
Check if logged in user have enough right to read this attribute value.
getRequiredAttributes()
Returns list of required LDAP attributes.
adapt_from_template(array $attrs, array $skip=[])
Adapt from template.
$attrs
Represent temporary LDAP data.
attrIsWriteable($attr)
Check if logged in user have enough right to write this attribute value.
$attributesInfo
This attribute store all information about attributes.
$displayHeader
Do we want a header allowing to able/disable this plugin.
static okButton($escape=TRUE)
Text for a ok button.
static permModify($name='', $field='')
Display that we have no permission to modify an object.
array_merge_unique(array $ar1, array $ar2)
deserializeValues(array $values, bool $checkAcl=TRUE)
Deserialize values.
handle_pre_events(string $mode, array $addAttrs=[])
Forward command execution requests to the pre hook execution method.
Parent class for all errors in FusionDirectory.
check()
This function checks the attributes values and yell if something is wrong.
showInTemplate(string $attr, array $templateAttrs)
Returns TRUE if this attribute should be asked in the creation by template dialog.
readOnly()
Indicates if this object is opened as read-only (because of locks)
array_remove_entries_ics(array $needles, array $haystack)
static link(string $dn, string $type, string $subaction='', $text=NULL, bool $icon=TRUE, bool $link=TRUE)
resetCopyInfos()
This function is called on the copied object to set its dn to where it will be saved.
static is_set($name)
Check if the name of the session is set.
static checkFields($attrs)
Check template fields.
aclHasPermissions()
Test if there are ACLs for this plugin.
This class allow to handle easily a String LDAP attribute.
is_modal_dialog()
Is there a modal dialog opened.
post_save()
This function is called after LDAP save to do some post operations and logging.
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...
static parseString(string $string, array $attrs, $escapeMethod=NULL, string $unique=NULL, string $target=NULL)
Parse template masks in a single string.
class_available($name)
Checks if a class is available.
$entryCSN
Object entry CSN.
static removeFeaturesButton($name)
Display Remove features button.
aclGetPermissions($attribute='0', string $base=NULL, bool $skipWrite=FALSE)
Get the acl permissions for an attribute or the plugin itself.
static clickEditToChange()
Display : Click the "Edit" button below to change information in this dialog.