1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | /** |
---|
15 | @ingroup DC_CORE |
---|
16 | @brief Dotclear helper methods |
---|
17 | |
---|
18 | Provides some Dotclear helpers |
---|
19 | */ |
---|
20 | class dcUtils |
---|
21 | { |
---|
22 | /** |
---|
23 | Static function that returns user's common name given to his |
---|
24 | <var>user_id</var>, <var>user_name</var>, <var>user_firstname</var> and |
---|
25 | <var>user_displayname</var>. |
---|
26 | |
---|
27 | @param user_id <b>string</b> User ID |
---|
28 | @param user_name <b>string</b> User's name |
---|
29 | @param user_firstname <b>string</b> User's first name |
---|
30 | @param user_displayname <b>string</b> User's display name |
---|
31 | @return <b>string</b> |
---|
32 | */ |
---|
33 | public static function getUserCN($user_id, $user_name, $user_firstname, $user_displayname) |
---|
34 | { |
---|
35 | if (!empty($user_displayname)) { |
---|
36 | return $user_displayname; |
---|
37 | } |
---|
38 | |
---|
39 | if (!empty($user_name)) { |
---|
40 | if (!empty($user_firstname)) { |
---|
41 | return $user_firstname.' '.$user_name; |
---|
42 | } else { |
---|
43 | return $user_name; |
---|
44 | } |
---|
45 | } elseif (!empty($user_firstname)) { |
---|
46 | return $user_firstname; |
---|
47 | } |
---|
48 | |
---|
49 | return $user_id; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | Cleanup a list of IDs |
---|
54 | |
---|
55 | @param ids <b>mixed</b> ID(s) |
---|
56 | @return <b>array</b> |
---|
57 | */ |
---|
58 | public static function cleanIds($ids) |
---|
59 | { |
---|
60 | $clean_ids = array(); |
---|
61 | |
---|
62 | if (!is_array($ids)) { |
---|
63 | $ids = array($ids); |
---|
64 | } |
---|
65 | |
---|
66 | foreach($ids as $id) |
---|
67 | { |
---|
68 | $id = abs((integer) $id); |
---|
69 | |
---|
70 | if (!empty($id)) { |
---|
71 | $clean_ids[] = $id; |
---|
72 | } |
---|
73 | } |
---|
74 | return $clean_ids; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | ?> |
---|