summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-11-29 11:31:10 -0800
committerBrion Vibber <brion@pobox.com>2010-11-29 11:31:10 -0800
commit6c4e5a89c1dd15bd9b408dc3ef257fc16551ab0b (patch)
treeb0ee656a84e35c54944415354af486e7856fa8e2
parent6a0fd59df28ac88bc1e7175507380873b240c835 (diff)
Add some doc comments on nickname-related stuff in util.php
-rw-r--r--lib/util.php59
1 files changed, 57 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php
index ce5da1cd8..f5a4dc87b 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -517,14 +517,32 @@ function common_user_cache_hash($user=false)
}
}
-// get canonical version of nickname for comparison
+/**
+ * get canonical version of nickname for comparison
+ *
+ * Currently this just runs strtolower(); more is needed.
+ *
+ * @fixme normalize punctuation chars where applicable
+ * @fixme reject invalid input
+ *
+ * @param string $nickname
+ * @return string
+ */
function common_canonical_nickname($nickname)
{
// XXX: UTF-8 canonicalization (like combining chars)
return strtolower($nickname);
}
-// get canonical version of email for comparison
+/**
+ * get canonical version of email for comparison
+ *
+ * @fixme actually normalize
+ * @fixme reject invalid input
+ *
+ * @param string $email
+ * @return string
+ */
function common_canonical_email($email)
{
// XXX: canonicalize UTF-8
@@ -532,6 +550,15 @@ function common_canonical_email($email)
return $email;
}
+/**
+ * Partial notice markup rendering step: build links to !group references.
+ *
+ * @fixme use abstracted group nickname regex
+ *
+ * @param string $text partially rendered HTML
+ * @param Notice $notice in whose context we're working
+ * @return string partially rendered HTML
+ */
function common_render_content($text, $notice)
{
$r = common_render_text($text);
@@ -597,6 +624,13 @@ function common_linkify_mention($mention)
return $output;
}
+/**
+ * @fixme use NICKNAME_FMT more consistently
+ *
+ * @param string $text
+ * @param Notice $notice notice in whose context we're building links
+ * @return array
+ */
function common_find_mentions($text, $notice)
{
$mentions = array();
@@ -1026,6 +1060,27 @@ function common_group_link($sender_id, $nickname)
}
}
+/**
+ * Resolve an ambiguous profile nickname reference, checking in following order:
+ * - profiles that $sender subscribes to
+ * - profiles that subscribe to $sender
+ * - local user profiles
+ *
+ * WARNING: does not validate or normalize $nickname -- MUST BE PRE-VALIDATED
+ * OR THERE MAY BE A RISK OF SQL INJECTION ATTACKS. THIS FUNCTION DOES NOT
+ * ESCAPE SQL.
+ *
+ * @fixme validate input
+ * @fixme escape SQL
+ * @fixme fix or remove mystery third parameter
+ * @fixme is $sender a User or Profile?
+ *
+ * @param <type> $sender the user or profile in whose context we're looking
+ * @param string $nickname validated nickname of
+ * @param <type> $dt unused mystery parameter.
+ *
+ * @return Profile or null
+ */
function common_relative_profile($sender, $nickname, $dt=null)
{
// Try to find profiles this profile is subscribed to that have this nickname