summaryrefslogtreecommitdiff
path: root/classes/Oauth_application.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-11-16 16:58:49 -0800
committerZach Copley <zach@status.net>2010-01-24 16:36:02 -0800
commit3c2b05d222a55cd1e148f3f887bf55e924898f1b (patch)
treed1ca17ba0782527ec43bb3026823e64913651d38 /classes/Oauth_application.php
parent035c475b45959057099c503d2cdcff8c8145e198 (diff)
Workflow for registering new OAuth apps pretty much done.
Diffstat (limited to 'classes/Oauth_application.php')
-rw-r--r--classes/Oauth_application.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/classes/Oauth_application.php b/classes/Oauth_application.php
index e2862bf97..ef1bbf6d9 100644
--- a/classes/Oauth_application.php
+++ b/classes/Oauth_application.php
@@ -31,4 +31,48 @@ class Oauth_application extends Memcached_DataObject
}
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ // Bit flags
+ public static $readAccess = 1;
+ public static $writeAccess = 2;
+
+ public static $browser = 1;
+ public static $desktop = 2;
+
+ function getConsumer()
+ {
+ return Consumer::staticGet('consumer_key', $this->consumer_key);
+ }
+
+ static function maxDesc()
+ {
+ $desclimit = common_config('application', 'desclimit');
+ // null => use global limit (distinct from 0!)
+ if (is_null($desclimit)) {
+ $desclimit = common_config('site', 'textlimit');
+ }
+ return $desclimit;
+ }
+
+ static function descriptionTooLong($desc)
+ {
+ $desclimit = self::maxDesc();
+ return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
+ }
+
+ function setAccessFlags($read, $write)
+ {
+ if ($read) {
+ $this->access_type |= self::$readAccess;
+ } else {
+ $this->access_type &= ~self::$readAccess;
+ }
+
+ if ($write) {
+ $this->access_type |= self::$writeAccess;
+ } else {
+ $this->access_type &= ~self::$writeAccess;
+ }
+ }
+
}