コード例 #1
0
ファイル: request.php プロジェクト: BackupTheBerlios/tip
 /**
  * Process an add action
  *
  * Overrides the default callback providing email notification
  * when requested.
  *
  * @param  array      &$row     The subject row
  * @param  array|null  $old_row The old row or null on no old row
  * @return bool                 true on success, false on errors
  */
 public function _onAdd(&$row, $old_row)
 {
     if (!parent::_onAdd($row, $old_row)) {
         return false;
     }
     if (empty($this->notify_to)) {
         // No notification required
         return true;
     }
     $eol = "\r\n";
     $env = 'TiP-' . TIP_VERSION_BRANCH;
     $sys = 'PHP-' . phpversion();
     $headers = 'From: ' . $this->_getServerEmail() . $eol;
     $headers .= 'X-Mailer: TIP_Request module ' . "({$env}; {$sys})" . $eol;
     $headers .= 'MIME-Version: 1.0' . $eol;
     $headers .= 'Content-Type: text/plain; charset=ISO-8859-1';
     // Assign current_row, so getField() checks for values in this row
     $this->_current_row =& $row;
     ob_start();
     if ($this->tryRun($this->message_template)) {
         $message = ob_get_clean();
     } elseif (array_key_exists($this->message_template, $row)) {
         ob_end_clean();
         $message = $row[$this->message_template];
     } else {
         ob_end_clean();
         $message = 'Undefined message';
     }
     $message = wordwrap(utf8_decode($message), 66);
     if (!mail($this->notify_to, $this->subject_text, $message, $headers)) {
         TIP::warning("Unable to send an email message to {$this->notify_to}");
         return false;
     }
     return true;
 }
コード例 #2
0
ファイル: sponsor.php プロジェクト: BackupTheBerlios/tip
 /**
  * Process an add action
  *
  * Overrides the default add callback setting 'count_field' and
  * 'counted_field' to the current sponsor count.
  *
  * @param  array      &$row     The subject row
  * @param  array|null  $old_row The old row or null on no old row
  * @return bool                 true on success, false on errors
  */
 public function _onAdd(&$row, $old_row)
 {
     if (isset($this->count_field)) {
         $row[$this->count_field] = $this->_row[$this->count_field];
     }
     if (isset($this->counted_field)) {
         $row[$this->counted_field] = $this->_row[$this->count_field];
     }
     return parent::_onAdd($row, $old_row);
 }
コード例 #3
0
ファイル: class.php プロジェクト: BackupTheBerlios/tip
 /**
  * Process an add action
  *
  * Overrides the default add action inserting both master and child rows.
  */
 public function _onAdd(&$row, $old_row)
 {
     $child =& $this->_getChildModule();
     if (is_null($child)) {
         // No child module: chain-up the parent method
         return parent::_onAdd($row, $old_row);
     } elseif (!$child) {
         // An error occurred somewhere: do nothing
         return false;
     }
     $child_data =& $child->getProperty('data');
     $key = $this->data->getProperty('primary_key');
     $child_key = $child_data->getProperty('primary_key');
     $engine =& $this->data->getProperty('engine');
     if (!$engine->startTransaction()) {
         // This error must be caught here to avoid the rollback
         return false;
     }
     $done = parent::_onAdd($row, $old_row);
     if ($done) {
         // Work on a copy of $row because putRow() is destructive
         $new_row = $row;
         $done = !is_null($new_row[$child_key] = $new_row[$key]) && $child_data->putRow($new_row) && ($row = array_merge($row, $new_row));
     }
     $done = $engine->endTransaction($done) && $done;
     return $done;
 }
コード例 #4
0
ファイル: comments.php プロジェクト: BackupTheBerlios/tip
 /**
  * Provide additional statistic update on the master module
  */
 public function _onAdd(&$row, $old_row)
 {
     $engine =& $this->data->getProperty('engine');
     if (!$engine->startTransaction()) {
         // This error must be caught here to avoid the rollback
         return false;
     }
     // Process the row
     $done = parent::_onAdd($row, $old_row) && $this->_updateMaster($row, +1);
     $done = $engine->endTransaction($done) && $done;
     return $done;
 }
コード例 #5
0
ファイル: expiration.php プロジェクト: BackupTheBerlios/tip
 /**
  * 'add' callback
  *
  * Overrides the default callback setting the initial expiration value.
  *
  * @param  array &$row The data row to add
  * @return bool        true on success, false on errors
  */
 public function _onAdd(&$row)
 {
     if (isset($this->expiration_field)) {
         TIP::arrayDefault($row, $this->expiration_field, TIP::formatDate('datetime_sql', strtotime($this->expiration)));
     }
     return parent::_onAdd($row);
 }