a5cfe724d5bf86ee5857252a1b624a44f40a8731
[mailer.git] / inc / libs / nickname_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/25/2004 *
4  * ===================                          Last change: 06/25/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : nickname_functions.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Nickname functions                               *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Nickname-Funktionen                              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Checks wether the nickname is active
44 function isNicknameOrUserid ($useridNick) {
45         // By default nothing is found...
46         $ret = false;
47
48         // Found in cache?
49         if (isset($GLOBALS['nickname_active'][$useridNick])) {
50                 // Use it directly
51                 $ret = $GLOBALS['nickname_active'][$useridNick];
52         } else {
53                 // Nickname or userid used?
54                 $nick = getNickname($useridNick);
55
56                 // Check for nickname
57                 $ret = ($nick == $useridNick);
58
59                 // Put it in cache
60                 $GLOBALS['nickname_active'][$useridNick] = $ret;
61         }
62
63         // Return nickname
64         return $ret;
65 }
66
67 // "Getter" for nickname for specfied userid
68 function getNickname ($userid) {
69         // If not found...
70         $ret = '';
71
72         // Found in cache?
73         if (isset($GLOBALS['nicknames'][$userid])) {
74                 // Use it directly
75                 $ret = $GLOBALS['nicknames'][$userid];
76         } else {
77                 // Init result
78                 $result = false;
79
80                 // Nickname or userid used?
81                 if ('' . round($userid) . '' === '' . $userid . '') {
82                         // Userid given, so try to load user data
83                         if (fetchUserData($userid)) {
84                                 // Load nickname from database
85                                 $ret = getUserData('nickname');
86
87                                 // Put it in cche
88                                 $GLOBALS['nicknames'][$userid] = $ret;
89                         } // END - if
90                 } else {
91                         // Direct nickname found!
92                         $ret = $userid;
93
94                         // Put it in cche
95                         $GLOBALS['nicknames'][$userid] = $ret;
96                 }
97         }
98
99         // Return nickname
100         return $ret;
101 }
102
103 // [EOF]
104 ?>