code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * List a user's OAuth connected applications
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Settings
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2008-2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('GNUSOCIAL')) { exit(1); }

/**
 * Show connected OAuth applications
 *
 * @category Settings
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 *
 * @see      SettingsAction
 */
class OauthconnectionssettingsAction extends SettingsAction
{
    var $page = null;

    protected $oauth_token = null;

    protected function doPreparation()
    {
        $this->oauth_token = $this->arg('oauth_token');
        $this->page = $this->int('page') ?: 1;
    }

    /**
     * Title of the page
     *
     * @return string Title of the page
     */
    function title()
    {
        // TRANS: Title for OAuth connection settings.
        return _('Connected applications');
    }

    /**
     * Instructions for use
     *
     * @return instructions for use
     */
    function getInstructions()
    {
        // TRANS: Instructions for OAuth connection settings.
        return _('The following connections exist for your account.');
    }

    /**
     * Content area of the page
     *
     * @return void
     */

    function showContent()
    {
        $offset = ($this->page - 1) * APPS_PER_PAGE;
        $limit  =  APPS_PER_PAGE + 1;

        $connection = $this->scoped->getConnectedApps($offset, $limit);

        $cnt = 0;

        if (!empty($connection)) {
            $cal = new ConnectedAppsList($connection, $this->scoped, $this);
            $cnt = $cal->show();
        }

        if ($cnt == 0) {
            $this->showEmptyListMessage();
        }

        $this->pagination(
            $this->page > 1,
            $cnt > APPS_PER_PAGE,
            $this->page,
            'connectionssettings',
            array('nickname' => $this->scoped->getNickname())
        );
    }

    /**
     * Handle posts to this form
     *
     * Based on the button that was pressed, muxes out to other functions
     * to do the actual task requested.
     *
     * All sub-functions reload the form with a message -- success or failure.
     *
     * @return void
     */
    protected function doPost()
    {
        if ($this->arg('revoke')) {
            return $this->revokeAccess($this->oauth_token);
        }

        // TRANS: Client error when submitting a form with unexpected information.
        throw new ClientException(_('Unexpected form submission.'), 401);
    }

    /**
     * Revoke an access token
     *
     * XXX: Confirm revoke before doing it
     *
     * @param int $appId the ID of the application
     *
     */
    function revokeAccess($token)
    {
        $cur = common_current_user();

        $appUser = Oauth_application_user::getByUserAndToken($cur, $token);

        if (empty($appUser)) {
            // TRANS: Client error when trying to revoke access for an application while not being a user of it.
            $this->clientError(_('You are not a user of that application.'), 401);
        }

        $app = Oauth_application::getKV('id', $appUser->application_id);

        $datastore = new ApiGNUsocialOAuthDataStore();
        $datastore->revoke_token($appUser->token, 1);

        $result = $appUser->delete();

        if (!$result) {
            common_log_db_error($orig, 'DELETE', __FILE__);
            // TRANS: Client error when revoking access has failed for some reason.
            // TRANS: %s is the application ID revoking access failed for.
            $this->clientError(sprintf(_('Unable to revoke access for application: %s.'), $app->id));
        }

        $msg = 'API OAuth - user %s (id: %d) revoked access token %s for app id %d';
        common_log(
            LOG_INFO,
            sprintf(
                $msg,
                $cur->nickname,
                $cur->id,
                $appUser->token,
                $appUser->application_id
            )
        );

        $msg = sprintf(
            // TRANS: Success message after revoking access for an application.
            // TRANS: %1$s is the application name, %2$s is the first part of the user token.
            _('You have successfully revoked access for %1$s and the access token starting with %2$s.'),
             $app->name,
             substr($appUser->token, 0, 7)
        );

        $this->showForm($msg, true);
    }

    function showEmptyListMessage()
    {
        // TRANS: Empty list message when no applications have been authorised yet.
        $message = _('You have not authorized any applications to use your account.');

        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }

    function showSections()
    {
        $cur = common_current_user();

        $this->elementStart('div', array('id' => 'developer-help', 'class' => 'section'));

        $this->element('h2', null, 'Developers');
        $this->elementStart('p');

        $devMsg = sprintf(
            // TRANS: Note for developers in the OAuth connection settings form.
            // TRANS: This message contains a Markdown link. Do not separate "](".
            // TRANS: %s is the URL to the OAuth settings.
            _('Are you a developer? [Register an OAuth client application](%s) to use with this instance of StatusNet.'),
            common_local_url('oauthappssettings')
        );

        $output = common_markup_to_html($devMsg);

        $this->raw($output);
        $this->elementEnd('p');

        $this->elementEnd('section');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Settings panel for old-school UI
 *
 * PHP version 5
 *
 * 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/>.
 *
 * @category  Oldschool
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('GNUSOCIAL')) { exit(1); }

/**
 * Old-school settings
 *
 * @category  Oldschool
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

class OldschoolsettingsAction extends SettingsAction
{
    /**
     * Title of the page
     *
     * @return string Title of the page
     */
    function title()
    {
        // TRANS: Page title for profile settings.
        return _('Old school UI settings');
    }

    /**
     * Instructions for use
     *
     * @return instructions for use
     */
    function getInstructions()
    {
        // TRANS: Usage instructions for profile settings.
        return _('If you like it "the old way", you can set that here.');
    }

    /**
     * For initializing members of the class.
     *
     * @param array $argarray misc. arguments
     *
     * @return boolean true
     */

    protected function doPreparation()
    {
        if (!common_config('oldschool', 'enabled')) {
            throw new ClientException("Old-school settings not enabled.");
        }
    }

    function doPost()
    {
        $osp = Old_school_prefs::getKV('user_id', $this->scoped->getID());
        $orig = null;

        if (!empty($osp)) {
            $orig = clone($osp);
        } else {
            $osp = new Old_school_prefs();
            $osp->user_id = $this->scoped->getID();
            $osp->created = common_sql_now();
        }

        $osp->stream_mode_only  = $this->boolean('stream_mode_only');
        $osp->stream_nicknames  = $this->boolean('stream_nicknames');
        $osp->modified          = common_sql_now();

        if ($orig instanceof Old_school_prefs) {
            $osp->update($orig);
        } else {
            $osp->insert();
        }

        // TRANS: Confirmation shown when user profile settings are saved.
        return _('Settings saved.');
    }
}

class OldSchoolSettingsForm extends Form
{
    var $user;

    function __construct(Action $out)
    {
        parent::__construct($out);
        $this->user = $out->getScoped()->getUser();
    }

    /**
     * Visible or invisible data elements
     *
     * Display the form fields that make up the data of the form.
     * Sub-classes should overload this to show their data.
     *
     * @return void
     */

    function formData()
    {
        $this->elementStart('fieldset');
        $this->elementStart('ul', 'form_data');
        $this->elementStart('li');
        $this->checkbox('stream_mode_only', _('Only stream mode (no conversations) in timelines'),
                        $this->user->streamModeOnly());
        $this->elementEnd('li');
        $this->elementStart('li');
        $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'),
                        $this->user->streamNicknames());
        $this->elementEnd('li');
        $this->elementEnd('fieldset');
        $this->elementEnd('ul');
    }

    /**
     * Buttons for form actions
     *
     * Submit and cancel buttons (or whatever)
     * Sub-classes should overload this to show their own buttons.
     *
     * @return void
     */

    function formActions()
    {
        $this->submit('submit', _('Save'));
    }

    /**
     * ID of the form
     *
     * Should be unique on the page. Sub-classes should overload this
     * to show their own IDs.
     *
     * @return int ID of the form
     */

    function id()
    {
        return 'form_oldschool';
    }

    /**
     * Action of the form.
     *
     * URL to post to. Should be overloaded by subclasses to give
     * somewhere to post to.
     *
     * @return string URL to post to
     */

    function action()
    {
        return common_local_url('oldschoolsettings');
    }

    /**
     * Class of the form. May include space-separated list of multiple classes.
     *
     * @return string the form's class
     */

    function formClass()
    {
        return 'form_settings';
    }
}

