3 * Data class for email summary status
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Data class for email summaries
39 * Email summary information for users
43 * @author Evan Prodromou <evan@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
45 * @link http://status.net/
49 class Email_summary_status extends Managed_DataObject
51 public $__table = 'email_summary_status'; // table name
52 public $user_id; // int(4) primary_key not_null
53 public $send_summary; // tinyint not_null
54 public $last_summary_id; // int(4) null
55 public $created; // datetime not_null
56 public $modified; // datetime not_null
58 public static function schemaDef()
62 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
63 'send_summary' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'not null' => true, 'description' => 'whether to send a summary or not'),
64 'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
65 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
66 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
68 'primary key' => array('user_id'),
69 'foreign keys' => array(
70 'email_summary_status_user_id_fkey' => array('user', array('user_id' => 'id')),
78 * @param integer $user_id ID of the user to get a count for
80 * @return int flag for whether to send this user a summary email
82 static function getSendSummary($user_id)
84 $ess = Email_summary_status::getKV('user_id', $user_id);
87 return $ess->send_summary;
94 * Get email summary status for a user
96 * @param integer $user_id ID of the user to get a count for
98 * @return Email_summary_status instance for this user, with count already incremented.
100 static function getLastSummaryID($user_id)
102 $ess = Email_summary_status::getKV('user_id', $user_id);
105 return $ess->last_summary_id;