Interface Inx_Api_Mailing_MailingManager

Description

The Inx_Api_Mailing_MailingManager manages all mailings.

The Inx_Api_Mailing_MailingManager manages all mailings. The MailingManager can be used to perform the following tasks:

  • Retrieve mailings
  • Create mailings
  • Clone mailings
  • Create a renderer to generate a preview of the mailing
<strong>Mailing retrieval</strong>

There are several ways to retrieve mailings. The simplest way is to call selectAll() which will retrieve all mailings. To retrieve a single mailing, use the get($iMailingId) method. To retrieve all mailings of a specific list use one of the select(...) methods. Using this type of method gives you the ability to define search filters, like the mailing state. It is also possible to order the result.

The following snippet shows how to retrieve all mailings of a specific list, which are either in the

  1. DRAFT
or the
  1. TO_BE_APPROVE
state and print out their names:
 $oMailingManager = $oSession->getMailingManager();
 $oBOResultSet = $oMailingManager->select($oListContext, Inx_Api_Mailing_Mailing::STATE_DRAFT
 		| Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE);

 for( $i = 0; $i < $oBOResultSet->size(); $i++ )
 {
   $oMailing = $oBOResultSet->get($i);
   echo $oMailing->getName()."<br>";
 }

 $oBOResultSet->close();
To retrieve all mailings of a specific list, disregarding their state, use the state filter STATE_FILTER_ALL. This filter produces the same result as a bitwise combination of all mailing states.

If needed, it is possible to create much more complex select statements than the one above. This can be accomplished using filter expressions. The following snippet extends the previous select statement with a filter that restricts the result to mailings which were modified during the last hour. The result is also ordered by the mailing name:

 $oMailingManager = $oSession->getMailingManager();

 $filterDate = date("d.m.Y H:i:s", strtotime("-1 hour"));
 $filter = "Attribute(".Inx_Api_Mailing_Mailing::ATTRIBUTE_MODIFICATION_DATETIME.") > #".$filterDate."#";

 $oBOResultSet = $oMailingManager->select($oListContext, Inx_Api_Mailing_Mailing::STATE_DRAFT
 		| Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE, $filter, Inx_Api_Mailing_Mailing::ATTRIBUTE_NAME,
 		Inx_Api_Order::ASC);

 for($i = 0; $i < $oBOResultSet->size(); $i++)
 {
   $oMailing = $oBOResultSet->get($i);
   echo $oMailing->getName()."<br>";
 }

 $oBOResultSet->close();

<strong>Mailing creation and editing</strong>

The following snippet shows how to create a mailing:

 $oMailingManager = $oSession->getMailingManager();
 $oMailing = $oMailingManager->createMailing($oListContext);
 $oMailing->updateSubject("Monthly Newsletter");
 $oMailing->commitUpdate();

<strong>Note:</strong> For existing mailings, always call lock() before updating it, and unlock() after committing changes!

The following snippet shows how to edit an existing mailing:

 $oMailingManager = $oSession->getMailingManager();
 $oMailing = $oMailingManager->get($iMailingId);

 try
 {
   $oMailing->lock();
   $oMailing->updateSubject("New Subject");
   $oMailing->commitUpdate();
   $oMailing->unlock();
 }
 catch(Inx_Api_LockException $x)
 {
   //somone else has locked this mailing
 }

It is not necessary to repeatedly create almost identical mailings. This can be accomplished a lot easier using the clone() method.

The following snippet shows how to clone a mailing and put the clone in the specified list:

 $oMailingManager = $oSession->getMailingManager();
 $oMailingManager->cloneMailing($iMailingId, $oListContext);

<strong>Preview generation</strong>

To create a preview of a mailing, an Inx_Api_Mail_MailingRenderer is needed. A renderer can be obtained using the createRenderer() method.

The following snippet shows how to create a

  1. MailingRenderer
and generate a preview of the mailing:
 $oMailingManager = $oSession->getMailingManager();
 $oMailingRenderer = $oMailingManager->createRenderer();
 $oMailingRenderer->parse($iMailingId, Inx_Api_Mail_MailingRenderer::BUILD_MODE_PREVIEW);
 $oMailContent = $oMailingRenderer->build($iRecipientId);

 echo $oMailContent->getPlainText()."<br>";

For more information on mailings, see the Inx_Api_Mailing_Mailing documentation.

Note: To use mailings, the following api user right is required: Inx_Api_UserRights::MAILING_FEATURE_USE

  • version: $Revision: 9553 $ $Date: 2008-01-04 11:28:41 +0200 (Pn, 04 Sau 2008) $ $Author: vladas $
  • see: Inx_Api_Mailing_Mailing

Located in /Api/Mailing/MailingManager.php (line 137)

Inx_Api_BOManager
   |
   --Inx_Api_Mailing_MailingManager
Class Constant Summary
Method Summary
the cloneMailing ( $iMailingId, Inx_Api_List_ListContext $oListContext)
Inx_Api_BOResultSet select ([Inx_Api_List_ListContext $oListContext = null], int $iStateFilter, [string $sFilter = null], [int $iOrderAttribute = null], [int $iOrderType = null])
Methods
cloneMailing (line 236)

