- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
<?php
/*---------------------------------------------------------------------------
* @Module Name: Clans
* @Description: ClanWars for LiveStreet
* @Version: 1.0
* @Author: trim06
* @LiveStreet Version: 0.3.1
* @File Name: Clans.mapper.class.php
* @License: GNU GPL v2, http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*----------------------------------------------------------------------------
*/
class Mapper_Clans extends Mapper {
public function AddClan($ownerId, $clanName, $nameUrl, $clanPeople, $clanDesc, $urlHomePage, $pathAvatar)
{
$sql = 'INSERT INTO '.DB_TABLE_CLANS.'
(owner_id,
name,
name_url,
people,
people_count,
description,
reg_date,
avator,
url_home_page
)
VALUES(?d, ?, ?, ?, ?d, ?, NOW(), ?, ?)
';
$clanPeopleCount = count(explode(',', $clanPeople));
if($this->oDb->query($sql, $ownerId, $clanName, $nameUrl, $clanPeople, $clanPeopleCount, $clanDesc, $pathAvatar, $urlHomePage))
{
$this->DropInviteClanCreate($ownerId);
return true;
}
return false;
}
public function UpdateClan($clanId, $ownerId, $clanPeople, $clanName, $nameUrl, $clanDesc, $urlHomePage, $pathAvatar)
{
$sql = 'UPDATE '.DB_TABLE_CLANS.'
SET
name = ?,
name_url = ?,
people = ?,
description = ?,'.
(($pathAvatar) ? "avator = '".$pathAvatar."'," : '').
'url_home_page = ?,
people_count = ?d
WHERE
owner_id = ?d AND id = ?d
';
$clanPeopleCount = count(explode(',', $clanPeople));
if ($this->oDb->query($sql, $clanName, $nameUrl, $clanPeople, $clanDesc, $urlHomePage, $clanPeopleCount, $ownerId, $clanId))
{
return true;
}
return false;
}
public function GetClans($status,&$iCount,$iCurrPage,$iPerPage)
{
$sql = 'SELECT * FROM '.DB_TABLE_CLANS.' WHERE status=?d
AND id NOT IN (SELECT clan_id
FROM '.DB_TABLE_CLANS_BANS.'
WHERE ban_active=1
GROUP BY clan_id)
ORDER BY rating DESC LIMIT ?d, ?d';
$status = ($status=='good') ? 0 : 1;
if($aRows=$this->oDb->selectPage($iCount, $sql, $status, ($iCurrPage-1)*$iPerPage, $iPerPage))
{
return $aRows;
}
return null;
}
public function GetBannedClans(&$iCount,$iCurrPage,$iPerPage)
{
$sql = 'SELECT c.*
FROM
(SELECT clan_id
FROM '.DB_TABLE_CLANS_BANS.'
WHERE ban_active=1
GROUP BY clan_id) as cb
JOIN '.DB_TABLE_CLANS.' as c ON c.id=cb.clan_id
ORDER BY rating
DESC LIMIT ?d, ?d';
if($aRows=$this->oDb->selectPage($iCount, $sql, ($iCurrPage-1)*$iPerPage, $iPerPage))
{
return $aRows;
}
return null;
}