Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(invitation): enhnance again UI
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed May 3, 2018
1 parent c12b5b0 commit 83daba9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
15 changes: 13 additions & 2 deletions inc/invitation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getEnumInvitationStatus() {
* @return string
*/
public static function getTypeName($nb = 0) {
return _n('Invitation', 'Invitations', $nb, "flyvemdm");
return _n('Invitation', 'Invitations', $nb, 'flyvemdm');
}

/**
Expand Down Expand Up @@ -173,6 +173,8 @@ public function prepareInputForAdd($input) {
$expirationDate->add(new DateInterval($tokenExpire));
$input['expiration_date'] = $expirationDate->format('Y-m-d H:i:s');

// Set a name for the invitation
$input['name'] = self::getTypeName(1);
return $input;
}

Expand Down Expand Up @@ -407,13 +409,22 @@ public function getSearchOptionsNew() {
'name' => __s('Invitation', 'flyvemdm'),
];

$tab[] = [
'id' => '1',
'table' => $this->getTable(),
'field' => 'name',
'name' => __('name'),
'massiveaction' => false,
'datatype' => 'itemlink',
];

$tab[] = [
'id' => '2',
'table' => $this->getTable(),
'field' => 'id',
'name' => __('ID'),
'massiveaction' => false,
'datatype' => 'itemlink',
'datatype' => 'integer',
];

$tab[] = [
Expand Down
31 changes: 31 additions & 0 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,37 @@ protected function createDisplayPreferences() {
User::getForeignKeyField() => '0'
]);
}

$itemtype = PluginFlyvemdmInvitation::class;
$criteria = "`itemtype` = '$itemtype' AND `num` = '3' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => PluginFlyvemdmInvitation::class,
'num' => '3',
'rank' => '2',
User::getForeignKeyField() => '0'
]);
}

$criteria = "`itemtype` = '$itemtype' AND `num` = '4' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => PluginFlyvemdmInvitation::class,
'num' => '4',
'rank' => '2',
User::getForeignKeyField() => '0'
]);
}

$criteria = "`itemtype` = '$itemtype' AND `num` = '5' AND `users_id` = '0'";
if (count($displayPreference->find($criteria)) == 0) {
$displayPreference->add([
'itemtype' => PluginFlyvemdmInvitation::class,
'num' => '5',
'rank' => '2',
User::getForeignKeyField() => '0'
]);
}
}

protected function deleteDisplayPreferences() {
Expand Down
1 change: 1 addition & 0 deletions install/mysql/plugin_flyvemdm_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ CREATE TABLE `glpi_plugin_flyvemdm_tasks` (
DROP TABLE IF EXISTS `glpi_plugin_flyvemdm_invitations`;
CREATE TABLE `glpi_plugin_flyvemdm_invitations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`invitation_token` varchar(255) NOT NULL DEFAULT '',
`users_id` int(11) NOT NULL DEFAULT '0',
`entities_id` int(11) NOT NULL DEFAULT '0',
Expand Down
5 changes: 5 additions & 0 deletions install/upgrade/update_to_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ function plugin_flyvemdm_update_to_dev(Migration $migration) {
$migration->addKey($table, 'plugin_flyvemdm_invitations_id', 'plugin_flyvemdm_invitations_id');

$table = 'glpi_plugin_flyvemdm_invitations';
if (!$DB->fieldExists($table, 'name')) {
$invitationName = _n('Invitation', 'Invitations', 1, 'flyvemdm');
$migration->addField($table, 'name', 'string', ['after' => 'id']);
$migration->addPostQuery("UPDATE `$table` SET `name` = '$invitationName'");
}
$migration->addKey($table, 'users_id', 'users_id');
$migration->addKey($table, 'entities_id', 'entities_id');
$migration->addKey($table, 'documents_id', 'documents_id');
Expand Down

0 comments on commit 83daba9

Please sign in to comment.