* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class SamplePlugin extends Plugin
{
/**
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function initialize()
{
return true;
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function cleanup()
{
return true;
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onCheckSchema()
{
$schema = Schema::get();
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onAutoload($cls)
{
$dir = dirname(__FILE__);
*
* @return boolean hook value; true means continue processing, false means stop.
*/
-
function onRouterInitialized($m)
{
$m->connect('main/hello',
*
* @see Action
*/
-
function onEndPrimaryNav($action)
{
// common_local_url() gets the correct URL for the action name
return true;
}
}
-
* @return User_greeting_count object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('User_greeting_count', $k, $v);
*
* @return array array of column definitions
*/
-
function table()
{
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
*
* @return array list of key field names
*/
-
function keys()
{
return array_keys($this->keyTypes());
* '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 magic three-false array that stops auto-incrementing.
*/
-
function sequenceKey()
{
return array(false, false, false);
*
* @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);
$result = $gc->insert();
if (!$result) {
- throw Exception(sprintf(_m("Could not save new greeting count for %d"),
+ // 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) {
- throw Exception(sprintf(_m("Could not increment greeting count for %d"),
+ // 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));
}
}