diff --git a/Classes/Controller/StatisticController.php b/Classes/Controller/StatisticController.php index 1942802..20e2546 100644 --- a/Classes/Controller/StatisticController.php +++ b/Classes/Controller/StatisticController.php @@ -60,6 +60,9 @@ public function indexAction(ClientFilterDemand $filter = null) $feedItems = $bulletinImport->start(); } + $monitorIpAddress = null; + + $this->view->assignMultiple([ 'filter' => $filter, 'clients' => $this->clientRepository->findByDemand($filter), @@ -76,6 +79,7 @@ public function indexAction(ClientFilterDemand $filter = null) 'numberOfClients' => $this->clientRepository->countAll(), 'slaVersions' => $this->slaRepository->findAll(), 'feedItems' => $feedItems, + 'monitorIpAddress' => $monitorIpAddress, 'importTimes' => [ 'client' => $this->registry->get('t3monitoring', 'importClient'), 'core' => $this->registry->get('t3monitoring', 'importCore'), 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 1e7fcd9..4a71ccf 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -130,6 +130,14 @@ class Client extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $extensions = null; + /** + * backendUsers + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3Monitor\T3monitoring\Domain\Model\Backend\User> + * @lazy + */ + protected $backendUsers = null; + /** * core * @@ -166,6 +174,7 @@ public function __construct() protected function initStorageObjects() { $this->extensions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->backendUsers = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); } /** @@ -546,6 +555,49 @@ public function setExtensions(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $exte $this->extensions = $extensions; } + /** + * Adds a backend user + * + * @param \T3Monitor\T3monitoring\Domain\Model\Backend\User $backendUser + * @return void + */ + public function addBackendUser(\T3Monitor\T3monitoring\Domain\Model\Backend\User $backendUser) + { + $this->backendUsers->attach($backendUser); + } + + /** + * Removes a backend user + * + * @param \T3Monitor\T3monitoring\Domain\Model\Backend\User $backendUserToRemove The backend user to be removed + * @return void + */ + public function removeBackendUser(\T3Monitor\T3monitoring\Domain\Model\Backend\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(\TYPO3\CMS\Extbase\Persistence\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']['mysqlClientVersion'], 'core' => $this->getUsedCore($json['core']['typo3Version']), 'extensions' => $this->handleExtensionRelations($row['uid'], $json['extensions']), + 'backend_users' => $this->handleBackendUserRelations($row['uid'], $json['users']['backend']), ); $this->addExtraData($json, $update, 'info'); @@ -211,6 +212,68 @@ 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); + } + protected function getUsedCore($version) { if (isset($this->coreVersions[$version])) { 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 9efa186..f373e62 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,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,', + 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,backend_users,core,sla,', 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_client.gif' ], 'interface' => [ - 'showRecordFieldList' => 'hidden, title, domain, secret, php_version, mysql_version, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla', + 'showRecordFieldList' => 'hidden, title, domain, secret, php_version, mysql_version, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, backend_users, core, sla', ], 'types' => [ '1' => [ 'showitem' => ' --div--;General,title, --palette--;;paletteDomain,sla, - --div--;Readonly information,last_successful_import,error_message,core, --palette--;;paletteVersions,extensions, + --div--;Readonly information,last_successful_import,error_message,core, --palette--;;paletteVersions,extensions,backend_users, insecure_core, outdated_core, insecure_extensions, outdated_extensions, --div--;Extra,extra_info,extra_warning,extra_danger' ], @@ -234,6 +234,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, diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 9f7542b..49e5de3 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 @@ -54,6 +72,9 @@ Extensions + + Backend Users + Core diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 1ecca80..9c41407 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 f00d853..f95dd74 100644 --- a/Resources/Private/Templates/Client/Show.html +++ b/Resources/Private/Templates/Client/Show.html @@ -90,6 +90,36 @@

+ +
+
+ Backend Users ({client.backendUsers -> f:count()}) +
+ + + + + + + + + + + + + + + + + + + + + +
User NameReal NameEmail AddressDescriptionLast Login
{backendUser.userName}{backendUser.realName}{backendUser.emailAddress}{backendUser.description}{backendUser.lastLogin}
+
+
+
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/ext_tables.sql b/ext_tables.sql index 6d59d2f..59cfce4 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' # @@ -22,6 +47,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', @@ -129,6 +155,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_client_extension_mm' #