コード例 #1
0
	/**
	 * Delete data from database
	 * @return boolean Returns TRUE if successful, FALSE otherwise
	 * @throws E_USER_NOTICE Invalid ID
	 *
	 * @uses module_Tracker::DO_Delete()
	 */
	function delete()
	{
		if(empty($this->_records['statid']) || empty($this->_records['stattype'])) {
			trigger_error('module_Tracker_DataObject::save() -- Invalid ID', E_USER_NOTICE);
			return false;
		}

		return $this->_cachedDAO->DO_Delete($this->_records['statid'], $this->_records['stattype']);
	}
コード例 #2
0
ファイル: link.php プロジェクト: hungnv0789/vhtm
$clicktime = $statsapi->GetServerTime();
$clickip = GetRealIp();

$click_details = array(
	'clicktime' => $clicktime,
	'clickip' => $clickip,
	'subscriberid' => $subscriberid,
	'statid' => $statid,
	'linkid' => $linkid,
	'listid' => $listinfo['listid'],
	'url' => $url
);

$statsapi->RecordLinkClick($click_details, $statstype);

/**
 * Do Tracking module
 */
	if ($sendstudio_functions->GetApi('module_TrackerFactory', false)) {
		$status = module_Tracker::ProcessURLForAllTracker($statid, $statstype, array('url' => $url), $subscriberinfo);
		if ($status != false) {
			$url = $status;
		}
	}
/**
 * -----
 */

header('Location: ' . $url);
コード例 #3
0
	/**
	* Delete
	* Deletes statistics from the database. This is different from HideStats in that HideStats does not remove any records from the database, it only prevents them from being displays in the control panel.
	*
	* @param Array $statids The statids you want to delete
	* @param String $statstype The type of statistics you want to delete (newsletter / autoresponder)
	*
	* @see HideStats
	*
	* @return Boolean Returns false if statistics couldn't be deleted (invalid arguments passed in for example), otherwise returns true.
	*/
	function Delete($statids=array(), $statstype='n')
	{
		if (!is_array($statids)) {
			$statids = array($statids);
		}

		$statids = $this->CheckIntVars($statids);
		if (empty($statids)) {
			return false;
		}

		$table = $this->GetStatsTable($statstype);
		if (!$table) {
			return false;
		}

		/**
		 * Cleanup trackers
		 *
		 * When statistics are deleted, delete associated tracker record too
		 * @todo ask Chris what happened when record delete failed
		 */
			$validStatTypes = array(	'n'	=> 'newsletter',
										'a' => 'autresponder');
			$convertedStatType = isset($validStatTypes[$statstype])? $validStatTypes[$statstype] : '';

			if ($convertedStatType != '') {
				$tempContinue = false;
				if (!class_exists('module_TrackerFactory', false)) {
					$tempFile = dirname(__FILE__) . '/module_trackerfactory.php';
					if (is_file($tempFile)) {
						require_once($tempFile);
						$tempContinue = true;
					}
				} else {
					$tempContinue = true;
				}

				if ($tempContinue) {
					foreach ($statids as $statid) {
						module_Tracker::DeleteRecordsForAllTrackerByID($statid, $convertedStatType);
					}
				}
			}
		/**
		 * -----
		 */

		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . $table . " WHERE statid IN (" . implode(',', $statids). ")";
		$result = $this->Db->Query($query);
		if (!$result) {
			return false;
		}

		if ($statstype == 'n') {
			$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "stats_newsletter_lists WHERE statid IN (" . implode(',', $statids). ")";
			$result = $this->Db->Query($query);
		}

		/**
		* Clean up old links.
		*/
		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "stats_links WHERE statid IN (" . implode(',', $statids). ")";
		$result = $this->Db->Query($query);

		/**
		* Clean up old link clicks.
		*/
		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "stats_linkclicks WHERE statid IN (" . implode(',', $statids). ")";
		$result = $this->Db->Query($query);

		/**
		* Clean up opening records.
		*/
		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "stats_emailopens WHERE statid IN (" . implode(',', $statids). ")";
		$result = $this->Db->Query($query);

		/**
		* Clean up forwarding records.
		*/
		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "stats_emailforwards WHERE statid IN (" . implode(',', $statids). ")";
		$result = $this->Db->Query($query);

		if ($statstype == 'a') {
			$query = "UPDATE " . SENDSTUDIO_TABLEPREFIX . "autoresponders SET statid=0 WHERE statid IN (" . implode(',', $statids). ")";
			$result = $this->Db->Query($query);
		}

		return true;
	}
