Exemplo n.º 1
0
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile') {
         return PluginAccountsAccount::getTypeName(2);
     }
     return '';
 }
Exemplo n.º 2
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $image = "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/pics/cadenas.png' title='" . _n('Encryption key', 'Encryption keys', 2) . "' alt='" . _n('Encryption key', 'Encryption keys', 2, 'accounts') . "'>";
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = "/plugins/accounts/front/account.php";
     $menu['page'] = "/plugins/accounts/front/account.php";
     $menu['links']['search'] = PluginAccountsAccount::getSearchURL(false);
     $menu['links'][$image] = PluginAccountsHash::getSearchURL(false);
     if (PluginAccountsAccount::canCreate()) {
         $menu['links']['add'] = PluginAccountsAccount::getFormURL(false);
     }
     $menu['options']['account']['title'] = PluginAccountsAccount::getTypeName(2);
     $menu['options']['account']['page'] = PluginAccountsAccount::getSearchURL(false);
     $menu['options']['account']['links']['search'] = PluginAccountsAccount::getSearchURL(false);
     $menu['options']['account']['links'][$image] = PluginAccountsHash::getSearchURL(false);
     if (PluginAccountsAccount::canCreate()) {
         $menu['options']['account']['links']['add'] = PluginAccountsAccount::getFormURL(false);
     }
     $menu['options']['hash']['title'] = PluginAccountsHash::getTypeName(2);
     $menu['options']['hash']['page'] = PluginAccountsHash::getSearchURL(false);
     $menu['options']['hash']['links']['search'] = PluginAccountsHash::getSearchURL(false);
     $menu['options']['hash']['links'][$image] = PluginAccountsHash::getSearchURL(false);
     if (PluginAccountsHash::canCreate()) {
         $menu['options']['hash']['links']['add'] = PluginAccountsHash::getFormURL(false);
     }
     return $menu;
 }