repo_name: suraj/sloth

license: mit


code:
<?php
/**
 * Opensearch action class.
 *
 * PHP version 5
 *
 * @category Action
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2008, 2009, 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') && !defined('LACONICA')) {
    exit(1);
}

/**
 * Opensearch action class.
 *
 * Formatting of RSS handled by Rss10Action
 *
 * @category Action
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 */
class OpensearchAction extends Action
{
    /**
     * Class handler.
     *
     * @param array $args query arguments
     *
     * @return boolean false if user doesn't exist
     */
    function handle()
    {
        parent::handle();
        $type       = $this->trimmed('type');
        $short_name = '';
        if ($type == 'people') {
            $type       = 'peoplesearch';
            // TRANS: ShortName in the OpenSearch interface when trying to find users.
            $short_name = _('People Search');
        } else {
            $type       = 'noticesearch';
            // TRANS: ShortName in the OpenSearch interface when trying to find notices.
            $short_name = _('Notice Search');
        }
        header('Content-Type: application/opensearchdescription+xml');
        $this->startXML();
        $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
        $short_name =  common_config('site', 'name').' '.$short_name;
        $this->element('ShortName', null, $short_name);
        $this->element('Contact', null, common_config('site', 'email'));
        $this->element('Url', array('type' => 'text/html', 'method' => 'get',
                       'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
        $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
        $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), Theme::path('logo.png'));
        $this->element('AdultContent', null, 'false');
        $this->element('Language', null, common_language());
        $this->element('OutputEncoding', null, 'UTF-8');
        $this->element('InputEncoding', null, 'UTF-8');
        $this->elementEnd('OpenSearchDescription');
        $this->endXML();
    }

