/**
	* EditJob
	* Allows you to edit a job's send time and view other details (which list(s), newsletter).
	*
	* @param Int $jobid JobId to edit.
	*
	* @see CheckJob
	* @see GetApi
	* @see Jobs_API::Load
	* @see GetUser
	* @see Newsletters_API::Load
	* @see Lists_API::Load
	* @see CreateDateTimeBox
	*
	* @return Void Prints out the form for editing, doesn't return anything.
	*
	* @uses EventData_IEM_SCHEDULE_EDITJOB
	*/
	function EditJob($jobid=0)
	{
		$check = $this->CheckJob($jobid);
		if (!$check) {
			return false;
		}

		$api = $this->GetApi('Jobs');
		$job = $api->LoadJob($jobid);

		/**
		 * Trigger event
		 */
			$tempEventData = new EventData_IEM_SCHEDULE_EDITJOB();
			$tempEventData->jobrecord = &$job;

			if (!$tempEventData->trigger()) {
				return;
			}

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

		$user = GetUser();
		$user_lists = $user->GetLists();

		$newslettername = '';
		$newsletterApi = $this->GetApi('Newsletters');
		$newsletterApi->Load($job['jobdetails']['Newsletter']);
		$newslettername = $newsletterApi->Get('name');

		$GLOBALS['JobID'] = $jobid;

		$listdetails = array();
		foreach ($job['jobdetails']['Lists'] as $l => $listid) {
			$listdetails[] = htmlspecialchars($user_lists[$listid]['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
		}
		$listnames = implode(', ', $listdetails);

		$GLOBALS['NewsletterID'] = $newsletterApi->Get('newsletterid');
		$GLOBALS['Send_NewsletterName'] = sprintf(GetLang('Send_NewsletterName'), htmlspecialchars($newslettername, ENT_QUOTES, SENDSTUDIO_CHARSET));

		$GLOBALS['Send_SubscriberList'] = sprintf(GetLang('Send_SubscriberList'), $listnames);

		$GLOBALS['SendTimeBox'] = $this->CreateDateTimeBox($job['jobtime']);

		$this->ParseTemplate('Schedule_Edit');
	}
示例#2
0
 /**
  * EditSchedule
  * This prints out the "edit schedule" page
  * which in reality isn't much different to a normal edit schedule page except:
  * - list multiple campaigns (each name being clickable to show a preview of that campaign)
  *
  * The data passed in contains the "jobdetails" array from the job being edited.
  * That array contains the splitid - which can then be used to work out the campaigns etc being used.
  *
  * If it's not a 'splittest' job type, this function/method just returns and doesn't do anything.
  *
  * @param EventData_IEM_SCHEDULE_EDITJOB $data The array of jobdetails for the scheduled event being edited.
  *
  * @uses InterspireEventData::preventDefault
  * @uses User_API::GetLists
  * @uses User_API::GetSegmentList
  * @uses SendStudio_Functions::CreateDateTimeBox
  */
 public static function EditSchedule(EventData_IEM_SCHEDULE_EDITJOB $data)
 {
     $jobinfo =& $data->jobrecord;
     if (empty($jobinfo) || !isset($jobinfo['jobtype'])) {
         FlashMessage(GetLang('Addon_splittest_Schedule_JobInvalid'), SS_FLASH_MSG_ERROR, self::application_url . 'index.php?Page=Schedule');
         return;
     }
     if ($jobinfo['jobtype'] != 'splittest') {
         return;
     }
     $data->preventDefault();
     $self = new self();
     $user = GetUser();
     $splitid = $jobinfo['jobdetails']['splitid'];
     /**
      * Check for messages.
      * If there are no flash messages, maybe it's being set in the "GLOBALS[Message]" string instead
      * by the admin/functions/schedule.php file.
      * Check that too :)
      */
     $flash_messages = GetFlashMessages();
     if (isset($GLOBALS['Message'])) {
         $flash_messages .= $GLOBALS['Message'];
     }
     $self->template_system->Assign('FlashMessages', $flash_messages, false);
     $self->template_system->Assign('Jobid', $jobinfo['jobid']);
     require_once SENDSTUDIO_API_DIRECTORY . '/newsletters.php';
     require_once SENDSTUDIO_API_DIRECTORY . '/jobs.php';
     require_once SENDSTUDIO_API_DIRECTORY . '/stats.php';
     $job_api = new Jobs_API();
     $stats_api = new Stats_API();
     $news_api = new Newsletters_API();
     $splitapi = $self->GetApi();
     $splitdetails = $splitapi->Load($splitid);
     $sendtype = $jobinfo['jobdetails']['sendingto']['sendtype'];
     $sending_to = $jobinfo['jobdetails']['sendingto']['sendids'];
     $sendinglist = array();
     if ($sendtype == 'list') {
         $user_lists = $user->GetLists();
         foreach ($sending_to as $listid) {
             $sendinglist[$listid] = htmlspecialchars($user_lists[$listid]['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
     }
     if ($sendtype == 'segment') {
         $user_segments = $user->GetSegmentList();
         foreach ($sending_to as $segmentid) {
             $sendinglist[$segmentid] = htmlspecialchars($user_segments[$segmentid]['segmentname'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
     }
     /**
      * Get the sendstudio functions file to create the date/time box.
      */
     require_once SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php';
     /**
      * also need to load the 'send' language file so it can put in the names/descriptions.
      */
     require_once SENDSTUDIO_LANGUAGE_DIRECTORY . '/default/send.php';
     $ssf = new SendStudio_Functions();
     $timebox = $ssf->CreateDateTimeBox($jobinfo['jobtime'], false, 'datetime', true);
     $self->template_system->Assign('ApplicationUrl', $self->application_url, false);
     $self->template_system->Assign('ScheduleTimeBox', $timebox, false);
     $self->template_system->Assign('SendType', $sendtype);
     $self->template_system->Assign('campaigns', $splitdetails['splittest_campaigns']);
     $self->template_system->Assign('sendinglist', $sendinglist);
     $self->template_system->ParseTemplate('schedule_edit');
 }