Exemplo n.º 3
0
function plugin_init_accounts()
{
    global $PLUGIN_HOOKS, $CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['accounts'] = true;
    $PLUGIN_HOOKS['change_profile']['accounts'] = array('PluginAccountsProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['accounts'] = true;
    if (Session::getLoginUserID()) {
        // Params : plugin name - string type - number - attributes
        Plugin::registerClass('PluginAccountsAccount', array('linkgroup_types' => true, 'linkuser_types' => true, 'linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'notificationtemplates_types' => true, 'header_types' => true));
        Plugin::registerClass('PluginAccountsConfig', array('addtabon' => 'CronTask'));
        Plugin::registerClass('PluginAccountsProfile', array('addtabon' => 'Profile'));
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_accounts"] = 1;
            if (plugin_accounts_haveRight("accounts", "r")) {
                $PLUGIN_HOOKS['helpdesk_menu_entry']['accounts'] = '/front/account.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['accounts']['title'] = PluginAccountsAccount::getTypeName(2);
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['accounts']['page'] = '/plugins/accounts/front/account.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['accounts']['links']['search'] = '/plugins/accounts/front/account.php';
                $PLUGIN_HOOKS['redirect_page']['accounts'] = "front/account.form.php";
            }
            if (plugin_accounts_haveRight("accounts", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['accounts']['links']['add'] = '/plugins/accounts/front/account.form.php';
                $PLUGIN_HOOKS['use_massive_action']['accounts'] = 1;
                if (Session::haveRight("config", "w") && plugin_accounts_haveRight("accounts", "w")) {
                    //TODO check it
                    $PLUGIN_HOOKS['submenu_entry']['environment']['options']['accounts']['links']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/pics/cadenas.png' title='" . _n('Encryption key', 'Encryption keys', 2) . "' alt='" . _n('Encryption key', 'Encryption keys', 2, 'accounts') . "'>"] = '/plugins/accounts/front/hash.php';
                    $PLUGIN_HOOKS['submenu_entry']['environment']['options']['hash']['page'] = '/plugins/accounts/front/hash.php';
                    $PLUGIN_HOOKS['submenu_entry']['environment']['options']['hash']['title'] = _n('Encryption key', 'Encryption keys', 2, 'accounts');
                    $PLUGIN_HOOKS['submenu_entry']['environment']['options']['hash']['links']['add'] = '/plugins/accounts/front/hash.form.php';
                    $PLUGIN_HOOKS['submenu_entry']['environment']['options']['hash']['links']['search'] = '/plugins/accounts/front/hash.php';
                }
            }
        } else {
            // Display a menu entry ?
            if (plugin_accounts_haveRight("accounts", "r")) {
                $PLUGIN_HOOKS['menu_entry']['accounts'] = 'front/account.php';
                $PLUGIN_HOOKS['helpdesk_menu_entry']['accounts'] = '/front/account.php';
                $PLUGIN_HOOKS['submenu_entry']['accounts']['search'] = 'front/account.php';
                $PLUGIN_HOOKS['redirect_page']['accounts'] = "front/account.form.php";
            }
            if (plugin_accounts_haveRight("accounts", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['accounts']['add'] = 'front/account.form.php';
                $PLUGIN_HOOKS['header_entry']['accounts'] = array(__('New account') => '/plugins/accounts/front/account.form.php');
                $PLUGIN_HOOKS['header_action']['accounts'] = 'plugin_accounts_header_action';
                $PLUGIN_HOOKS['use_massive_action']['accounts'] = 1;
                if (Session::haveRight("config", "w") && plugin_accounts_haveRight("accounts", "w")) {
                    $PLUGIN_HOOKS['submenu_entry']['accounts']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/pics/cadenas.png' title='" . _n('Encryption key', 'Encryption keys', 2) . "' alt='" . _n('Encryption key', 'Encryption keys', 2, 'accounts') . "'>"] = 'front/hash.php';
                    $PLUGIN_HOOKS['submenu_entry']['accounts']['options']['hash']['page'] = '/plugins/accounts/front/hash.php';
                    $PLUGIN_HOOKS['submenu_entry']['accounts']['options']['hash']['title'] = _n('Encryption key', 'Encryption keys', 2, 'accounts');
                    $PLUGIN_HOOKS['submenu_entry']['accounts']['options']['hash']['links']['add'] = '/plugins/accounts/front/hash.form.php';
                    $PLUGIN_HOOKS['submenu_entry']['accounts']['options']['hash']['links']['search'] = '/plugins/accounts/front/hash.php';
                }
            }
        }
        //Clean Plugin on Profile delete
        if (class_exists('PluginAccountsAccount_Item')) {
            // only if plugin activated
            $PLUGIN_HOOKS['pre_item_purge']['accounts'] = array('Profile' => array('PluginAccountsProfile', 'purgeProfiles'));
            $PLUGIN_HOOKS['plugin_datainjection_populate']['accounts'] = 'plugin_datainjection_populate_accounts';
        }
        // Add specific files to add to the header : javascript or css
        //$PLUGIN_HOOKS['add_javascript']['example']="example.js";
        $PLUGIN_HOOKS['add_javascript']['accounts'] = "lightcrypt.js";
        $PLUGIN_HOOKS['migratetypes']['accounts'] = 'plugin_datainjection_migratetypes_accounts';
        // End init, when all types are registered
        $PLUGIN_HOOKS['post_init']['accounts'] = 'plugin_accounts_postinit';
    }
}
Exemplo n.º 4
0
}
$plugin = new Plugin();
if ($plugin->isActivated("accounts")) {
    Session::checkRight("config", UPDATE);
    $PluginAccountsHash = new PluginAccountsHash();
    $PluginAccountsHash->getFromDB(1);
    $hash = $PluginAccountsHash->fields["hash"];
    $update = 0;
    if (countElementsInTable("glpi_plugin_accounts_accounts") > 0) {
        $update = 1;
    }
    if (empty($hash)) {
        if ($plugin->isActivated("environment")) {
            Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "accounts");
        } else {
            Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginaccountsmenu", "account");
        }
        if ($_SESSION['glpiactive_entity'] == 0) {
            if ($update == 1) {
                echo "<div class='center b'>" . __('Upgrade') . "</div><br><br>";
                echo "<div class='center b'>" . __('1. Define the encryption key and create hash', 'accounts') . "</div><br><br>";
                $options = array("update" => true, "upgrade" => 1);
                $PluginAccountsHash->showForm(1, $options);
            }
        } else {
            echo "<div class='center red'>" . __('Go to Root Entity', 'accounts') . "</div>";
        }
        Html::footer();
    }
} else {
    Html::header(__('Setup'), '', "config", "plugins");
Exemplo n.º 5
0
                             if (isset($_POST["deleteaccounts"])) {
                                 $input = array('id' => $_POST["id"]);
                                 $account_item->check($_POST["id"], 'w');
                                 $account_item->delete($input);
                                 Html::back();
                             } else {
                                 $account->checkGlobal("r");
                                 if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
                                     $plugin = new Plugin();
                                     if ($plugin->isActivated("environment")) {
                                         Html::header(PluginAccountsAccount::getTypeName(2), '', "plugins", "environment", "accounts");
                                     } else {
                                         Html::header(PluginAccountsAccount::getTypeName(2), '', "plugins", "accounts");
                                     }
                                 } else {
                                     Html::helpHeader(PluginAccountsAccount::getTypeName(2));
                                 }
                                 $account->showForm($_GET["id"]);
                                 if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
                                     Html::footer();
                                 } else {
                                     Html::helpFooter();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
accounts 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 accounts. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("config", "w");
$plugin = new plugin();
if ($plugin->isActivated("environment")) {
    Html::header(PluginAccountsAccount::getTypeName(2), '', "plugins", "environment", "accounts");
} else {
    Html::header(PluginAccountsAccount::getTypeName(2), '', "plugins", "accounts");
}
$PluginAccountsHash = new PluginAccountsHash();
$account = new PluginAccountsAccount();
if (isset($_POST["update_encrypted_password"]) && isset($_POST["item"])) {
    foreach ($_POST["upgrade_accounts"] as $key => $val) {
        foreach ($_POST["item"] as $key2 => $val2) {
            $encrypted_password = "******" . $key2;
            $_POST[$encrypted_password] = addslashes($_POST[$encrypted_password]);
            if (isset($_POST[$encrypted_password]) && $_POST[$encrypted_password]) {
                $query = "UPDATE `glpi_plugin_accounts_accounts`\n                     SET `encrypted_password` ='" . $_POST[$encrypted_password] . "'\n                              WHERE `id` ='" . $key2 . "' ;";
                $result = $DB->query($query);
                $_SESSION['plugin_accounts']['upgrade'][] = $key2;
            }
        }
    }
Exemplo n.º 7
0
                                $hash = $hashe["hash"];
                            }
                        }
                        if (!empty($_POST["aeskeynew"]) && !empty($_POST["aeskey"]) && !empty($hash)) {
                            if ($hash != hash("sha256", hash("sha256", $_POST["aeskey"]))) {
                                Session::addMessageAfterRedirect(__('Wrong encryption key', 'accounts'), true, ERROR);
                                Html::back();
                            } else {
                                PluginAccountsHash::updateHash($_POST["aeskey"], $_POST["aeskeynew"], $hash_id);
                                Session::addMessageAfterRedirect(__('Encryption key modified', 'accounts'), true);
                                Html::back();
                            }
                        } else {
                            Session::addMessageAfterRedirect(__('The old or the new encryption key can not be empty', 'accounts'), true, ERROR);
                            Html::back();
                        }
                    }
                } else {
                    if ($plugin->isActivated("environment")) {
                        Html::header(PluginAccountsAccount::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "hash");
                    } else {
                        Html::header(PluginAccountsAccount::getTypeName(2), '', "admin", "pluginaccountsmenu", "hash");
                    }
                    $options = array("id" => $_GET['id'], "update" => false, "upgrade" => 0);
                    $hashClass->display($options);
                    Html::footer();
                }
            }
        }
    }
}
Exemplo n.º 8
0
 public function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'accounts'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginAccountsAccount::getTypeName(2) . ":</td><td>";
     Profile::dropdownNoneReadWrite("accounts", $this->fields["accounts"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . __('See accounts of my groups', 'accounts') . ":</td><td>";
     Profile::dropdownNoneReadWrite("my_groups", $this->fields["my_groups"], 1, 1, 0);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See all accounts', 'accounts') . ":</td><td>";
     Profile::dropdownNoneReadWrite("all_users", $this->fields["all_users"], 1, 1, 0);
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginAccountsAccount::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 9
0
 /**
  * Get Tab Name used for itemtype
  *
  * NB : Only called for existing object
  *      Must check right on what will be displayed + template
  *
  * @since version 0.83
  *
  * @param $item                     CommonDBTM object for which the tab need to be displayed
  * @param $withtemplate    boolean  is a template object ? (default 0)
  *
  *  @return string tab name
  **/
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         if ($item->getType() == 'PluginAccountsAccount' && count(PluginAccountsAccount::getTypes(false))) {
             if ($_SESSION['glpishow_count_on_tabs']) {
                 return self::createTabEntry(_n('Associated item', 'Associated items', 2), self::countForAccount($item));
             }
             return _n('Associated item', 'Associated items', 2);
         } else {
             if (in_array($item->getType(), PluginAccountsAccount::getTypes(true)) && plugin_accounts_haveRight('accounts', 'r')) {
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     return self::createTabEntry(PluginAccountsAccount::getTypeName(2), self::countForItem($item));
                 }
                 return PluginAccountsAccount::getTypeName(2);
             }
         }
     }
     return '';
 }