Copies a

  1. Inx_Api_Mail_Mailing
to the specified list.

Copies a

  1. Inx_Api_Mail_Mailing
to the specified list.

  • return: new
    1. Inx_Api_Mail_Mailing
  • since: API 1.6.0
  • access: public
the cloneMailing ( $iMailingId, Inx_Api_List_ListContext $oListContext)
createMailing (line 212)

Creates a new mailing in the specified list.

Creates a new mailing in the specified list.

  • return: a new mailing
  • access: public
Inx_Api_Mailing_Mailing createMailing (Inx_Api_List_ListContext $oListContext)
  • $oListContext $oListContext: list owner of the mailing
createRenderer (line 220)

Creates the new Inx_Api_Mail_MailingRenderer to rendering a Inx_Api_Mailing_Mailing.

Creates the new Inx_Api_Mail_MailingRenderer to rendering a Inx_Api_Mailing_Mailing.

  • return: the new Inx_Api_Mail_MailingRenderer
  • access: public
Inx_Api_Mail_MailingRenderer createRenderer ()
createRendererForTestRecipient (line 228)

Creates the new

to rendering a
  1. Mailing
with test recipients.

Creates the new

to rendering a
  1. Mailing
with test recipients.

the createRendererForTestRecipient ()
select (line 203)

Selects mailings in specified order, filtered by the supplied condition. The Inx_Api_BOResultSet contains a set of Inx_Api_Mailing_Mailing objects.

Selects mailings in specified order, filtered by the supplied condition.
The Inx_Api_BOResultSet contains a set of Inx_Api_Mailing_Mailing objects. The stateFilter must be either a single value like:

  • Inx_Api_Mailing_Mailing::STATE_DRAFT
  • Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE
  • Inx_Api_Mailing_Mailing::STATE_APPROVED
  • Inx_Api_Mailing_Mailing::STATE_SCHEDULED
  • Inx_Api_Mailing_Mailing::STATE_SENDING
  • Inx_Api_Mailing_Mailing::STATE_INTERRUPTED
  • Inx_Api_Mailing_Mailing::STATE_SENT
  • Inx_Api_Mailing_Mailing::STATE_SENDING_FAILED
or a bitwise combination, e.g. Inx_Api_Mailing_Mailing::STATE_SCHEDULED|Inx_Api_Mailing_Mailing::STATE_SENDING or Inx_Api_Mailing_Mailing::STATE_DRAFT|Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE|Inx_Api_Mailing_Mailing::STATE_APPROVED The filter is a boolean expression on one mailing attribute. Attributes are specified with the function Attribute(id). Please note that date-values for the filter have to be specified in german 24-hour date-format. To accomplish this, the date() function with the following date-pattern can be used:
 $filterDate = date("d.m.Y H:i:s");
The orderAttribute is the id of the order attribute. Allowed values for attribute ids are:
  • Inx_Api_Mailing_Mailing::ATTRIBUTE_SUBJECT
  • Inx_Api_Mailing_Mailing::ATTRIBUTE_MODIFICATION_DATETIME
  • Inx_Api_Mailing_Mailing::ATTRIBUTE_SENT_START_DATETIME
  • Inx_Api_Mailing_Mailing::ATTRIBUTE_SENT_END_DATETIME

  • return: the result set of Inx_Api_Mailing_Mailing objects
  • throws: Inx_Api_FilterStmtException
  • access: public
Inx_Api_BOResultSet select ([Inx_Api_List_ListContext $oListContext = null], int $iStateFilter, [string $sFilter = null], [int $iOrderAttribute = null], [int $iOrderType = null])
  • Inx_Api_List_ListContext $oListContext: list from which to select
  • int $iStateFilter: s.above.
  • string $sFilter: filter expression
  • int $iOrderAttribute: order attribute id
  • int $iOrderType: one of Order.ASC and Order.DESC fort order direction

Inherited Methods

Inherited From Inx_Api_BOManager

Inx_Api_BOManager::get()
Inx_Api_BOManager::remove()
Inx_Api_BOManager::selectAll()
Class Constants
ORDER_ASC = 0 (line 141)
  • deprecated: replaced by Inx_Api_Order::ASC
ORDER_DESC = 1 (line 144)
  • deprecated: replaced by Inx_Api_Order::DESC
STATE_FILTER_ALL = 0xFFFF (line 156)

State filter constants to returning all mailings.

State filter constants to returning all mailings. It's the same like:

 $iStateFilter = Inx_Api_Mailing_Mailing::STATE_DRAFT | Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE | Inx_Api_Mailing_Mailing::STATE_APPROVED
 		| Inx_Api_Mailing_Mailing::STATE_SCHEDULED | Inx_Api_Mailing_Mailing::STATE_SENDING| Inx_Api_Mailing_Mailing::STATE_INTERRUPTED
 		| Inx_Api_Mailing_Mailing::STATE_SENT | Inx_Api_Mailing_Mailing::STATE_SENDING_FAILED;

Documentation generated on Thu, 17 Sep 2015 14:27:27 +0200 by phpDocumentor 1.3.2