- $group: group that was saved
StartInterpretCommand: Before running a command
-- $cmd: First word in the string, 'foo' in 'foo argument'
+- $cmd: First word in the string, 'foo' in 'foo argument'
- $arg: Argument, if any, like 'argument' in 'foo argument'
- $user: User who issued the command
- &$result: Resulting command; you can set this!
EndInterpretCommand: Before running a command
-- $cmd: First word in the string, 'foo' in 'foo argument'
+- $cmd: First word in the string, 'foo' in 'foo argument'
- $arg: Argument, if any, like 'argument' in 'foo argument'
- $user: User who issued the command
- $result: Resulting command
StartGroupProfileElements: Start showing stuff about the group on its profile page
- $action: action being executed (for output and params)
- $group: group for the page
-
+
EndGroupProfileElements: Start showing stuff about the group on its profile page
- $action: action being executed (for output and params)
- $group: group for the page
- $user: user doing the invite
- $email: email address
- &$valid: flag for if it's valid; can be modified
+
+StartLocalURL: before resolving a local url for an action
+- &$action: action to find a path for
+- &$paramsi: parameters to pass to the action
+- &$fragment: any url fragement
+- &$addSession: whether to add session variable
+- &$url: resulting URL to local resource
+
+EndLocalURL: before resolving a local url for an action
+- &$action: action to find a path for
+- &$paramsi: parameters to pass to the action
+- &$fragment: any url fragement
+- &$addSession: whether to add session variable
+- &$url: resulting URL to local resource
+
function common_local_url($action, $args=null, $params=null, $fragment=null, $addSession=true)
{
- $r = Router::get();
- $path = $r->build($action, $args, $params, $fragment);
+ if (Event::handle('StartLocalURL', array(&$action, &$params, &$fragment, &$addSession, &$url))) {
+ $r = Router::get();
+ $path = $r->build($action, $args, $params, $fragment);
- $ssl = common_is_sensitive($action);
+ $ssl = common_is_sensitive($action);
- if (common_config('site','fancy')) {
- $url = common_path(mb_substr($path, 1), $ssl, $addSession);
- } else {
- if (mb_strpos($path, '/index.php') === 0) {
+ if (common_config('site','fancy')) {
$url = common_path(mb_substr($path, 1), $ssl, $addSession);
} else {
- $url = common_path('index.php'.$path, $ssl, $addSession);
+ if (mb_strpos($path, '/index.php') === 0) {
+ $url = common_path(mb_substr($path, 1), $ssl, $addSession);
+ } else {
+ $url = common_path('index.php'.$path, $ssl, $addSession);
+ }
}
+ Event::handle('EndLocalURL', array(&$action, &$params, &$fragment, &$addSession, &$url));
}
return $url;
}
switch ($cls)
{
case 'UserdirectoryAction':
+ case 'GroupdirectoryAction':
include_once $dir
. '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
*/
function onRouterInitialized($m)
{
+
$m->connect(
'directory/users',
array('action' => 'userdirectory'),
array('filter' => '([0-9a-zA-Z_]{1,64}|0-9)')
);
+ $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');
+ }
return true;
}