コード例 #4
0
    /**
     * ProcessJob
     * Does most of the work setting up the job (creates the queue, removes duplicates and so on) to run. Once the job has been set up ready to run, it 'Actions' the job, then marks it as 'finished'.
     *
     * @param Int $jobid The job to run.
     *
     * @see Email_API
     * @see Subscriber_API
     * @see Lists_API
     * @see newsletter_api
     * @see GetUser
     * @see StartJob
     * @see GetJobQueue
     * @see CreateQueue
     * @see JobQueue
     * @see Subscribers_API::GetSubscribers
     * @see RemoveDuplicatesInQueue
     * @see RemoveBannedEmails
     * @see ActionJob
     * @see FinishJob
     *
     * @return Boolean Returns false if the job can't be started. Otherwise runs the job and returns true.
     */
    function ProcessJob($jobid=0) {
        if (!$this->StartJob($jobid)) {
            $this->PauseJob($jobid);
            $this->jobstatus = 'p';
            trigger_error("Unable to start send job {$jobid}");
            return false;
        }

        $user = GetUser($this->jobowner);
        IEM::userLogin($this->jobowner, false);

        $queueid = false;

        // if there's no queue, start one up.
        if (!$queueid = $this->GetJobQueue($jobid)) {
            $sendqueue = $this->CreateQueue('send');
            $queueok = $this->JobQueue($jobid, $sendqueue);
            $send_criteria = $this->jobdetails['SendCriteria'];

            $original_queuesize = $this->jobdetails['SendSize'];

            $queueinfo = array('queueid' => $sendqueue, 'queuetype' => 'send', 'ownerid' => $this->jobowner);

            if (isset($this->jobdetails['Segments']) && is_array($this->jobdetails['Segments'])) {
                $this->Subscriber_API->GetSubscribersFromSegment($this->jobdetails['Segments'], false, $queueinfo, 'nosort');
            } else {
                $this->Subscriber_API->GetSubscribers($send_criteria, array(), false, $queueinfo, $sendqueue);
            }

            $this->Subscriber_API->RemoveDuplicatesInQueue($sendqueue, 'send', $this->jobdetails['Lists']);

            $this->Subscriber_API->RemoveBannedEmails($this->jobdetails['Lists'], $sendqueue, 'send');

            $this->Subscriber_API->RemoveUnsubscribedEmails($this->jobdetails['Lists'], $sendqueue, 'send');

            $queueid = $sendqueue;

            $newsletterstats = $this->jobdetails;
            $newsletterstats['Job'] = $jobid;
            $newsletterstats['Queue'] = $sendqueue;
            $newsletterstats['SentBy'] = $queueinfo['ownerid'];

            $real_queuesize = $this->Subscriber_API->QueueSize($queueid, 'send');

            $newsletterstats['SendSize'] = $real_queuesize;

            $statid = $this->Stats_API->SaveNewsletterStats($newsletterstats);

            /**
             * Process tracker request where because cron was not enabled, we need to parse the option straight away
             * @todo Result for the call to module_Tracker::ParseOptionsForAllTracker() is not being processed and being ignored
             */
            $tempAPIFile = dirname(__FILE__) . '/module_trackerfactory.php';
            if (is_file($tempAPIFile)) {
                require_once($tempAPIFile);
                $temp = array_merge($this->jobdetails, array('statid' => $statid,
                    'stattype' => 'newsletter',
                    'newsletterid' => $this->jobdetails['Newsletter']));

                $status = module_Tracker::ParseOptionsForAllTracker($temp);
            }
            /**
             * -----
             */
            /**
             * So we can link user stats to send stats, we need to update it.
             */
            $this->Stats_API->UpdateUserStats($queueinfo['ownerid'], $jobid, $statid);

            /**
             * The 'queuesize' in the stats_users table is updated by MarkNewsletterFinished in send.php
             * so we don't need to worry about it while setting up the send.
             * That takes into account whether some recipients were skipped because a html-only email was sent etc.
             */
            /**
             * We re-check the user stats in case a bunch of subscribers have joined, or the user has done something like:
             * - create a list
             * - added a few subscribers
             * - scheduled a send
             * - added more subscribers
             */
            $check_stats = $this->Stats_API->ReCheckUserStats($user, $original_queuesize, $real_queuesize, AdjustTime());

            list($ok_to_send, $not_ok_to_send_reason) = $check_stats;
            if (!$ok_to_send) {
                trigger_error(__CLASS__ . '::' . __METHOD__ . " -- " . GetLang($not_ok_to_send_reason), E_USER_WARNING);
                $this->PauseJob($jobid);
                $this->UnapproveJob($jobid);
                IEM::userLogout();
                return false;
            }

            API_USERS::creditEvaluateWarnings($user->GetNewAPI());
        }

        $this->statid = $this->LoadStats($jobid);
        if (empty($this->statid)) {
            trigger_error(__CLASS__ . '::' . __METHOD__ . " -- Cannot find statid. Previous preliminary job process did not get finalized (either CRON died, or it hasn't finished processing the job). Ignoring this job: jobid {$jobid}.", E_USER_NOTICE);
            IEM::userLogout();
            return false;
        }

        $queuesize = $this->Subscriber_API->QueueSize($queueid, 'send');

        // used by send.php::CleanUp
        $this->queuesize = $this->jobdetails['SendSize'];

        /**
         * There's nothing left? Just mark it as done.
         */
        if ($queuesize == 0) {
            $this->jobstatus = 'c';
            $this->FinishJob($jobid);
            IEM::userLogout();
            return true;
        }

        $finished = $this->ActionJob($jobid, $queueid);

        if ($finished) {
            $this->jobstatus = 'c';
            $this->FinishJob($jobid);
        }

        IEM::userLogout();
        return true;
    }
