mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +02:00
iTop Newsroom implementation - painfully merged manually...
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
require_once(APPROOT.'application/newsroomprovider.class.inc.php');
|
||||
|
||||
class HubNewsroomProvider extends NewsroomProviderBase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see NewsroomProviderBase::GetTTL()
|
||||
*/
|
||||
public function GetTTL()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 15*60; // Update every 15 minutes
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see NewsroomProviderBase::IsApplicable()
|
||||
*/
|
||||
public function IsApplicable(User $oUser = null)
|
||||
{
|
||||
if ($oUser !== null)
|
||||
{
|
||||
return UserRights::IsAdministrator($oUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see NewsroomProviderBase::GetLabel()
|
||||
*/
|
||||
public function GetLabel()
|
||||
{
|
||||
return 'iTop Hub'; // No need to translate...
|
||||
}
|
||||
|
||||
public function GetMarkAllAsReadURL()
|
||||
{
|
||||
return $this->MakeURL('route_mark_all_messages_as_read');
|
||||
}
|
||||
|
||||
public function GetFetchURL()
|
||||
{
|
||||
return $this->MakeURL('route_fetch_unread_messages');
|
||||
}
|
||||
|
||||
public function GetViewAllURL()
|
||||
{
|
||||
return $this->MakeURL('route_view_all_messages');
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see NewsroomProviderBase::GetPreferencesUrl()
|
||||
*/
|
||||
public function GetPreferencesUrl()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function MakeURL($sRouteCode)
|
||||
{
|
||||
$sBaseUrl = $this->oConfig->GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', $sRouteCode);
|
||||
|
||||
$sParameters = 'uuid[bdd]='.urlencode((string) trim(DBProperty::GetProperty('database_uuid', ''), '{}'));
|
||||
$sParameters .= '&uuid[file]='.urlencode((string) trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n"));
|
||||
$sParameters .= '&uuid[user]='.urlencode(UserRights::GetUserId());
|
||||
|
||||
return $sBaseUrl.'?'.$sParameters;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user