3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET') && !defined('LACONICA')) {
24 class User_urlshortener_prefs extends Managed_DataObject
27 /* the code below is auto generated do not remove the above tag */
29 public $__table = 'user_urlshortener_prefs'; // table name
30 public $user_id; // int(4) primary_key not_null
31 public $urlshorteningservice; // varchar(50) default_ur1.ca
32 public $maxurllength; // int(4) not_null
33 public $maxnoticelength; // int(4) not_null
34 public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
35 public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
38 function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_urlshortener_prefs',$k,$v); }
40 /* the code above is auto generated do not remove the tag below */
43 public static function schemaDef()
47 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user'),
48 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'),
49 'maxurllength' => array('type' => 'int', 'not null' => true, 'description' => 'urls greater than this length will be shortened, 0 = always, null = never'),
50 'maxnoticelength' => array('type' => 'int', 'not null' => true, 'description' => 'notices with content greater than this value will have all urls shortened, 0 = always, null = never'),
52 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
53 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
55 'primary key' => array('user_id'),
56 'foreign keys' => array(
57 'user_urlshortener_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
62 static function maxUrlLength($user)
64 $def = common_config('url', 'maxlength');
66 $prefs = self::getPrefs($user);
71 return $prefs->maxurllength;
75 static function maxNoticeLength($user)
77 $def = common_config('url', 'maxnoticelength');
80 $def = Notice::maxContent();
83 $prefs = self::getPrefs($user);
88 return $prefs->maxnoticelength;
92 static function urlShorteningService($user)
94 $def = common_config('url', 'shortener');
96 $prefs = self::getPrefs($user);
100 return $user->urlshorteningservice;
105 return $prefs->urlshorteningservice;
109 static function getPrefs($user)
115 $prefs = User_urlshortener_prefs::staticGet('user_id', $user->id);