Cheetah
ChAvaDb.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbModuleDb');
9 
10 define('CH_AVATAR_TABLE_PREFIX', 'ch_avatar_');
11 
12 /*
13  * Avatar module Data
14  */
15 class ChAvaDb extends ChWsbModuleDb
16 {
17  var $_oConfig;
18  /*
19  * Constructor.
20  */
21  function __construct(&$oConfig)
22  {
23  parent::__construct();
24 
25  $this->_oConfig = $oConfig;
26  }
27 
28  function updateProfile ($iAvatar, $iOwner, $isAdmin)
29  {
30  if (-1 == $iAvatar)
31  $iAvatar = (int)$this->getOne ("SELECT `id` FROM `" . CH_AVATAR_TABLE_PREFIX . "images` WHERE `author_id` = $iOwner LIMIT 1");
32 
33  if ((int)$iOwner)
34  return $this->query("UPDATE `Profiles` SET `Avatar` = '$iAvatar' WHERE `ID` = " . (int)$iOwner);
35  else
36  return false;
37  }
38 
39  function getCurrentAvatar ($iOwner, $isAdmin)
40  {
41  if ((int)$iOwner)
42  return $this->getOne("SELECT `Avatar` FROM `Profiles` WHERE `ID` = " . (int)$iOwner);
43  else
44  return 0;
45  }
46 
47  function getAvatarByIdAndOwner ($iId, $iOwner, $isAdmin)
48  {
49  $sWhere = '';
50  if (!$isAdmin)
51  $sWhere = " AND `author_id` = '$iOwner' ";
52  return $this->getRow ("SELECT * FROM `" . CH_AVATAR_TABLE_PREFIX . "images` WHERE `id` = ? $sWhere LIMIT 1", [$iId]);
53  }
54 
56  {
57  return $this->getPairs ("SELECT `id` FROM `" . CH_AVATAR_TABLE_PREFIX . "images` WHERE `author_id` = '$iProfileId'", 'id', 'id');
58  }
59 
61  {
62  if (!$this->query ("INSERT INTO `" . CH_AVATAR_TABLE_PREFIX . "images` SET `author_id` = '$iProfileId'"))
63  return false;
64  return $this->lastId();
65  }
66 
67  function deleteAvatarByIdAndOwner ($iId, $iOwner, $isAdmin)
68  {
69  $sWhere = '';
70  if (!$isAdmin)
71  $sWhere = " AND `author_id` = '$iOwner' ";
72  if (!($iRet = $this->query ("DELETE FROM `" . CH_AVATAR_TABLE_PREFIX . "images` WHERE `id` = $iId $sWhere LIMIT 1")))
73  return false;
74  return true;
75  }
76 
78  {
79  return $this->getOne("SELECT `ID` FROM `sys_options_cats` WHERE `name` = 'Avatar' LIMIT 1");
80  }
81 
83  {
84  return $this->query("UPDATE `Profiles` SET `Status` = 'Approval' WHERE `ID` = $iProfileId AND `Status` = 'Active' LIMIT 1");
85  }
86 }
ChAvaDb\getCurrentAvatar
getCurrentAvatar($iOwner, $isAdmin)
Definition: ChAvaDb.php:39
ChAvaDb\__construct
__construct(&$oConfig)
Definition: ChAvaDb.php:21
ChAvaDb\updateProfile
updateProfile($iAvatar, $iOwner, $isAdmin)
Definition: ChAvaDb.php:28
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
ChWsbModuleDb
Definition: ChWsbModuleDb.php:12
$iId
$iId
Definition: license.php:15
ChAvaDb
Definition: ChAvaDb.php:16
ChWsbDb\getPairs
getPairs($sQuery, $sFieldKey, $sFieldValue, $aBindings=[])
Definition: ChWsbDb.php:363
ChWsbDb\getRow
getRow($sQuery, $aBindings=[], $iFetchStyle=PDO::FETCH_ASSOC)
Definition: ChWsbDb.php:225
ChAvaDb\deleteAvatarByIdAndOwner
deleteAvatarByIdAndOwner($iId, $iOwner, $isAdmin)
Definition: ChAvaDb.php:67
ChWsbDb\query
query($sQuery, $aBindings=[])
Definition: ChWsbDb.php:386
ChAvaDb\getAvatarByIdAndOwner
getAvatarByIdAndOwner($iId, $iOwner, $isAdmin)
Definition: ChAvaDb.php:47
ChWsbDb\getOne
getOne($sQuery, $aBindings=[], $iIndex=0)
Definition: ChWsbDb.php:263
ChAvaDb\getSettingsCategory
getSettingsCategory()
Definition: ChAvaDb.php:77
ChAvaDb\$_oConfig
$_oConfig
Definition: ChAvaDb.php:17
CH_AVATAR_TABLE_PREFIX
const CH_AVATAR_TABLE_PREFIX
Definition: ChAvaDb.php:10
ChAvaDb\addAvatar
addAvatar($iProfileId)
Definition: ChAvaDb.php:60
ChWsbDb\lastId
lastId()
Definition: ChWsbDb.php:449
ChAvaDb\getAvatarsByAuthor
getAvatarsByAuthor($iProfileId)
Definition: ChAvaDb.php:55
ChAvaDb\suspendProfile
suspendProfile($iProfileId)
Definition: ChAvaDb.php:82
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29