diff --git a/Classes/Domain/Model/Backend/User.php b/Classes/Domain/Model/Backend/User.php new file mode 100644 index 0000000..ac7d622 --- /dev/null +++ b/Classes/Domain/Model/Backend/User.php @@ -0,0 +1,119 @@ +userName; + } + + /** + * @param string $userName + */ + public function setUserName($userName) + { + $this->userName = $userName; + } + + /** + * @return string + */ + public function getRealName() + { + return $this->realName; + } + + /** + * @param string $realName + */ + public function setRealName($realName) + { + $this->realName = $realName; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getLastLogin() + { + return $this->lastLogin; + } + + /** + * @param string $lastLogin + */ + public function setLastLogin($lastLogin) + { + $this->lastLogin = $lastLogin; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->emailAddress; + } + + /** + * @param string $emailAddress + */ + public function setEmailAddress($emailAddress) + { + $this->emailAddress = $emailAddress; + } +} \ No newline at end of file diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php index b2ecbe2..2c4bcb4 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -8,6 +8,7 @@ * LICENSE.txt file that was distributed with this source code. */ +use T3Monitor\T3monitoring\Domain\Model\Backend\User; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; @@ -18,6 +19,7 @@ class Client extends AbstractEntity { /** + * * @var string * @validate NotEmpty */ @@ -115,6 +117,12 @@ class Client extends AbstractEntity */ protected $lastSuccessfulImport = null; + /** + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Backend\User> + * @lazy + */ + protected $backendUsers = null; + /** * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Extension> * @lazy @@ -159,6 +167,7 @@ public function __construct() protected function initStorageObjects() { $this->extensions = new ObjectStorage(); + $this->backendUsers = new ObjectStorage(); } /** @@ -613,6 +622,49 @@ public function setExtensions(ObjectStorage $extensions) $this->extensions = $extensions; } + /** + * Adds a backend user + * + * @param User $backendUser + * @return void + */ + public function addBackendUser(User $backendUser) + { + $this->backendUsers->attach($backendUser); + } + + /** + * Removes a backend user + * + * @param User $backendUserToRemove The backend user to be removed + * @return void + */ + public function removeBackendUser(User $backendUserToRemove) + { + $this->backendUsers->detach($backendUserToRemove); + } + + /** + * Returns the backend users + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Backend\User> $backendUsers + */ + public function getBackendUsers() + { + return $this->backendUsers; + } + + /** + * Sets the backend users + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Backend\User> $backendUsers + * @return void + */ + public function setBackendUsers(ObjectStorage $backendUsers) + { + $this->backendUsers = $backendUsers; + } + /** * Returns the core * diff --git a/Classes/Domain/Repository/Backend/UserRepository.php b/Classes/Domain/Repository/Backend/UserRepository.php new file mode 100644 index 0000000..cd1f28c --- /dev/null +++ b/Classes/Domain/Repository/Backend/UserRepository.php @@ -0,0 +1,16 @@ + $json['core']['diskFreeSpace'], 'core' => $this->getUsedCore($json['core']['typo3Version']), 'extensions' => $this->handleExtensionRelations($row['uid'], (array)$json['extensions']), + 'backend_users' => $this->handleBackendUserRelations($row['uid'], (array)$json['users']['backend']), ); $this->addExtraData($json, $update, 'info'); @@ -264,6 +265,64 @@ protected function handleExtensionRelations($client, array $extensions = array() return count($extensions); } + /** + * @param int $client client uid + * @param array $users list of extensions + * @return int count of used extensions + */ + protected function handleBackendUserRelations($client, array $users = array()) + { + $table = 'tx_t3monitoring_domain_model_backend_user'; + $mmTable = 'tx_t3monitoring_client_backend_user_mm'; + + $existingUsers = $this->getDatabaseConnection()->exec_SELECTgetRows('A.*', $table.' A LEFT OUTER JOIN '.$mmTable.' B ON A.uid=B.uid_foreign', 'B.uid_local='.(int)$client); + + foreach ($users as $user) { + $found = null; + + foreach ($existingUsers as $existingUser) { + if($existingUser['user_name'] == $user['userName']) { + $found = $existingUser; + break; + } + } + + if ($found) { + $relationId = $found['uid']; + $update = array( + 'real_name' => (string)$user['realName'], + 'email_address' => (string)$user['emailAddress'], + 'description' => (string)$user['description'], + 'last_login' => (string)$user['lastLogin'], + 'tstamp' => $GLOBALS['EXEC_TIME'], + ); + $this->getDatabaseConnection()->exec_UPDATEquery($table, 'uid='.(int)$relationId, $update); + } else { + $insert = array( + 'pid' => $this->emConfiguration->getPid(), + 'user_name' => (string)$user['userName'], + 'real_name' => (string)$user['realName'], + 'email_address' => (string)$user['emailAddress'], + 'description' => (string)$user['description'], + 'last_login' => (string)$user['lastLogin'], + 'tstamp' => $GLOBALS['EXEC_TIME'], + ); + $this->getDatabaseConnection()->exec_INSERTquery($table, $insert); + $relationId = $this->getDatabaseConnection()->sql_insert_id(); + } + $fields = array('uid_local', 'uid_foreign'); + $relationsToBeAdded[] = array( + $client, + $relationId + ); + + $this->getDatabaseConnection()->exec_DELETEquery($mmTable, 'uid_local=' . (int)$client); + $this->getDatabaseConnection()->exec_INSERTmultipleRows($mmTable, $fields, $relationsToBeAdded); + } + + return count($users); + } + /** * @param string $version * @return int diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_backend_user.php b/Configuration/TCA/tx_t3monitoring_domain_model_backend_user.php new file mode 100644 index 0000000..a88f1c9 --- /dev/null +++ b/Configuration/TCA/tx_t3monitoring_domain_model_backend_user.php @@ -0,0 +1,100 @@ + [ + 'title' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user', + 'label' => 'real_name', + 'label_alt' => 'user_name', + 'label_alt_force' => true, + 'hideTable' => true, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + ], + 'searchFields' => 'user_name,real_name,email_address,last_login,description,', + 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_backend_user.gif' + ], + 'interface' => [ + 'showRecordFieldList' => 'hidden, user_name, real_name, email_address, description, last_login', + ], + 'types' => [ + '1' => [ + 'showitem' => ' + --div--;Readonly information,user_name, real_name, email_address, description, last_login' + ], + ], + 'palettes' => [ + ], + 'columns' => [ + + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + + 'user_name' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user.user_name', + 'config' => [ + 'readOnly' => true, + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required', + 'max' => 255 + ], + + ], + 'email_address' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user.email_address', + 'config' => [ + 'readOnly' => true, + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim', + 'max' => 255 + ], + + ], + 'real_name' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user.real_name', + 'config' => [ + 'readOnly' => true, + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required', + 'max' => 255 + ], + + ], + 'description' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user.description', + 'config' => [ + 'readOnly' => true, + 'type' => 'text', + 'default' => '', + 'cols' => 40, + 'rows' => 5, + ], + + ], + 'last_login' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_backend_user.last_login', + 'config' => [ + 'readOnly' => true, + 'type' => 'input', + 'size' => 30, + 'eval' => 'datetime' + ], + + ], + ], +]; diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_client.php b/Configuration/TCA/tx_t3monitoring_domain_model_client.php index 9ad41ec..0c80bbb 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_client.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_client.php @@ -10,17 +10,17 @@ 'enablecolumns' => [ 'disabled' => 'hidden', ], - 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,tag', + 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,backend_users,core,sla,tag', 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_client.gif' ], 'interface' => [ - 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla, tag', + 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, backend_users, core, sla, tag', ], 'types' => [ '1' => [ 'showitem' => ' --div--;General,title, --palette--;;paletteDomain,email,sla,tag, - --div--;Readonly information,last_successful_import,error_message,core, --palette--;;paletteVersions, --palette--;;paletteDiskSpace,extensions, + --div--;Readonly information,last_successful_import,error_message,core, --palette--;;paletteVersions, --palette--;;paletteDiskSpace,extensions,backend_users, insecure_core, outdated_core, insecure_extensions, outdated_extensions, --div--;Extra,extra_info,extra_warning,extra_danger' ], @@ -277,6 +277,24 @@ 'multiple' => 0, ], ], + 'backend_users' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.backend_users', + 'config' => [ + 'readOnly' => true, + 'type' => 'group', + 'internal_type' => 'db', + 'allowed' => 'tx_t3monitoring_domain_model_backend_user', + 'foreign_table' => 'tx_t3monitoring_domain_model_backend_user', + 'foreign_table_where' => 'ORDER BY tx_t3monitoring_domain_model_backend_user.user_name', + 'MM' => 'tx_t3monitoring_client_backend_user_mm', + 'size' => 10, + 'autoSizeMax' => 30, + 'maxitems' => 9999, + 'multiple' => 0, + ], + + ], 'core' => [ 'exclude' => 1, 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.core', diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index ab97fcd..feb08ed 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -3,6 +3,24 @@
+ + Backend User + + + Username + + + Real Name + + + Description + + + Last login + + + Email Address + Client @@ -75,6 +93,9 @@ Extensions + + Backend Users + Core diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 7d2e143..37383f2 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -3,6 +3,24 @@
+ + Backend User + + + Username + + + Real Name + + + Description + + + Last login + + + Email Address + Client diff --git a/Resources/Private/Templates/Client/Show.html b/Resources/Private/Templates/Client/Show.html index 69c7ac9..7abcd5e 100644 --- a/Resources/Private/Templates/Client/Show.html +++ b/Resources/Private/Templates/Client/Show.html @@ -105,6 +105,36 @@

+ +
+
+ Backend Users ({client.backendUsers -> f:count()}) +
+ + + + + + + + + + + + + + + + + + + + + +
{f:translate(key:'tx_t3monitoring_domain_model_backend_user.user_name')}{f:translate(key:'tx_t3monitoring_domain_model_backend_user.real_name')}{f:translate(key:'tx_t3monitoring_domain_model_backend_user.email_address')}{f:translate(key:'tx_t3monitoring_domain_model_backend_user.description')}{f:translate(key:'tx_t3monitoring_domain_model_backend_user.last_login')}
{backendUser.userName}{backendUser.realName}{backendUser.emailAddress}{backendUser.description}{backendUser.lastLogin}
+
+
+
diff --git a/Resources/Public/Css/t3monitoring.css b/Resources/Public/Css/t3monitoring.css index 970136b..fe64f1f 100644 --- a/Resources/Public/Css/t3monitoring.css +++ b/Resources/Public/Css/t3monitoring.css @@ -21,11 +21,13 @@ } .client-list th, -.extension-list th { +.extension-list th, +.user-list th { cursor: pointer; } .client-list th.no-sorting, -.extension-list th.no-sorting { +.extension-list th.no-sorting, +.user-list th.no-sorting { cursor: default; } diff --git a/Resources/Public/Icons/tx_t3monitoring_domain_model_backend_user.gif b/Resources/Public/Icons/tx_t3monitoring_domain_model_backend_user.gif new file mode 100644 index 0000000..6cc5f16 Binary files /dev/null and b/Resources/Public/Icons/tx_t3monitoring_domain_model_backend_user.gif differ diff --git a/Resources/Public/JavaScript/Main.js b/Resources/Public/JavaScript/Main.js index f3f95ac..60c59e9 100644 --- a/Resources/Public/JavaScript/Main.js +++ b/Resources/Public/JavaScript/Main.js @@ -38,6 +38,18 @@ define([ ordering: true }); } + var userList = $('.user-list'); + if (userList.length > 0) { + userList.DataTable({ + "order": [0, "desc"], + paging: false, + lengthChange: false, + stateSave: false, + searching: false, + dom: 'tir', + ordering: true + }); + } }); }); diff --git a/ext_tables.sql b/ext_tables.sql index 2800bf0..7a7611a 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -1,3 +1,28 @@ +# +# Table structure for table 'tx_t3monitoring_domain_model_backend_user' +# +CREATE TABLE tx_t3monitoring_domain_model_backend_user ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + user_name varchar(255) DEFAULT '' NOT NULL, + real_name varchar(255) DEFAULT '' NOT NULL, + email_address varchar(255) DEFAULT '' NOT NULL, + description text NOT NULL, + last_login int(11) DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + +); + # # Table structure for table 'tx_t3monitoring_domain_model_client' # @@ -26,6 +51,7 @@ CREATE TABLE tx_t3monitoring_domain_model_client ( extra_danger text NOT NULL, last_successful_import int(11) DEFAULT '0' NOT NULL, extensions int(11) unsigned DEFAULT '0' NOT NULL, + backend_users int(11) unsigned DEFAULT '0' NOT NULL, core int(11) unsigned DEFAULT '0', sla int(11) unsigned DEFAULT '0', tag int(11) unsigned DEFAULT '0', @@ -134,6 +160,19 @@ CREATE TABLE tx_t3monitoring_domain_model_sla ( ); +# +# Table structure for table 'tx_t3monitoring_client_backend_user_mm' +# +CREATE TABLE tx_t3monitoring_client_backend_user_mm ( + uid_local int(11) unsigned DEFAULT '0' NOT NULL, + uid_foreign int(11) unsigned DEFAULT '0' NOT NULL, + sorting int(11) unsigned DEFAULT '0' NOT NULL, + sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL, + + KEY uid_local (uid_local), + KEY uid_foreign (uid_foreign) +); + # # Table structure for table 'tx_t3monitoring_domain_model_tag' # @@ -154,8 +193,7 @@ CREATE TABLE tx_t3monitoring_domain_model_tag ( sorting int(11) DEFAULT '0' NOT NULL, PRIMARY KEY (uid), - KEY parent (pid), - + KEY parent (pid) ); #