\seekquarry\yioop\library\media_jobsBulkEmailJob

MediaJob class for sending out emails from a Yioop instance (either in response to account registrations or in response to group posts and similar activities)

Subclasses should implement methods they use among init(), checkPrerequisites(), nondistributedTasks(), prepareTasks(), finishTasks(), getTasks(), doTasks(), and putTask(). MediaUpdating can be configured to run in either distributed or nameserver only mode. In the former mode, prepareTasks(), finishTasks() run on the name server, getTasks() and putTask() run in the name server's web app, and doTasks() run on any MediaUpdater clients. In the latter mode, only the method nondistributedTasks() is called by the MediaUpdater and by only the updater on the name server.

Summary

Methods
Properties
Constants
__construct()
init()
run()
checkPrerequisites()
nondistributedTasks()
prepareTasks()
finishTasks()
doTasks()
getTasks()
putTasks()
execNameServer()
getJobName()
getCurrentMachine()
$controller
$media_updater
$name_server_does_client_tasks
$name_server_does_client_tasks_only
$tasks
$mail_server
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$controller

$controller : object

If MediaJob was instantiated in the web app, the controller that instatiated it

Type

object

$media_updater

$media_updater : object

If the MediaJob was instantiated in a MediaUpdater, this is a reference to that updater

Type

object

$name_server_does_client_tasks

$name_server_does_client_tasks : boolean

Whether to run the job's client tasks on the name server in addition to prepareTasks and finishTasks

Type

boolean

$name_server_does_client_tasks_only

$name_server_does_client_tasks_only : boolean

Whether this MediaJob performs name server only tasks

Type

boolean

$tasks

$tasks : array

The most recently received from the name server tasks for this MediaJob

Type

array

$mail_server

$mail_server : object

Mail Server object used to send mails from media updater

Type

object

Methods

__construct()

__construct(object  $media_updater = null, object  $controller = null) 

Instiates the MediaJob with a reference to the object that instatiated it

Parameters

object $media_updater

a reference to the media updater that instatiated this object (if being run in MediaUpdater)

object $controller

a reference to the controller that instantiated this object (if being run in the web app)

init()

init() 

Set up the MailServer object used to actually send mail

run()

run() 

Method executed by MediaUpdater to perform the MediaJob. This method shouldn't need to be overriden. Instead, the various callbacks it calls (listed in the class description) wshould be overriden.

checkPrerequisites()

checkPrerequisites() : true

Bulk mail runs if the media updater is in distributed mode or if Yioop configured to send mail from media updater

Returns

true —

if bulk mail task should be run.

nondistributedTasks()

nondistributedTasks() 

Function to send emails to mailer batches created by mail_server. This function would periodically be invoked and send emails reading data from the text files.

prepareTasks()

prepareTasks() 

This method is called on the name server to prepare data for any MediaUpdater clients.

finishTasks()

finishTasks() 

This method is called on the name server to finish processing any data returned by MediaUpdater clients.

doTasks()

doTasks(array  $tasks) : mixed

Emails a list of emails provided by the name server to the media updater client

Parameters

array $tasks

contains emails which should be sent out

Returns

mixed —

data to send back to name server (in this case the name of the email file that was completely sent)

getTasks()

getTasks(integer  $machine_id, array  $data = null) : array

Handles the request to get the mailer list file for sending emails. This selection is based upon if the file was taken previously or not. If it was then it is skipped.

Otherwise new file is sent for sending emails and new text file with taken prepended to the file name is generated.

Parameters

integer $machine_id

id of client requesting data (not used)

array $data

not used

Returns

array —

work for the client to process

putTasks()

putTasks(integer  $machine_id, mixed  $data) : array

After a MediaUpdater client is done with the task given to it by the name server's media updater, the client contact the name server's web app. The name servers web app's JobController then calls this method to receive the data on the name server

Parameters

integer $machine_id

id of client that is sending data to name server

mixed $data

results of computation done by client

Returns

array —

any response information to send back to the client

execNameServer()

execNameServer(string  $command, string  $args = null) : array

Executes a method on the name server's JobController.

It will typically execute either getTask or putTask for a specific Mediajob or getUpdateProperties to find out the current MediaUpdater should be configured.

Parameters

string $command

the method to invoke on the name server

string $args

additional arguments to be passed to the name server

Returns

array —

data returned by the name server.

getJobName()

getJobName() : string

Gets the class name (less namespace and the word Job ) of the current MediaJob

Returns

string —

name of the current job

getCurrentMachine()

getCurrentMachine() : string

Returns a hash of the url of the current machine based on the value saved to current_machine_info.txt by a machine statuses request

Returns

string —

hash of current machine url