コード例 #5
0
ファイル: send.php プロジェクト: hungnv0789/vhtm
	/**
	* SelectNewsletter
	* Displays a list of newsletters you can send.
	* Only gets live newsletters.
	* If cron scheduling is enabled, then you get extra options to choose from (whether to notify the owner and of course what time to send the newsletter).
	* You can also choose the character set for the send to use.
	*
	* @see GetApi
	* @see Newsletters_API::GetLiveNewsletters
	* @see CreateDateTimeBox
	* @see CharsetList
	* @see SENDSTUDIO_CRON_ENABLED
	*
	* @return Void Doesn't return anything, prints out the step where you select the newsletter you want to send to your list(s).
	*/
	function SelectNewsletter($errormsg=false)
	{
		$send_details = IEM::sessionGet('SendDetails');
		$user = IEM::getCurrentUser();
		$newsletterapi = $this->GetApi('Newsletters');

		$sendsize = $send_details['SendSize'];
		if ($sendsize == 1) {
			$sendSizeInfo = GetLang('SendSize_One');
		} else {
			$sendinfo = IEM::sessionGet('SendInfoDetails');
			$sendSizeInfo = $sendinfo['Msg'];
		}

		if (SENDSTUDIO_CRON_ENABLED && SENDSTUDIO_CRON_SEND > 0) {
			$sendSizeInfo .= sprintf(' <a href="javascript:void(0)" onClick="alert(\'%s\')">%s</a>', GetLang('ReadMoreWhyApprox'), GetLang('ReadMore'));
		}

		$GLOBALS['Message'] = '';

		if (!IEM::sessionGet('MyError')) {
			$GLOBALS['Success'] = $sendSizeInfo;
			$GLOBALS['Message'] = $this->ParseTemplate('SuccessMsg', true, false);
		}

		if ($errormsg) {
			$GLOBALS['Error'] = $errormsg;
			$GLOBALS['Message'] .= $this->ParseTemplate('ErrorMsg', true, false);
		}

		if (IEM::sessionGet('MyError')) {
			$GLOBALS['Message'] .= IEM::sessionGet('MyError') . IEM::sessionGet('ExtraMessage');
		}

		$newsletterowner = ($user->Admin() ? 0 : $user->userid);

		$newsletters = $newsletterapi->GetLiveNewsletters($newsletterowner);
		$newsletterlist = '';
		$count = sizeof(array_keys($newsletters));
		$newsletterlist = '<option value="0">' . GetLang('SelectNewsletterToSend') . '</option>';

		foreach ($newsletters as $pos => $newsletterinfo) {
			$chosen = '';
			if ($newsletterinfo['newsletterid'] == $send_details['NewsletterChosen']) {
				$chosen = ' SELECTED';
			}
			$newsletterlist .= '<option value="' . $newsletterinfo['newsletterid'] . '"' . $chosen . '>' . htmlspecialchars($newsletterinfo['name'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>';
		}

		$list = $send_details['Lists'][0]; // always choose the first list. doesn't matter if there are multiple lists to choose from.
		$listapi = $this->GetApi('Lists');
		$listapi->Load($list);

		$customfields = $listapi->GetCustomFields($send_details['Lists'], 'text');

		if (empty($customfields)) {
			$GLOBALS['DisplayNameOptions'] = 'none';
		} else {
			$GLOBALS['NameOptions'] = '';
			foreach ($customfields as $p => $details) {
				$GLOBALS['NameOptions'] .= "<option value='" . $details['fieldid'] . "'>" . htmlspecialchars($details['name'], ENT_QUOTES, SENDSTUDIO_CHARSET) . "</option>";
			}
		}

		$GLOBALS['SendFromEmail'] = $listapi->Get('owneremail');
		$GLOBALS['SendFromName'] = $listapi->Get('ownername');
		$GLOBALS['ReplyToEmail'] = $listapi->Get('replytoemail');
		$GLOBALS['BounceEmail'] = $listapi->Get('bounceemail');

		$GLOBALS['ShowBounceInfo'] = 'none';

		if ($user->HasAccess('Lists', 'BounceSettings')) {
			$GLOBALS['ShowBounceInfo'] = '';
		}

		$GLOBALS['SendCharset'] = SENDSTUDIO_CHARSET;

		$GLOBALS['SendTimeBox'] = $this->CreateDateTimeBox(0, false, 'datetime', true);

		$GLOBALS['NewsletterList'] = $newsletterlist;

		$GLOBALS['DisplayEmbedImages'] = 'none';
		if (SENDSTUDIO_ALLOW_EMBEDIMAGES) {
			$GLOBALS['DisplayEmbedImages'] = '';
			if (SENDSTUDIO_DEFAULT_EMBEDIMAGES) {
				$GLOBALS['EmbedImages'] = ' CHECKED';
			}
		}

		$cron_options = '';
		if (SENDSTUDIO_CRON_ENABLED && SENDSTUDIO_CRON_SEND > 0) {
			$cron_options = $this->ParseTemplate('Send_Step3_Cron', true);
		}
		$GLOBALS['CronOptions'] = $cron_options;


		if (check('send', $user->Admin(), $list) && (!SENDSTUDIO_CRON_ENABLED || SENDSTUDIO_CRON_SEND == 0)) {
			if ($user->Admin()) {
				$NoCronMessage = 'Send_NoCronEnabled_Explain_Admin';
			} else {
				$NoCronMessage = 'Send_NoCronEnabled_Explain_NotAdmin';
			}

			$GLOBALS['NoCronMessage'] = $this->PrintWarning($NoCronMessage);
		}

		if (check('TrackThisSend', 'enabled')) {
			if ($this->GetApi('module_TrackerFactory', false)) {
				$trackerOptions = module_Tracker::GetDisplayOptionsForAllTracker();
				$GLOBALS['TrackerOptions'] = implode('', $trackerOptions);
			}
		}

		$template = $this->ParseTemplate('Send_Step3');
	}
コード例 #6
0
ファイル: module_tracker.php プロジェクト: hungnv0789/vhtm
		/**
		 * DO_CheckStatisticAvailable
		 * Data Object Method: Check whether or not statistic type is valid
		 * Method should only be called by DataObject class
		 *
		 * @param String $statisticType Statistic type to be checked
		 *
		 * @return Boolean Returns TRUE if valid, FALSE otherwise
		 */
		function DO_CheckValidStatisticType($statisticType)
		{
			return in_array($statisticType, module_Tracker::_getValidStatisticTypes());
		}
コード例 #7
0
ファイル: newsletters.php プロジェクト: hungnv0789/vhtm
	/**
	* Delete
	* Delete a newsletter from the database
	*
	* @param Int $newsletterid Newsletterid of the newsletter to delete. If not passed in, it will delete 'this' newsletter. We delete the newsletter, then reset all class vars.
	* @param Int $userid The user doing the deleting of the newsletter. This is passed through to the stats api to "hide" statistics rather than deleting them.
	*
	* @see Stats_API::HideStats
	*
	* @return Boolean True if it deleted the newsletter, false otherwise.
	*
	* @uses module_TrackerFactory
	* @uses module_Tracker
	* @uses module_Tracker::DeleteRecordsForAllTrackerByID()
	*/
	function Delete($newsletterid=0, $userid=0)
	{
		if ($newsletterid == 0) {
			$newsletterid = $this->newsletterid;
		}

		$newsletterid = intval($newsletterid);

		/**
		 * Status being 'true' means
		 * it's ok to delete the newsletter.
		 * If it's not true, then the delete method returns false.
		 */
		$trigger_details = array (
			'status' => true,
			'newsletterid' => $newsletterid
		);

		/**
		 * Trigger event
		 */
			$tempEventData = new EventData_IEM_NEWSLETTERSAPI_DELETE();
			$tempEventData->status = &$trigger_details['status'];
			$tempEventData->newsletterid = &$trigger_details['newsletterid'];
			$tempEventData->trigger();

			unset($tempEventData);
		/**
		 * -----
		 */

		if ($trigger_details['status'] !== true) {
			return false;
		}

		$this->Db->StartTransaction();

		/**
		 * Cleanup trackers
		 *
		 * When newsletter are deleted, delete associated tracker record too
		 *
		 * This was added here, because it's not calling the stats API to clear it's statistic
		 */
			$tempContinue = false;
			if (!class_exists('module_TrackerFactory', false)) {
				$tempFile = dirname(__FILE__) . '/module_trackerfactory.php';
				if (is_file($tempFile)) {
					require_once($tempFile);
					$tempContinue = true;
				}
			} else {
				$tempContinue = true;
			}

			if ($tempContinue) {
				module_Tracker::DeleteRecordForAllTrackerByNewsletterID($newsletterid);
			}
		/**
		 * -----
		 */

		$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "newsletters WHERE newsletterid=" . $newsletterid;
		$result = $this->Db->Query($query);
		if (!$result) {
			$this->Db->RollbackTransaction();
			list($error, $level) = $this->Db->GetError();
			trigger_error($error, $level);
			return false;
		}

		$newsletter_dir = TEMP_DIRECTORY . '/newsletters/' . $newsletterid;
		remove_directory($newsletter_dir);

		$this->newsletterid = 0;
		$this->name = '';
		$this->format = 'h';
		$this->active = 0;
		$this->archive = 0;
		$this->SetBody('text', '');
		$this->SetBody('html', '');
		$this->ownerid = 0;

		$stats = array();
		$query = "SELECT statid FROM " . SENDSTUDIO_TABLEPREFIX . "stats_newsletters WHERE newsletterid=" . $newsletterid;
		$result = $this->Db->Query($query);
		if (!$result) {
			$this->Db->RollbackTransaction();
			list($error, $level) = $this->Db->GetError();
			trigger_error($error, $level);
			return false;
		}

		while ($row = $this->Db->Fetch($result)) {
			$stats[] = $row['statid'];
		}

		// clean up stats
		if (!class_exists('stats_api', false)) {
			require_once(dirname(__FILE__) . '/stats.php');
		}

		$stats_api = new Stats_API();

		$stats_api->HideStats($stats, 'newsletter', $userid);

		$this->Db->CommitTransaction();

		return true;
	}