19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
51 function id($format=
'N')
53 return $this->getVar(
'avatar_id', $format);
59 function avatar_id($format=
'')
61 return $this->getVar(
'avatar_id', $format);
67 function avatar_file($format=
'')
69 return $this->getVar(
'avatar_file', $format);
75 function avatar_name($format=
'')
77 return $this->getVar(
'avatar_name', $format);
83 function avatar_mimetype($format=
'')
85 return $this->getVar(
'avatar_mimetype', $format);
91 function avatar_created($format=
'')
93 return $this->getVar(
'avatar_created', $format);
99 function avatar_display($format=
'')
101 return $this->getVar(
'avatar_display', $format);
107 function avatar_weight($format=
'')
109 return $this->getVar(
'avatar_weight', $format);
115 function avatar_type($format=
'')
117 return $this->getVar(
'avatar_type', $format);
125 function setUserCount($value)
127 $this->_userCount = intval($value);
135 function getUserCount()
137 return $this->_userCount;
180 $sql =
'SELECT * FROM ' . $this->db->prefix(
'avatar') .
' WHERE avatar_id=' . $id;
184 $numrows = $this->db->getRowsNum(
$result);
205 if (!is_a(
$avatar,
'xoopsavatar')) {
214 foreach(
$avatar->cleanVars as $k => $v) {
218 $avatar_id = $this->db->genId(
'avatar_avatar_id_seq');
219 $sql = sprintf(
"INSERT INTO %s (avatar_id, avatar_file, avatar_name, avatar_created, avatar_mimetype, avatar_display, avatar_weight, avatar_type) VALUES (%u, %s, %s, %u, %s, %u, %u, %s)", $this->db->prefix(
'avatar'), $avatar_id, $this->db->quoteString($avatar_file), $this->db->quoteString($avatar_name), time(), $this->db->quoteString($avatar_mimetype), $avatar_display, $avatar_weight, $this->db->quoteString($avatar_type));
221 $sql = sprintf(
"UPDATE %s SET avatar_file = %s, avatar_name = %s, avatar_created = %u, avatar_mimetype= %s, avatar_display = %u, avatar_weight = %u, avatar_type = %s WHERE avatar_id = %u", $this->db->prefix(
'avatar'), $this->db->quoteString($avatar_file), $this->db->quoteString($avatar_name), $avatar_created, $this->db->quoteString($avatar_mimetype), $avatar_display, $avatar_weight, $this->db->quoteString($avatar_type), $avatar_id);
226 if (empty($avatar_id)) {
227 $avatar_id = $this->db->getInsertId();
229 $avatar->assignVar(
'avatar_id', $avatar_id);
244 if (!is_a(
$avatar,
'xoopsavatar')) {
248 $id =
$avatar->getVar(
'avatar_id');
249 $sql = sprintf(
"DELETE FROM %s WHERE avatar_id = %u", $this->db->prefix(
'avatar'), $id);
253 $sql = sprintf(
"DELETE FROM %s WHERE avatar_id = %u", $this->db->prefix(
'avatar_user_link'), $id);
269 $sql =
'SELECT a.*, COUNT(u.user_id) AS count FROM ' . $this->db->prefix(
'avatar') .
' a LEFT JOIN ' . $this->db->prefix(
'avatar_user_link') .
' u ON u.avatar_id=a.avatar_id';
272 $sql .=
' GROUP BY a.avatar_id ORDER BY avatar_weight, avatar_id';
280 while ($myrow = $this->db->fetchArray(
$result)) {
283 $avatar->setUserCount($myrow[
'count']);
302 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix(
'avatar');
309 list ($count) = $this->db->fetchRow(
$result);
322 $avatar_id = intval($avatar_id);
324 if ($avatar_id < 1 ||
$user_id < 1) {
327 $sql = sprintf(
"DELETE FROM %s WHERE user_id = %u", $this->db->prefix(
'avatar_user_link'),
$user_id);
328 $this->db->query(
$sql);
329 $sql = sprintf(
"INSERT INTO %s (avatar_id, user_id) VALUES (%u, %u)", $this->db->prefix(
'avatar_user_link'), $avatar_id,
$user_id);
348 if (!is_a(
$avatar,
'xoopsavatar')) {
351 $sql =
'SELECT user_id FROM ' . $this->db->prefix(
'avatar_user_link') .
' WHERE avatar_id=' .
$avatar->getVar(
'avatar_id');
355 while ($myrow = $this->db->fetchArray(
$result)) {
356 $ret[] = & $myrow[
'user_id'];
368 function getList($avatar_type = null, $avatar_display = null)
371 if (isset($avatar_type)) {
372 $avatar_type = ($avatar_type ==
'C') ?
'C' :
'S';
375 if (isset($avatar_display)) {
380 'blank.gif' =>
_NONE);
381 foreach(array_keys($avatars) as
$i) {
382 $ret[$avatars[
$i]->getVar(
'avatar_file')] = $avatars[
$i]->getVar(
'avatar_name');