From: Evan Prodromou Date: Wed, 19 Jan 2011 23:31:07 +0000 (-0500) Subject: data structures X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4618641da23aab0822bec008ff7406ffc13e1cad;p=quix0rs-gnu-social.git data structures --- diff --git a/plugins/PrivateGroup/Group_privacy_settings.php b/plugins/PrivateGroup/Group_privacy_settings.php index 38d68c91ed..7861571222 100644 --- a/plugins/PrivateGroup/Group_privacy_settings.php +++ b/plugins/PrivateGroup/Group_privacy_settings.php @@ -1,6 +1,6 @@ DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, - 'greeting_count' => DB_DATAOBJECT_INT); + return array('group_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, + 'allow_privacy' => DB_DATAOBJECT_INT, + 'allow_sender' => DB_DATAOBJECT_INT, + 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL, + 'modified' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL); + } /** @@ -98,6 +115,7 @@ class User_greeting_count extends Memcached_DataObject * * @return array list of key field names */ + function keys() { return array_keys($this->keyTypes()); @@ -106,79 +124,24 @@ class User_greeting_count extends Memcached_DataObject /** * return key definitions for Memcached_DataObject * - * Our caching system uses the same key definitions, but uses a different - * method to get them. This key information is used to store and clear - * cached data, so be sure to list any key that will be used for static - * lookups. - * * @return array associative array of key definitions, field name to type: * 'K' for primary key: for compound keys, add an entry for each component; * 'U' for unique keys: compound keys are not well supported here. */ + function keyTypes() { - return array('user_id' => 'K'); + return array('group_id' => 'K'); } /** * Magic formula for non-autoincrementing integer primary keys * - * If a table has a single integer column as its primary key, DB_DataObject - * assumes that the column is auto-incrementing and makes a sequence table - * to do this incrementation. Since we don't need this for our class, we - * overload this method and return the magic formula that DB_DataObject needs. - * * @return array magic three-false array that stops auto-incrementing. */ + function sequenceKey() { return array(false, false, false); } - - /** - * Increment a user's greeting count and return instance - * - * This method handles the ins and outs of creating a new greeting_count for a - * user or fetching the existing greeting count and incrementing its value. - * - * @param integer $user_id ID of the user to get a count for - * - * @return User_greeting_count instance for this user, with count already incremented. - */ - static function inc($user_id) - { - $gc = User_greeting_count::staticGet('user_id', $user_id); - - if (empty($gc)) { - - $gc = new User_greeting_count(); - - $gc->user_id = $user_id; - $gc->greeting_count = 1; - - $result = $gc->insert(); - - if (!$result) { - // TRANS: Exception thrown when the user greeting count could not be saved in the database. - // TRANS: %d is a user ID (number). - throw Exception(sprintf(_m("Could not save new greeting count for %d."), - $user_id)); - } - } else { - $orig = clone($gc); - - $gc->greeting_count++; - - $result = $gc->update($orig); - - if (!$result) { - // TRANS: Exception thrown when the user greeting count could not be saved in the database. - // TRANS: %d is a user ID (number). - throw Exception(sprintf(_m("Could not increment greeting count for %d."), - $user_id)); - } - } - - return $gc; - } } diff --git a/plugins/PrivateGroup/Group_private_inbox.php b/plugins/PrivateGroup/Group_private_inbox.php index 38d68c91ed..11142314bc 100644 --- a/plugins/PrivateGroup/Group_private_inbox.php +++ b/plugins/PrivateGroup/Group_private_inbox.php @@ -1,6 +1,6 @@