Commit 4dff3693 by Scott Vivian

Merge pull request from pupi1985 (deprecate qa_post_userid_to_handle); fixes #18

parents 32e9ee6a de7b2702
......@@ -34,6 +34,7 @@
require_once QA_INCLUDE_DIR.'qa-app-format.php';
require_once QA_INCLUDE_DIR.'qa-app-post-create.php';
require_once QA_INCLUDE_DIR.'qa-app-post-update.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-util-string.php';
......@@ -56,7 +57,7 @@
post types you can specify the $name of the post's author, which is relevant if the $userid is null.
*/
{
$handle=qa_post_userid_to_handle($userid);
$handle=qa_userid_to_handle($userid);
$text=qa_post_content_to_text($content, $format);
switch ($type) {
......@@ -118,7 +119,8 @@
else
$setnotify=$oldpost['notify'];
$byhandle=qa_post_userid_to_handle($byuserid);
$byhandle=qa_userid_to_handle($byuserid);
$text=qa_post_content_to_text($content, $format);
switch ($oldpost['basetype']) {
......@@ -151,7 +153,7 @@
$oldpost=qa_post_get_full($postid, 'QAC');
if ($oldpost['basetype']=='Q') {
$byhandle=qa_post_userid_to_handle($byuserid);
$byhandle=qa_userid_to_handle($byuserid);
$answers=qa_post_get_question_answers($postid);
$commentsfollows=qa_post_get_question_commentsfollows($postid);
$closepost=qa_post_get_question_closepost($postid);
......@@ -169,7 +171,7 @@
*/
{
$oldquestion=qa_post_get_full($questionid, 'Q');
$byhandle=qa_post_userid_to_handle($byuserid);
$byhandle=qa_userid_to_handle($byuserid);
$answers=qa_post_get_question_answers($questionid);
if (isset($answerid) && !isset($answers[$answerid]))
......@@ -188,7 +190,7 @@
{
$oldquestion=qa_post_get_full($questionid, 'Q');
$oldclosepost=qa_post_get_question_closepost($questionid);
$byhandle=qa_post_userid_to_handle($byuserid);
$byhandle=qa_userid_to_handle($byuserid);
if ($closed) {
if (isset($originalpostid))
......@@ -220,7 +222,7 @@
*/
{
$oldpost=qa_post_get_full($postid, 'QAC');
$byhandle=qa_post_userid_to_handle($byuserid);
$byhandle=qa_userid_to_handle($byuserid);
switch ($oldpost['basetype']) {
case 'Q':
......@@ -331,25 +333,8 @@
Return the handle corresponding to $userid, unless it is null in which case return null.
*/
{
if (isset($userid)) {
if (QA_FINAL_EXTERNAL_USERS) {
require_once QA_INCLUDE_DIR.'qa-app-users.php';
$handles=qa_get_public_from_userids(array($userid));
return @$handles[$userid];
} else {
$user=qa_db_single_select(qa_db_user_account_selectspec($userid, true));
if (!is_array($user))
qa_fatal_error('User ID could not be found: '.$userid);
return $user['handle'];
}
}
return null;
trigger_error('Function qa_post_userid_to_handle is deprecated; use qa_userid_to_handle instead', E_USER_DEPRECATED);
return qa_userid_to_handle($userid);
}
......
......@@ -634,6 +634,16 @@
}
function qa_userid_to_handle($userid)
/*
Return an string mapping the received userid to that user's handle (public username), or to null if not found
*/
{
$handles=qa_userids_to_handles(array($userid));
return empty($handles) ? null : $handles[$userid];
}
function qa_handles_to_userids($handles, $exactonly=false)
/*
Return an array mapping each handle in $handles the user's userid, or null if not found. If $exactonly is true then
......@@ -1151,4 +1161,4 @@ in a category for which they have elevated privileges).
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment