mirror of
https://github.com/Findus23/plugin-ProfileAvatar.git
synced 2024-09-19 15:23:45 +02:00
allow also showing the avatar in the visitor log
This commit is contained in:
parent
268adcd2d0
commit
6a43cc2bc3
5 changed files with 40 additions and 9 deletions
|
@ -2,9 +2,27 @@
|
|||
|
||||
namespace Piwik\Plugins\ProfileAvatar;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Plugin;
|
||||
|
||||
class ProfileAvatar extends Plugin
|
||||
{
|
||||
|
||||
public function registerEvents()
|
||||
{
|
||||
return array(
|
||||
'Live.renderVisitorDetails' => 'addImageToTemplate',
|
||||
);
|
||||
}
|
||||
|
||||
public function addImageToTemplate(string &$outString, Row $visit)
|
||||
{
|
||||
$settings = new UserSettings();
|
||||
if (!$settings->showInVisitorLog->getValue()) {
|
||||
return;
|
||||
}
|
||||
$visitorID = $visit->getColumn("visitorId");
|
||||
$hash = hash("sha256", $visitorID);
|
||||
|
||||
$outString .= "<img width='32' height='32' alt='user profile' src='?module=ProfileAvatar&action=getProfileAvatar&hash=$hash' aria-hidden='true'>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ class UserSettings extends \Piwik\Settings\Plugin\UserSettings
|
|||
/** @var Setting */
|
||||
public $dataURLs;
|
||||
|
||||
/** @var Setting */
|
||||
public $showInVisitorLog;
|
||||
|
||||
protected $title = "Visitor Profile Avatar";
|
||||
|
||||
protected function init()
|
||||
|
@ -27,6 +30,8 @@ class UserSettings extends \Piwik\Settings\Plugin\UserSettings
|
|||
$this->avatarType = $this->createAvatarTypeSetting();
|
||||
|
||||
$this->dataURLs = $this->createDataURLsSetting();
|
||||
|
||||
$this->showInVisitorLog = $this->createShowInVisitorLogSetting();
|
||||
}
|
||||
|
||||
private function createAvatarTypeSetting(): Setting
|
||||
|
@ -47,4 +52,13 @@ class UserSettings extends \Piwik\Settings\Plugin\UserSettings
|
|||
$field->description = Piwik::translate('ProfileAvatar_DataURLsDescription');
|
||||
});
|
||||
}
|
||||
|
||||
private function createShowInVisitorLogSetting(): Setting
|
||||
{
|
||||
return $this->makeSetting("showInVisitorLog", FALSE, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
|
||||
$field->title = Piwik::translate('ProfileAvatar_ShowInVisitorLogTitle');
|
||||
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
|
||||
$field->description = Piwik::translate('ProfileAvatar_ShowInVisitorLogDescription');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,4 @@ class VisitorDetails extends VisitorDetailsAbstract
|
|||
$profile['visitorAvatar'] = "?module=ProfileAvatar&action=getProfileAvatar&hash=$hash";
|
||||
}
|
||||
}
|
||||
|
||||
public function extendVisitorDetails(&$visitor)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
"AvatarTypeTitle": "Avatar Typ",
|
||||
"AvatarTypeDescription": "Wähle das Aussehen der Avatars aus.",
|
||||
"DataURLsTitle": "Verwende data URLs",
|
||||
"DataURLsDescription": "Wenn dies aktiviert ist, werden die Bilder in der ursprünglichen Anfrage mitgesendet, was die Ladezeit verringert, aber vor allem bei den größeren Bildern die Größe von API Anfragen stark erhöhen kann."
|
||||
"DataURLsDescription": "Wenn dies aktiviert ist, werden die Bilder in der ursprünglichen Anfrage mitgesendet, was die Ladezeit verringert, aber vor allem bei den größeren Bildern die Größe von API Anfragen stark erhöhen kann.",
|
||||
"ShowInVisitorLogTitle": "Im Besucher-Log anzeigen",
|
||||
"ShowInVisitorLogDescription": "Wenn dies aktiviert ist, werden die Avatare auch im Besucher-Log angezeigt."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
"AvatarTypeTitle": "Avatar Type",
|
||||
"AvatarTypeDescription": "Choose the mode for generating avatars.",
|
||||
"DataURLsTitle": "Use data URLs",
|
||||
"DataURLsDescription": "Enabling this ships the images in the main request which causes them to load much faster, but especially with larger images this can bloat the API requests."
|
||||
"DataURLsDescription": "Enabling this ships the images in the main request which causes them to load much faster, but especially with larger images this can bloat the API requests.",
|
||||
"ShowInVisitorLogTitle": "Show in Visitor Log",
|
||||
"ShowInVisitorLogDescription": "Enabling this also shows the avatar in the Visitor Log."
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue