123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- class Email_reminder extends Managed_DataObject
- {
- public $__table = 'email_reminder';
- public $type;
- public $code;
- public $days;
- public $sent;
- public $created;
- public $modified;
-
- static function needsReminder($type, $object, $days = null) {
- $reminder = new Email_reminder();
- $reminder->type = $type;
- $reminder->code = $object->code;
- if (!empty($days)) {
- $reminder->days = $days;
- }
- $result = $reminder->find();
- if (!empty($result)) {
- return false;
- }
- return true;
- }
-
- static function recordReminder($type, $object, $days) {
- $reminder = new Email_reminder();
- $reminder->type = $type;
- $reminder->code = $object->code;
- $reminder->days = $days;
- $reminder->sent = $reminder->created = common_sql_now();
- $result = $reminder->insert();
- if (empty($result)) {
- common_log_db_error($reminder, 'INSERT', __FILE__);
- throw new ServerException(
-
- _m('Database error inserting reminder record.')
- );
- }
- return $result;
- }
-
- public static function schemaDef()
- {
- return array(
- 'description' => 'Record of email reminders that have been sent',
- 'fields' => array(
- 'type' => array(
- 'type' => 'varchar',
- 'length' => 191,
- 'not null' => true,
- 'description' => 'type of reminder'
- ),
- 'code' => array(
- 'type' => 'varchar',
- 'not null' => 'true',
- 'length' => 191,
- 'description' => 'confirmation code'
- ),
- 'days' => array(
- 'type' => 'int',
- 'not null' => 'true',
- 'description' => 'number of days since code creation'
- ),
- 'sent' => array(
- 'type' => 'datetime',
- 'not null' => true,
- 'description' => 'Date and time the reminder was sent'
- ),
- 'created' => array(
- 'type' => 'datetime',
- 'not null' => true,
- 'description' => 'Date and time the record was created'
- ),
- 'modified' => array(
- 'type' => 'timestamp',
- 'not null' => true,
- 'description' => 'Date and time the record was last modified'
- ),
- ),
- 'primary key' => array('type', 'code', 'days'),
- 'indexes' => array(
- 'sent_idx' => array('sent'),
- ),
- );
- }
- }
|