/** * DO_CheckValidStatisticType * Data Object Method: Check whether or not statistic record exists * Method should only be called by DataObject class * * @param Int $statisticID Statistic ID * @param String $statisticType Statistic type * * @uses Stats_API * @uses Stats_API::FetchStats() * * @return Boolean Returns TRUE if exists, FALSE otherwise */ function DO_CheckStatisticAvailable($statisticID, $statisticType) { if (is_null($this->_cachedStatisticAPI)) { require_once(SENDSTUDIO_API_DIRECTORY . '/stats.php'); $this->_cachedStatisticAPI = new Stats_API(); } $status = $this->_cachedStatisticAPI->FetchStats($statisticID, $statisticType); // It should only return boolean AND NOTHING ELSE if ($status == false) { return false; } return true; }
/** * OpenTracked * Logs an event when a user opens a campaign or autoresponder * * @uses Subscriber_API::AddEvent * @uses Stats_API::GetNewsletterSummary * @uses Stats_API::GetAutoresponderSummary * * @return Void Returns nothing */ public static function OpenTracked($eventdata) { if (!self::LoadSelf()) { return; } $subscribersapi = new Subscribers_API(); $statsapi = new Stats_API(); if (!isset($eventdata->open_details['subscriberid']) || !isset($eventdata->open_details['listid'])) { return; } switch ($eventdata->statstype[0]) { case 'n': $newsletter = $statsapi->GetNewsletterSummary($eventdata->open_details['statid'], true); if (empty($newsletter) || !isset($newsletter['newsletterid'])) { return false; } $event = array('type' => GetLang('Addon_emaileventlog_open'), 'eventdate' => $subscribersapi->GetServerTime(), 'subject' => sprintf(GetLang('Addon_emaileventlog_open_subject'), htmlspecialchars($newsletter['newslettername'], ENT_QUOTES, SENDSTUDIO_CHARSET)), 'notes' => GetLang('Addon_emaileventlog_opened_campaign')); break; case 'a': $stats = $statsapi->FetchStats($eventdata->open_details['statid'], 'a'); $autoresponder = $statsapi->GetAutoresponderSummary($stats['autoresponderid'], true); if (empty($autoresponder) || !isset($autoresponder['autoresponderid'])) { return false; } $event = array('type' => GetLang('Addon_emaileventlog_open_autoresponder'), 'eventdate' => $subscribersapi->GetServerTime(), 'subject' => sprintf(GetLang('Addon_emaileventlog_open_autoresponder_subject'), htmlspecialchars($autoresponder['autorespondername'], ENT_QUOTES, SENDSTUDIO_CHARSET)), 'notes' => GetLang('Addon_emaileventlog_opened_autoresponder')); break; default: } $subscribersapi->AddEvent($eventdata->open_details['subscriberid'], $eventdata->open_details['listid'], $event); }