|
@@ 597-608 (lines=12) @@
|
| 594 |
|
* @param $msg_id_fk |
| 595 |
|
* @return bool|int false if not found, integer of uid otherwise |
| 596 |
|
*/ |
| 597 |
|
function smallworld_getOwnerFromComment($msg_id_fk) |
| 598 |
|
{ |
| 599 |
|
$owner = false; |
| 600 |
|
/** @todo looks like this should have LIMIT set to 1 to reduce execution time & possible ambiguity */ |
| 601 |
|
$sql = 'SELECT uid_fk FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . " WHERE msg_id = '" . $msg_id_fk . "'"; |
| 602 |
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
| 603 |
|
while (false !== ($r = $GLOBALS['xoopsDB']->fetchArray($result))) { |
| 604 |
|
$owner = $r['uid_fk']; |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
return $owner; |
| 608 |
|
} |
| 609 |
|
|
| 610 |
|
/** |
| 611 |
|
* Get username from userID |
|
@@ 1004-1013 (lines=10) @@
|
| 1001 |
|
* @param $id |
| 1002 |
|
* @return mixed |
| 1003 |
|
*/ |
| 1004 |
|
function smallworldCheckPriv($id) |
| 1005 |
|
{ |
| 1006 |
|
$public = 'SELECT priv FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . ' WHERE msg_id = ' . $id . ''; |
| 1007 |
|
$result = $GLOBALS['xoopsDB']->queryF($public); |
| 1008 |
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
| 1009 |
|
$priv = $row['priv']; |
| 1010 |
|
} |
| 1011 |
|
|
| 1012 |
|
return $priv; |
| 1013 |
|
} |
| 1014 |
|
|
| 1015 |
|
/** |
| 1016 |
|
* Function to calculate remaining seconds until user's birthday |
|
@@ 1166-1179 (lines=14) @@
|
| 1163 |
|
* @param int $userid |
| 1164 |
|
* @return bool|string false if no image found |
| 1165 |
|
*/ |
| 1166 |
|
function smallworld_getRndImg($userid) |
| 1167 |
|
{ |
| 1168 |
|
$sql = 'SELECT imgname FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_images') |
| 1169 |
|
. ' WHERE userid = ' . (int)$userid . ' AND time BETWEEN UNIX_TIMESTAMP( ) - 3000 AND UNIX_TIMESTAMP() ORDER BY rand() LIMIT 1'; |
| 1170 |
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
| 1171 |
|
while (false !== ($r = $GLOBALS['xoopsDB']->fetchArray($result))) { |
| 1172 |
|
$img = $r['imgname']; |
| 1173 |
|
} |
| 1174 |
|
if (!empty($img)) { |
| 1175 |
|
return $img; |
| 1176 |
|
} |
| 1177 |
|
|
| 1178 |
|
return false; |
| 1179 |
|
} |
| 1180 |
|
|
| 1181 |
|
/** |
| 1182 |
|
* Get url of smallworld |
|
@@ 1571-1581 (lines=11) @@
|
| 1568 |
|
* @param $name |
| 1569 |
|
* @return array @users |
| 1570 |
|
*/ |
| 1571 |
|
function smallworld_getUidFromName($name) |
| 1572 |
|
{ |
| 1573 |
|
$id = []; |
| 1574 |
|
$sql = 'SELECT userid FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " WHERE username = '" . $name . "'"; |
| 1575 |
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
| 1576 |
|
while (false !== ($r = $GLOBALS['xoopsDB']->fetchArray($result))) { |
| 1577 |
|
$id = $r['userid']; |
| 1578 |
|
} |
| 1579 |
|
|
| 1580 |
|
return $id; |
| 1581 |
|
} |
| 1582 |
|
|
| 1583 |
|
/** |
| 1584 |
|
* Extract users from @tags |