interface_SimpleTab.inc 4.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)

  Copyright (C) 2018-2019  FusionDirectory

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/*!
23 24
 * \file interface_SimpleTab.inc
 * Source code for the interface SimpleTab
25 26 27 28 29
 */

/*! \brief This interface is implemented by classes intended to be used as tabs, mainly simplePlugin itself.
 */

30
interface SimpleTab
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
{
  /*
   * Public vars expected as well by classes implementing this interface:
   * bool $is_account
   * bool $ignore_account
   * string $dn
   * bool $is_template
   * string $_template_cn (only for main tab of templates)
   * array $attributesAccess (only for main tab of templates)
   * simpleTabs $parent
   * string $acl_base
   */

  /*
   * Public methods needed in some cases:
   * compute_dn (): string (only for main tab)
   * move (string $src_dn, string $dst_dn): TRUE|string (only for main tab)
   */

  public static function plInfo (): array;

  /*! \brief This function returns the html code to display for this tab
   */
  public function execute (): string;

  /*! \brief Save information from POST if needed
   */
  public function save_object ();

  /*! \brief Checks data and return errors
   */
  public function check (): array;

  /*! \brief Delete tab data from LDAP and return errors
   */
  public function remove (bool $fulldelete = FALSE): array;

  /*! \brief Save data to the LDAP and return errors
   */
  public function save (): array;

  /*! \brief Reset information after a copy/paste
   */
  public function resetCopyInfos ();

  /*! \brief    Forward plugin acls
   */
  public function set_acl_base (string $base);

  /*! \brief Sets ACL category provided by simpleTabs
   */
  public function set_acl_category (string $category);

  /*!
   * \brief Can we delete the object
   *
   * Only used on main tab
   *
   * \param string $base
   */
  public function acl_is_removeable (string $base = NULL): bool;

  /*!
   * \brief Sets whether the opened objet is a template
   *
   * \param bool $isTemplate
   */
  public function setTemplate (bool $isTemplate);

  /*!
   * \brief Sets whether the opened objet has an edit button
   *
   * \param bool $needEditMode
   */
  public function setNeedEditMode (bool $needEditMode);

  /*!
   * \brief Is there a modal dialog opened
   */
  public function is_modal_dialog (): bool;

  /*!
   * \brief Returns list of required LDAP attributes
   *
   * Used by template
   */
  public function getRequiredAttributes (): array;

  /*!
   * \brief Returns TRUE if this attribute should be asked in the creation by template dialog
   */
  public function showInTemplate (string $attr, array $templateAttrs): bool;

  /*!
   * \brief Adapt from template
   */
  public function adapt_from_template (array $attrs, array $skip = []);

  /*!
   * \brief Deserialize values
   */
  public function deserializeValues (array $values, bool $checkAcl = TRUE);

  /*!
   * \brief Get the acl permissions for an attribute or the plugin itself
   */
  public function aclGetPermissions ($attribute = '0', string $base = NULL, bool $skipWrite = FALSE): string;

  /*!
   * \brief Merge in objectClasses needed by this tab
   *
   *  Used by prepare_save and template::apply
   */
  public function mergeObjectClasses (array $oc): array;
145 146 147 148 149 150 151

  /*!
   * \brief Fill attributes which may be used in hooks
   *
   *  Used by simplePlugin::callHook
   */
  public function fillHookAttrs (array &$addAttrs);
152
}