Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/Controller/StatisticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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'),
Expand Down
119 changes: 119 additions & 0 deletions Classes/Domain/Model/Backend/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
namespace T3Monitor\T3monitoring\Domain\Model\Backend;

/*
* This file is part of the t3monitoring extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

class User extends AbstractEntity
{
/**
* @var string
*/
protected $userName;

/**
* @var string
*/
protected $realName;

/**
* @var string
*/
protected $description;

/**
* @var string
*/
protected $lastLogin;

/**
* @var string
*/
protected $emailAddress;

/**
* @return string
*/
public function getUserName()
{
return $this->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;
}
}
52 changes: 52 additions & 0 deletions Classes/Domain/Model/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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
*
Expand Down
16 changes: 16 additions & 0 deletions Classes/Domain/Repository/Backend/UserRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace T3Monitor\T3monitoring\Domain\Repository\Backend;

/*
* This file is part of the t3monitoring extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

use T3Monitor\T3monitoring\Domain\Repository\BaseRepository;

class UserRepository extends BaseRepository
{

}
63 changes: 63 additions & 0 deletions Classes/Service/Import/ClientImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ protected function importSingleClient(array $row)
'mysql_version' => $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');
Expand Down Expand Up @@ -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])) {
Expand Down
Loading