    function isReadOnly($args)
    {
        return true;
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Allow one-time password login
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Login
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * Allow one-time password login
 *
 * This action will automatically log in the user identified by the user_id
 * parameter. A login_token record must be constructed beforehand, typically
 * by code where the user is already authenticated.
 *
 * @category  Login
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
 * @link      http://status.net/
 */
class OtpAction extends Action
{
    var $user;
    var $token;
    var $rememberme;
    var $returnto;
    var $lt;

    function prepare(array $args = array())
    {
        parent::prepare($args);

        if (common_is_real_login()) {
            // TRANS: Client error displayed trying to use "one time password login" when already logged in.
            $this->clientError(_('Already logged in.'));
        }

        $id = $this->trimmed('user_id');

        if (empty($id)) {
            // TRANS: Client error displayed trying to use "one time password login" without specifying a user.
            $this->clientError(_('No user ID specified.'));
        }

        $this->user = User::getKV('id', $id);

        if (empty($this->user)) {
            // TRANS: Client error displayed trying to use "one time password login" without using an existing user.
            $this->clientError(_('No such user.'));
        }

        $this->token = $this->trimmed('token');

        if (empty($this->token)) {
            // TRANS: Client error displayed trying to use "one time password login" without specifying a login token.
            $this->clientError(_('No login token specified.'));
        }

        $this->lt = Login_token::getKV('user_id', $id);

        if (empty($this->lt)) {
            // TRANS: Client error displayed trying to use "one time password login" without requesting a login token.
            $this->clientError(_('No login token requested.'));
        }

        if ($this->lt->token != $this->token) {
            // TRANS: Client error displayed trying to use "one time password login" while specifying an invalid login token.
            $this->clientError(_('Invalid login token specified.'));
        }

        if ($this->lt->modified > time() + Login_token::TIMEOUT) {
            //token has expired
            //delete the token as it is useless
            $this->lt->delete();
            $this->lt = null;
            // TRANS: Client error displayed trying to use "one time password login" while specifying an expired login token.
            $this->clientError(_('Login token expired.'));
        }

        $this->rememberme = $this->boolean('rememberme');
        $this->returnto = $this->trimmed('returnto');

        return true;
    }

    function handle()
    {
        parent::handle();

        // success!
        if (!common_set_user($this->user)) {
            // TRANS: Server error displayed when a user object could not be created trying to login using "one time password login".
            $this->serverError(_('Error setting user. You are probably not authorized.'));
        }

        // We're now logged in; disable the lt

        $this->lt->delete();
        $this->lt = null;

        common_real_login(true);

        if ($this->rememberme) {
            common_rememberme($this->user);
        }

        if (!empty($this->returnto)) {
            $url = $this->returnto;
            // We don't have to return to it again
            common_set_returnto(null);
        } else {
            $url = common_local_url('all',
                                    array('nickname' =>
                                          $this->user->nickname));
        }

        common_redirect($url, 303);
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Change user password
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Settings
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @author    Zach Copley <zach@status.net>
 * @copyright 2008-2009 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * Change password
 *
 * @category Settings
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 */
class PasswordsettingsAction extends SettingsAction
{
    /**
     * Title of the page
     *
     * @return string Title of the page
     */

    public function title()
    {
        // TRANS: Title for page where to change password.
        return _m('TITLE', 'Change password');
    }

    /**
     * Instructions for use
     *
     * @return string instructions for use
     */

    public function getInstructions()
    {
        // TRANS: Instructions for page where to change password.
        return _('Change your password.');
    }

    public function showScripts()
    {
        parent::showScripts();
        $this->autofocus('oldpassword');
    }

    public function showContent()
    {
        $this->elementStart('form', ['method' => 'POST',
                                     'id'     => 'form_password',
                                     'class'  => 'form_settings',
                                     'action' => common_local_url('passwordsettings')]);
        $this->elementStart('fieldset');
        // TRANS: Fieldset legend on page where to change password.
        $this->element('legend', null, _('Password change'));
        $this->hidden('token', common_session_token());

        $this->elementStart('ul', 'form_data');
        // Users who logged in with OpenID won't have a pwd
        if ($this->scoped->hasPassword()) {
            $this->elementStart('li');
            // TRANS: Field label on page where to change password.
            $this->password('oldpassword', _('Old password'));
            $this->elementEnd('li');
        }
        $this->elementStart('li');
        // TRANS: Field label on page where to change password.
        $this->password('newpassword', _('New password'),
                        // TRANS: Field title on page where to change password.
                        _('6 or more characters.'));
        $this->elementEnd('li');
        $this->elementStart('li');
        // TRANS: Field label on page where to change password. In this field the new password should be typed a second time.
        $this->password('confirm', _m('LABEL', 'Confirm'),
                        // TRANS: Field title on page where to change password.
                        _('Same as password above.'));
        $this->elementEnd('li');
        $this->elementEnd('ul');

        // TRANS: Button text on page where to change password.
        $this->submit('changepass', _m('BUTTON', 'Change'));

        $this->elementEnd('fieldset');
        $this->elementEnd('form');
    }

    protected function doPost()
    {
        // FIXME: scrub input

        $newpassword = $this->arg('newpassword');
        $confirm = $this->arg('confirm');

        // Some validation

        if (strlen($newpassword) < 6) {
            // TRANS: Form validation error on page where to change password.
            throw new ClientException(_('Password must be 6 or more characters.'));
        } elseif (0 != strcmp($newpassword, $confirm)) {
            // TRANS: Form validation error on password change when password confirmation does not match.
            throw new ClientException(_('Passwords do not match.'));
        }

        $oldpassword = null;
        if ($this->scoped->hasPassword()) {
            $oldpassword = $this->arg('oldpassword');

            if (!common_check_user($this->scoped->getNickname(), $oldpassword)) {
                // TRANS: Form validation error on page where to change password.
                throw new ClientException(_('Incorrect old password.'));
            }
        }

        if (Event::handle('StartChangePassword', [$this->scoped, $oldpassword, $newpassword])) {
            // no handler changed the password, so change the password internally
            $user = $this->scoped->getUser();
            $user->setPassword($newpassword);

            Event::handle('EndChangePassword', [$this->scoped]);
        }

        // TRANS: Form validation notice on page where to change password.
        return _('Password saved.');
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Paths administration panel
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Settings
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @author    Zach Copley <zach@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * Paths settings
 *
 * @category Admin
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Zach Copley <zach@status.net>
 * @author   Sarven Capadisli <csarven@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 */
class PathsadminpanelAction extends AdminPanelAction
{
    /**
     * Returns the page title
     *
     * @return string page title
     */

    function title()
    {
        // TRANS: Title for Paths admin panel.
        return _('Paths');
    }

    /**
     * Instructions for using this form.
     *
     * @return string instructions
     */
    function getInstructions()
    {
        // TRANS: Form instructions for Path admin panel.
        return _('Path and server settings for this StatusNet site');
    }

    /**
     * Show the paths admin panel form
     *
     * @return void
     */
    function showForm()
    {
        $form = new PathsAdminPanelForm($this);
        $form->show();
        return;
    }

    /**
     * Save settings from the form
     *
     * @return void
     */
    function saveSettings()
    {
        static $settings = array(
                                 'site' => array('path', 'locale_path', 'ssl', 'sslserver'),
                                 'theme' => array('server', 'dir', 'path', 'sslserver', 'sslpath'),
                                 'avatar' => array('server', 'dir', 'path'),
                                 'attachments' => array('server', 'dir', 'path', 'sslserver', 'sslpath')
                                 );

        // XXX: If we're only going to have one boolean on thi page we
        // can remove some of the boolean processing code --Z

        static $booleans = array('site' => array('fancy'));

        $values = array();

        foreach ($settings as $section => $parts) {
            foreach ($parts as $setting) {
                $values[$section][$setting] = $this->trimmed("$section-$setting");
            }
        }

        foreach ($booleans as $section => $parts) {
            foreach ($parts as $setting) {
                $values[$section][$setting] = ($this->boolean($setting)) ? 1 : 0;
            }
        }

        $this->validate($values);

        // assert(all values are valid);

        $config = new Config();

        $config->query('BEGIN');

        foreach ($settings as $section => $parts) {
            foreach ($parts as $setting) {
                Config::save($section, $setting, $values[$section][$setting]);
            }
        }

        foreach ($booleans as $section => $parts) {
            foreach ($parts as $setting) {
                Config::save($section, $setting, $values[$section][$setting]);
            }
        }

        $config->query('COMMIT');

        return;
    }

    /**
     * Attempt to validate setting values
     *
     * @return void
     */
    function validate(&$values)
    {
        // Validate theme dir

        if (!empty($values['theme']['dir']) && !is_readable($values['theme']['dir'])) {
            // TRANS: Client error in Paths admin panel.
            // TRANS: %s is the directory that could not be read from.
            $this->clientError(sprintf(_('Theme directory not readable: %s.'), $values['theme']['dir']));
        }

        // Validate avatar dir

        if (empty($values['avatar']['dir']) || !is_writable($values['avatar']['dir'])) {
            // TRANS: Client error in Paths admin panel.
            // TRANS: %s is the avatar directory that could not be written to.
            $this->clientError(sprintf(_('Avatar directory not writable: %s.'), $values['avatar']['dir']));
        }

        // Validate locales dir

        // XXX: What else do we need to validate for lacales path here? --Z

        if (!empty($values['site']['locale_path']) && !is_readable($values['site']['locale_path'])) {
            // TRANS: Client error in Paths admin panel.
            // TRANS: %s is the locales directory that could not be read from.
            $this->clientError(sprintf(_('Locales directory not readable: %s.'), $values['site']['locale_path']));
        }

        // Validate SSL setup

        if (mb_strlen($values['site']['sslserver']) > 255) {
            // TRANS: Client error in Paths admin panel.
            // TRANS: %s is the SSL server URL that is too long.
            $this->clientError(_('Invalid SSL server. The maximum length is 255 characters.'));
        }
    }
}

class PathsAdminPanelForm extends AdminForm
{
    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'form_paths_admin_panel';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('pathsadminpanel');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
        // TRANS: Fieldset legend in Paths admin panel.
        $this->out->element('legend', null, _('Site'), 'site');
        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->input('server',
                     // TRANS: Field label in Paths admin panel.
                     _('Server'),
                     // TRANS: Field title in Paths admin panel.
                     _('Site\'s server hostname.'));
        $this->unli();

        $this->li();
        $this->input('path',
                     // TRANS: Field label in Paths admin panel.
                     _('Path'),
                     // TRANS: Field title in Paths admin panel.
                     _('Site path.'));
        $this->unli();

        $this->li();
        $this->input('locale_path',
                     // TRANS: Field label in Paths admin panel.
                     _('Locale directory'),
                     // TRANS: Field title in Paths admin panel.
                     _('Directory path to locales.'),
                     'site');
        $this->unli();

        $this->li();
        $this->out->checkbox('fancy',
                             // TRANS: Checkbox label in Paths admin panel.
                             _('Fancy URLs'),
                             (bool) $this->value('fancy'),
                             // TRANS: Field title in Paths admin panel.
                             _('Use fancy URLs (more readable and memorable)?'));
        $this->unli();

        $this->out->elementEnd('ul');
        $this->out->elementEnd('fieldset');

        $this->out->elementStart('fieldset', array('id' => 'settings_paths_theme'));
        // TRANS: Fieldset legend in Paths admin panel.
        $this->out->element('legend', null, _m('LEGEND','Theme'));

        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->input('server',
                     // TRANS: Field label in Paths admin panel.
                     _('Server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Server for themes.'),
                     'theme');
        $this->unli();

        $this->li();
        $this->input('path',
                     // TRANS: Field label in Paths admin panel.
                     _('Path'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Web path to themes.'),
                     'theme');
        $this->unli();

        $this->li();
        $this->input('sslserver',
                     // TRANS: Field label in Paths admin panel.
                     _('SSL server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('SSL server for themes (default: SSL server).'),
                     'theme');
        $this->unli();

        $this->li();
        $this->input('sslpath',
                     // TRANS: Field label in Paths admin panel.
                     _('SSL path'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('SSL path to themes (default: /theme/).'),
                     'theme');
        $this->unli();

        $this->li();
        $this->input('dir',
                     // TRANS: Field label in Paths admin panel.
                     _('Directory'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Directory where themes are located.'),
                     'theme');
        $this->unli();

        $this->out->elementEnd('ul');

        $this->out->elementEnd('fieldset');
        $this->out->elementStart('fieldset', array('id' => 'settings_avatar-paths'));
        // TRANS: Fieldset legend in Paths admin panel.
        $this->out->element('legend', null, _('Avatars'));

        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->input('server',
                     // TRANS: Field label in Paths admin panel.
                     _('Avatar server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Server for avatars.'),
                     'avatar');
        $this->unli();

        $this->li();
        $this->input('path',
                     // TRANS: Field label in Paths admin panel.
                     _('Avatar path'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Web path to avatars.'),
                     'avatar');
        $this->unli();

        $this->li();
        $this->input('dir',
                     // TRANS: Field label in Paths admin panel.
                     _('Avatar directory'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Directory where avatars are located.'),
                     'avatar');
        $this->unli();

        $this->out->elementEnd('ul');

        $this->out->elementEnd('fieldset');

        $this->out->elementStart('fieldset', array('id' =>
                                                   'settings_attachments-paths'));

        // TRANS: Fieldset legens in Paths admin panel.
        $this->out->element('legend', null, _('Attachments'));
        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->input('server',
                     // TRANS: Field label in Paths admin panel.
                     _('Server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Server for attachments.'),
                     'attachments');
        $this->unli();

        $this->li();
        $this->input('path',
                     // TRANS: Field label in Paths admin panel.
                     _('Path'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Web path to attachments.'),
                     'attachments');
        $this->unli();

        $this->li();
        $this->input('sslserver',
                     // TRANS: Field label in Paths admin panel.
                     _('SSL server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Server for attachments on SSL pages.'),
                     'attachments');
        $this->unli();

        $this->li();
        $this->input('sslpath',
                     // TRANS: Field label in Paths admin panel.
                     _('SSL path'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Web path to attachments on SSL pages.'),
                     'attachments');
        $this->unli();

        $this->li();
        $this->input('dir',
                     // TRANS: Field label in Paths admin panel.
                     _('Directory'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Directory where attachments are located.'),
                     'attachments');
        $this->unli();

        $this->out->elementEnd('ul');
        $this->out->elementEnd('fieldset');

        $this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl'));
        // TRANS: Fieldset legend in Paths admin panel.
        $this->out->element('legend', null, _m('LEGEND','SSL'));
        $this->out->elementStart('ul', 'form_data');
        $this->li();

        // TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
        $ssl = array('never' => _('Never'),
                      // TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
                     'always' => _('Always'));

        $this->out->dropdown('site-ssl',
                             // TRANS: Drop down label in Paths admin panel.
                             _('Use SSL'),
                             // TRANS: Tooltip for field label in Paths admin panel.
                             $ssl, _('When to use SSL.'),
                             false,
                             $this->value('ssl', 'site'));
        $this->unli();

        $this->li();
        $this->input('sslserver',
                     // TRANS: Field label in Paths admin panel.
                     _('SSL server'),
                     // TRANS: Tooltip for field label in Paths admin panel.
                     _('Server to direct SSL requests to.'),
                     'site');
        $this->unli();
        $this->out->elementEnd('ul');
        $this->out->elementEnd('fieldset');
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text to store form data in the Paths admin panel.
        $this->out->submit('save', _m('BUTTON','Save'), 'submit',
                           // TRANS: Button title text to store form data in the Paths admin panel.
                           'save', _('Save path settings.'));
    }

    /**
     * Utility to simplify some of the duplicated code around
     * params and settings. Overriding the input() in the base class
     * to handle a whole bunch of cases of settings with the same
     * name under different sections.
     *
     * @param string $setting      Name of the setting
     * @param string $title        Title to use for the input
     * @param string $instructions Instructions for this field
     * @param string $section      config section, default = 'site'
     *
     * @return void
     */
    function input($setting, $title, $instructions, $section='site')
    {
        $this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
    }
}


code:
<?php
/**
 * People search action class.
 *
 * PHP version 5
 *
 * @category Action
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2008, 2009, 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') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/search/searchaction.php';
require_once INSTALLDIR . '/lib/profile/profilelist.php';

/**
 * People search action class.
 *
 * @category Action
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 */
class PeoplesearchAction extends SearchAction
{
    function getInstructions()
    {
        // TRANS: Instructions for the "People search" page.
        // TRANS: %%site.name%% is the name of the StatusNet site.
        return _('Search for people on %%site.name%% by their name, location, or interests. ' .
                  'Separate the terms by spaces; they must be 3 characters or more.');
    }

    function title()
    {
        // TRANS: Title of a page where users can search for other users.
        return _('People search');
    }

    function showResults($q, $page)
    {
        $profile = new Profile();
        $search_engine = $profile->getSearchEngine('profile');
        $search_engine->set_sort_mode('chron');
        // Ask for an extra to see if there's more.
        $search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1);
        if (false === $search_engine->query($q)) {
            $cnt = 0;
        }
        else {
            $cnt = $profile->find();
        }
        if ($cnt > 0) {
            $terms = preg_split('/[\s,]+/', $q);
            $results = new PeopleSearchResults($profile, $terms, $this);
            $results->show();
            $profile->free();
            $this->pagination($page > 1, $cnt > PROFILES_PER_PAGE,
                          $page, 'peoplesearch', array('q' => $q));

        } else {
            // TRANS: Message on the "People search" page where a query has no results.
            $this->element('p', 'error', _('No results.'));
            $this->searchSuggestions($q);
            $profile->free();
        }
    }

    function showScripts()
    {
        parent::showScripts();
        $this->autofocus('q');
    }
}

/**
 * People search results class
 *
 * Derivative of ProfileList with specialization for highlighting search terms.
 *
 * @category Widget
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see PeoplesearchAction
 */

class PeopleSearchResults extends ProfileList
{
    var $terms = null;
    var $pattern = null;

    function __construct($profile, $terms, $action)
    {
        parent::__construct($profile, $action);

        $this->terms = array_map('preg_quote',
                                 array_map('htmlspecialchars', $terms));

        $this->pattern = '/('.implode('|',$terms).')/i';
    }

    function newProfileItem($profile)
    {
        return new PeopleSearchResultItem($profile, $this->action);
    }
}

class PeopleSearchResultItem extends ProfileListItem
{
    function highlight($text)
    {
        return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Lists by a user
 *
 * PHP version 5
 *
 * LICENCE: 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.
 *
 * PHP version 5
 *
 * 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/>.
 *
 * @category  Personal
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @author    Zach Copley <zach@status.net>
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @copyright 2009 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/peopletaglist.php';
// cache 3 pages
define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);

class PeopletagAction extends Action
{
    var $page = null;
    var $tag = null;

    function isReadOnly($args)
    {
        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Title for list page.
            // TRANS: %s is a list.
            return sprintf(_('Public list %s'), $this->tag);
        } else {
            // TRANS: Title for list page.
            // TRANS: %1$s is a list, %2$d is a page number.
            return sprintf(_('Public list %1$s, page %2$d'), $this->tag, $this->page);
        }
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        $tag_arg = $this->arg('tag');
        $tag = common_canonical_tag($tag_arg);

        // Permanent redirect on non-canonical nickname

        if ($tag_arg != $tag) {
            $args = array('tag' => $nickname);
            if ($this->page && $this->page != 1) {
                $args['page'] = $this->page;
            }
            common_redirect(common_local_url('peopletag', $args), 301);
        }
        $this->tag = $tag;

        return true;
    }

    function handle()
    {
        parent::handle();
        $this->showPage();
    }

    function showLocalNav()
    {
        $nav = new PublicGroupNav($this);
        $nav->show();
    }

    function showAnonymousMessage()
    {
        $notice =
          // TRANS: Message for anonymous users on list page.
          // TRANS: This message contains Markdown links in the form [description](link).
          _('Lists are how you sort similar ' .
            'people on %%site.name%%, a [micro-blogging]' .
            '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
            'based on the Free Software [StatusNet](http://status.net/) tool. ' .
            'You can then easily keep track of what they ' .
            'are doing by subscribing to the list\'s timeline.' );
        $this->elementStart('div', array('id' => 'anon_notice'));
        $this->raw(common_markup_to_html($notice));
        $this->elementEnd('div');
    }

    function showContent()
    {
        $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
        $limit  = PEOPLETAGS_PER_PAGE + 1;

        $ptags = new Profile_list();
        $ptags->tag = $this->tag;

        $user = common_current_user();

        if (empty($user)) {
            $ckey = sprintf('profile_list:tag:%s', $this->tag);
            $ptags->private = false;
            $ptags->orderBy('profile_list.modified DESC');

            $c = Cache::instance();
            if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) {
                $cached_ptags = Profile_list::getCached($ckey, $offset, $limit);
                if ($cached_ptags === false) {
                    $ptags->limit(0, PEOPLETAG_CACHE_WINDOW);
                    $ptags->find();

                    Profile_list::setCache($ckey, $ptags, $offset, $limit);
                } else {
                    $ptags = clone($cached_ptags);
                }
            } else {
                $ptags->limit($offset, $limit);
                $ptags->find();
            }
        } else {
            $ptags->whereAdd('(profile_list.private = false OR (' .
                             ' profile_list.tagger =' . $user->id .
                             ' AND profile_list.private = true) )');

            $ptags->orderBy('profile_list.modified DESC');
            $ptags->find();
        }

        $pl = new PeopletagList($ptags, $this);
        $cnt = $pl->show();

        $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
                          $this->page, 'peopletag', array('tag' => $this->tag));
    }

    function showSections()
    {
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2008-2010, StatusNet, Inc.
 *
 * Peopletag autocomple action.
 *
 * 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/>.
 *
 * PHP version 5
 *
 * @category  Action
 * @package   StatusNet
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    exit(1);
}

class PeopletagautocompleteAction extends Action
{
    var $user;
    var $tags;
    var $last_mod;

    /**
     * Check pre-requisites and instantiate attributes
     *
     * @param Array $args array of arguments (URL, GET, POST)
     *
     * @return boolean success flag
     */
    function prepare(array $args = array())
    {
        parent::prepare($args);

        // Only for logged-in users

        $this->user = common_current_user();

        if (empty($this->user)) {
            // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
            $this->clientError(_('Not logged in.'));
        }

        // CSRF protection

        $token = $this->trimmed('token');

        if (!$token || $token != common_session_token()) {
            // TRANS: Client error displayed when the session token does not match or is not given.
            $this->clientError(_('There was a problem with your session token.'.
                                 ' Try again, please.'));
        }

        $profile = $this->user->getProfile();
        $tags = $profile->getLists($this->scoped);

        $this->tags = array();
        while ($tags->fetch()) {

            if (empty($this->last_mod)) {
                $this->last_mod = $tags->modified;
            }

            $arr = array();
            $arr['tag'] = $tags->tag;
            $arr['mode'] = $tags->private ? 'private' : 'public';
            // $arr['url'] = $tags->homeUrl();
            $arr['freq'] = $tags->taggedCount();

            $this->tags[] = $arr;
        }

        $tags = NULL;

        return true;
    }

    /**
     * Last modified time
     *
     * Helps in browser-caching
     *
     * @return String time
     */
    function lastModified()
    {
        return strtotime($this->last_mod);
    }

    /**
     * Handle request
     *
     * Print the JSON autocomplete data
     *
     * @param Array $args unused.
     *
     * @return void
     */
    function handle()
    {
        //common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($this->tags));
        if ($this->tags) {
            print(json_encode($this->tags));
            exit(0);
        }
        return false;
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * List of people tagged by the user with a tag
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Group
 * @package   StatusNet
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/profilelist.php';

/**
 * List of people tagged by the user with a tag
 *
 * @category Peopletag
 * @package  StatusNet
 * @author   Shashi Gowda <connect2shashi@gmail.com>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 */
class PeopletaggedAction extends Action
{
    var $page = null;
    var $peopletag = null;
    var $tagger = null;

    function isReadOnly($args)
    {
        return true;
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        if (common_config('singleuser', 'enabled')) {
            $tagger_arg = User::singleUserNickname();
        } else {
            $tagger_arg = $this->arg('tagger');
        }

        $tag_arg = $this->arg('tag');
        $tagger = common_canonical_nickname($tagger_arg);
        $tag = common_canonical_tag($tag_arg);

        // Permanent redirect on non-canonical nickname

        if ($tagger_arg != $tagger || $tag_arg != $tag) {
            $args = array('tagger' => $nickname, 'tag' => $tag);
            if ($this->page != 1) {
                $args['page'] = $this->page;
            }
            common_redirect(common_local_url('peopletagged', $args), 301);
        }

        if (!$tagger) {
            // TRANS: Client error displayed when a tagger is expected but not provided.
            $this->clientError(_('No tagger.'), 404);
        }

        $user = User::getKV('nickname', $tagger);

        if (!$user) {
            // TRANS: Client error displayed when referring to non-existing user.
            $this->clientError(_('No such user.'), 404);
        }

        $this->tagger = $user->getProfile();
        $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));

        if (!$this->peopletag) {
            // TRANS: Client error displayed when referring to a non-existing list.
            $this->clientError(_('No such list.'), 404);
        }

        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Title for list of people listed by the user.
            // TRANS: %1$s is a list, %2$s is a username.
            return sprintf(_('People listed in %1$s by %2$s'),
                           $this->peopletag->tag, $this->tagger->nickname);
        } else {
            // TRANS: Title for list of people listed by the user.
            // TRANS: %1$s is a list, %2$s is a username, %2$s is a page number.
            return sprintf(_('People listed in %1$s by %2$s, page %3$d'),
                           $this->peopletag->tag, $this->user->nickname,
                           $this->page);
        }
    }

    function handle()
    {
        parent::handle();
        $this->showPage();
    }

    function showPageNotice()
    {
    }

    function showLocalNav()
    {
        $nav = new PeopletagGroupNav($this, $this->peopletag);
        $nav->show();
    }

    function showContent()
    {
        $offset = ($this->page-1) * PROFILES_PER_PAGE;
        $limit =  PROFILES_PER_PAGE + 1;

        $cnt = 0;

        $subs = $this->peopletag->getTagged($offset, $limit);

        if ($subs) {
            $subscriber_list = new PeopletagMemberList($subs, $this->peopletag, $this);
            $cnt = $subscriber_list->show();
        }

        $subs->free();

        $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
                          $this->page, 'peopletagged',
                          array('tagger' => $this->tagger->nickname,
                                'tag'    => $this->peopletag->tag));
    }
}

class PeopletagMemberList extends ProfileList
{
    var $peopletag = null;

    function __construct($profile, $peopletag, $action)
    {
        parent::__construct($profile, $action);

        $this->peopletag = $peopletag;
    }

    function newListItem(Profile $profile)
    {
        return new PeopletagMemberListItem($profile, $this->peopletag, $this->action);
    }
}

class PeopletagMemberListItem extends ProfileListItem
{
    var $peopletag = null;

    function __construct($profile, $peopletag, $action)
    {
        parent::__construct($profile, $action);

        $this->peopletag = $peopletag;
    }

    function showFullName()
    {
        parent::showFullName();
        if ($this->profile->id == $this->peopletag->tagger) {
            $this->out->text(' ');
            // TRANS: Addition in tag membership list for creator of a tag.
            $this->out->element('span', 'role', _('Creator'));
        }
    }

    function showActions()
    {
        $this->startActions();
        if (Event::handle('StartProfileListItemActionElements', array($this))) {
            $this->showSubscribeButton();
            // TODO: Untag button
            Event::handle('EndProfileListItemActionElements', array($this));
        }
        $this->endActions();
    }

    function linkAttributes()
    {
        // tagging people is healthy page-rank flow.
        return parent::linkAttributes();
    }

    /**
     * Fetch necessary return-to arguments for the profile forms
     * to return to this list when they're done.
     *
     * @return array
     */
    protected function returnToArgs()
    {
        $args = array('action' => 'peopletagged',
                      'tag' => $this->peopletag->tag,
                      'tagger' => $this->profile->nickname);
        $page = $this->out->arg('page');
        if ($page) {
            $args['param-page'] = $page;
        }
        return $args;
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Lists by a user
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Personal
 * @package   StatusNet
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/peopletaglist.php';

class PeopletagsbyuserAction extends Action
{
    var $page = null;
    var $tagger = null;
    var $tags = null;

    function isReadOnly($args)
    {
        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            if ($this->isOwner()) {
                if ($this->arg('private')) {
                    // TRANS: Title for lists by a user page for a private tag.
                    return _('Private lists by you');
                } else if ($this->arg('public')) {
                    // TRANS: Title for lists by a user page for a public tag.
                    return _('Public lists by you');
                }
                // TRANS: Title for lists by a user page.
                return _('Lists by you');
            }
            // TRANS: Title for lists by a user page.
            // TRANS: %s is a user nickname.
            return sprintf(_('Lists by %s'), $this->tagger->nickname);
        } else {
            // TRANS: Title for lists by a user page.
            // TRANS: %1$s is a user nickname, %2$d is a page number.
            return sprintf(_('Lists by %1$s, page %2$d'), $this->tagger->nickname, $this->page);
        }
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);

        if ($this->arg('public') && $this->arg('private')) {
            $this->args['public'] = $this->args['private'] = false;
        }

        if (common_config('singleuser', 'enabled')) {
            $nickname_arg = User::singleUserNickname();
        } else {
            $nickname_arg = $this->arg('nickname');
        }

        $nickname = common_canonical_nickname($nickname_arg);

        // Permanent redirect on non-canonical nickname

        if ($nickname_arg != $nickname) {
            $args = $this->getSelfUrlArgs();
            if ($this->arg('page') && $this->arg('page') != 1) {
                $args['page'] = $this->arg['page'];
            }
            common_redirect(common_local_url('peopletagsbyuser', $args), 301);
        }

        $this->user = User::getKV('nickname', $nickname);

        if (!$this->user) {
            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
            $this->clientError(_('No such user.'), 404);
        }

        $this->tagger = $this->user->getProfile();

        if (!$this->tagger) {
            // TRANS: Error message displayed when referring to a user without a profile.
            $this->serverError(_('User has no profile.'));
        }

        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
        $limit  = PEOPLETAGS_PER_PAGE + 1;

        $user = common_current_user();
        if ($this->arg('public')) {
            $this->tags = $this->tagger->getLists(null, $offset, $limit);
        } else if ($this->arg('private')) {
            if (empty($user)) {
                // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
                $this->clientError(_('Not logged in.'), 403);
            }

            if ($this->isOwner()) {
                $this->tags = $this->tagger->getPrivateTags($offset, $limit);
            } else {
                // TRANS: Client error displayed when trying view another user's private lists.
                $this->clientError(_('You cannot view others\' private lists'), 403);
            }
        } else {
            $this->tags = $this->tagger->getLists($this->scoped, $offset, $limit);
        }
        return true;
    }

    function handle()
    {
        parent::handle();

		# Post from the tag dropdown; redirect to a GET

		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		    common_redirect(common_local_url('peopletagsbyuser', $this->getSelfUrlArgs()), 303);
		}

        $this->showPage();
    }

    function showModeSelector()
    {
        $this->elementStart('dl', array('id'=>'filter_tags'));
        // TRANS: Mode selector label.
        $this->element('dt', null, _('Mode'));
        $this->elementStart('dd');
        $this->elementStart('ul');
        $this->elementStart('li', array('id' => 'filter_tags_for',
                                         'class' => 'child_1'));
        $this->element('a',
                       array('href' =>
                             common_local_url('peopletagsforuser',
                                              array('nickname' => $this->user->nickname))),
                       // TRANS: Link text to show lists for user %s.
                       sprintf(_('Lists for %s'), $this->tagger->nickname));
        $this->elementEnd('li');

        if ($this->isOwner()) {
            $this->elementStart('li', array('id'=>'filter_tags_item'));
            $this->elementStart('form', array('name' => 'modeselector',
                                               'id' => 'form_filter_bymode',
                                               'action' => common_local_url('peopletagsbyuser',
                                                    array('nickname' => $this->tagger->nickname)),
                                               'method' => 'post'));
            $this->elementStart('fieldset');
            // TRANS: Fieldset legend.
            $this->element('legend', null, _('Select tag to filter'));

            $priv = $this->arg('private');
            $pub  = $this->arg('public');

            if (!$priv && !$pub) {
                $priv = $pub = true;
            }
            // TRANS: Checkbox label to show private tags.
            $this->checkbox('private', _m('LABEL','Private'), $priv,
                                // TRANS: Checkbox title.
                                _('Show private tags.'));
            // TRANS: Checkbox label to show public tags.
            $this->checkbox('public', _m('LABEL','Public'), $pub,
                                // TRANS: Checkbox title.
                                _('Show public tags.'));
            $this->hidden('nickname', $this->user->nickname);
            // TRANS: Submit button text for tag filter form.
            $this->submit('submit', _m('BUTTON','Go'));
            $this->elementEnd('fieldset');
            $this->elementEnd('form');
            $this->elementEnd('li');
        }
        $this->elementEnd('ul');
        $this->elementEnd('dd');
        $this->elementEnd('dl');
    }

    function showAnonymousMessage()
    {
        $notice =
          // TRANS: Message displayed for anonymous users on page that displays lists by a user.
          // TRANS: This message contains Markdown links in the form [description](links).
          // TRANS: %s is a tagger nickname.
          sprintf(_('These are lists created by **%s**. ' .
                    'Lists are how you sort similar ' .
                    'people on %%%%site.name%%%%, a [micro-blogging]' .
                    '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
                    'based on the Free Software [StatusNet](http://status.net/) tool. ' .
                    'You can easily keep track of what they ' .
                    'are doing by subscribing to the list\'s timeline.' ), $this->tagger->nickname);
        $this->elementStart('div', array('id' => 'anon_notice'));
        $this->raw(common_markup_to_html($notice));
        $this->elementEnd('div');
    }

    function showPageNotice()
    {
        $this->elementStart('div', 'instructions');
        $this->showModeSelector();
        $this->elementEnd('div');
    }

    function showContent()
    {
        #TODO: controls here.

        $pl = new PeopletagList($this->tags, $this);
        $cnt = $pl->show();

        if ($cnt == 0) {
            $this->showEmptyListMessage();
        }
        $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
                          $this->page, 'peopletagsbyuser', $this->getSelfUrlArgs());
    }

    function getSelfUrlArgs()
    {
        $args = array();
        if ($this->arg('private')) {
            $args['private'] = 1;
        } else if ($this->arg('public')) {
            $args['public'] = 1;
        }
        $args['nickname'] = $this->trimmed('nickname');

        return $args;
    }

    function isOwner()
    {
        $user = common_current_user();
        return !empty($user) && $user->id == $this->tagger->id;
    }

    function showObjectNav()
    {
        $nav = new PeopletagNav($this, $this->tagger);
        $nav->show();
    }

    function showEmptyListMessage()
    {
          // TRANS: Message displayed on page that displays lists by a user when there are none.
          // TRANS: This message contains Markdown links in the form [description](links).
          // TRANS: %s is a tagger nickname.
        $message = sprintf(_('%s has not created any [lists](%%%%doc.lists%%%%) yet.'), $this->tagger->nickname);
        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }

    function showProfileBlock()
    {
        $block = new AccountProfileBlock($this, $this->tagger);
        $block->show();
    }

    function showSections()
    {
        #TODO: tags with most subscribers
        #TODO: tags with most "members"
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * People tags for a user
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Personal
 * @package   StatusNet
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/peopletaglist.php';

class PeopletagsforuserAction extends Action
{
    var $page = null;
    var $tagged = null;

    function isReadOnly($args)
    {
        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Page title. %s is a tagged user's nickname.
            return sprintf(_('Lists with %s in them'), $this->tagged->nickname);
        } else {
            // TRANS: Page title. %1$s is a tagged user's nickname, %2$s is a page number.
            return sprintf(_('Lists with %1$s, page %2$d'), $this->tagged->nickname, $this->page);
        }
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);

        if (common_config('singleuser', 'enabled')) {
            $nickname_arg = User::singleUserNickname();
        } else {
            $nickname_arg = $this->arg('nickname');
        }

        $nickname = common_canonical_nickname($nickname_arg);

        // Permanent redirect on non-canonical nickname

        if ($nickname_arg != $nickname) {
            $args = array('nickname' => $nickname);
            if ($this->arg('page') && $this->arg('page') != 1) {
                $args['page'] = $this->arg['page'];
            }
            common_redirect(common_local_url('peopletagsforuser', $args), 301);
        }

        $this->user = User::getKV('nickname', $nickname);

        if (!$this->user) {
            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
            $this->clientError(_('No such user.'), 404);
        }

        $this->tagged = $this->user->getProfile();

        if (!$this->tagged) {
            // TRANS: Error message displayed when referring to a user without a profile.
            $this->serverError(_('User has no profile.'));
        }

        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        return true;
    }

    function handle()
    {
        parent::handle();
        $this->showPage();
    }

    function showAnonymousMessage()
    {
        $notice =
          // TRANS: Message displayed for anonymous users on page that displays lists for a user.
          // TRANS: This message contains Markdown links in the form [description](links).
          // TRANS: %s is a tagger nickname.
          sprintf(_('These are lists for **%s**. ' .
                    'lists are how you sort similar ' .
                    'people on %%%%site.name%%%%, a [micro-blogging]' .
                    '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
                    'based on the Free Software [StatusNet](http://status.net/) tool. ' .
                    'You can easily keep track of what they ' .
                    'are doing by subscribing to the list\'s timeline.' ), $this->tagged->nickname);
        $this->elementStart('div', array('id' => 'anon_notice'));
        $this->raw(common_markup_to_html($notice));
        $this->elementEnd('div');
    }

    function showContent()
    {
        #TODO: controls here.

        $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
        $limit  = PEOPLETAGS_PER_PAGE + 1;

        $ptags = $this->tagged->getOtherTags($this->scoped, $offset, $limit);

        $pl = new PeopletagList($ptags, $this);
        $cnt = $pl->show();

        if ($cnt == 0) {
            $this->showEmptyListMessage();
        }
        $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
                          $this->page, 'peopletagsforuser', array('nickname' => $this->tagged->id));
    }

    function showEmptyListMessage()
    {
        // TRANS: Message displayed on page that displays lists a user was added to when there are none.
        // TRANS: This message contains Markdown links in the form [description](links).
        // TRANS: %s is a user nickname.
        $message = sprintf(_('%s has not been [listed](%%%%doc.lists%%%%) by anyone yet.'), $this->tagged->nickname);
        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }

    function showObjectNav()
    {
        $nav = new PeopletagNav($this, $this->tagged);
        $nav->show();
    }

    function showProfileBlock()
    {
        $block = new AccountProfileBlock($this, $this->tagged);
        $block->show();
    }

    function showSections()
    {
        #TODO: tags with most subscribers
        #TODO: tags with most "members"
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * List of peopletag subscribers
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Group
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/profilelist.php';

/**
 * List of peopletag subscribers
 *
 * @category Peopletag
 * @package  StatusNet
 * @author   Evan Prodromou <evan@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 */
class PeopletagsubscribersAction extends Action
{
    var $page = null;
    var $peopletag = null;
    var $tagger = null;

    function isReadOnly($args)
    {
        return true;
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        if (common_config('singleuser', 'enabled')) {
            $tagger_arg = User::singleUserNickname();
        } else {
            $tagger_arg = $this->arg('tagger');
        }

        $tag_arg = $this->arg('tag');
        $tagger = common_canonical_nickname($tagger_arg);
        $tag = common_canonical_tag($tag_arg);

        // Permanent redirect on non-canonical nickname

        if ($tagger_arg != $tagger || $tag_arg != $tag) {
            $args = array('tagger' => $nickname, 'tag' => $tag);
            if ($this->page != 1) {
                $args['page'] = $this->page;
            }
            common_redirect(common_local_url('peopletagged', $args), 301);
        }

        if (!$tagger) {
            // TRANS: Client error displayed when a tagger is expected but not provided.
            $this->clientError(_('No tagger.'), 404);
        }

        $user = User::getKV('nickname', $tagger);

        if (!$user) {
            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
            $this->clientError(_('No such user.'), 404);
        }

        $this->tagger = $user->getProfile();
        $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));

        if (!$this->peopletag) {
            // TRANS: Client error displayed trying to reference a non-existing list.
            $this->clientError(_('No such list.'), 404);
        }

        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Page title for list of list subscribers.
            // TRANS: %1$s is a list, %2$s is a user nickname.
            return sprintf(_('Subscribers to list %1$s by %2$s'),
                           $this->peopletag->tag, $this->tagger->nickname);
        } else {
            // TRANS: Page title for list of list subscribers.
            // TRANS: %1$s is a list, %2$s is a user nickname, %3$d is a page number.
            return sprintf(_('Subscribers to list %1$s by %2$s, page %3$d'),
                           $this->peopletag->tag, $this->tagger->nickname,
                           $this->page);
        }
    }

    function handle()
    {
        parent::handle();
        $this->showPage();
    }

    function showPageNotice()
    {
    }

    function showLocalNav()
    {
        $nav = new PeopletagGroupNav($this);
        $nav->show();
    }

    function showContent()
    {
        $offset = ($this->page-1) * PROFILES_PER_PAGE;
        $limit =  PROFILES_PER_PAGE + 1;

        $cnt = 0;

        $subs = $this->peopletag->getSubscribers($offset, $limit);

        if ($subs) {
            $subscriber_list = new PeopletagSubscriberList($subs, $this->peopletag, $this);
            $cnt = $subscriber_list->show();
        }

        $subs->free();

        $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
                          $this->page, 'peopletagsubscribers',
                          array('tagger' => $this->tagger->nickname,
                                'tag'    => $this->peopletag->tag));
    }
}

class PeopletagSubscriberList extends ProfileList
{
    var $peopletag = null;

    function __construct($profile, $peopletag, $action)
    {
        parent::__construct($profile, $action);

        $this->peopletag = $peopletag;
    }

    function newListItem(Profile $profile)
    {
        return new PeopletagSubscriberListItem($profile, $this->peopletag, $this->action);
    }
}

class PeopletagSubscriberListItem extends ProfileListItem
{
    var $peopletag = null;

    function __construct($profile, $peopletag, $action)
    {
        parent::__construct($profile, $action);

        $this->peopletag = $peopletag;
    }

    function showFullName()
    {
        parent::showFullName();
        if ($this->profile->id == $this->peopletag->tagger) {
            $this->out->text(' ');
            // TRANS: Addition in tag subscribers list for creator of a tag.
            $this->out->element('span', 'role', _('Creator'));
        }
    }

    function showActions()
    {
        $this->startActions();
        if (Event::handle('StartProfileListItemActionElements', array($this))) {
            $this->showSubscribeButton();
            Event::handle('EndProfileListItemActionElements', array($this));
        }
        $this->endActions();
    }

    function linkAttributes()
    {
        $aAttrs = parent::linkAttributes();

        if (common_config('nofollow', 'members')) {
            $aAttrs['rel'] .= ' nofollow';
        }

        return $aAttrs;
    }

    function homepageAttributes()
    {
        $aAttrs = parent::linkAttributes();

        if (common_config('nofollow', 'members')) {
            $aAttrs['rel'] = 'nofollow';
        }

        return $aAttrs;
    }

    /**
     * Fetch necessary return-to arguments for the profile forms
     * to return to this list when they're done.
     *
     * @return array
     */
    protected function returnToArgs()
    {
        $args = array('action' => 'peopletagsubscribers',
                      'tag' => $this->peopletag->tag,
                      'tagger' => $this->profile->nickname);
        $page = $this->out->arg('page');
        if ($page) {
            $args['param-page'] = $page;
        }
        return $args;
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * People tags subscribed to by a user
 *
 * PHP version 5
 *
 * LICENCE: 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/>.
 *
 * @category  Personal
 * @package   StatusNet
 * @author    Shashi Gowda <connect2shashi@gmail.com>
 * @copyright 2008-2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

require_once INSTALLDIR . '/lib/profile/peopletaglist.php';

class PeopletagsubscriptionsAction extends Action
{
    var $page = null;
    var $profile = null;

    function isReadOnly($args)
    {
        return true;
    }

    function title()
    {
        if ($this->page == 1) {
            // TRANS: Title for page that displays lists subscribed to by a user.
            // TRANS: %s is a profile nickname.
            return sprintf(_('Lists subscribed to by %s'), $this->profile->nickname);
        } else {
            // TRANS: Title for page that displays lists subscribed to by a user.
            // TRANS: %1$s is a profile nickname, %2$d is a page number.
            return sprintf(_('Lists subscribed to by %1$s, page %2$d'), $this->profile->nickname, $this->page);
        }
    }

    function prepare(array $args = array())
    {
        parent::prepare($args);

        if (common_config('singleuser', 'enabled')) {
            $nickname_arg = User::singleUserNickname();
        } else {
            $nickname_arg = $this->arg('nickname');
        }

        $nickname = common_canonical_nickname($nickname_arg);

        // Permanent redirect on non-canonical nickname

        if ($nickname_arg != $nickname) {
            $args = array('nickname' => $nickname);
            if ($this->arg('page') && $this->arg('page') != 1) {
                $args['page'] = $this->arg['page'];
            }
            common_redirect(common_local_url('peopletagsbyuser', $args), 301);
        }

        $user = User::getKV('nickname', $nickname);

        if (!$user) {
            // TRANS: Client error displayed trying to perform an action related to a non-existing user.
            $this->clientError(_('No such user.'), 404);
        }

        $this->profile = $user->getProfile();

        if (!$this->profile) {
            // TRANS: Error message displayed when referring to a user without a profile.
            $this->serverError(_('User has no profile.'));
        }

        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

        return true;
    }

    function handle()
    {
        parent::handle();
        $this->showPage();
    }

    function showAnonymousMessage()
    {
        $notice =
          // TRANS: Message displayed for anonymous users on page that displays lists subscribed to by a user.
          // TRANS: This message contains Markdown links in the form [description](links).
          // TRANS: %s is a profile nickname.
          sprintf(_('These are lists subscribed to by **%s**. ' .
                    'Lists are how you sort similar ' .
                    'people on %%%%site.name%%%%, a [micro-blogging]' .
                    '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
                    'based on the Free Software [StatusNet](http://status.net/) tool. ' .
                    'You can easily keep track of what they ' .
                    'are doing by subscribing to the list\'s timeline.' ), $this->profile->nickname);
        $this->elementStart('div', array('id' => 'anon_notice'));
        $this->raw(common_markup_to_html($notice));
        $this->elementEnd('div');
    }

    function showContent()
    {
        $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
        $limit  = PEOPLETAGS_PER_PAGE + 1;

        $ptags = $this->profile->getTagSubscriptions($offset, $limit);

        $pl = new PeopletagList($ptags, $this);
        $cnt = $pl->show();

        $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
                          $this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id));
    }

    function showObjectNav()
    {
        $nav = new PeopletagNav($this, $this->profile);
        $nav->show();
    }

    function showProfileBlock()
    {
        $block = new AccountProfileBlock($this, $this->profile);
        $block->show();
    }

    function showSections()
    {
        #TODO: tags with most subscribers
        #TODO: tags with most "members"
    }
}


code:
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social.  If not, see <http://www.gnu.org/licenses/>.

defined('STATUSNET') || die();

require_once INSTALLDIR . '/lib/util/deletetree.php';

/**
 * Form for deleting a plugin
 *
 * @category  Action
 * @package   GNUsocial
 * @author    Diogo Cordeiro <diogo@fc.up.pt>
 * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
 * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
 */
class PlugindeleteAction extends Action
{
    var $user;
    var $plugin;

    /**
     * Check pre-requisites and instantiate attributes
     *
     * @param array $args array of arguments (URL, GET, POST)
     *
     * @return bool success flag
     * @throws ClientException
     */
    function prepare(array $args = [])
    {
        parent::prepare($args);

        // @fixme these are pretty common, should a parent class factor these out?

        // Only allow POST requests

        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
            // TRANS: Client error displayed when trying to use another method than POST.
            // TRANS: Do not translate POST.
            $this->clientError(_m('This action only accepts POST requests.'));
        }

        // CSRF protection

        $token = $this->trimmed('token');

        if (!$token || $token != common_session_token()) {
            // TRANS: Client error displayed when the session token does not match or is not given.
            $this->clientError(_m('There was a problem with your session token.'.
                ' Try again, please.'));
        }

        // Only for logged-in users

        $this->user = common_current_user();

        if (empty($this->user)) {
            // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
            $this->clientError(_m('Not logged in.'));
        }

        if (!AdminPanelAction::canAdmin('plugins')) {
            // TRANS: Client error displayed when trying to enable or disable a plugin without access rights.
            $this->clientError(_m('You cannot administer plugins.'));
        }

        $this->plugin = $this->arg('plugin');
        if (!array_key_exists($this->plugin, array_flip(PluginList::grabAllPluginNames()))) {
            // TRANS: Client error displayed when trying to enable or disable a non-existing plugin.
            $this->clientError(_m('No such plugin.'));
        }

        return true;
    }

    /**
     * Handle request
     *
     * Does the subscription and returns results.
     *
     * @return void
     * @throws ClientException
     */
    function handle()
    {
        if (PluginList::isPluginLoaded($this->plugin)) {
            $this->clientError(_m('You can\'t delete a plugin without first removing its loader from your config.php.'));
        }
        if (!is_writable(INSTALLDIR . '/local/plugins/'.$this->plugin)) {
            $this->clientError(_m('We can only delete third party plugins.'));
        }
        deleteTree(INSTALLDIR . '/local/plugins/'.$this->plugin);
        deleteTree(PUBLICDIR . '/local/plugins/'.$this->plugin);

        $url = common_local_url('pluginsadminpanel');
        common_redirect($url, 303);
    }

}


code:
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social.  If not, see <http://www.gnu.org/licenses/>.

defined('STATUSNET') || die();

/**
 * Plugin enable action.
 *
 * (Re)-enables a plugin from the default plugins list.
 *
 * Takes parameters:
 *
 *    - plugin: plugin name
 *    - token: session token to prevent CSRF attacks
 *    - ajax: boolean; whether to return Ajax or full-browser results
 *
 * Only works if the current user is logged in.
 *
 * @category  Action
 * @package   StatusNet
 * @author    Brion Vibber <brion@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
 * @link      http://status.net/
 */
class PlugindisableAction extends PluginenableAction
{
    /**
     * Handle request
     *
     * Disables the plugin and returns results.
     *
     * @return void
     * @throws ClientException
     */
    function handle()
    {
        if (PluginList::isPluginLoaded($this->plugin)) {
            $config_file = INSTALLDIR . DIRECTORY_SEPARATOR . 'config.php';
            $config_lines = file($config_file, FILE_IGNORE_NEW_LINES);
            foreach($config_lines as $key => $line) {
                // We are doing it this way to avoid deleting things we shouldn't
                $line = str_replace('addPlugin(\''.$this->plugin.'\');', '', $line);
                $config_lines[$key] = $line;
                if($line === ' // Added by sysadmin\'s Plugin UI.') {
                    unset($config_lines[$key]);
                }
            }
            $new_config_data = implode(PHP_EOL, $config_lines);
            if (!file_put_contents($config_file, $new_config_data)) {
                $this->clientError(_m('No permissions for writing to config.php'));
            }
        }
        $key = 'disable-' . $this->plugin;
        Config::save('plugins', $key, $this->overrideValue());

        // @fixme this is a pretty common pattern and should be refactored down
        if ($this->boolean('ajax')) {
            $this->startHTML('text/xml;charset=utf-8');
            $this->elementStart('head');
            $this->element('title', null, $this->successShortTitle());
            $this->elementEnd('head');
            $this->elementStart('body');
            $form = $this->successNextForm();
            $form->show();
            $this->elementEnd('body');
            $this->endHTML();
        } else {
            $url = common_local_url('pluginsadminpanel');
            common_redirect($url, 303);
        }
    }

    /**
     * Value to save into $config['plugins']['disable-<name>']
     */
    protected function overrideValue()
    {
        return 1;
    }

    protected function successShortTitle()
    {
        // TRANS: Page title for AJAX form return when a disabling a plugin.
        return _m('plugin', 'Disabled');
    }

    protected function successNextForm()
    {
        return new PluginEnableForm($this, $this->plugin);
    }
}