@@ 68-134 (lines=67) @@ | ||
65 | * @param array $moderators |
|
66 | * @return array|bool |
|
67 | */ |
|
68 | public function Updates($last, $moderators) |
|
69 | { |
|
70 | global $xoopsUser, $xoopsDB, $moduleConfig, $xoopsLogger; |
|
71 | $moderators = is_array($moderators) ? $moderators : [$moderators]; |
|
72 | $hm = smallworld_GetModuleOption('msgtoshow'); |
|
73 | $set = smallworld_checkPrivateOrPublic(); |
|
74 | $mods = implode(',', Smallworld_array_flatten(array_unique($moderators), 0)); |
|
75 | $inspected = $this->inspected(); |
|
76 | $perm = smallworld_GetModuleOption('smallworldshowPoPubPage'); |
|
77 | $i = 0; |
|
78 | ||
79 | if (0 == $last) { |
|
80 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
81 | . $xoopsDB->prefix('smallworld_messages') |
|
82 | . ' M, ' |
|
83 | . $xoopsDB->prefix('smallworld_user') |
|
84 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
85 | . $mods |
|
86 | . ') AND M.uid_fk NOT IN (' |
|
87 | . $inspected |
|
88 | . ") AND M.priv = '0'"; |
|
89 | } elseif ($last > 0) { |
|
90 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
91 | . $xoopsDB->prefix('smallworld_messages') |
|
92 | . ' M, ' |
|
93 | . $xoopsDB->prefix('smallworld_user') |
|
94 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
95 | . $mods |
|
96 | . ') AND M.uid_fk NOT IN (' |
|
97 | . $inspected |
|
98 | . ") AND M.priv = '0' AND M.msg_id < '" |
|
99 | . $last |
|
100 | . "'"; |
|
101 | } elseif ('a' === $last) { |
|
102 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
103 | . $xoopsDB->prefix('smallworld_messages') |
|
104 | . ' M, ' |
|
105 | . $xoopsDB->prefix('smallworld_user') |
|
106 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
107 | . $mods |
|
108 | . ') AND M.uid_fk NOT IN (' |
|
109 | . $inspected |
|
110 | . ") AND M.priv = '0'"; |
|
111 | } |
|
112 | ||
113 | if ($last > 0) { |
|
114 | $query .= ' order by created DESC LIMIT ' . $hm; |
|
115 | } elseif ('a' === $last) { |
|
116 | $query .= ' order by M.msg_id DESC LIMIT ' . $hm; |
|
117 | } else { |
|
118 | $query .= ' order by created DESC LIMIT ' . $hm; |
|
119 | } |
|
120 | ||
121 | $result = $xoopsDB->queryF($query); |
|
122 | $count = $xoopsDB->getRowsNum($result); |
|
123 | if (0 == $count) { |
|
124 | return false; |
|
125 | } else { |
|
126 | while ($row = $xoopsDB->fetchArray($result)) { |
|
127 | $data[] = $row; |
|
128 | } |
|
129 | ||
130 | if (!empty($data)) { |
|
131 | return $data; |
|
132 | } |
|
133 | } |
|
134 | } |
|
135 | ||
136 | /** |
|
137 | * @Get comments based on msg id |
@@ 68-134 (lines=67) @@ | ||
65 | * @param array $moderators |
|
66 | * @return array|bool |
|
67 | */ |
|
68 | public function Updates($last, $moderators) |
|
69 | { |
|
70 | global $xoopsUser, $xoopsDB, $moduleConfig, $xoopsLogger; |
|
71 | $moderators = is_array($moderators) ? $moderators : [$moderators]; |
|
72 | $hm = smallworld_GetModuleOption('msgtoshow'); |
|
73 | $set = smallworld_checkPrivateOrPublic(); |
|
74 | $mods = implode(',', Smallworld_array_flatten(array_unique($moderators), 0)); |
|
75 | $inspected = $this->inspected(); |
|
76 | $perm = smallworld_GetModuleOption('smallworldshowPoPubPage'); |
|
77 | $i = 0; |
|
78 | ||
79 | if (0 == $last) { |
|
80 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
81 | . $xoopsDB->prefix('smallworld_messages') |
|
82 | . ' M, ' |
|
83 | . $xoopsDB->prefix('smallworld_user') |
|
84 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
85 | . $mods |
|
86 | . ') AND M.uid_fk NOT IN (' |
|
87 | . $inspected |
|
88 | . ") AND M.priv = '0'"; |
|
89 | } elseif ($last > 0) { |
|
90 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
91 | . $xoopsDB->prefix('smallworld_messages') |
|
92 | . ' M, ' |
|
93 | . $xoopsDB->prefix('smallworld_user') |
|
94 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
95 | . $mods |
|
96 | . ') AND M.uid_fk NOT IN (' |
|
97 | . $inspected |
|
98 | . ") AND M.priv = '0' AND M.msg_id < '" |
|
99 | . $last |
|
100 | . "'"; |
|
101 | } elseif ('a' == $last) { |
|
102 | $query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' |
|
103 | . $xoopsDB->prefix('smallworld_messages') |
|
104 | . ' M, ' |
|
105 | . $xoopsDB->prefix('smallworld_user') |
|
106 | . ' U WHERE M.uid_fk=U.userid AND M.uid_fk IN (' |
|
107 | . $mods |
|
108 | . ') AND M.uid_fk NOT IN (' |
|
109 | . $inspected |
|
110 | . ") AND M.priv = '0'"; |
|
111 | } |
|
112 | ||
113 | if ($last > 0) { |
|
114 | $query .= ' order by created DESC LIMIT ' . $hm; |
|
115 | } elseif ('a' == $last) { |
|
116 | $query .= ' order by M.msg_id DESC LIMIT ' . $hm; |
|
117 | } else { |
|
118 | $query .= ' order by created DESC LIMIT ' . $hm; |
|
119 | } |
|
120 | ||
121 | $result = $xoopsDB->queryF($query); |
|
122 | $count = $xoopsDB->getRowsNum($result); |
|
123 | if (0 == $count) { |
|
124 | return false; |
|
125 | } else { |
|
126 | while ($row = $xoopsDB->fetchArray($result)) { |
|
127 | $data[] = $row; |
|
128 | } |
|
129 | ||
130 | if (!empty($data)) { |
|
131 | return $data; |
|
132 | } |
|
133 | } |
|
134 | } |
|
135 | ||
136 | /** |
|
137 | * @Get comments based on msg id |