diff --git a/accounts.css b/accounts.css
index 15b0380..d2e3abb 100644
--- a/accounts.css
+++ b/accounts.css
@@ -33,3 +33,8 @@
color: red;
font-weight: 900;
}
+
+.default_encryption_key {
+ font-weight: bold;
+ color: red;
+}
\ No newline at end of file
diff --git a/ajax/getHashOnSelectEncryptionKey.php b/ajax/getHashOnSelectEncryptionKey.php
new file mode 100644
index 0000000..ed7c11e
--- /dev/null
+++ b/ajax/getHashOnSelectEncryptionKey.php
@@ -0,0 +1,42 @@
+.
+ --------------------------------------------------------------------------
+ */
+
+
+include('../../../inc/includes.php');
+
+header("Content-Type: text/html; charset=UTF-8");
+
+Session::checkLoginUser();
+
+if (isset($_POST["id"])) {
+ $hashKey = new PluginAccountsHash();
+ $hashKey->getFromDB($_POST["id"]);
+ echo $hashKey->getField('hash');
+}
+
diff --git a/hook.php b/hook.php
index b8f6266..fc305bf 100644
--- a/hook.php
+++ b/hook.php
@@ -39,117 +39,127 @@ function plugin_accounts_install() {
$update78 = false;
$update171 = false;
if (!$DB->tableExists("glpi_plugin_compte")
- && !$DB->tableExists("glpi_plugin_comptes")
- && !$DB->tableExists("glpi_comptes")
- && !$DB->tableExists("glpi_plugin_accounts_accounts")) {
+ && !$DB->tableExists("glpi_plugin_comptes")
+ && !$DB->tableExists("glpi_comptes")
+ && !$DB->tableExists("glpi_plugin_accounts_accounts")) {
$install = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/empty-2.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/empty-2.6.0.sql");
} else if ($DB->tableExists("glpi_comptes")
- && !$DB->fieldExists("glpi_comptes", "notes")) {
+ && !$DB->fieldExists("glpi_comptes", "notes")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
$_SESSION['plugin_acounts_upgrading'] = 1;
} else if ($DB->tableExists("glpi_plugin_comptes")
- && !$DB->fieldExists("glpi_plugin_comptes", "all_users")) {
+ && !$DB->fieldExists("glpi_plugin_comptes", "all_users")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
$_SESSION['plugin_acounts_upgrading'] = 1;
} else if ($DB->tableExists("glpi_plugin_compte_profiles")
- && !$DB->fieldExists("glpi_plugin_compte_profiles", "my_groups")) {
+ && !$DB->fieldExists("glpi_plugin_compte_profiles", "my_groups")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
$_SESSION['plugin_acounts_upgrading'] = 1;
} else if ($DB->tableExists("glpi_plugin_compte_profiles")
- && $DB->fieldExists("glpi_plugin_compte_profiles", "interface")) {
+ && $DB->fieldExists("glpi_plugin_compte_profiles", "interface")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
$_SESSION['plugin_acounts_upgrading'] = 1;
} else if ($DB->tableExists("glpi_plugin_compte")
- && !$DB->fieldExists("glpi_plugin_compte", "date_mod")) {
+ && !$DB->fieldExists("glpi_plugin_compte", "date_mod")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
} else if ($DB->tableExists("glpi_plugin_compte")
- && !$DB->tableExists("glpi_plugin_compte_aeskey")) {
+ && !$DB->tableExists("glpi_plugin_compte_aeskey")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.5.3.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
} else if ($DB->tableExists("glpi_plugin_compte")
- && !$DB->tableExists("glpi_plugin_accounts_accounts")) {
+ && !$DB->tableExists("glpi_plugin_accounts_accounts")) {
$update78 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.6.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
} else if ($DB->tableExists("glpi_plugin_accounts_accounts")
- && !$DB->fieldExists("glpi_plugin_accounts_accounts", "locations_id")) {
+ && !$DB->fieldExists("glpi_plugin_accounts_accounts", "locations_id")) {
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql");
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.0.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
} else if ($DB->tableExists("glpi_plugin_accounts_hashes")
- && !$DB->fieldExists("glpi_plugin_accounts_hashes", "entities_id")) {
+ && !$DB->fieldExists("glpi_plugin_accounts_hashes", "entities_id")) {
$update171 = true;
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql");
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.7.1.sql");
}
//from 1.6 version
if ($DB->tableExists("glpi_plugin_accounts_accounts")
- && !$DB->fieldExists("glpi_plugin_accounts_accounts", "users_id_tech")) {
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.8.0.sql");
+ && !$DB->fieldExists("glpi_plugin_accounts_accounts", "users_id_tech")) {
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.8.0.sql");
}
//from 1.9 version
if ($DB->tableExists("glpi_plugin_accounts_accounttypes")
- && !$DB->fieldExists("glpi_plugin_accounts_accounttypes", "is_recursive")) {
- $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.9.0.sql");
+ && !$DB->fieldExists("glpi_plugin_accounts_accounttypes", "is_recursive")) {
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-1.9.0.sql");
}
+ //from 2.7 version
+ if ($DB->tableExists("glpi_plugin_accounts_accounts")
+ && !$DB->fieldExists("glpi_plugin_accounts_accounts", "plugin_accounts_hash_id")) {
+ $DB->runFile(GLPI_ROOT . "/plugins/accounts/install/sql/update-2.7.0.sql");
+ include_once(GLPI_ROOT . "/plugins/accounts/install/update_270_migrateMultiHashEntities.php");
+ update_270_migrateMultiHashEntities();
+ }
+
+
+
if ($install || $update78) {
/***** Begin Notif New account *****/
//Do One time on 0.78
@@ -265,18 +275,18 @@ function plugin_accounts_install() {
Plugin::migrateItemType(
[1900 => 'PluginAccountsAccount',
- 1901 => 'PluginAccountsHelpdesk',
- 1902 => 'PluginAccountsGroup'],
+ 1901 => 'PluginAccountsHelpdesk',
+ 1902 => 'PluginAccountsGroup'],
["glpi_savedsearches", "glpi_savedsearches_users", "glpi_displaypreferences",
- "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"],
+ "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"],
["glpi_plugin_accounts_accounts_items"]);
Plugin::migrateItemType(
[1200 => "PluginAppliancesAppliance",
- 1300 => "PluginWebapplicationsWebapplication",
- 1700 => "PluginCertificatesCertificate",
- 4400 => "PluginDomainsDomain",
- 2400 => "PluginDatabasesDatabase"],
+ 1300 => "PluginWebapplicationsWebapplication",
+ 1700 => "PluginCertificatesCertificate",
+ 4400 => "PluginDomainsDomain",
+ 2400 => "PluginDatabasesDatabase"],
["glpi_plugin_accounts_accounts_items"]);
}
@@ -342,14 +352,14 @@ function plugin_accounts_uninstall() {
}
$tables = ["glpi_plugin_accounts_accounts",
- "glpi_plugin_accounts_accounts_items",
- "glpi_plugin_accounts_accounttypes",
- "glpi_plugin_accounts_accountstates",
- "glpi_plugin_accounts_configs",
- "glpi_plugin_accounts_hashs",
- "glpi_plugin_accounts_hashes",
- "glpi_plugin_accounts_aeskeys",
- "glpi_plugin_accounts_notificationstates"];
+ "glpi_plugin_accounts_accounts_items",
+ "glpi_plugin_accounts_accounttypes",
+ "glpi_plugin_accounts_accountstates",
+ "glpi_plugin_accounts_configs",
+ "glpi_plugin_accounts_hashs",
+ "glpi_plugin_accounts_hashes",
+ "glpi_plugin_accounts_aeskeys",
+ "glpi_plugin_accounts_notificationstates"];
foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `$table`;");
@@ -357,17 +367,17 @@ function plugin_accounts_uninstall() {
//old versions
$tables = ["glpi_plugin_comptes",
- "glpi_plugin_compte_device",
- "glpi_dropdown_plugin_compte_type",
- "glpi_dropdown_plugin_compte_status",
- "glpi_plugin_compte_profiles",
- "glpi_plugin_compte_config",
- "glpi_plugin_compte_default",
- "glpi_plugin_compte_mailing",
- "glpi_plugin_compte",
- "glpi_plugin_compte_hash",
- "glpi_plugin_compte_aeskey",
- "glpi_plugin_accounts_profiles"];
+ "glpi_plugin_compte_device",
+ "glpi_dropdown_plugin_compte_type",
+ "glpi_dropdown_plugin_compte_status",
+ "glpi_plugin_compte_profiles",
+ "glpi_plugin_compte_config",
+ "glpi_plugin_compte_default",
+ "glpi_plugin_compte_mailing",
+ "glpi_plugin_compte",
+ "glpi_plugin_compte_hash",
+ "glpi_plugin_compte_aeskey",
+ "glpi_plugin_accounts_profiles"];
foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `$table`;");
@@ -377,20 +387,20 @@ function plugin_accounts_uninstall() {
$notif_template = new Notification_NotificationTemplate();
$options = ['itemtype' => 'PluginAccountsAccount',
- 'event' => 'new',
- 'FIELDS' => 'id'];
+ 'event' => 'new',
+ 'FIELDS' => 'id'];
foreach ($DB->request('glpi_notifications', $options) as $data) {
$notif->delete($data);
}
$options = ['itemtype' => 'PluginAccountsAccount',
- 'event' => 'ExpiredAccounts',
- 'FIELDS' => 'id'];
+ 'event' => 'ExpiredAccounts',
+ 'FIELDS' => 'id'];
foreach ($DB->request('glpi_notifications', $options) as $data) {
$notif->delete($data);
}
$options = ['itemtype' => 'PluginAccountsAccount',
- 'event' => 'AccountsWhichExpire',
- 'FIELDS' => 'id'];
+ 'event' => 'AccountsWhichExpire',
+ 'FIELDS' => 'id'];
foreach ($DB->request('glpi_notifications', $options) as $data) {
$notif->delete($data);
@@ -400,10 +410,10 @@ function plugin_accounts_uninstall() {
$template = new NotificationTemplate();
$translation = new NotificationTemplateTranslation();
$options = ['itemtype' => 'PluginAccountsAccount',
- 'FIELDS' => 'id'];
+ 'FIELDS' => 'id'];
foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
$options_template = ['notificationtemplates_id' => $data['id'],
- 'FIELDS' => 'id'];
+ 'FIELDS' => 'id'];
foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template)
as $data_template) {
@@ -417,12 +427,12 @@ function plugin_accounts_uninstall() {
}
$tables_glpi = ["glpi_displaypreferences",
- "glpi_documents_items",
- "glpi_savedsearches",
- "glpi_logs",
- "glpi_items_tickets",
- "glpi_dropdowntranslations",
- "glpi_impactitems"];
+ "glpi_documents_items",
+ "glpi_savedsearches",
+ "glpi_logs",
+ "glpi_items_tickets",
+ "glpi_dropdowntranslations",
+ "glpi_impactitems"];
foreach ($tables_glpi as $table_glpi) {
$DB->query("DELETE FROM `$table_glpi`
@@ -555,14 +565,14 @@ function plugin_accounts_getAddSearchOptions($itemtype) {
$sopt[1900]['itemlink_type'] = 'PluginAccountsAccount';
if ($itemtype != 'User') {
$sopt[1900]['joinparams'] = ['beforejoin' => ['table' => 'glpi_plugin_accounts_accounts_items',
- 'joinparams' => ['jointype' => 'itemtype_item']]];
+ 'joinparams' => ['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'] = ['beforejoin' => [['table' => 'glpi_plugin_accounts_accounts',
- 'joinparams' => $sopt[1900]['joinparams']]]];
+ 'joinparams' => $sopt[1900]['joinparams']]]];
$sopt[1901]['datatype'] = 'dropdown';
$sopt[1901]['massiveaction'] = false;
}
@@ -719,9 +729,9 @@ function plugin_accounts_giveItem($type, $ID, $data, $num) {
$query = "SELECT `" . $table_item . "`.*,
`glpi_plugin_accounts_accounts_items`.`id` AS items_id,
`glpi_entities`.`id` AS entity "
- . " FROM `glpi_plugin_accounts_accounts_items`, `" . $table_item
- . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table_item . "`.`entities_id`) "
- . " WHERE `" . $table_item . "`.`id` = `glpi_plugin_accounts_accounts_items`.`items_id`
+ . " FROM `glpi_plugin_accounts_accounts_items`, `" . $table_item
+ . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table_item . "`.`entities_id`) "
+ . " WHERE `" . $table_item . "`.`id` = `glpi_plugin_accounts_accounts_items`.`items_id`
AND `glpi_plugin_accounts_accounts_items`.`itemtype` = '$itemtype'
AND `glpi_plugin_accounts_accounts_items`.`plugin_accounts_accounts_id` = '" . $accounts . "' ";
@@ -735,11 +745,11 @@ function plugin_accounts_giveItem($type, $ID, $data, $num) {
$query = "SELECT `" . $table_item . "`.*,
`glpi_plugin_accounts_accounts_items`.`id` AS items_id,
`glpi_entities`.`id` AS entity "
- . " FROM `glpi_plugin_accounts_accounts_items`, `" . $table_item
- . "` WHERE `" . $table_item . "`.`id` = `glpi_plugin_accounts_accounts_items`.`items_id`
+ . " FROM `glpi_plugin_accounts_accounts_items`, `" . $table_item
+ . "` WHERE `" . $table_item . "`.`id` = `glpi_plugin_accounts_accounts_items`.`items_id`
AND `glpi_plugin_accounts_accounts_items`.`itemtype` = '$itemtype'
AND `glpi_plugin_accounts_accounts_items`.`plugin_accounts_accounts_id` = '" . $accounts . "' "
- . $dbu->getEntitiesRestrictRequest(" AND ", $table_item, '', '', $item->maybeRecursive());
+ . $dbu->getEntitiesRestrictRequest(" AND ", $table_item, '', '', $item->maybeRecursive());
if ($item->maybeTemplate()) {
$query .= " AND " . $table_item . ".is_template='0'";
diff --git a/inc/account.class.php b/inc/account.class.php
index b3307a9..f13436b 100644
--- a/inc/account.class.php
+++ b/inc/account.class.php
@@ -439,37 +439,86 @@ public function showForm($ID, $options = []) {
echo "";
echo "
";
+ echo "" . __('Key name', 'accounts') . " | ";
+ echo "";
+
+ if (empty($ID) || $ID < 0) {
+ $encryption_key_params = ['comments' =>false, 'name' => 'plugin_accounts_hash_id', 'value' => $this->fields["plugin_accounts_hash_id"],
+ 'on_change' => 'checkInputIfNewEncryptionKey(this.value, '
+ . $this->fields["plugin_accounts_hash_id"] .')'];
+
+
+ $rand_hash = Dropdown::show('PluginAccountsHash', $encryption_key_params);
+
+ echo Html::scriptBlock("function checkInputIfNewEncryptionKey(newValue, currentValue) {
+ if (newValue != currentValue) {
+ $('#check-password').show();
+ $('#encryption-key').hide();
+ } else {
+ $('#check-password').hide();
+ $('#encryption-key').show();
+ }
+ };");
+
+ } else {
+ $hash_name = new PluginAccountsHash();
+ $hash_name->getFromDB($this->fields["plugin_accounts_hash_id"]);
+ echo "
+ " . $hash_name->getField('name') . " ";
+ }
+ echo " | ";
+ echo "";
+ echo " | ";
+ echo "
";
+ echo "";
+ echo "" . __('Encryption key', 'accounts') . " | ";
+ echo "";
+ echo " | ";
+ echo "
";
+
+ if (empty($ID) || $ID < 0) {
+ $params = ['id'=> '__VALUE__'];
+ Ajax::updateItemOnSelectEvent("dropdown_plugin_accounts_hash_id$rand_hash", "change_good_hash","../ajax/getHashOnSelectEncryptionKey.php", $params);
+ echo Html::hidden('change_good_hash', ['id' => 'change_good_hash']);
+ echo "";
+ }
+
//hash
- $hash = 0;
- $hash_id = 0;
- $restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '',
+ $hash_account = new PluginAccountsHash();
+ $hash = 0;
+ $hash_id = 0;
+ $restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '',
$this->getEntityID(), $hashclass->maybeRecursive());
$hashes = $dbu->getAllDataFromTable("glpi_plugin_accounts_hashes", $restrict);
if (!empty($hashes)) {
- foreach ($hashes as $hashe) {
- $hash = $hashe["hash"];
- $hash_id = $hashe["id"];
+ $hash_account->getFromDBByCrit(['id' => $this->fields["plugin_accounts_hash_id"]]);
+ if (count($hash_account->fields) > 0) {
+ $hash = $hash_account->getField("hash");
+ $hash_id = $hash_account->getField("id");
+ $alert = '';
+ } else {
+ $alert = __('There is no encryption key associated to this account, please select one above', 'accounts');
}
- $alert = '';
} else {
$alert = __('There is no encryption key for this entity', 'accounts');
}
$aeskey = new PluginAccountsAesKey();
+ echo Html::hidden('encrypted_password', ['value' => $this->fields["encrypted_password"],
+ 'id' => 'encrypted_password']);
+ echo Html::hidden('good_hash', ['value' => $hash,
+ 'id' => 'good_hash']);
+ echo Html::hidden('wrong_key_locale', ['value' => __('Wrong encryption key', 'accounts'),
+ 'id' => 'wrong_key_locale']);
+
//aeskey non enregistre
if ($hash) {
if (!$aeskey->getFromDBByHash($hash_id) || !$aeskey->fields["name"]) {
echo "" . __('Encryption key', 'accounts') . " | ";
echo "";
- echo Html::hidden('encrypted_password', ['value' => $this->fields["encrypted_password"],
- 'id' => 'encrypted_password']);
- echo Html::hidden('good_hash', ['value' => $hash,
- 'id' => 'good_hash']);
- echo Html::hidden('wrong_key_locale', ['value' => __('Wrong encryption key', 'accounts'),
- 'id' => 'wrong_key_locale']);
if (!empty($ID) || $ID > 0) {
echo " ";
@@ -648,7 +697,7 @@ class='submit'>";
echo "";
echo "";
echo Html::scriptBlock("$('#account_form').submit(function(event){
- if ($('#hidden_password').val() == '' || $('#aeskey').val() == '') {
+ if ($('#hidden_password').val() == '' || $('#checkaeskey').val() == '') {
alert('" . __('You have not filled the password and encryption key', 'accounts') . "');
return false;
};
@@ -669,7 +718,11 @@ class='submit'>";
echo Html::hidden('id', ['value' => $ID]);
echo "";
echo Html::scriptBlock("$('#account_form').submit(function(event){
- if ($('#hidden_password').val() == '' || $('#aeskey').val() == '') {
+ let checkAESKey = $('#checkaeskey').val();
+ let hiddenPassword = $('#hidden_password').val();
+ let aeskey = $('#aeskey').val();
+
+ if ((hiddenPassword == '' || aeskey == '') && checkAESKey == '') {
alert('" . __('Password will not be modified', 'accounts') . "');
} else if (!check_hash()) {
alert('" . __('Wrong encryption key', 'accounts') . "');
diff --git a/sql/empty-1.3.sql b/install/sql/empty-1.3.sql
similarity index 100%
rename from sql/empty-1.3.sql
rename to install/sql/empty-1.3.sql
diff --git a/sql/empty-1.4.sql b/install/sql/empty-1.4.sql
similarity index 100%
rename from sql/empty-1.4.sql
rename to install/sql/empty-1.4.sql
diff --git a/sql/empty-1.5.0.sql b/install/sql/empty-1.5.0.sql
similarity index 100%
rename from sql/empty-1.5.0.sql
rename to install/sql/empty-1.5.0.sql
diff --git a/sql/empty-1.5.1.sql b/install/sql/empty-1.5.1.sql
similarity index 100%
rename from sql/empty-1.5.1.sql
rename to install/sql/empty-1.5.1.sql
diff --git a/sql/empty-1.5.3.sql b/install/sql/empty-1.5.3.sql
similarity index 100%
rename from sql/empty-1.5.3.sql
rename to install/sql/empty-1.5.3.sql
diff --git a/sql/empty-1.6.0.sql b/install/sql/empty-1.6.0.sql
similarity index 100%
rename from sql/empty-1.6.0.sql
rename to install/sql/empty-1.6.0.sql
diff --git a/sql/empty-1.7.0.sql b/install/sql/empty-1.7.0.sql
similarity index 100%
rename from sql/empty-1.7.0.sql
rename to install/sql/empty-1.7.0.sql
diff --git a/sql/empty-1.7.1.sql b/install/sql/empty-1.7.1.sql
similarity index 100%
rename from sql/empty-1.7.1.sql
rename to install/sql/empty-1.7.1.sql
diff --git a/sql/empty-1.8.0.sql b/install/sql/empty-1.8.0.sql
similarity index 100%
rename from sql/empty-1.8.0.sql
rename to install/sql/empty-1.8.0.sql
diff --git a/sql/empty-1.9.0.sql b/install/sql/empty-1.9.0.sql
similarity index 100%
rename from sql/empty-1.9.0.sql
rename to install/sql/empty-1.9.0.sql
diff --git a/sql/empty-2.0.0.sql b/install/sql/empty-2.0.0.sql
similarity index 100%
rename from sql/empty-2.0.0.sql
rename to install/sql/empty-2.0.0.sql
diff --git a/sql/empty-2.2.0.sql b/install/sql/empty-2.2.0.sql
similarity index 100%
rename from sql/empty-2.2.0.sql
rename to install/sql/empty-2.2.0.sql
diff --git a/sql/empty-2.4.0.sql b/install/sql/empty-2.4.0.sql
similarity index 100%
rename from sql/empty-2.4.0.sql
rename to install/sql/empty-2.4.0.sql
diff --git a/sql/empty-2.6.0.sql b/install/sql/empty-2.6.0.sql
similarity index 100%
rename from sql/empty-2.6.0.sql
rename to install/sql/empty-2.6.0.sql
diff --git a/install/sql/empty-2.7.0.sql b/install/sql/empty-2.7.0.sql
new file mode 100644
index 0000000..d002bb5
--- /dev/null
+++ b/install/sql/empty-2.7.0.sql
@@ -0,0 +1,132 @@
+DROP TABLE IF EXISTS `glpi_plugin_accounts_accounts`;
+CREATE TABLE `glpi_plugin_accounts_accounts` (
+ `id` int(11) NOT NULL auto_increment,
+ `entities_id` int(11) NOT NULL default '0',
+ `is_recursive` tinyint(1) NOT NULL default '0',
+ `name` varchar(255) collate utf8_unicode_ci default NULL,
+ `login` varchar(255) collate utf8_unicode_ci default NULL,
+ `encrypted_password` varchar(255) collate utf8_unicode_ci default NULL,
+ `others` varchar(255) collate utf8_unicode_ci default NULL,
+ `plugin_accounts_accounttypes_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_accounts_accounttypes (id)',
+ `plugin_accounts_accountstates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_accounts_accountstates (id)',
+ `plugin_accounts_hash_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_accounts_hashes (id)',
+ `date_creation` timestamp NULL DEFAULT NULL,
+ `date_expiration` timestamp NULL DEFAULT NULL,
+ `users_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_users (id)',
+ `groups_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_groups (id)',
+ `users_id_tech` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_users (id)',
+ `groups_id_tech` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_groups (id)',
+ `locations_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_locations (id)',
+ `is_helpdesk_visible` int(11) NOT NULL default '1',
+ `date_mod` timestamp NULL DEFAULT NULL,
+ `comment` text collate utf8_unicode_ci,
+ `is_deleted` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`),
+ KEY `entities_id` (`entities_id`),
+ KEY `plugin_accounts_accounttypes_id` (`plugin_accounts_accounttypes_id`),
+ KEY `plugin_accounts_accountstates_id` (`plugin_accounts_accountstates_id`),
+ KEY `users_id` (`users_id`),
+ KEY `groups_id` (`groups_id`),
+ KEY `users_id_tech` (`users_id_tech`),
+ KEY `groups_id_tech` (`groups_id_tech`),
+ KEY `date_mod` (`date_mod`),
+ KEY `is_helpdesk_visible` (`is_helpdesk_visible`),
+ KEY `is_deleted` (`is_deleted`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_accounttypes`;
+CREATE TABLE `glpi_plugin_accounts_accounttypes` (
+ `id` int(11) NOT NULL auto_increment,
+ `entities_id` int(11) NOT NULL default '0',
+ `is_recursive` tinyint(1) NOT NULL default '0',
+ `name` varchar(255) collate utf8_unicode_ci default NULL,
+ `comment` text collate utf8_unicode_ci,
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_accountstates`;
+CREATE TABLE `glpi_plugin_accounts_accountstates` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(255) collate utf8_unicode_ci default NULL,
+ `comment` text collate utf8_unicode_ci,
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_hashes`;
+CREATE TABLE `glpi_plugin_accounts_hashes` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(255) collate utf8_unicode_ci default NULL,
+ `entities_id` int(11) NOT NULL default '0',
+ `is_recursive` tinyint(1) NOT NULL default '0',
+ `hash` varchar(255) collate utf8_unicode_ci default NULL,
+ `comment` text collate utf8_unicode_ci,
+ `date_mod` timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `entities_id` (`entities_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_aeskeys`;
+CREATE TABLE `glpi_plugin_accounts_aeskeys` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(255) collate utf8_unicode_ci default NULL,
+ `plugin_accounts_hashes_id` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `plugin_accounts_hashes_id` (`plugin_accounts_hashes_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_accounts_items`;
+CREATE TABLE `glpi_plugin_accounts_accounts_items` (
+ `id` int(11) NOT NULL auto_increment,
+ `plugin_accounts_accounts_id` int(11) NOT NULL default '0',
+ `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',
+ `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `unicity` (`plugin_accounts_accounts_id`,`itemtype`,`items_id`),
+ KEY `FK_device` (`items_id`,`itemtype`),
+ KEY `item` (`itemtype`,`items_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_configs`;
+CREATE TABLE `glpi_plugin_accounts_configs` (
+ `id` int(11) NOT NULL auto_increment,
+ `delay_expired` varchar(50) collate utf8_unicode_ci NOT NULL default '30',
+ `delay_whichexpire` varchar(50) collate utf8_unicode_ci NOT NULL default '30',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+INSERT INTO `glpi_plugin_accounts_configs` ( `id` , `delay_expired` , `delay_whichexpire`) VALUES (1, '30', '30');
+
+DROP TABLE IF EXISTS `glpi_plugin_accounts_notificationstates`;
+CREATE TABLE `glpi_plugin_accounts_notificationstates` (
+ `id` int(11) NOT NULL auto_increment,
+ `plugin_accounts_accountstates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_accounts_accountstates (id)',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DROP TABLE IF EXISTS `glpi_plugin_compte_mailing`;
+
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','2','3','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','3','1','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','4','2','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','5','4','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','6','5','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsAccount','7','6','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','2','3','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','3','1','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','4','2','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','5','4','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','6','5','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsHelpdesk','7','6','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','2','3','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','3','1','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','4','2','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','5','4','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','6','5','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','7','6','0');
+INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginAccountsGroup','8','7','0');
+
+INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'New Accounts', 'PluginAccountsAccount', '2010-02-17 22:36:46','',NULL, '2010-02-17 22:36:46');
+INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert Accounts', 'PluginAccountsAccount', '2010-02-23 11:37:46','',NULL, '2010-02-17 22:36:46');
diff --git a/sql/update-1.1.sql b/install/sql/update-1.1.sql
similarity index 100%
rename from sql/update-1.1.sql
rename to install/sql/update-1.1.sql
diff --git a/sql/update-1.3.sql b/install/sql/update-1.3.sql
similarity index 100%
rename from sql/update-1.3.sql
rename to install/sql/update-1.3.sql
diff --git a/sql/update-1.4.sql b/install/sql/update-1.4.sql
similarity index 100%
rename from sql/update-1.4.sql
rename to install/sql/update-1.4.sql
diff --git a/sql/update-1.5.0.sql b/install/sql/update-1.5.0.sql
similarity index 100%
rename from sql/update-1.5.0.sql
rename to install/sql/update-1.5.0.sql
diff --git a/sql/update-1.5.1.sql b/install/sql/update-1.5.1.sql
similarity index 100%
rename from sql/update-1.5.1.sql
rename to install/sql/update-1.5.1.sql
diff --git a/sql/update-1.5.3.sql b/install/sql/update-1.5.3.sql
similarity index 100%
rename from sql/update-1.5.3.sql
rename to install/sql/update-1.5.3.sql
diff --git a/sql/update-1.6.0.sql b/install/sql/update-1.6.0.sql
similarity index 100%
rename from sql/update-1.6.0.sql
rename to install/sql/update-1.6.0.sql
diff --git a/sql/update-1.7.0.sql b/install/sql/update-1.7.0.sql
similarity index 100%
rename from sql/update-1.7.0.sql
rename to install/sql/update-1.7.0.sql
diff --git a/sql/update-1.7.1.sql b/install/sql/update-1.7.1.sql
similarity index 100%
rename from sql/update-1.7.1.sql
rename to install/sql/update-1.7.1.sql
diff --git a/sql/update-1.8.0.sql b/install/sql/update-1.8.0.sql
similarity index 100%
rename from sql/update-1.8.0.sql
rename to install/sql/update-1.8.0.sql
diff --git a/sql/update-1.9.0.sql b/install/sql/update-1.9.0.sql
similarity index 100%
rename from sql/update-1.9.0.sql
rename to install/sql/update-1.9.0.sql
diff --git a/install/sql/update-2.7.0.sql b/install/sql/update-2.7.0.sql
new file mode 100644
index 0000000..93c5eb3
--- /dev/null
+++ b/install/sql/update-2.7.0.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `glpi_plugin_accounts_accounts`
+ADD `plugin_accounts_hash_id` INT(11) NOT NULL default '0';
\ No newline at end of file
diff --git a/install/update_270_migrateMultiHashEntities.php b/install/update_270_migrateMultiHashEntities.php
new file mode 100644
index 0000000..99bb168
--- /dev/null
+++ b/install/update_270_migrateMultiHashEntities.php
@@ -0,0 +1,61 @@
+.
+ --------------------------------------------------------------------------
+ */
+
+/**
+ * Update from 1.3.3 to 1.5.0
+ *
+ * @return bool for success (will die for most error)
+ * */
+function update_270_migrateMultiHashEntities() {
+ global $DB;
+ $dbu = new DbUtils();
+ $entity = new Entity();
+ $hashes = new PluginAccountsHash();
+ $account = new PluginAccountsAccount();
+
+ $restrict = '';
+ $entities = $entity->find();
+ foreach ($entities as $e) {
+ $restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '', $e['id'], $hashes->maybeRecursive());
+ $hashesList = $dbu->getAllDataFromTable("glpi_plugin_accounts_hashes", $restrict);
+ $idHash = 0;
+
+ if (count($hashesList) > 0) {
+ foreach ($hashesList as $hashItem) {
+ $idHash = $hashItem['id'];
+ }
+
+ $accounts = $account->find(['entities_id' => $e['id']]);
+ foreach ($accounts as $a) {
+ $input = [];
+ $input['id'] = $a['id'];
+ $input['plugin_accounts_hash_id'] = $idHash;
+ $account->update($input);
+ }
+ }
+ }
+ return true;
+}
diff --git a/scripts/account.form.js b/scripts/account.form.js
index efd98dd..872f41d 100644
--- a/scripts/account.form.js
+++ b/scripts/account.form.js
@@ -17,8 +17,8 @@ $(document).ready(function () {
}
// find the good element
- var target = $($('.account_to_clipboard_wrapper'));
- if (target.attr('class') == 'account_to_clipboard_wrapper') {
+ var target = $('.account_to_clipboard_wrapper');
+ if (target.attr('class') === 'account_to_clipboard_wrapper') {
target = target.find('*');
}
diff --git a/scripts/clipboard.js b/scripts/clipboard.js
index 9ea5a25..52f2c74 100644
--- a/scripts/clipboard.js
+++ b/scripts/clipboard.js
@@ -31,7 +31,7 @@
$(function() {
// set a function to track drag hover event
$(document).on("click", ".account_to_clipboard_wrapper", function(event) {
-
+ event.preventDefault();
var input = $('#hidden_password');
if (input.attr("type") == "password") {
input.attr("type", "text");
@@ -40,10 +40,8 @@ $(function() {
}
// find the good element
- var target = $(event.target);
- console.log(event);
- console.log(target);
- if (target.attr('class') == 'account_to_clipboard_wrapper') {
+ var target = $('.account_to_clipboard_wrapper');
+ if (target.attr('class') === 'account_to_clipboard_wrapper') {
target = target.find('*');
}
diff --git a/scripts/crypt.js b/scripts/crypt.js
index f40ae9a..972e711 100644
--- a/scripts/crypt.js
+++ b/scripts/crypt.js
@@ -1,52 +1,92 @@
var check_hash = function () {
- var good_hash = $("#good_hash").val();
- var aeskey = $("#aeskey").val();
- if (aeskey == '' || aeskey == undefined) {
- return false;
- }
+ var good_hash = $("#good_hash").val();
+ var aeskey = $("#aeskey").val();
+ var on_change_hash = $("#change_good_hash").text();
+ var checkAeskey = $("#checkaeskey").val();
+
+ var select_encryption_key = false;
+
+ if (checkAeskey != '') {
+ select_encryption_key = true;
+ }
+
+ if (select_encryption_key) {
+ return generic_check_hash(on_change_hash, checkAeskey)
+ } else {
+ return generic_check_hash(good_hash, aeskey)
+ }
+};
+
+
+
+var generic_check_hash = function (good_hash, aeskey) {
+
+ if (aeskey == '' || aeskey == undefined) {
+ return false;
+ }
var hash = SHA256(SHA256(aeskey));
- if (hash != good_hash) {
- return false;
- }
+ if (hash != good_hash) {
+ return false;
+ }
return true;
};
+
var decrypt_password = function (sufix) {
sufix = sufix || "";
+
var aeskey = $("#aeskey").val();
var decrypted_password = AESDecryptCtr($("#encrypted_password" + sufix).val(),
SHA256(aeskey),
256);
- if ($("#hidden_password" + sufix).length) { //isset ?
- $("#hidden_password" + sufix).val(decrypted_password);
- }
-
- if (document.location.pathname.indexOf('accounts') > 0) {
- var idcrypt = $('form#account_form input[name=id]').val();
- var url = '../ajax/log_decrypt.php'
- } else {
- var idcrypt = sufix;
- var url = '../plugins/accounts/ajax/log_decrypt.php';
- }
+ if ($("#hidden_password" + sufix).length) { //isset ?
+ $("#hidden_password" + sufix).val(decrypted_password);
+ }
+
+ if (document.location.pathname.indexOf('accounts') > 0) {
+ var idcrypt = $('form#account_form input[name=id]').val();
+ var url = '../ajax/log_decrypt.php'
+ } else {
+ var idcrypt = sufix;
+ var url = '../plugins/accounts/ajax/log_decrypt.php';
+ }
$.ajax({
- 'url': url,
- 'type': 'POST',
- 'data': {'idcrypt': idcrypt}
- });
+ 'url': url,
+ 'type': 'POST',
+ 'data': {'idcrypt': idcrypt}
+ });
return decrypted_password;
};
var encrypt_password = function (sufix) {
- sufix = sufix || "";
- var aeskey = $("#aeskey").val();
- var encrypted_password = AESEncryptCtr($('#hidden_password' + sufix).val(),
- SHA256(aeskey),
- 256);
+ sufix = sufix || "";
+ var aeskey = $("#aeskey").val();
+ var checkAeskey = $("#checkaeskey").val();
+ var select_encryption_key = false;
+ var encrypted_password = '';
+
+ if (checkAeskey != '') {
+ select_encryption_key = true;
+ }
+
+ console.log(select_encryption_key)
+
+
+ if (select_encryption_key) {
+ encrypted_password = AESEncryptCtr($('#hidden_password' + sufix).val(),
+ SHA256(checkAeskey),
+ 256);
+ } else {
+ encrypted_password = AESEncryptCtr($('#hidden_password' + sufix).val(),
+ SHA256(aeskey),
+ 256);
+ }
+
$('#encrypted_password').val(encrypted_password);
$('#account_form').submit();
};
diff --git a/setup.php b/setup.php
index ed7fa85..bac14fd 100644
--- a/setup.php
+++ b/setup.php
@@ -27,7 +27,7 @@
--------------------------------------------------------------------------
*/
-define('PLUGIN_ACCOUNTS_VERSION', '2.6.0');
+define('PLUGIN_ACCOUNTS_VERSION', '2.7.0');
// Init the hooks of the plugins -Needed
function plugin_init_accounts() {
|