summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Foreign_user.php16
-rw-r--r--classes/Memcached_DataObject.php4
-rw-r--r--classes/Notice.php12
-rw-r--r--classes/Status_network.php59
-rw-r--r--classes/Status_network_tag.php69
-rw-r--r--classes/User.php2
-rw-r--r--classes/status_network.ini15
7 files changed, 166 insertions, 11 deletions
diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php
index 0dd94ffb9..e98a16064 100644
--- a/classes/Foreign_user.php
+++ b/classes/Foreign_user.php
@@ -39,6 +39,22 @@ class Foreign_user extends Memcached_DataObject
return null;
}
+ static function getByNickname($nickname, $service)
+ {
+ if (empty($nickname) || empty($service)) {
+ return null;
+ } else {
+ $fuser = new Foreign_user();
+ $fuser->service = $service;
+ $fuser->nickname = $nickname;
+ $fuser->limit(1);
+
+ $result = $fuser->find(true);
+
+ return empty($result) ? null : $fuser;
+ }
+ }
+
function updateKeys(&$orig)
{
$this->_connect();
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 4579f64df..a7fec365e 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -593,7 +593,7 @@ class Memcached_DataObject extends Safe_DataObject
return $c->get($cacheKey);
}
- static function cacheSet($keyPart, $value)
+ static function cacheSet($keyPart, $value, $flag=null, $expiry=null)
{
$c = self::memcache();
@@ -603,7 +603,7 @@ class Memcached_DataObject extends Safe_DataObject
$cacheKey = common_cache_key($keyPart);
- return $c->set($cacheKey, $value);
+ return $c->set($cacheKey, $value, $flag, $expiry);
}
static function valueString($v)
diff --git a/classes/Notice.php b/classes/Notice.php
index 482bc550b..8552248ba 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -42,10 +42,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-/* We keep the first three 20-notice pages, plus one for pagination check,
+/* We keep 200 notices, the max number of notices available per API request,
* in the memcached cache. */
-define('NOTICE_CACHE_WINDOW', 61);
+define('NOTICE_CACHE_WINDOW', 200);
define('MAX_BOXCARS', 128);
@@ -90,7 +90,13 @@ class Notice extends Memcached_DataObject
function getProfile()
{
- return Profile::staticGet('id', $this->profile_id);
+ $profile = Profile::staticGet('id', $this->profile_id);
+
+ if (empty($profile)) {
+ throw new ServerException(sprintf(_('No such profile (%d) for notice (%d)'), $this->profile_id, $this->id));
+ }
+
+ return $profile;
}
function delete()
diff --git a/classes/Status_network.php b/classes/Status_network.php
index 64016dd79..a0f3ba5f7 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -27,7 +27,8 @@ class Status_network extends Safe_DataObject
/* the code below is auto generated do not remove the above tag */
public $__table = 'status_network'; // table name
- public $nickname; // varchar(64) primary_key not_null
+ public $site_id; // int(4) primary_key not_null
+ public $nickname; // varchar(64) unique_key not_null
public $hostname; // varchar(255) unique_key
public $pathname; // varchar(255) unique_key
public $dbhost; // varchar(255)
@@ -39,7 +40,6 @@ class Status_network extends Safe_DataObject
public $logo; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
- public $tags; // text
/* Static get */
function staticGet($k,$v=NULL) {
@@ -308,10 +308,63 @@ class Status_network extends Safe_DataObject
*/
function getTags()
{
- return array_filter(explode("|", strval($this->tags)));
+ $result = array();
+
+ $tags = new Status_network_tag();
+ $tags->site_id = $this->site_id;
+ if ($tags->find()) {
+ while ($tags->fetch()) {
+ $result[] = $tags->tag;
+ }
+ }
+
+ // XXX : for backwards compatibility
+ if (empty($result)) {
+ return explode('|', $this->tags);
+ }
+
+ return $result;
}
/**
+ * Save a given set of tags
+ * @param array tags
+ */
+ function setTags($tags)
+ {
+ $this->clearTags();
+ foreach ($tags as $tag) {
+ if (!empty($tag)) {
+ $snt = new Status_network_tag();
+ $snt->site_id = $this->site_id;
+ $snt->tag = $tag;
+ $snt->created = common_sql_now();
+
+ $id = $snt->insert();
+ if (!$id) {
+ throw new Exception(_("Unable to save tag."));
+ }
+ }
+ }
+
+ return true;
+ }
+
+ function clearTags()
+ {
+ $tag = new Status_network_tag();
+ $tag->site_id = $this->site_id;
+
+ if ($tag->find()) {
+ while($tag->fetch()) {
+ $tag->delete();
+ }
+ }
+
+ $tag->free();
+ }
+
+ /**
* Check if this site record has a particular meta-info tag attached.
* @param string $tag
* @return bool
diff --git a/classes/Status_network_tag.php b/classes/Status_network_tag.php
new file mode 100644
index 000000000..18c508bc8
--- /dev/null
+++ b/classes/Status_network_tag.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, 2010 StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('STATUSNET')) { exit(1); }
+
+class Status_network_tag extends Safe_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'status_network_tag'; // table name
+ public $site_id; // int(4) primary_key not_null
+ public $tag; // varchar(64) primary_key not_null
+ public $created; // datetime() not_null
+
+
+ function __construct()
+ {
+ global $config;
+ global $_DB_DATAOBJECT;
+
+ $sn = new Status_network();
+ $sn->_connect();
+
+ $config['db']['table_'. $this->__table] = $sn->_database;
+
+ $this->_connect();
+ }
+
+
+ /* Static get */
+ function staticGet($k,$v=null)
+ {
+ $i = DB_DataObject::staticGet('Status_network_tag',$k,$v);
+
+ // Don't use local process cache; if we're fetching multiple
+ // times it's because we're reloading it in a long-running
+ // process; we need a fresh copy!
+ global $_DB_DATAOBJECT;
+ unset($_DB_DATAOBJECT['CACHE']['status_network_tag']);
+ return $i;
+ }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+
+
+ function pkeyGet($kv)
+ {
+ return Memcached_DataObject::pkeyGet('Status_network_tag', $kv);
+ }
+}
diff --git a/classes/User.php b/classes/User.php
index 2abb7eeb6..cf8d4527b 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -524,7 +524,7 @@ class User extends Memcached_DataObject
if ($this->id == $other->id) {
common_log(LOG_WARNING,
sprintf(
- "Profile ID %d (%s) tried to block his or herself.",
+ "Profile ID %d (%s) tried to block themself.",
$this->id,
$this->nickname
)
diff --git a/classes/status_network.ini b/classes/status_network.ini
index adb71cba7..83226e915 100644
--- a/classes/status_network.ini
+++ b/classes/status_network.ini
@@ -1,4 +1,5 @@
[status_network]
+side_id = 129
nickname = 130
hostname = 2
pathname = 2
@@ -11,9 +12,19 @@ theme = 2
logo = 2
created = 142
modified = 384
-tags = 34
[status_network__keys]
-nickname = K
+site_id = K
+nickname = U
hostname = U
pathname = U
+
+[status_network_tag]
+site_id = 129
+tag = 130
+created = 142
+
+[status_network_tag__keys]
+site_id = K
+tag = K
+