+ $m->connect(
+ 'groups/:filter',
+ array('action' => 'groupdirectory'),
+ array('filter' => '([0-9a-zA-Z_]{1,64}|0-9)')
+ );
+
+ return true;
+ }
+
+ /**
+ * Hijack the routing (URL -> Action) for the normal directory page
+ * and substitute our group directory action
+ *
+ * @param string $path path to connect
+ * @param array $defaults path defaults
+ * @param array $rules path rules
+ * @param array $result unused
+ *
+ * @return boolean hook return
+ */
+ function onStartConnectPath(&$path, &$defaults, &$rules, &$result)
+ {
+ if (in_array($path, array('group', 'group/', 'groups', 'groups/'))) {
+ $defaults['action'] = 'groupdirectory';
+ $rules = array('filter' => 'all');
+ return true;
+ }
+ return true;
+ }
+
+ /**
+ * Hijack the mapping (Action -> URL) and return the URL to our
+ * group directory page instead of the normal groups page
+ *
+ * @param Action $action action to find a path for
+ * @param array $params parameters to pass to the action
+ * @param string $fragment any url fragement
+ * @param boolean $addSession whether to add session variable
+ * @param string $url resulting URL to local resource
+ *
+ * @return string the local URL
+ */
+ function onEndLocalURL(&$action, &$params, &$fragment, &$addSession, &$url) {
+ if (in_array($action, array('group', 'group/', 'groups', 'groups/'))) {
+ $url = common_local_url('groupdirectory');
+ }