]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Add config option for RequireValidatedEmail plugin to skip the check for folks with...
[quix0rs-gnu-social.git] / lib / router.php
index c0ddc8db3874c0ee31687bffd30573c420d11d19..a9d07276f3cab33284dc97547a52f375da143827 100644 (file)
@@ -33,6 +33,33 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
 
 require_once 'Net/URL/Mapper.php';
 
+class StatusNet_URL_Mapper extends Net_URL_Mapper {
+
+    private static $_singleton = null;
+
+    private function __construct()
+    {
+    }
+
+    public static function getInstance($id = '__default__')
+    {
+        if (empty(self::$_singleton)) {
+            self::$_singleton = new StatusNet_URL_Mapper();
+        }
+        return self::$_singleton;
+    }
+
+    public function connect($path, $defaults = array(), $rules = array())
+    {
+        $result = null;
+        if (Event::handle('StartConnectPath', array(&$path, &$defaults, &$rules, &$result))) {
+            $result = parent::connect($path, $defaults, $rules);
+            Event::handle('EndConnectPath', array($path, $defaults, $rules, $result));
+        }
+        return $result;
+    }
+}
+
 /**
  * URL Router
  *
@@ -69,10 +96,12 @@ class Router
 
     function initialize()
     {
-        $m = Net_URL_Mapper::getInstance();
+        $m = StatusNet_URL_Mapper::getInstance();
 
         if (Event::handle('StartInitializeRouter', array(&$m))) {
 
+            $m->connect('robots.txt', array('action' => 'robotstxt'));
+
             $m->connect('opensearch/people', array('action' => 'opensearch',
                                                    'type' => 'people'));
             $m->connect('opensearch/notice', array('action' => 'opensearch',
@@ -96,6 +125,7 @@ class Router
                           'groupblock', 'groupunblock',
                           'sandbox', 'unsandbox',
                           'silence', 'unsilence',
+                          'grantrole', 'revokerole',
                           'repeat',
                           'deleteuser',
                           'geocode',
@@ -150,6 +180,10 @@ class Router
                 array('action' => 'editapplication'),
                 array('id' => '[0-9]+')
             );
+            $m->connect('settings/oauthapps/delete/:id',
+                array('action' => 'deleteapplication'),
+                array('id' => '[0-9]+')
+            );
 
             // search
 
@@ -241,6 +275,9 @@ class Router
                 $m->connect('group/:nickname/'.$v,
                             array('action' => $v.'group'),
                             array('nickname' => '[a-zA-Z0-9]+'));
+                $m->connect('group/:id/id/'.$v,
+                            array('action' => $v.'group'),
+                            array('id' => '[0-9]+'));
             }
 
             foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
@@ -618,6 +655,12 @@ class Router
                         array('action' => 'ApiTimelineTag',
                               'format' => '(xmljson|rss|atom)'));
 
+            // media related
+            $m->connect(
+                'api/statusnet/media/upload',
+                array('action' => 'ApiMediaUpload')
+            );
+
             // search
             $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
             $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
@@ -637,7 +680,11 @@ class Router
             $m->connect('admin/site', array('action' => 'siteadminpanel'));
             $m->connect('admin/design', array('action' => 'designadminpanel'));
             $m->connect('admin/user', array('action' => 'useradminpanel'));
+               $m->connect('admin/access', array('action' => 'accessadminpanel'));
             $m->connect('admin/paths', array('action' => 'pathsadminpanel'));
+            $m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
+            $m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
+            $m->connect('admin/snapshot', array('action' => 'snapshotadminpanel'));
 
             $m->connect('getfile/:filename',
                         array('action' => 'getfile'),
@@ -647,11 +694,20 @@ class Router
 
             if (common_config('singleuser', 'enabled')) {
 
-                $nickname = common_config('singleuser', 'nickname');
+                $user = User::siteOwner();
+
+                if (!empty($user)) {
+                    $nickname = $user->nickname;
+                } else {
+                    $nickname = common_config('singleuser', 'nickname');
+                    if (empty($nickname)) {
+                        throw new ServerException(_("No single user defined for single-user mode."));
+                    }
+                }
 
                 foreach (array('subscriptions', 'subscribers',
                                'all', 'foaf', 'xrds',
-                               'replies', 'microsummary') as $a) {
+                               'replies', 'microsummary', 'hcard') as $a) {
                     $m->connect($a,
                                 array('action' => $a,
                                       'nickname' => $nickname));
@@ -695,6 +751,10 @@ class Router
                                   'nickname' => $nickname),
                             array('tag' => '[a-zA-Z0-9]+'));
 
+                $m->connect('rsd.xml',
+                            array('action' => 'rsd',
+                                  'nickname' => $nickname));
+
                 $m->connect('',
                             array('action' => 'showstream',
                                   'nickname' => $nickname));
@@ -709,10 +769,11 @@ class Router
                 $m->connect('featured', array('action' => 'featured'));
                 $m->connect('favorited/', array('action' => 'favorited'));
                 $m->connect('favorited', array('action' => 'favorited'));
+                $m->connect('rsd.xml', array('action' => 'rsd'));
 
                 foreach (array('subscriptions', 'subscribers',
                                'nudge', 'all', 'foaf', 'xrds',
-                               'replies', 'inbox', 'outbox', 'microsummary') as $a) {
+                               'replies', 'inbox', 'outbox', 'microsummary', 'hcard') as $a) {
                     $m->connect(':nickname/'.$a,
                                 array('action' => $a),
                                 array('nickname' => '[a-zA-Z0-9]{1,64}'));
@@ -756,6 +817,10 @@ class Router
                             array('nickname' => '[a-zA-Z0-9]{1,64}'),
                             array('tag' => '[a-zA-Z0-9]+'));
 
+                $m->connect(':nickname/rsd.xml',
+                            array('action' => 'rsd'),
+                            array('nickname' => '[a-zA-Z0-9]{1,64}'));
+
                 $m->connect(':nickname',
                             array('action' => 'showstream'),
                             array('nickname' => '[a-zA-Z0-9]{1,64}'));