当前位置: 首页>>代码示例>>PHP>>正文


PHP Newsletter::get方法代码示例

本文整理汇总了PHP中Newsletter::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Newsletter::get方法的具体用法?PHP Newsletter::get怎么用?PHP Newsletter::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newsletter的用法示例。


在下文中一共展示了Newsletter::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: report

    public function report()
    {
        $data = Newsletter::get(FALSE);
        $html = '<table>
						<tr>
							<th>nome</th>
							<th>email</th>
							
						</tr>';
        foreach ($data as $row) {
            $html .= "<tr>\n\t\t\t\t\t\t\t<td>{$row->name}</td>\n\t\t\t\t\t\t\t<td>{$row->email}</td>\n\t\t\t\t\t\t</tr>";
        }
        $html .= '</table><script type="text/javascript"><!--window.close()--></script>';
        header("Content-type: application/vnd.ms-excel");
        header("Content-Disposition: attachment;Filename=relatorio_newsletter" . date('Y_m_d_-_H_i_s') . ".xls");
        echo $html;
    }
开发者ID:alegalliard,项目名称:aug,代码行数:17,代码来源:NewsletterController.php

示例2: create

 /**
  * Creates a newsletter job
  * @param $name        string    Specifies the name of the newsletter, the same name may be used more than once
  * @param $idnews    integer Newsletter id
  */
 public function create($iIDNews, $iIDCatArt, $sName = "")
 {
     global $client, $lang, $cfg, $cfgClient, $auth;
     $oNewsletter = new Newsletter();
     if ($oNewsletter->loadByPrimaryKey($iIDNews)) {
         $iIDNews = Contenido_Security::toInteger($iIDNews);
         $iIDCatArt = Contenido_Security::toInteger($iIDCatArt);
         $lang = Contenido_Security::toInteger($lang);
         $client = Contenido_Security::toInteger($client);
         $sName = Contenido_Security::escapeDB($sName, null);
         $oItem = parent::create();
         $oItem->set("idnews", $iIDNews);
         $oItem->set("idclient", $client);
         $oItem->set("idlang", $lang);
         if ($sName == "") {
             $oItem->set("name", $oNewsletter->get("name"));
         } else {
             $oItem->set("name", $sName);
         }
         $oItem->set("type", $oNewsletter->get("type"));
         $oItem->set("use_cronjob", $oNewsletter->get("use_cronjob"));
         $oLang = new cApiLanguage($lang);
         $oItem->set("encoding", $oLang->get("encoding"));
         unset($oLang);
         $oItem->set("idart", $oNewsletter->get("idart"));
         $oItem->set("subject", $oNewsletter->get("subject"));
         // Precompile messages
         #$sPath = $cfgClient[$client]["path"]["htmlpath"]."front_content.php?changelang=".$lang."&idcatart=".$iIDCatArt."&";
         $sPath = Contenido_Url::getInstance()->build(array('idcatart' => $iIDCatArt, 'client' => $client, 'lang' => $lang), true);
         $sPath .= strpos($sPath, '?') === false ? '?' : '&';
         $sMessageText = $oNewsletter->get("message");
         // Preventing double lines in mail, you may wish to disable this function on windows servers
         if (!getSystemProperty("newsletter", "disable-rn-replacement")) {
             $sMessageText = str_replace("\r\n", "\n", $sMessageText);
         }
         $oNewsletter->_replaceTag($sMessageText, false, "unsubscribe", $sPath . "unsubscribe={KEY}");
         $oNewsletter->_replaceTag($sMessageText, false, "change", $sPath . "change={KEY}");
         $oNewsletter->_replaceTag($sMessageText, false, "stop", $sPath . "stop={KEY}");
         $oNewsletter->_replaceTag($sMessageText, false, "goon", $sPath . "goon={KEY}");
         $oItem->set("message_text", $sMessageText);
         if ($oNewsletter->get("type") == "text") {
             // Text newsletter, no html message
             $sMessageHTML = "";
         } else {
             // HTML newsletter, get article content
             $sMessageHTML = $oNewsletter->getHTMLMessage();
             if ($sMessageHTML) {
                 $oNewsletter->_replaceTag($sMessageHTML, true, "name", "MAIL_NAME");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "number", "MAIL_NUMBER");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "date", "MAIL_DATE");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "time", "MAIL_TIME");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "unsubscribe", $sPath . "unsubscribe={KEY}");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "change", $sPath . "change={KEY}");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "stop", $sPath . "stop={KEY}");
                 $oNewsletter->_replaceTag($sMessageHTML, true, "goon", $sPath . "goon={KEY}");
                 // Replace plugin tags by simple MAIL_ tags
                 if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") {
                     if (is_array($cfg['plugins']['recipients'])) {
                         foreach ($cfg['plugins']['recipients'] as $sPlugin) {
                             plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php");
                             if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) {
                                 $aPluginVars = array();
                                 $aPluginVars = call_user_func("recipients_" . $sPlugin . "_wantedVariables");
                                 foreach ($aPluginVars as $sPluginVar) {
                                     $oNewsletter->_replaceTag($sMessageHTML, true, $sPluginVar, "MAIL_" . strtoupper($sPluginVar));
                                 }
                             }
                         }
                     }
                 }
             } else {
                 // There was a problem getting html message (maybe article deleted)
                 // Cancel job generation
                 return false;
             }
         }
         $oItem->set("message_html", $sMessageHTML);
         $oItem->set("newsfrom", $oNewsletter->get("newsfrom"));
         if ($oNewsletter->get("newsfromname") == "") {
             $oItem->set("newsfromname", $oNewsletter->get("newsfrom"));
         } else {
             $oItem->set("newsfromname", $oNewsletter->get("newsfromname"));
         }
         $oItem->set("newsdate", date("Y-m-d H:i:s"), false);
         //$oNewsletter->get("newsdate"));
         $oItem->set("dispatch", $oNewsletter->get("dispatch"));
         $oItem->set("dispatch_count", $oNewsletter->get("dispatch_count"));
         $oItem->set("dispatch_delay", $oNewsletter->get("dispatch_delay"));
         // Store "send to" info in serialized array (just info)
         $aSendInfo = array();
         $aSendInfo[] = $oNewsletter->get("send_to");
         switch ($oNewsletter->get("send_to")) {
             case "selection":
                 $oGroups = new RecipientGroupCollection();
                 $oGroups->setWhere("idnewsgroup", unserialize($oNewsletter->get("send_ids")), "IN");
//.........这里部分代码省略.........
开发者ID:Spider-IT-Deutschland,项目名称:drugCMS-Plugin_newsletter,代码行数:101,代码来源:class.newsletter.jobs.php

示例3: doSaveAsNew

 public function doSaveAsNew($data, $form)
 {
     $originalID = $data['NEWSLETTER_ORIGINAL_ID'];
     $origNewsletter = DataObject::get_by_id("Newsletter", $originalID);
     $controller = Controller::curr();
     try {
         $newNewsletter = clone $origNewsletter;
         //unset doesn't work, set system used fields to nulls.
         $newNewsletter->ID = null;
         $newNewsletter->Created = null;
         $newNewsletter->Status = null;
         $newNewsletter->LastEdited = null;
         $newNewsletter->SentDate = null;
         //write once without validation
         Newsletter::set_validation_enabled(false);
         //save once to get the new Newsletter created so as to add to mailing list
         $newNewsletter->write($showDebug = false, $forceInsert = true);
         $origMailinglists = $origNewsletter->MailingLists();
         if ($origMailinglists && $origMailinglists->count()) {
             $newNewsletter->MailingLists()->addMany($origMailinglists);
         }
         Newsletter::set_validation_enabled(true);
         $newNewsletter->Status = 'Draft';
         //custom: changing the status of to indicate we are sending
         //add a (1) (2) count to new newsletter names if the subject name already exists elsewhere
         $subjectCount = 0;
         $newSubject = $newNewsletter->Subject;
         do {
             if ($subjectCount > 0) {
                 $newSubject = $newNewsletter->Subject . " ({$subjectCount})";
             }
             $existingSubjectCount = Newsletter::get()->filter(array('Subject' => $newSubject))->count();
             $subjectCount++;
         } while ($existingSubjectCount != 0);
         $newNewsletter->Subject = $newSubject;
         $newNewsletter->write();
     } catch (ValidationException $e) {
         $form->sessionMessage($e->getResult()->message(), 'bad');
         $responseNegotiator = new PjaxResponseNegotiator(array('CurrentForm' => function () use(&$form) {
             return $form->forTemplate();
         }, 'default' => function () use(&$controller) {
             return $controller->redirectBack();
         }));
         if ($controller->getRequest()->isAjax()) {
             $controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
         }
         return $responseNegotiator->respond($controller->getRequest());
     }
     $form->sessionMessage(_t('NewsletterAdmin.SaveAsNewMessage', 'New Newsletter created as copy of the sent newsletter'), 'good');
     //create a link to the newly created object and open that instead of the old sent newsletter we had open before
     $link = Controller::join_links($this->gridField->Link('item'), $newNewsletter->ID ? $newNewsletter->ID : 'new');
     $link = str_replace('_Sent', '', $link);
     return Controller::curr()->redirect($link);
 }
开发者ID:alexandruz,项目名称:silverstripe-newsletter,代码行数:54,代码来源:NewsletterGridFieldDetailForm.php

示例4: Newsletter

 function Newsletter()
 {
     if ($this->newsletterID) {
         return Newsletter::get()->byID($this->newsletterID);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-newsletter-viewarchive,代码行数:6,代码来源:NewsletterArchivePage.php

示例5: initializeJob

 /**
  * Gets all active recipients as specified for the newsletter and adds for
  * every recipient a log item
  * @param integer    $idnewsjob    ID of corresponding newsletter dispatch job
  * @param integer    $idnews        ID of newsletter
  * @return integer    Recipient count
  */
 public function initializeJob($idnewsjob, $idnews)
 {
     global $cfg;
     $idnewsjob = Contenido_Security::toInteger($idnewsjob);
     $idnews = Contenido_Security::toInteger($idnews);
     $oNewsletter = new Newsletter();
     if ($oNewsletter->loadByPrimaryKey($idnews)) {
         $sDestination = $oNewsletter->get("send_to");
         $iIDClient = $oNewsletter->get("idclient");
         $iIDLang = $oNewsletter->get("idlang");
         switch ($sDestination) {
             case "all":
                 $sDistinct = "";
                 $sFrom = "";
                 $sSQL = "deactivated='0' AND confirmed='1' AND idclient='" . $iIDClient . "' AND idlang='" . $iIDLang . "'";
                 break;
             case "default":
                 $sDistinct = "distinct";
                 $sFrom = $cfg["tab"]["news_groups"] . " AS groups, " . $cfg["tab"]["news_groupmembers"] . " AS groupmembers ";
                 $sSQL = "recipientcollection.idclient = '" . $iIDClient . "' AND " . "recipientcollection.idlang = '" . $iIDLang . "' AND " . "recipientcollection.deactivated = '0' AND " . "recipientcollection.confirmed = '1' AND " . "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND " . "groupmembers.idnewsgroup = groups.idnewsgroup AND " . "groups.defaultgroup = '1' AND groups.idclient = '" . $iIDClient . "' AND " . "groups.idlang = '" . $iIDLang . "'";
                 break;
             case "selection":
                 $aGroups = unserialize($oNewsletter->get("send_ids"));
                 if (is_array($aGroups) && count($aGroups) > 0) {
                     $sGroups = "'" . implode("','", $aGroups) . "'";
                     $sDistinct = "distinct";
                     $sFrom = $cfg["tab"]["news_groupmembers"] . " AS groupmembers ";
                     $sSQL = "recipientcollection.idclient = '" . $iIDClient . "' AND " . "recipientcollection.idlang = '" . $iIDLang . "' AND " . "recipientcollection.deactivated = '0' AND " . "recipientcollection.confirmed = '1' AND " . "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND " . "groupmembers.idnewsgroup IN (" . $sGroups . ")";
                 } else {
                     $sDestination = "unknown";
                 }
                 break;
             case "single":
                 $iID = $oNewsletter->get("send_ids");
                 if (is_numeric($iID)) {
                     $sDistinct = "";
                     $sFrom = "";
                     $sSQL = "idnewsrcp = '" . $iID . "'";
                 } else {
                     $sDestination = "unknown";
                 }
                 break;
             default:
                 $sDestination = "unknown";
         }
         unset($oNewsletter);
         if ($sDestination == "unknown") {
             return 0;
         } else {
             $oRecipients = new RecipientCollection();
             $oRecipients->flexSelect($sDistinct, $sFrom, $sSQL, "", "", "");
             $iRecipients = $oRecipients->count();
             while ($oRecipient = $oRecipients->next()) {
                 $this->create($idnewsjob, $oRecipient->get($oRecipient->primaryKey));
             }
             return $iRecipients;
         }
     } else {
         return 0;
     }
 }
开发者ID:Spider-IT-Deutschland,项目名称:drugCMS-Plugin_newsletter,代码行数:68,代码来源:class.newsletter.logs.php

示例6: processQueue

 function processQueue($newsletterID, $lockFile)
 {
     set_time_limit(0);
     //no time limit for running process
     if (!empty($newsletterID)) {
         $newsletter = Newsletter::get()->byID($newsletterID);
         if (!empty($newsletter)) {
             //try to clean up any stuck items
             $this->cleanUpStalledQueue($newsletterID);
             // Start a transaction
             $conn = DB::getConn();
             if ($conn->supportsTransactions()) {
                 $conn->transactionStart();
             }
             $queueItemsList = array();
             try {
                 //get the first X items to process
                 $queueItems = SendRecipientQueue::get()->filter(array('NewsletterID' => $newsletterID, 'Status' => 'Scheduled'))->sort('Created ASC')->limit(self::$items_to_batch_process);
                 //set them all to "in process" at once
                 foreach ($queueItems as $item) {
                     $item->Status = 'InProgress';
                     $queueItemsList[] = $item->write();
                 }
                 // Commit transaction
                 if ($conn->supportsTransactions()) {
                     $conn->transactionEnd();
                 }
             } catch (Exception $e) {
                 // Rollback
                 if ($conn->supportsTransactions()) {
                     $conn->transactionRollback();
                 }
                 //retry the processing
                 SS_Log::log(new Exception("newsletter send out restart because of error"), SS_Log::ERR);
                 $this->processQueueOnShutdown($newsletterID);
             }
             //fetch the queue items from the database again (after writing in-process to them)
             $queueItems2 = null;
             if (!empty($queueItemsList)) {
                 $queueItems2 = SendRecipientQueue::get()->filter(array('ID' => $queueItemsList));
             }
             //do the actual mail out
             if (!empty($queueItems2) && $queueItems2->count() > 0) {
                 //fetch all the recipients at once in one query
                 $recipients = Recipient::get()->filter(array('ID' => $queueItems2->column('RecipientID')));
                 if ($recipients->count() > 0) {
                     $recipientsMap = array();
                     foreach ($recipients as $r) {
                         $recipientsMap[$r->ID] = $r;
                     }
                     //send out the mails
                     foreach ($queueItems2 as $item) {
                         try {
                             $item->send($newsletter, $recipientsMap[$item->RecipientID]);
                         } catch (Exception $e) {
                             $item->Status = 'Failed';
                             $item->write();
                         }
                     }
                 }
                 unlink($lockFile);
                 //do more processing, in case there are more items to process, do nothing if we've reached the end
                 $this->processQueueOnShutdown($newsletterID);
                 //wait to avoid overloading the email server with too many emails that look like spam
                 if (!empty(self::$throttle_batch_delay)) {
                     sleep(self::$throttle_batch_delay);
                 }
             } else {
                 //mark the send process as complete
                 $newsletter->SentDate = SS_Datetime::now()->getValue();
                 $newsletter->Status = 'Sent';
                 $newsletter->write();
                 unlink($lockFile);
             }
         }
     }
 }
开发者ID:Zauberfisch,项目名称:silverstripe-newsletter,代码行数:77,代码来源:NewsletterSendController.php

示例7: duplicate

 /**
  * Duplicates the newsletter specified by $itemID
  * @param $itemID integer specifies the newsletter id
  */
 public function duplicate($iItemID)
 {
     global $client, $lang, $auth;
     $client = Contenido_Security::toInteger($client);
     $lang = Contenido_Security::toInteger($lang);
     cInclude("includes", "functions.con.php");
     $oBaseItem = new Newsletter();
     $oBaseItem->loadByPrimaryKey($iItemID);
     $oItem = parent::create();
     $oItem->set("name", $oBaseItem->get("name") . "_" . substr(md5(rand()), 0, 10));
     $iIDArt = 0;
     if ($oBaseItem->get("type") == "html" && $oBaseItem->get("idart") > 0 && $oBaseItem->get("template_idart") > 0) {
         $oClientLang = new cApiClientLanguage(false, $client, $lang);
         if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") {
             $iIDArt = conCopyArticle($oBaseItem->get("idart"), $oClientLang->getProperty("newsletter", "html_newsletter_idcat"), sprintf(i18n("Newsletter: %s", $plugin_name), $oItem->get("name")));
             conMakeOnline($iIDArt, $lang);
             // Article has to be online for sending...
         }
         unset($oClientLang);
     }
     $oItem->set("idart", $iIDArt);
     $oItem->set("template_idart", $oBaseItem->get("template_idart"));
     $oItem->set("idclient", $client);
     $oItem->set("idlang", $lang);
     $oItem->set("welcome", 0);
     $oItem->set("type", $oBaseItem->get("type"));
     $oItem->set("subject", $oBaseItem->get("subject"));
     $oItem->set("message", $oBaseItem->get("message"));
     $oItem->set("newsfrom", $oBaseItem->get("newsfrom"));
     $oItem->set("newsfromname", $oBaseItem->get("newsfromname"));
     $oItem->set("newsdate", date("Y-m-d H:i:s"), false);
     // But more or less deprecated
     $oItem->set("use_cronjob", $oBaseItem->get("use_cronjob"));
     $oItem->set("send_to", $oBaseItem->get("send_to"));
     $oItem->set("send_ids", $oBaseItem->get("send_ids"));
     $oItem->set("dispatch", $oBaseItem->get("dispatch"));
     $oItem->set("dispatch_count", $oBaseItem->get("dispatch_count"));
     $oItem->set("dispatch_delay", $oBaseItem->get("dispatch_delay"));
     $oItem->set("author", $auth->auth["uid"]);
     $oItem->set("created", date("Y-m-d H:i:s"), false);
     // Copy properties, runtime on-demand allocation of the properties object
     if (!is_object($this->properties)) {
         $this->properties = new PropertyCollection();
     }
     $this->properties->setWhere("idclient", $client);
     $this->properties->setWhere("itemtype", $this->primaryKey);
     $this->properties->setWhere("itemid", $iItemID);
     $this->properties->query();
     while ($oPropertyItem = $this->properties->next()) {
         $oItem->setProperty($oPropertyItem->get("type"), $oPropertyItem->get("name"), $oPropertyItem->get("value"));
     }
     $oItem->store();
     return $oItem;
 }
开发者ID:Spider-IT-Deutschland,项目名称:drugCMS-Plugin_newsletter,代码行数:58,代码来源:class.newsletter.php

示例8: cPage

$plugin_name = 'newsletter';
cInclude("includes", "functions.con.php");
// For conDeleteArt and conCopyArt
// Initialization
$oPage = new cPage();
$oClientLang = new cApiClientLanguage(false, $client, $lang);
// Include plugins
if (is_array($cfg['plugins']['newsletters'])) {
    foreach ($cfg['plugins']['newsletters'] as $plugin) {
        plugin_include("newsletters", $plugin . "/" . $plugin . ".php");
    }
}
// Exec actions
$oNewsletter = new Newsletter();
$oNewsletter->loadByPrimaryKey($idnewsletter);
if ($oNewsletter->virgin == false && $oNewsletter->get("idclient") == $client && $oNewsletter->get("idlang") == $lang) {
    // Check and set values
    if (!is_numeric($_REQUEST["selTemplate"])) {
        $_REQUEST["selTemplate"] = 0;
    }
    // Saving message changes; note, that if a user doesn't have the right to save the
    // text message he may still have the right to change the html article. To prevent
    // changing the html article, give the user only read access right for the newsletter
    // article category - the article will be shown also, if he doesn't have any rights at all...
    if ($action == "news_save" && $perm->have_perm_area_action("news", $action)) {
        // Changing e.g. \' back to ' (magic_quotes)
        $sMessage = Contenido_Security::unescapeDB($_REQUEST["txtMessage"]);
        $oNewsletter->set("message", $sMessage);
        if ($oNewsletter->get("template_idart") != $_REQUEST["selTemplate"]) {
            if ($oNewsletter->get("idart") > 0) {
                // Template has been changed: Delete old article
开发者ID:Spider-IT-Deutschland,项目名称:drugCMS-Plugin_newsletter,代码行数:31,代码来源:include.newsletter_edit_message.php


注:本文中的Newsletter::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。