code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Primary nav, show on all pages
 *
 * 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  Menu
 * @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('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Primary, top-level menu
 *
 * @category  General
 * @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 PrimaryNav extends Menu
{
    function show()
    {
        $user = common_current_user();
        $this->action->elementStart('ul', array('class' => 'nav'));
        if (Event::handle('StartPrimaryNav', array($this->action))) {
            if (!empty($user)) {
                $this->action->menuItem(common_local_url('profilesettings'),
                                // TRANS: Menu item in primary navigation panel.
                                _m('MENU','Settings'),
                                // TRANS: Menu item title in primary navigation panel.
                                _('Change your personal settings.'),
                                false,
                                'nav_account');
                if ($user->hasRight(Right::CONFIGURESITE)) {
                    $this->action->menuItem(common_local_url('siteadminpanel'),
                                    // TRANS: Menu item in primary navigation panel.
                                    _m('MENU','Admin'),
                                    // TRANS: Menu item title in primary navigation panel.
                                    _('Site configuration.'),
                                    false,
                                    'nav_admin');
                }
                $this->action->menuItem(common_local_url('logout'),
                                // TRANS: Menu item in primary navigation panel.
                                _m('MENU','Logout'),
                                // TRANS: Menu item title in primary navigation panel.
                                _('Logout from the site.'),
                                false,
                                'nav_logout');
            } else {
                $this->action->menuItem(common_local_url('login'),
                                // TRANS: Menu item in primary navigation panel.
                                _m('MENU','Login'),
                                // TRANS: Menu item title in primary navigation panel.
                                _('Login to the site.'),
                                false,
                                'nav_login');
            }

            Event::handle('EndPrimaryNav', array($this->action));
        }

        $this->action->elementEnd('ul');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Secondary menu, shown at foot of all pages
 *
 * 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  Cache
 * @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('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Secondary menu, shown at the bottom of all pages
 *
 * @category  General
 * @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 SecondaryNav extends Menu
{
    function show()
    {
        $this->out->elementStart('ul', array('class' => 'nav',
                                             'id' => 'site_nav_global_secondary'));
        if (Event::handle('StartSecondaryNav', array($this->action))) {
            $this->out->menuItem(common_local_url('doc', array('title' => 'help')),
                                 // TRANS: Secondary navigation menu item leading to help on StatusNet.
                                 _m('MENU','Help'));
            $this->out->menuItem(common_local_url('doc', array('title' => 'about')),
                                 // TRANS: Secondary navigation menu item leading to text about StatusNet site.
                                 _m('MENU','About'));
            $this->out->menuItem(common_local_url('doc', array('title' => 'faq')),
                                 // TRANS: Secondary navigation menu item leading to Frequently Asked Questions.
                                 _m('MENU','FAQ'));
            $bb = common_config('site', 'broughtby');
            if (!empty($bb)) {
                $this->out->menuItem(common_local_url('doc', array('title' => 'tos')),
                                     // TRANS: Secondary navigation menu item leading to Terms of Service.
                                     _m('MENU','TOS'));
            }
            $this->out->menuItem(common_local_url('doc', array('title' => 'privacy')),
                                 // TRANS: Secondary navigation menu item leading to privacy policy.
                                 _m('MENU','Privacy'));
            $this->out->menuItem(common_local_url('doc', array('title' => 'source')),
                                 // TRANS: Secondary navigation menu item. Leads to information about StatusNet and its license.
                                 _m('MENU','Source'));
            $this->out->menuItem(common_local_url('version'),
                                 // TRANS: Secondary navigation menu item leading to version information on the StatusNet site.
                                 _m('MENU','Version'));
            $this->out->menuItem(common_local_url('doc', array('title' => 'contact')),
                                 // TRANS: Secondary navigation menu item leading to e-mail contact information on the
                                 // TRANS: StatusNet site, where to report bugs, ...
                                 _m('MENU','Contact'));
            Event::handle('EndSecondaryNav', array($this->action));
        }
        $this->out->elementEnd('ul');
    }
}

repo_name: suraj/sloth

license: mit


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Base class for sections (sidebar widgets)
 *
 * 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  Widget
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @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('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }

/**
 * Base class for sections
 *
 * These are the widgets that show interesting data about a person
 * group, or site.
 *
 * @category Widget
 * @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/
 */
abstract class Section extends Widget
{
    /**
     * Show the form
     *
     * Uses a recipe to output the form.
     *
     * @return void
     * @see Widget::show()
     */
    function show()
    {
        $this->out->elementStart('div',
                                 array('id' => $this->divId(),
                                       'class' => 'section'));

        $this->showTitle();

        $have_more = $this->showContent();

        if ($have_more) {
            $this->showMore();
        }

        $this->out->elementEnd('div');
    }

    function showTitle()
    {
        $link = $this->link();
        if (!empty($link)) {
            $this->out->elementStart('h2');
            $this->out->element('a', array('href' => $link), $this->title());
            $this->out->elementEnd('h2');
        } else {
            $this->out->element('h2', null,
                                $this->title());
        }
    }

    function showMore()
    {
        $this->out->elementStart('p');
        $this->out->element('a', array('href' => $this->moreUrl(),
                                       'class' => 'more'),
                            $this->moreTitle());
        $this->out->elementEnd('p');
    }

    abstract public function divId();

    function title()
    {
        // TRANS: Default title for section/sidebar widget.
        return _('Untitled section');
    }

    function link()
    {
        return null;
    }

    function showContent()
    {
        $this->out->element('p', null,
                            // TRANS: Default content for section/sidebar widget.
                            _('(None)'));
        return false;
    }

    function moreUrl()
    {
        return null;
    }

    function moreTitle()
    {
        // TRANS: Default "More..." title for section/sidebar widget.
        return _('More...');
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * widget for displaying a list of notices
 *
 * 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  UI
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
 * @copyright 2008 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') && !defined('STATUSNET')) { exit(1); }

/**
 * widget for displaying a list of notices in the primary content area
 *
 * @category UI
 * @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/
 * @see      Notice
 * @see      NoticeListItem
 * @see      ProfileNoticeList
 */
class SectionNoticeList extends NoticeList
{
    protected $addressees = false;
    protected $attachments = false;
    protected $maxchars = 140;
    protected $options = false;
    protected $show_n = NOTICES_PER_SECTION;
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Tags for a profile
 *
 * 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  Action
 * @package   StatusNet
 * @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); }

class SelftagsWidget extends PeopletagsWidget
{
    public function url()
    {
        // link to self tag page
        return common_local_url('selftag', array('tag' => $this->tag->tag));
    }

    function label()
    {
        // TRANS: Label in self tags widget.
        return _m('LABEL','Tags');
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Base class for settings actions
 *
 * 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>
 * @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('GNUSOCIAL')) { exit(1); }

/**
 * Base class for settings group of actions
 *
 * @category Settings
 * @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/
 *
 * @see      Widget
 */

class SettingsAction extends FormAction
{
    /**
     * Show the local navigation menu
     *
     * This is the same for all settings, so we show it here.
     *
     * @return void
     */

    function showLocalNav()
    {
        $menu = new SettingsNav($this);
        $menu->show();
    }

    /**
     * Show notice form.
     *
     * @return nothing
     */

    function showNoticeForm()
    {
        return;
    }

    function showProfileBlock()
    {
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2010,2011, StatusNet, Inc.
 *
 * Settings menu
 *
 * 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  Widget
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2010,2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * A widget for showing the settings group local nav menu
 *
 * @category Widget
 * @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/
 *
 * @see      HTMLOutputter
 */
class SettingsNav extends Menu
{
    /**
     * Show the menu
     *
     * @return void
     */
    function show()
    {
        $actionName = $this->action->trimmed('action');
        $user = common_current_user();
        $nickname = $user->nickname;
        $name = $user->getProfile()->getBestName();

        $stub = new HomeStubNav($this->action);
        $this->submenu(_m('MENU','Home'), $stub);

        $this->action->elementStart('ul');
        $this->action->elementStart('li');
        // TRANS: Header in settings navigation panel.
        $this->action->element('h3', null, _m('HEADER','Settings'));
        $this->action->elementStart('ul', array('class' => 'nav'));

        if (Event::handle('StartAccountSettingsNav', array(&$this->action))) {
            $this->action->menuItem(common_local_url('profilesettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','Profile'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('Change your profile settings'),
                                    $actionName == 'profilesettings');

            $this->action->menuItem(common_local_url('avatarsettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','Avatar'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('Upload an avatar'),
                                    $actionName == 'avatarsettings');

            $this->action->menuItem(common_local_url('passwordsettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','Password'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('Change your password'),
                                    $actionName == 'passwordsettings');

            $this->action->menuItem(common_local_url('emailsettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','Email'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('Change email handling'),
                                    $actionName == 'emailsettings');

            $this->action->menuItem(common_local_url('urlsettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','URL'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('URL shorteners'),
                                    $actionName == 'urlsettings');

            Event::handle('EndAccountSettingsNav', array(&$this->action));

            $haveImPlugin = false;

            Event::handle('HaveImPlugin', array(&$haveImPlugin));

            if ($haveImPlugin) {
                $this->action->menuItem(common_local_url('imsettings'),
                                        // TRANS: Menu item in settings navigation panel.
                                        _m('MENU','IM'),
                                        // TRANS: Menu item title in settings navigation panel.
                                        _('Updates by instant messenger (IM)'),
                                        $actionName == 'imsettings');
            }

            if (common_config('sms', 'enabled')) {
                $this->action->menuItem(common_local_url('smssettings'),
                                        // TRANS: Menu item in settings navigation panel.
                                        _m('MENU','SMS'),
                                        // TRANS: Menu item title in settings navigation panel.
                                        _('Updates by SMS'),
                                        $actionName == 'smssettings');
            }

            $this->action->menuItem(common_local_url('oauthconnectionssettings'),
                                    // TRANS: Menu item in settings navigation panel.
                                    _m('MENU','Connections'),
                                    // TRANS: Menu item title in settings navigation panel.
                                    _('Authorized connected applications'),
                                    $actionName == 'oauthconnectionsettings');

            if (common_config('oldschool', 'enabled')) {
                $this->action->menuItem(common_local_url('oldschoolsettings'),
                                        // TRANS: Menu item in settings navigation panel.
                                        _m('MENU','Old school'),
                                        // TRANS: Menu item title in settings navigation panel.
                                        _('UI tweaks for old-school users'),
                                        $actionName == 'oldschoolsettings');
            }

            Event::handle('EndConnectSettingsNav', array(&$this->action));
        }

        $this->action->elementEnd('ul');
        $this->action->elementEnd('li');
        $this->action->elementEnd('ul');
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * A site profile is a set of default settings for a particular style of
 * StatusNet site: public, private, community, etc.
 *
 * 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  Installation
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 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('GNUSOCIAL')) {
    exit(1);
}

/**
 * Helper class for getting the settings for a particular site profile
 */
class SiteProfile
{
    /**
     * Returns the config settings for a site profile by name
     *
     * @param  string $name name of a site profile
     * @return array  config settings
     */
    static public function getSettings($name)
    {
        $sprofileClass = ucfirst($name) . "Site";

        if (class_exists($sprofileClass)) {
            return call_user_func(array($sprofileClass, 'getSettings'));
        } else {
            common_log(
                LOG_ERR,
                "Unknown site profile '{$name}' specified in config file.",
                __FILE__
            );
            return array();
        }
    }
}

/**
 * Site profile settings contain the list of the default settings (and
 * possibly other information for a particular flavor of StatusNet
 * installation). These will overwrite base defaults in $config global.
 *
 * @category Installation
 * @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/
 */
abstract class SiteProfileSettings
{
    static function getSettings()
    {
        throw new MethodNotImplementedException(__METHOD__);
    }

    static function corePlugins() {
        return common_config('plugins', 'core');
    }
    static function defaultPlugins() {
        return common_config('plugins', 'default');
    }
}

/**
 * Settings for a 'public' site
 */
class PublicSite extends SiteProfileSettings
{
    /**
     * Get the settings for this site profile
     *
     * @return type array   an array of settings
     */
    static function getSettings() {
        global $config;
        return array(
            // We only want to change these values, not replace entire 'site' array
            'site' => array_merge(
                $config['site'], array(
                    'inviteonly' => false,
                    'private'    => false,
                    'closed'     => false
                )
            ),
            'plugins' => array(
                'core'    => self::corePlugins(),
                'default' => array_merge(self::defaultPlugins(), array(
                    'RegisterThrottle'        => array(),
                ))
            ),
            'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
        );
    }
}

/**
 * Settings for a 'private' site
 *
 * // XXX Too business oriented?
 */
class PrivateSite extends SiteProfileSettings
{
    /**
     * Get the settings for this site profile
     *
     * @return type array  an array of settings
     */
    static function getSettings() {
        global $config;
        return array(
            // We only want to change these values, not replace entire 'site' array
            'site' => array_merge(
                $config['site'], array(
                    'inviteonly' => true,
                    'private'    => true,
                )
            ),
            'plugins' => array(
                'core'    => self::corePlugins(),
                'default' => array_merge(self::defaultPlugins(), array(
                    'ExtendedProfile'         => array(),
                    'EmailRegistration'       => array(),
                    'MobileProfile'           => array(),
                )),
                'disable-OStatus' => 1,
                'disable-WebFinger' => 1,
             ),
            'public'        => array('localonly' => true),
            'profile'       => array('delete' => 'true'),
            'license'       => array('type'   => 'private'),
            'attachments'   => array(
                // Only allow uploads of pictures and MS Office files
                'supported' => array(
                    'image/png',
                    'image/jpeg',
                    'image/gif',
                    'image/svg+xml',
                    'application/pdf',
                    'application/msword',
                    'application/vnd.ms-office',
                    'application/vnd.ms-excel',
                    'application/vnd.ms-powerpoint',
                    'application/ogg'
                )
             ),
            'discovery' => array('cors'   => false) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
        );
    }
}

/**
 * Settings for a 'community' site
 */
class CommunitySite extends SiteProfileSettings
{
    /**
     * Get the settings for this site profile
     *
     * @return type array  an array of settings
     */
    static function getSettings() {
        global $config;
        return array(
            // We only want to change these values, not replace entire 'site' array
            'site' => array_merge(
                $config['site'], array(
                    'private'    => false,
                    'inviteonly' => true,
                    'closed'     => false
                )
            ),
            'plugins' => array(
                'core'    => self::corePlugins(),
                'default' => array_merge(self::defaultPlugins(), array(
                ))
            ),
            'public'    => array('localonly' => true),
            'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
        );
    }

}

/**
 * Settings for a 'singleuser' site
 */
class SingleuserSite extends SiteProfileSettings
{
    /**
     * Get the settings for this site profile
     *
     * @return type array  an array of settings
     */
    static function getSettings() {
        global $config;
        return array(
            'singleuser' => array('enabled' => true),
            // We only want to change these values, not replace entire 'site' array
            'site' => array_merge(
                $config['site'], array(
                    'private'    => false,
                    'closed'     => true,
                    'localonly'  => true,
                )
            ),
            'plugins' => array(
                'core'    => self::corePlugins(),
                'default' => array_merge(self::defaultPlugins(), array(
                    'MobileProfile'           => array(),
                )),
                'disable-Directory' => 1,
            ),
            'public'    => array('localonly' => true),
            'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
        );
    }

}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Local navigation for subscriptions group of pages
 *
 * 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  Subs
 * @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/ui/widget.php';

/**
 * Local nav menu for subscriptions, subscribers
 *
 * @category Subs
 * @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 SubGroupNav extends Menu
{
    var $user = null;

    /**
     * Construction
     *
     * @param Action $action current action, used for output
     * @param User   $user   Current user or NULL if "guest"
     */
    function __construct(Action $action=null, User $user=null)
    {
        parent::__construct($action);
        $this->user = $user;
    }

    /**
     * Show the menu
     *
     * @return void
     */
    function show()
    {
        $cur = common_current_user();
        $action = $this->action->trimmed('action');

        $this->out->elementStart('ul', array('class' => 'nav'));

        if (Event::handle('StartSubGroupNav', array($this))) {

            $this->out->menuItem(common_local_url('showstream', array('nickname' =>
                                                                      $this->user->nickname)),
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Profile'),
                                 (empty($profile)) ? $this->user->nickname : $profile->getBestName(),
                                 $action == 'showstream',
                                 'nav_profile');
            $this->out->menuItem(common_local_url('subscriptions',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Subscriptions'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('People %s subscribes to.'),
                                         $this->user->nickname),
                                 $action == 'subscriptions',
                                 'nav_subscriptions');
            $this->out->menuItem(common_local_url('subscribers',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Subscribers'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('People subscribed to %s.'),
                                         $this->user->nickname),
                                 $action == 'subscribers',
                                 'nav_subscribers');
            if ($cur && $cur->id == $this->user->id) {
                // Possibly site admins should be able to get in here too
                $pending = $this->countPendingSubs();
                if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) {
                    $this->out->menuItem(common_local_url('subqueue',
                                                          array('nickname' =>
                                                                $this->user->nickname)),
                                         // TRANS: Menu item in local navigation menu.
                                         // TRANS: %d is the number of pending subscription requests.
                                         sprintf(_m('MENU','Pending (%d)'), $pending),
                                         // TRANS: Menu item title in local navigation menu.
                                         sprintf(_('Approve pending subscription requests.'),
                                                 $this->user->nickname),
                                         $action == 'subqueueaction',
                                         'nav_subscribers');
                }
            }
            $this->out->menuItem(common_local_url('usergroups',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
                                 // TRANS: Menu item in local navigation menu.
                                 _m('MENU','Groups'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('Groups %s is a member of.'),
                                         $this->user->nickname),
                                 $action == 'usergroups',
                                 'nav_usergroups');
            $this->out->menuItem(common_local_url('peopletagsubscriptions',
                                                  array('nickname' =>
                                                        $this->user->nickname)),
                                 // TRANS: Menu item title in local navigation menu.
                                 _m('MENU','Lists'),
                                 // TRANS: Menu item title in local navigation menu.
                                 // TRANS: %s is a user nickname.
                                 sprintf(_('List subscriptions by %s.'),
                                         $this->user->nickname),
                                 in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')),
                                 'nav_timeline_peopletags');

            if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
                $this->out->menuItem(common_local_url('invite'),
                                     // TRANS: Menu item in local navigation menu.
                                     _m('MENU','Invite'),
                                     // TRANS: Menu item title in local navigation menu.
                                     // TRANS: %s is the StatusNet sitename.
                                     sprintf(_('Invite friends and colleagues to join you on %s.'),
                                             common_config('site', 'name')),
                                     $action == 'invite',
                                     'nav_invite');
            }

            Event::handle('EndSubGroupNav', array($this));
        }

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

    function countPendingSubs()
    {
        $req = new Subscription_queue();
        $req->subscribed = $this->user->id;
        return $req->count();
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Utilities for theme files and paths
 *
 * 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  Paths
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@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') && !defined('LACONICA')) {
    exit(1);
}

/**
 * Class for querying and manipulating a theme
 *
 * Themes are directories with some expected sub-directories and files
 * in them. They're found in either local/theme (for locally-installed themes)
 * or theme/ subdir of installation dir.
 *
 * Note that the 'local' directory can be overridden as $config['local']['path']
 * and $config['local']['dir'] etc.
 *
 * This used to be a couple of functions, but for various reasons it's nice
 * to have a class instead.
 *
 * @category Output
 * @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 Theme
{
    const FALLBACK = 'neo';

    var $name = null;
    var $dir  = null;
    var $path = null;
    protected $metadata = null; // access via getMetadata() lazy-loader
    protected $externals = null;
    protected $deps = null;

    /**
     * Constructor
     *
     * Determines the proper directory and path for this theme.
     *
     * @param string $name Name of the theme; defaults to config value
     * @throws ServerException
     */
    function __construct($name = null)
    {
        if (empty($name)) {
            $name = common_config('site', 'theme');
        }
        if (!self::validName($name)) {
            // TRANS: Server exception displayed if a theme name was invalid.
            throw new ServerException(_('Invalid theme name.'));
        }
        $this->name = $name;

        // Check to see if it's in the local dir

        $localroot = self::localRoot();

        $fulldir = $localroot.'/'.$name;

        if (file_exists($fulldir) && is_dir($fulldir)) {
            $this->dir  = $fulldir;
            $this->path = $this->relativeThemePath('local', 'local', 'theme/' . $name);
            return;
        }

        // Check to see if it's in the distribution dir

        $instroot = self::installRoot();

        $fulldir = $instroot.'/'.$name;

        if (file_exists($fulldir) && is_dir($fulldir)) {
            $this->dir = $fulldir;
            $this->path = $this->relativeThemePath('theme', 'theme', $name);
            return;
        }

        // Ruh roh. Fall back to default, then.

        common_log(LOG_WARNING, sprintf("Unable to find theme '%s', falling back to default theme '%s'",
                                        $name,
                                        Theme::FALLBACK));

        $this->name = Theme::FALLBACK;
        $this->dir  = $instroot.'/'.Theme::FALLBACK;
        $this->path = $this->relativeThemePath('theme', 'theme', Theme::FALLBACK);

    }

    /**
     * Build a full URL to the given theme's base directory, possibly
     * using an offsite theme server path.
     *
     * @param string $group configuration section name to pull paths from
     * @param string $fallbackSubdir default subdirectory under PUBLICDIR
     * @param string $name theme name
     *
     * @return string URL
     *
     * @todo consolidate code with that for other customizable paths
     */
    protected function relativeThemePath($group, $fallbackSubdir, $name)
    {
        if (GNUsocial::isHTTPS()) {
            $sslserver = common_config($group, 'sslserver');

            if (empty($sslserver)) {
                if (is_string(common_config('site', 'sslserver')) &&
                    mb_strlen(common_config('site', 'sslserver')) > 0) {
                    $server = common_config('site', 'sslserver');
                } else if (common_config('site', 'server')) {
                    $server = common_config('site', 'server');
                }
                $path   = common_config('site', 'path') . '/';
                if ($fallbackSubdir) {
                    $path .= $fallbackSubdir . '/';
                }
            } else {
                $server = $sslserver;
                $path   = common_config($group, 'sslpath');
                if (empty($path)) {
                    $path = common_config($group, 'path');
                }
            }

            $protocol = 'https';
        } else {
            $path = common_config($group, 'path');

            if (empty($path)) {
                $path = common_config('site', 'path') . '/';
                if ($fallbackSubdir) {
                    $path .= $fallbackSubdir . '/';
                }
            }

            $server = common_config($group, 'server');

            if (empty($server)) {
                $server = common_config('site', 'server');
            }

            $protocol = 'http';
        }

        if ($path[strlen($path)-1] != '/') {
            $path .= '/';
        }

        if ($path[0] != '/') {
            $path = '/'.$path;
        }

        return $protocol.'://'.$server.$path.$name;
    }

    /**
     * Gets the full local filename of a file in this theme.
     *
     * @param string $relative relative name, like 'logo.png'
     *
     * @return string full pathname, like /var/www/mublog/theme/default/logo.png
     */
    function getFile($relative)
    {
        return $this->dir.'/'.$relative;
    }

    /**
     * Gets the full HTTP url of a file in this theme
     *
     * @param string $relative relative name, like 'logo.png'
     *
     * @return string full URL, like 'http://example.com/theme/default/logo.png'
     */
    function getPath($relative)
    {
        return $this->path.'/'.$relative;
    }

    /**
     * Fetch a list of other themes whose CSS needs to be pulled in before
     * this theme's, based on following the theme.ini 'include' settings.
     * (May be empty if this theme has no include dependencies.)
     *
     * @return array of strings with theme names
     */
    function getDeps()
    {
        if ($this->deps === null) {
            $chain = $this->doGetDeps(array($this->name));
            array_pop($chain); // Drop us back off
            $this->deps = $chain;
        }
        return $this->deps;
    }

    protected function doGetDeps($chain)
    {
        $data = $this->getMetadata();
        if (!empty($data['include'])) {
            $include = $data['include'];

            // Protect against cycles!
            if (!in_array($include, $chain)) {
                try {
                    $theme = new Theme($include);
                    array_unshift($chain, $include);
                    return $theme->doGetDeps($chain);
                } catch (Exception $e) {
                    common_log(LOG_ERR,
                            "Exception while fetching theme dependencies " .
                            "for $this->name: " . $e->getMessage());
                }
            }
        }
        return $chain;
    }

    /**
     * Pull data from the theme's theme.ini file.
     * @fixme calling getFile will fall back to default theme, this may be unsafe.
     *
     * @return array associative of strings
     */
    function getMetadata()
    {
        if ($this->metadata == null) {
            $this->metadata = $this->doGetMetadata();
        }
        return $this->metadata;
    }

    /**
     * Pull data from the theme's theme.ini file.
     * @fixme calling getFile will fall back to default theme, this may be unsafe.
     *
     * @return array associative of strings
     */
    private function doGetMetadata()
    {
        $iniFile = $this->getFile('theme.ini');
        if (file_exists($iniFile)) {
            return parse_ini_file($iniFile);
        } else {
            return [];
        }
    }

    /**
     * Get list of any external URLs required by this theme and any
     * dependencies. These are lazy-loaded from theme.ini.
     *
     * @return array of URL strings
     * @throws ServerException
     */
    function getExternals()
    {
        if ($this->externals == null) {
            $data = $this->getMetadata();
            if (!empty($data['external'])) {
                $ext = (array)$data['external'];
            } else {
                $ext = array();
            }

            if (!empty($data['include'])) {
                $theme = new Theme($data['include']);
                $ext = array_merge($ext, $theme->getExternals());
            }

            $this->externals = array_unique($ext);
        }
        return $this->externals;
    }

    /**
     * Gets the full path of a file in a theme dir based on its relative name
     *
     * @param string $relative relative path within the theme directory
     * @param string $name name of the theme; defaults to current theme
     *
     * @return string File path to the theme file
     * @throws ServerException
     */
    static function file($relative, $name=null)
    {
        $theme = new Theme($name);
        return $theme->getFile($relative);
    }

    /**
     * Gets the full URL of a file in a theme dir based on its relative name
     *
     * @param string $relative relative path within the theme directory
     * @param string $name name of the theme; defaults to current theme
     *
     * @return string URL of the file
     * @throws ServerException
     */
    static function path($relative, $name=null)
    {
        $theme = new Theme($name);
        return $theme->getPath($relative);
    }

    /**
     * list available theme names
     *
     * @return array list of available theme names
     */
    static function listAvailable()
    {
        $local   = self::subdirsOf(self::localRoot());
        $install = self::subdirsOf(self::installRoot());

        $i = array_search('base', $install);

        unset($install[$i]);

        return array_merge($local, $install);
    }

    /**
     * Utility for getting subdirs of a directory
     *
     * @param string $dir full path to directory to check
     *
     * @return array relative filenames of subdirs, or empty array
     */
    protected static function subdirsOf($dir)
    {
        $subdirs = array();

        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($filename = readdir($dh)) !== false) {
                    if ($filename != '..' && $filename !== '.' &&
                        is_dir($dir.'/'.$filename)) {
                        $subdirs[] = $filename;
                    }
                }
                closedir($dh);
            }
        }

        return $subdirs;
    }

    /**
     * Local root dir for themes
     *
     * @return string
     */
    protected static function localRoot()
    {
        $basedir = common_config('local', 'dir');

        if (empty($basedir)) {
            $basedir = PUBLICDIR . '/local';
        }

        return $basedir . '/theme';
    }

    /**
     * Root dir for themes that are shipped with GNU social
     *
     * @return string
     */
    protected static function installRoot()
    {
        $instroot = common_config('theme', 'dir');

        if (empty($instroot)) {
            $instroot = PUBLICDIR.'/theme';
        }

        return $instroot;
    }

    static function validName($name)
    {
        return preg_match('/^[a-z0-9][a-z0-9_-]*$/i', $name);
    }
}


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/>.

/**
 * Base class for sections showing lists of people
 *
 * @category  Widget
 * @package   GNUsocial
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2009 StatusNet, Inc.
 * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
 */

defined('GNUSOCIAL') || die();

/**
 * Base class for sections
 *
 * These are the widgets that show interesting data about a person
 * group, or site.
 *
 * @copyright 2009 StatusNet, Inc.
 * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
 */
class TopPostersSection extends ProfileSection
{
    public function getProfiles()
    {
        $limit = PROFILES_PER_SECTION;

        $qry = 'SELECT profile.*, COUNT(*) AS value ' .
            'FROM profile JOIN notice ON profile.id = notice.profile_id ' .
            (common_config('public', 'localonly') ? 'WHERE is_local = 1 ' : '') .
            'GROUP BY profile.id, nickname, fullname, profileurl, homepage, bio, location, profile.created, profile.modified ' .
            'ORDER BY value DESC LIMIT ' . $limit;

        $profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
        return $profile;
    }

    public function title()
    {
        // TRANS: Title for top posters section.
        return _('Top posters');
    }

    public function divId()
    {
        return 'top_posters';
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Widget showing a drop-down of potential addressees
 *
 * 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  Widget
 * @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('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Widget showing a drop-down of potential addressees
 *
 * @category  Widget
 * @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 ToSelector extends Widget
{
    protected $user;
    protected $to;
    protected $id;
    protected $name;
    protected $private;

    /**
     * Constructor
     *
     * @param HTMLOutputter $out  output context
     * @param User          $user Current user
     * @param mixed         $to   Default selection for addressee
     */
    function __construct($out, $user, $to, $private=false, $id='notice_to', $name='notice_to')
    {
        parent::__construct($out);

        $this->user    = $user;
        $this->to      = $to;
        $this->private = $private;
        $this->id      = $id;
        $this->name    = $name;
    }

    /**
     * Constructor
     *
     * @param HTMLOutputter $out  output context
     * @param User          $user Current user
     * @param mixed         $to   Default selection for addressee
     */
    function show()
    {
        $choices = array();
        $default = common_config('site', 'private') ? 'public:site' : 'public:everyone';

        $groups = $this->user->getGroups();

        while ($groups instanceof User_group && $groups->fetch()) {
            $value = 'group:'.$groups->getID();
            if (($this->to instanceof User_group) && $this->to->id == $groups->id) {
                $default = $value;
            }
            $choices[$value] = "!{$groups->getNickname()} [{$groups->getBestName()}]";
        }

        // Add subscribed users to dropdown menu
        $users = $this->user->getSubscribed();
        while ($users->fetch()) {
            $value = 'profile:'.$users->getID();
            try {
                $choices[$value] = substr($users->getAcctUri(), 5) . " [{$users->getBestName()}]";
            } catch (ProfileNoAcctUriException $e) {
                $choices[$value] = "[?@?] " . $e->profile->getBestName();
            }
        }

        if ($this->to instanceof Profile) {
            $value = 'profile:'.$this->to->getID();
            $default = $value;
            try {
                $choices[$value] = substr($this->to->getAcctUri(), 5) . " [{$this->to->getBestName()}]";
            } catch (ProfileNoAcctUriException $e) {
                $choices[$value] = "[?@?] " . $e->profile->getBestName();
            }
        }

        // alphabetical order
        asort($choices);

        // Reverse so we can add entries at the end (can't unshift with a key)
        $choices = array_reverse($choices);

        if (common_config('notice', 'allowprivate')) {
            // TRANS: Option in drop-down of potential addressees.
            // TRANS: %s is a StatusNet sitename.
            $choices['public:site'] = sprintf(_('Everyone at %s'), common_config('site', 'name'));
        }

        if (!common_config('site', 'private')) {
            // TRANS: Option in drop-down of potential addressees.
            $choices['public:everyone'] = _m('SENDTO','Everyone');
        }

        // Return the order
        $choices = array_reverse($choices);

        $this->out->dropdown($this->id,
                             // TRANS: Label for drop-down of potential addressees.
                             _m('LABEL','To:'),
                             $choices,
                             null,
                             false,
                             $default);

        $this->out->elementStart('span', 'checkbox-wrapper');
        if (common_config('notice', 'allowprivate')) {
            $this->out->checkbox('notice_private',
                                 // TRANS: Checkbox label in widget for selecting potential addressees to mark the notice private.
                                 _('Private?'),
                                 $this->private);
        }
        $this->out->elementEnd('span');
    }

    static function fillActivity(Action $action, Activity $act, array &$options)
    {
        if (!$act->context instanceof ActivityContext) {
            $act->context = new ActivityContext();
        }
        self::fillOptions($action, $options);
        if (isset($options['groups'])) {
            foreach ($options['groups'] as $group_id) {
                $group = User_group::getByID($group_id);
                $act->context->attention[$group->getUri()] = $group->getObjectType();
            }
        }
        if (isset($options['replies'])) {
            foreach ($options['replies'] as $profile_uri) {
                $profile = Profile::fromUri($profile_uri);
                $act->context->attention[$profile->getUri()] = $profile->getObjectType();
            }
        }
    }

    static function fillOptions($action, &$options)
    {
        // XXX: make arg name selectable
        $toArg = $action->trimmed('notice_to');
        $private = common_config('notice', 'allowprivate') ? $action->boolean('notice_private') : false;

        if (empty($toArg)) {
            return;
        }

        list($prefix, $value) = explode(':', $toArg);
        switch ($prefix) {
        case 'group':
            $options['groups'] = array($value);
            if ($private) {
                $options['scope'] = Notice::GROUP_SCOPE;
            }
            break;
        case 'profile':
            $profile = Profile::getKV('id', $value);
            $options['replies'] = array($profile->getUri());
            if ($private) {
                $options['scope'] = Notice::ADDRESSEE_SCOPE;
            }
            break;
        case 'public':
            if ($value == 'everyone' && !common_config('site', 'private')) {
                $options['scope'] = 0;
            } else if ($value == 'site') {
                $options['scope'] = Notice::SITE_SCOPE;
            }
            break;
        default:
            // TRANS: Client exception thrown in widget for selecting potential addressees when an invalid fill option was received.
            throw new ClientException(sprintf(_('Unknown to value: "%s".'),$toArg));
            break;
        }
    }
}


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/>.

/**
 * Base class for UI widgets
 *
 * @category  Widget
 * @package   GNUsocial
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
 * @copyright 2009-2019 Free Software Foundation, Inc http://www.fsf.org
 * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
 */

defined('GNUSOCIAL') || die();

/**
 * Base class for UI widgets
 *
 * A widget is a cluster of HTML elements that provide some functionality
 * that's used on different parts of the site. Examples would be profile
 * lists, notice lists, navigation menus (tabsets) and common forms.
 *
 * @category  Widget
 * @package   GNUsocial
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
 * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
 *
 * @see       HTMLOutputter
 */

class Widget
{
    protected $avatarSize = AVATAR_STREAM_SIZE;

    /**
     * Action (HTMLOutputter) to use for output
     */

    public $out = null;

    /**
     * Prepare the widget for use
     *
     * @param Action $out output helper, defaults to null
     * @param array $widgetOpts
     */
    public function __construct(?Action $out = null, array $widgetOpts = [])
    {
        $this->out = $out;
        if (!array_key_exists('scoped', $widgetOpts)) {
            $this->widgetOpts['scoped'] = Profile::current();
        }
        $this->scoped = $this->widgetOpts['scoped'];
    }

    /**
     * Show the widget
     *
     * Emit the HTML for the widget, using the configured outputter.
     *
     * @return void
     */

    public function show()
    {
    }

    /**
     * Get HTMLOutputter
     *
     * Return the HTMLOutputter for the widget.
     *
     * @return HTMLOutputter the output helper
     */

    public function getOut()
    {
        return $this->out;
    }

    /**
     * Delegate output methods to the outputter attribute.
     *
     * @param string $name      Name of the method
     * @param array  $arguments Arguments called
     *
     * @return mixed Return value of the method.
     */
    public function __call($name, $arguments)
    {
        return call_user_func_array(array($this->out, $name), $arguments);
    }

    /**
     * Default avatar size for this widget.
     */
    public function avatarSize()
    {
        return $this->avatarSize;
    }

    protected function showAvatar(Profile $profile, $size=null)
    {
        $avatar_url = $profile->avatarUrl($size ?: $this->avatarSize());
        $this->out->element('img', array('src' => $avatar_url,
                                         'class' => 'avatar u-photo',
                                         'width' => $this->avatarSize(),
                                         'height' => $this->avatarSize(),
                                         'alt' => $profile->getBestName()));
    }
}


code:
<?php
/*
 * 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);
}

class ArrayWrapper
{
    var $_items = null;
    var $_count = 0;
    var $N = 0;
    var $_i = -1;

    function __construct($items)
    {
        $this->_items = $items;
        $this->_count = count($this->_items);
        $this->N = $this->_count;
    }

    function fetch()
    {
        if (!$this->_items) {
            return false;
        }
        $this->_i++;
        if ($this->_i < $this->_count) {
            return true;
        } else {
            return false;
        }
    }

	function fetchAll($k= false, $v = false, $method = false)
	{
		if ($k !== false || $v !== false || $method !== false)
		{
			$item =& $this->_items[$this->_i];
			return $item->fetchAll($k, $v, $method);
		}
		return $this->_items;
	}

    function __set($name, $value)
    {
        $item =& $this->_items[$this->_i];
        $item->$name = $value;
        return $item->$name;
    }

    function __get($name)
    {
        $item =& $this->_items[$this->_i];
        return $item->$name;
    }

    function __isset($name)
    {
        $item =& $this->_items[$this->_i];
        return isset($item->$name);
    }

    function __unset($name)
    {
        $item =& $this->_items[$this->_i];
        unset($item->$name);
    }

    function __call($name, $args)
    {
        $item =& $this->_items[$this->_i];
        if (!is_object($item)) {
            common_log(LOG_ERR, "Invalid entry " . var_export($item, true) . " at index $this->_i of $this->N; calling $name()");
            throw new ServerException("Internal error: bad entry in array wrapper list.");
        }
        return call_user_func_array(array($item, $name), $args);
    }
}


code:
<?php
/*
 * 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/>.
 */

/**
 * PHP 5.3 implementation of function currying, using native closures.
 * On 5.2 and lower we use the fallback implementation in util.php
 *
 * @param callback $fn
 * @param ... any remaining arguments will be appended to call-time params
 * @return callback
 */
function callableLeftCurry($fn) {
    $extra_args = func_get_args();
    array_shift($extra_args);
    return function() use ($fn, $extra_args) {
        $args = func_get_args();
        return call_user_func_array($fn,
            array_merge($args, $extra_args));
    };
}