Exemplo n.º 10
0
function plugin_accounts_getAddSearchOptions($itemtype)
{
    $sopt = array();
    if (in_array($itemtype, PluginAccountsAccount::getTypes(true))) {
        if (plugin_accounts_haveRight("accounts", "r")) {
            $sopt[1900]['table'] = 'glpi_plugin_accounts_accounts';
            $sopt[1900]['field'] = 'name';
            $sopt[1900]['name'] = PluginAccountsAccount::getTypeName(2) . " - " . __('Name');
            $sopt[1900]['forcegroupby'] = true;
            $sopt[1900]['datatype'] = 'itemlink';
            $sopt[1900]['massiveaction'] = false;
            $sopt[1900]['itemlink_type'] = 'PluginAccountsAccount';
            if ($itemtype != 'User') {
                $sopt[1900]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_accounts_accounts_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            }
            $sopt[1901]['table'] = 'glpi_plugin_accounts_accounttypes';
            $sopt[1901]['field'] = 'name';
            $sopt[1901]['name'] = PluginAccountsAccount::getTypeName(2) . " - " . __('Type');
            $sopt[1901]['forcegroupby'] = true;
            $sopt[1901]['joinparams'] = array('beforejoin' => array(array('table' => 'glpi_plugin_accounts_accounts', 'joinparams' => $sopt[1900]['joinparams'])));
            $sopt[1901]['datatype'] = 'dropdown';
            $sopt[1901]['massiveaction'] = false;
        }
    }
    return $sopt;
}