Pommo_Mail_Ctl::addNotices PHP Method

addNotices() public method

public addNotices ( $id )
    function addNotices($id)
    {
        global $pommo;
        $logger =& Pommo::$_logger;
        $dbo =& Pommo::$_dbo;
        if (!is_numeric($id)) {
            return;
        }
        $notices = array();
        $i = 0;
        foreach ($logger->getAll() as $n) {
            $i++;
            $notices[] = $dbo->prepare("(%i,'%s', %i)", array($id, $n, $i));
        }
        // update DB notices
        if (!empty($notices)) {
            $query = "\n                INSERT INTO " . $dbo->table['mailing_notices'] . "\n                (mailing_id,notice,id) VALUES " . implode(',', $notices);
            $dbo->query($query);
        }
        // trim notices
        Pommo_Mail_Ctl::delNotices($id);
    }

Usage Example

Example #1
0
 function update()
 {
     $dbo = Pommo::$_dbo;
     if (!empty($this->_sent)) {
         $a = array();
         foreach ($this->_sent as $e) {
             $a[] = $this->_hash[$e];
         }
         $query = "\n                UPDATE " . $dbo->table['queue'] . "\n                SET status=1\n                WHERE subscriber_id IN(%q)";
         $query = $dbo->prepare($query, array($a));
         if (!$dbo->query($query)) {
             $this->shutdown('Database Query failed: ' . $query);
         }
     }
     if (!empty($this->_failed)) {
         $a = array();
         foreach ($this->_failed as $e) {
             $a[] = $this->_hash[$e];
         }
         $query = "\n                UPDATE " . $dbo->table['queue'] . "\n                SET status=2\n                WHERE subscriber_id IN(%q)";
         $query = $dbo->prepare($query, array($a));
         if (!$dbo->query($query)) {
             $this->shutdown('Database Query failed: ' . $query);
         }
     }
     // add notices
     Pommo_Mail_Ctl::addNotices($this->_id);
     // reset sent/failed
     $this->_sent = $this->_failed = array();
     return;
 }