+// where should the avatar go for this user?
+
+function common_avatar_filename($user, $extension, $size=NULL) {
+ global $config;
+
+ if ($size) {
+ return $user->id . '-' . $size . $extension;
+ } else {
+ return $user->id . '-original' . $extension;
+ }
+}
+
+function common_avatar_path($filename) {
+ global $config;
+ return $config['avatar']['directory'] . '/' . $filename;
+}
+
+function common_avatar_url($filename) {
+ global $config;
+ return $config['avatar']['path'] . '/' . $filename;
+}
+
+function common_local_url($action, $args=NULL) {
+ global $config;
+ /* XXX: pretty URLs */
+ $extra = '';
+ if ($args) {
+ foreach ($args as $key => $value) {
+ $extra .= "&${key}=${value}";
+ }
+ }
+ $pathpart = ($config['site']['path']) ? $config['site']['path']."/" : '';
+ return "http://".$config['site']['server'].'/'.$pathpart."index.php?action=${action}${extra}";
+}
+
+function commmon_date_string($dt) {
+ // XXX: do some sexy date formatting
+ return date(DATE_RFC822);
+}
+
+function common_redirect($url, $code=307) {
+ static $status = array(301 => "Moved Permanently",
+ 302 => "Found",
+ 303 => "See Other",
+ 307 => "Temporary Redirect");
+ header("Status: ${code} $status[$code]");
+ header("Location: $url");
+ common_element('a', array('href' => $url), $url);
+}
+
+function common_broadcast_notices($id) {
+ // XXX: broadcast notices to remote subscribers
+ // XXX: broadcast notices to SMS
+ // XXX: broadcast notices to Jabber
+ // XXX: broadcast notices to other IM
+ // XXX: use a queue system like http://code.google.com/p/microapps/wiki/NQDQ
+ return true;
+}
+