| Server IP : 213.186.33.4 / Your IP : 216.73.216.59 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/piwik/plugins/ScheduledReports/ |
Upload File : |
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\ScheduledReports;
use Piwik\Menu\MenuAdmin;
use Piwik\Piwik;
use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\Plugins\MobileMessaging\API as APIMobileMessaging;
class Menu extends \Piwik\Plugin\Menu
{
const MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY = 'MobileMessaging_TopMenu';
const PDF_REPORTS_TOP_MENU_TRANSLATION_KEY = 'ScheduledReports_EmailReports';
public function configureAdminMenu(MenuAdmin $menu)
{
$tooltip = Piwik::translate(
\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging')
? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip');
$menu->addPersonalItem(
$this->getTopMenuTranslationKey(),
$this->urlForAction('index', array('segment' => false)),
7,
$tooltip
);
}
function getTopMenuTranslationKey()
{
// if MobileMessaging is not activated, display 'Email reports'
if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging')) {
return self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
}
if (Piwik::isUserIsAnonymous()) {
return self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY;
}
try {
$reports = API::getInstance()->getReports();
$reportCount = count($reports);
// if there are no reports and the mobile account is
// - not configured: display 'Email reports'
// - configured: display 'Email & SMS reports'
if ($reportCount == 0) {
return APIMobileMessaging::getInstance()->areSMSAPICredentialProvided() ?
self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY : self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
}
} catch(\Exception $e) {
return self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
}
$anyMobileReport = false;
foreach ($reports as $report) {
if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$anyMobileReport = true;
break;
}
}
// if there is at least one sms report, display 'Email & SMS reports'
if ($anyMobileReport) {
return self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY;
}
return self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
}
}