summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-10 04:46:20 +0000
committerEvan Prodromou <evan@controlyourself.ca>2009-06-10 04:46:20 +0000
commit4110838cb44c9e2e54f8ff8d722fdcbc5666fafe (patch)
tree51335c05e93194217c90a46b21e5477bba47c378 /classes
parent003c63e587128c6d095386c563c2615c2ac245c2 (diff)
parent207750e75774c823328889cb4102aad6a0b12281 (diff)
Merge branch '0.8.x' of git://gitorious.org/laconica/dev into dev/0.8.x
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php26
-rw-r--r--classes/File_redirection.php2
-rw-r--r--classes/Foreign_link.php2
-rw-r--r--[-rwxr-xr-x]classes/Group_inbox.php0
-rw-r--r--[-rwxr-xr-x]classes/Group_member.php0
-rw-r--r--classes/Memcached_DataObject.php18
-rw-r--r--classes/Notice.php12
-rw-r--r--[-rwxr-xr-x]classes/Related_group.php0
-rw-r--r--[-rwxr-xr-x]classes/Status_network.php0
-rw-r--r--[-rwxr-xr-x]classes/User_group.php0
-rw-r--r--classes/laconica.ini118
11 files changed, 116 insertions, 62 deletions
diff --git a/classes/File.php b/classes/File.php
index e5913115b..24ab11b8e 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -120,4 +120,30 @@ class File extends Memcached_DataObject
File_to_post::processNew($file_id, $notice_id);
return $x;
}
+
+ function isRespectsQuota($user) {
+ if ($_FILES['attach']['size'] > common_config('attachments', 'file_quota')) {
+ return sprintf(_('No file may be larger than %d bytes ' .
+ 'and the file you sent was %d bytes. Try to upload a smaller version.'),
+ common_config('attachments', 'file_quota'), $_FILES['attach']['size']);
+ }
+
+ $query = "select sum(size) as total from file join file_to_post on file_to_post.file_id = file.id join notice on file_to_post.post_id = notice.id where profile_id = {$user->id} and file.url like '%/notice/%/file'";
+ $this->query($query);
+ $this->fetch();
+ $total = $this->total + $_FILES['attach']['size'];
+ if ($total > common_config('attachments', 'user_quota')) {
+ return sprintf(_('A file this large would exceed your user quota of %d bytes.'), common_config('attachments', 'user_quota'));
+ }
+
+ $query .= ' month(modified) = month(now()) and year(modified) = year(now())';
+ $this->query($query);
+ $this->fetch();
+ $total = $this->total + $_FILES['attach']['size'];
+ if ($total > common_config('attachments', 'monthly_quota')) {
+ return sprintf(_('A file this large would exceed your monthly quota of %d bytes.'), common_config('attachments', 'monthly_quota'));
+ }
+ return true;
+ }
}
+
diff --git a/classes/File_redirection.php b/classes/File_redirection.php
index 0eae68178..212cc3615 100644
--- a/classes/File_redirection.php
+++ b/classes/File_redirection.php
@@ -133,7 +133,7 @@ class File_redirection extends Memcached_DataObject
$file->limit(1);
$file->orderBy('len');
$file->find(true);
- if (!empty($file->id)) {
+ if (!empty($file->url) && (strlen($file->url) < strlen($long_url))) {
return $file->url;
}
diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php
index 606560951..c0b356ece 100644
--- a/classes/Foreign_link.php
+++ b/classes/Foreign_link.php
@@ -11,7 +11,7 @@ class Foreign_link extends Memcached_DataObject
public $__table = 'foreign_link'; // table name
public $user_id; // int(4) primary_key not_null
- public $foreign_id; // int(4) primary_key not_null
+ public $foreign_id; // bigint(8) primary_key not_null unsigned
public $service; // int(4) primary_key not_null
public $credentials; // varchar(255)
public $noticesync; // tinyint(1) not_null default_1
diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php
index b80ba4272..b80ba4272 100755..100644
--- a/classes/Group_inbox.php
+++ b/classes/Group_inbox.php
diff --git a/classes/Group_member.php b/classes/Group_member.php
index 3c23a991f..3c23a991f 100755..100644
--- a/classes/Group_member.php
+++ b/classes/Group_member.php
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 5f71f716b..52ad4100f 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -227,4 +227,22 @@ class Memcached_DataObject extends DB_DataObject
$c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry);
return new ArrayWrapper($cached);
}
+
+ // We overload so that 'SET NAMES "utf8"' is called for
+ // each connection
+
+ function _connect()
+ {
+ global $_DB_DATAOBJECT;
+ $exists = !empty($this->_database_dsn_md5) &&
+ isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]);
+ $result = parent::_connect();
+ if (!$exists) {
+ $DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
+ if (common_config('db', 'utf8')) {
+ $DB->query('SET NAMES "utf8"');
+ }
+ }
+ return $result;
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 1b5c0ab0a..0b1017e12 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -277,6 +277,18 @@ class Notice extends Memcached_DataObject
return true;
}
+ function getUploadedAttachment() {
+ $post = clone $this;
+ $query = 'select file.url as uploaded from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"';
+ $post->query($query);
+ $post->fetch();
+ $ret = $post->uploaded;
+// var_dump($post);
+ $post->free();
+// die();
+ return $ret;
+ }
+
function hasAttachments() {
$post = clone $this;
$query = "select count(file_id) as n_attachments from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $post->escape($post->id);
diff --git a/classes/Related_group.php b/classes/Related_group.php
index c00ad9c44..c00ad9c44 100755..100644
--- a/classes/Related_group.php
+++ b/classes/Related_group.php
diff --git a/classes/Status_network.php b/classes/Status_network.php
index f7747f71d..f7747f71d 100755..100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
diff --git a/classes/User_group.php b/classes/User_group.php
index 7cc31e702..7cc31e702 100755..100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
diff --git a/classes/laconica.ini b/classes/laconica.ini
index 316923af0..92bbb35d4 100644
--- a/classes/laconica.ini
+++ b/classes/laconica.ini
@@ -46,6 +46,64 @@ modified = 384
notice_id = K
user_id = K
+[file]
+id = 129
+url = 2
+mimetype = 2
+size = 1
+title = 2
+date = 1
+protected = 1
+
+[file__keys]
+id = N
+
+[file_oembed]
+id = 129
+file_id = 1
+version = 2
+type = 2
+provider = 2
+provider_url = 2
+width = 1
+height = 1
+html = 34
+title = 2
+author_name = 2
+author_url = 2
+url = 2
+
+[file_oembed__keys]
+id = N
+
+[file_redirection]
+id = 129
+url = 2
+file_id = 1
+redirections = 1
+httpcode = 1
+
+[file_redirection__keys]
+id = N
+
+[file_thumbnail]
+id = 129
+file_id = 1
+url = 2
+width = 1
+height = 1
+
+[file_thumbnail__keys]
+id = N
+
+[file_to_post]
+id = 129
+file_id = 1
+post_id = 1
+
+[file_to_post__keys]
+id = N
+
[foreign_link]
user_id = 129
foreign_id = 129
@@ -392,63 +450,3 @@ modified = 384
[user_openid__keys]
canonical = K
display = U
-
-[file]
-id = 129
-url = 2
-mimetype = 2
-size = 1
-title = 2
-date = 1
-protected = 1
-
-[file__keys]
-id = N
-
-[file_oembed]
-id = 129
-file_id = 129
-version = 2
-type = 2
-provider = 2
-provider_url = 2
-width = 1
-height = 1
-html = 34
-title = 2
-author_name = 2
-author_url = 2
-url = 2
-
-[file_oembed__keys]
-id = N
-
-[file_redirection]
-id = 129
-url = 2
-file_id = 129
-redirections = 1
-httpcode = 1
-
-[file_redirection__keys]
-id = N
-
-[file_thumbnail]
-id = 129
-file_id = 129
-url = 2
-width = 1
-height = 1
-
-[file_thumbnail__keys]
-id = N
-
-[file_to_post]
-id = 129
-file_id = 129
-post_id = 129
-
-[file_to_post__keys]
-id = N
-
-