mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Use $db->exec where appropriate
May bring some performance boost (little, but still)
This commit is contained in:
parent
82e64559a8
commit
2dbf189f43
@ -329,15 +329,15 @@ function delete_player($name)
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if($player->isLoaded()) {
|
||||
try { $db->query("DELETE FROM player_skills WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM guild_invites WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_items WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_depotitems WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_spells WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_storage WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_viplist WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_deaths WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->query("DELETE FROM player_deaths WHERE killed_by = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_skills WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM guild_invites WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_items WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_depotitems WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_spells WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_storage WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_viplist WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_deaths WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_deaths WHERE killed_by = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded()) {
|
||||
$guild = $rank->getGuild();
|
||||
|
@ -90,7 +90,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// saves blank account info
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('accounts') . ' (' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('password') . ', ' . $this->db->fieldName('email') . ') VALUES (' . $this->db->quote($name) . ', \'\', \'\')');
|
||||
$this->db->exec('INSERT INTO ' . $this->db->tableName('accounts') . ' (' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('password') . ', ' . $this->db->fieldName('email') . ') VALUES (' . $this->db->quote($name) . ', \'\', \'\')');
|
||||
|
||||
// reads created account's ID
|
||||
$this->data['id'] = $this->db->lastInsertId();
|
||||
@ -138,7 +138,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
public function create($name = NULL, $id = NULL)
|
||||
{
|
||||
// saves blank account info
|
||||
$this->db->query('INSERT INTO `accounts` (' . (isset($id) ? '`id`,' : '') . (isset($name) ? '`name`,' : '') . '`password`, `email`, `created`) VALUES (' . (isset($id) ? $id . ',' : '') . (isset($name) ? $this->db->quote($name) . ',' : '') . ' \'\', \'\',' . time() . ')');
|
||||
$this->db->exec('INSERT INTO `accounts` (' . (isset($id) ? '`id`,' : '') . (isset($name) ? '`name`,' : '') . '`password`, `email`, `created`) VALUES (' . (isset($id) ? $id . ',' : '') . (isset($name) ? $this->db->quote($name) . ',' : '') . ' \'\', \'\',' . time() . ')');
|
||||
|
||||
if(isset($name))
|
||||
$this->data['name'] = $name;
|
||||
@ -265,7 +265,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,7 +658,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
{
|
||||
$value = $this->db->quote($value);
|
||||
}
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('accounts') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('accounts') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -847,7 +847,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// deletes row from database
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
|
||||
// resets object handle
|
||||
unset($this->data['id']);
|
||||
@ -955,7 +955,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$ip = '';
|
||||
}
|
||||
|
||||
return $this->db->query('INSERT INTO `' . TABLE_PREFIX . 'account_actions` (`account_id`, `ip`, `ipv6`, `date`, `action`) VALUES (' . $this->db->quote($this->getId()).', ' . ($ip == '' ? '0' : $this->db->quote(ip2long($ip))) . ', (' . ($ipv6 == '0' ? $this->db->quote('') : $this->db->quote(inet_pton($ipv6))) . '), UNIX_TIMESTAMP(NOW()), ' . $this->db->quote($action).')');
|
||||
return $this->db->exec('INSERT INTO `' . TABLE_PREFIX . 'account_actions` (`account_id`, `ip`, `ipv6`, `date`, `action`) VALUES (' . $this->db->quote($this->getId()).', ' . ($ip == '' ? '0' : $this->db->quote(ip2long($ip))) . ', (' . ($ipv6 == '0' ? $this->db->quote('') : $this->db->quote(inet_pton($ipv6))) . '), UNIX_TIMESTAMP(NOW()), ' . $this->db->quote($action).')');
|
||||
}
|
||||
|
||||
public function getActionsLog($limit1, $limit2)
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
/**
|
||||
* List of accounts.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.3
|
||||
*/
|
||||
@ -23,16 +23,16 @@ class OTS_Accounts_List extends OTS_Base_List
|
||||
*/
|
||||
public function deleteAccount(OTS_Account $account)
|
||||
{
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('account') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $account->getId() );
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('account') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $account->getId() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list parameters.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method is called at object creation.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @since 0.0.5
|
||||
*/
|
||||
@ -44,11 +44,11 @@ class OTS_Accounts_List extends OTS_Base_List
|
||||
|
||||
/**
|
||||
* Returns string representation of object.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If any display driver is currently loaded then it uses it's method.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @since 0.1.0
|
||||
* @return string String representation of object.
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
/**
|
||||
* OTServ ban generic class. For particular purpose use {@link OTS_AccountBan OTS_AccountBan}, {@link OTS_PlayerBan OTS_PlayerBan} or {@link OTS_IPBan OTS_IPBan} classes respectively.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
@ -30,7 +30,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
{
|
||||
/**
|
||||
* Ban data.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
@ -39,7 +39,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Loads ban with given id.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $id Ban ID.
|
||||
@ -53,7 +53,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Checks if object is loaded.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return bool Load state.
|
||||
@ -65,11 +65,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Saves ban in database.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If object is not loaded to represent any existing ban it will create new row for it.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @throws PDOException On PDO operation error.
|
||||
@ -80,13 +80,13 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
if( isset($this->data['id']) )
|
||||
{
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('bans') . ' SET ' . $this->db->fieldName('type') . ' = ' . $this->data['type'] . ', ' . $this->db->fieldName('value') . ' = ' . $this->data['value'] . ', ' . $this->db->fieldName('param') . ' = ' . $this->data['param'] . ', ' . $this->db->fieldName('active') . ' = ' . (int) $this->data['active'] . ', ' . $this->db->fieldName('expires') . ' = ' . $this->data['expires'] . ', ' . $this->db->fieldName('added') . ' = ' . $this->data['added'] . ', ' . $this->db->fieldName('admin_id') . ' = ' . $this->data['admin_id'] . ', ' . $this->db->fieldName('comment') . ' = ' . $this->db->quote($this->data['comment']) . ', ' . $this->db->fieldName('reason') . ' = ' . $this->data['reason'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('bans') . ' SET ' . $this->db->fieldName('type') . ' = ' . $this->data['type'] . ', ' . $this->db->fieldName('value') . ' = ' . $this->data['value'] . ', ' . $this->db->fieldName('param') . ' = ' . $this->data['param'] . ', ' . $this->db->fieldName('active') . ' = ' . (int) $this->data['active'] . ', ' . $this->db->fieldName('expires') . ' = ' . $this->data['expires'] . ', ' . $this->db->fieldName('added') . ' = ' . $this->data['added'] . ', ' . $this->db->fieldName('admin_id') . ' = ' . $this->data['admin_id'] . ', ' . $this->db->fieldName('comment') . ' = ' . $this->db->quote($this->data['comment']) . ', ' . $this->db->fieldName('reason') . ' = ' . $this->data['reason'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
// creates new ban
|
||||
else
|
||||
{
|
||||
// INSERT query on database
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('bans') . ' (' . $this->db->fieldName('type') . ', ' . $this->db->fieldName('value') . ', ' . $this->db->fieldName('param') . ', ' . $this->db->fieldName('active') . ', ' . $this->db->fieldName('expires') . ', ' . $this->db->fieldName('added') . ', ' . $this->db->fieldName('admin_id') . ', ' . $this->db->fieldName('comment') . ', ' . $this->db->fieldName('reason') . ') VALUES (' . $this->data['type'] . ', ' . $this->data['value'] . ', ' . $this->data['param'] . ', ' . (int) $this->data['active'] . ', ' . $this->data['expires'] . ', ' . $this->data['added'] . ', ' . $this->data['admin_id'] . ', ' . $this->db->quote($this->data['comment']) . ', ' . $this->data['reason'] . ')');
|
||||
$this->db->exec('INSERT INTO ' . $this->db->tableName('bans') . ' (' . $this->db->fieldName('type') . ', ' . $this->db->fieldName('value') . ', ' . $this->db->fieldName('param') . ', ' . $this->db->fieldName('active') . ', ' . $this->db->fieldName('expires') . ', ' . $this->db->fieldName('added') . ', ' . $this->db->fieldName('admin_id') . ', ' . $this->db->fieldName('comment') . ', ' . $this->db->fieldName('reason') . ') VALUES (' . $this->data['type'] . ', ' . $this->data['value'] . ', ' . $this->data['param'] . ', ' . (int) $this->data['active'] . ', ' . $this->data['expires'] . ', ' . $this->data['added'] . ', ' . $this->data['admin_id'] . ', ' . $this->db->quote($this->data['comment']) . ', ' . $this->data['reason'] . ')');
|
||||
// ID of new ban
|
||||
$this->data['id'] = $this->db->lastInsertId();
|
||||
}
|
||||
@ -94,7 +94,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Ban ID.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Ban ID.
|
||||
@ -112,7 +112,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Deletes ban.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @throws E_OTS_NotLoaded If ban is not loaded.
|
||||
@ -126,7 +126,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
// deletes row from database
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('bans') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('bans') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
|
||||
// resets object handle
|
||||
unset($this->data['id']);
|
||||
@ -134,7 +134,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Banned target.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Target identifier.
|
||||
@ -152,11 +152,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets banned target.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $value Banned target identifier.
|
||||
@ -168,7 +168,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Additional parameter.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Parameter value (usualy used as IP mask).
|
||||
@ -186,11 +186,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets additional parameter.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $param Parameter value (usualy used as IP mask).
|
||||
@ -202,7 +202,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Activation state.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return bool Is ban active.
|
||||
@ -220,11 +220,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Activates ban.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
*/
|
||||
@ -235,11 +235,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Deactivates ban.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
*/
|
||||
@ -250,7 +250,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Expiration time.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Ban expiration time (0 - forever).
|
||||
@ -268,11 +268,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets expiration time.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $expires Ban expiration time (0 - forever).
|
||||
@ -284,7 +284,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Banned time.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Ban creation time.
|
||||
@ -302,11 +302,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets banned time.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $added Ban creation time.
|
||||
@ -318,7 +318,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Ban creator.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int ID of administrator who created ban entry.
|
||||
@ -336,11 +336,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets ban creator.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $adminId ID of administrator who created ban entry.
|
||||
@ -352,7 +352,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Explaination comment.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return string Ban description.
|
||||
@ -370,11 +370,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets explaination comment.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param string $comment Ban description.
|
||||
@ -386,7 +386,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Ban reason.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @return int Reason for which ban was created.
|
||||
@ -404,11 +404,11 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets ban reason.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Ban::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param int $reason Reason for which ban was created.
|
||||
@ -420,15 +420,15 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Reads custom field.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Reads field by it's name. Can read any field of given record that exists in database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param string $field Field name.
|
||||
@ -449,19 +449,19 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Writes custom field.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Write field by it's name. Can write any field of given record that exists in database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: Make sure that you pass $value argument of correct type. This method determinates whether to quote field name. It is safe - it makes you sure that no unproper queries that could lead to SQL injection will be executed, but it can make your code working wrong way. For example: $object->setCustomField('foo', '1'); will quote 1 as as string ('1') instead of passing it as a integer.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param string $field Field name.
|
||||
@ -482,12 +482,12 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
$value = $this->db->quote($value);
|
||||
}
|
||||
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('bans') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('bans') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param string $name Property name.
|
||||
@ -537,7 +537,7 @@ abstract class OTS_Ban extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @version 0.1.5
|
||||
* @since 0.1.5
|
||||
* @param string $name Property name.
|
||||
|
@ -128,13 +128,13 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
if( isset($this->data['id']) )
|
||||
{
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('groups') . ' SET ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('flags') . ' = ' . $this->data['flags'] . ', ' . $this->db->fieldName('access') . ' = ' . $this->data['access'] . ', ' . $this->db->fieldName('maxdepotitems') . ' = ' . $this->data['maxdepotitems'] . ', ' . $this->db->fieldName('maxviplist') . ' = ' . $this->data['maxviplist'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('groups') . ' SET ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('flags') . ' = ' . $this->data['flags'] . ', ' . $this->db->fieldName('access') . ' = ' . $this->data['access'] . ', ' . $this->db->fieldName('maxdepotitems') . ' = ' . $this->data['maxdepotitems'] . ', ' . $this->db->fieldName('maxviplist') . ' = ' . $this->data['maxviplist'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
// creates new group
|
||||
else
|
||||
{
|
||||
// INSERT query on database
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('groups') . ' (' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('flags') . ', ' . $this->db->fieldName('access') . ', ' . $this->db->fieldName('maxdepotitems') . ', ' . $this->db->fieldName('maxviplist') . ') VALUES (' . $this->db->quote($this->data['name']) . ', ' . $this->data['flags'] . ', ' . $this->data['access'] . ', ' . $this->data['maxdepotitems'] . ', ' . $this->data['maxviplist'] . ')');
|
||||
$this->db->exec('INSERT INTO ' . $this->db->tableName('groups') . ' (' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('flags') . ', ' . $this->db->fieldName('access') . ', ' . $this->db->fieldName('maxdepotitems') . ', ' . $this->db->fieldName('maxviplist') . ') VALUES (' . $this->db->quote($this->data['name']) . ', ' . $this->data['flags'] . ', ' . $this->data['access'] . ', ' . $this->data['maxdepotitems'] . ', ' . $this->data['maxviplist'] . ')');
|
||||
// ID of new group
|
||||
$this->data['id'] = $this->db->lastInsertId();
|
||||
}
|
||||
@ -435,7 +435,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$value = $this->db->quote($value);
|
||||
}
|
||||
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('groups') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('groups') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -519,7 +519,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// deletes row from database
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('groups') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('groups') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
|
||||
// resets object handle
|
||||
unset($this->data['id']);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/**
|
||||
* OTServ guild abstraction.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.4
|
||||
* @property string $read Guild name.
|
||||
@ -34,30 +34,30 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
{
|
||||
/**
|
||||
* Guild data.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $data = array();
|
||||
|
||||
/**
|
||||
* Invites handler.
|
||||
*
|
||||
*
|
||||
* @var IOTS_GuildAction
|
||||
*/
|
||||
private $invites;
|
||||
|
||||
/**
|
||||
* Membership requests handler.
|
||||
*
|
||||
*
|
||||
* @var IOTS_GuildAction
|
||||
*/
|
||||
private $requests;
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* Allows object serialisation.
|
||||
*
|
||||
*
|
||||
* @return array List of properties that should be saved.
|
||||
*/
|
||||
public function __sleep()
|
||||
@ -67,11 +67,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Creates clone of object.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Copy of object needs to have different ID. Also invites and requests drivers are copied and assigned to object's copy.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
*/
|
||||
/*
|
||||
@ -94,7 +94,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
/**
|
||||
* Assigns invites handler.
|
||||
*
|
||||
*
|
||||
* @param IOTS_GuildAction $invites Invites driver (don't pass it to clear driver).
|
||||
*/
|
||||
public function setInvitesDriver(IOTS_GuildAction $invites = null)
|
||||
@ -104,7 +104,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Assigns requests handler.
|
||||
*
|
||||
*
|
||||
* @param IOTS_GuildAction $requests Membership requests driver (don't pass it to clear driver).
|
||||
*/
|
||||
public function setRequestsDriver(IOTS_GuildAction $requests = null)
|
||||
@ -114,7 +114,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Loads guild with given id.
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @param int $id Guild's ID.
|
||||
* @throws PDOException On PDO operation error.
|
||||
@ -124,7 +124,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$ownerid = 'ownerid';
|
||||
if($this->db->hasColumn('guilds', 'owner_id'))
|
||||
$ownerid = 'owner_id';
|
||||
|
||||
|
||||
$creationdata = 'creationdata';
|
||||
if($this->db->hasColumn('guilds', 'creationdate'))
|
||||
$creationdata = 'creationdate';
|
||||
@ -137,7 +137,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Loads guild by it's name.
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @param string $name Guild's name.
|
||||
* @throws PDOException On PDO operation error.
|
||||
@ -156,7 +156,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Checks if object is loaded.
|
||||
*
|
||||
*
|
||||
* @return bool Load state.
|
||||
*/
|
||||
public function isLoaded()
|
||||
@ -166,11 +166,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Saves guild in database.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If guild is not loaded to represent any existing group it will create new row for it.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
@ -179,7 +179,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$ownerid = 'ownerid';
|
||||
if($this->db->hasColumn('guilds', 'owner_id'))
|
||||
$ownerid = 'owner_id';
|
||||
|
||||
|
||||
$creationdata = 'creationdata';
|
||||
if($this->db->hasColumn('guilds', 'creationdate'))
|
||||
$creationdata = 'creationdate';
|
||||
@ -190,13 +190,13 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
if( isset($this->data['id']) )
|
||||
{
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE `guilds` SET `name` = ' . $this->db->quote($this->data['name']) . ', `' . $ownerid . '` = ' . $this->data['ownerid'] . ', `' . $creationdata . '` = ' . $this->data['creationdata'] . ' WHERE `id` = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE `guilds` SET `name` = ' . $this->db->quote($this->data['name']) . ', `' . $ownerid . '` = ' . $this->data['ownerid'] . ', `' . $creationdata . '` = ' . $this->data['creationdata'] . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
// creates new guild
|
||||
else
|
||||
{
|
||||
// INSERT query on database
|
||||
$this->db->query("INSERT INTO `guilds` (`name`, `" . $ownerid . "`, `" . $creationdata . "`, `description`) VALUES (" . $this->db->quote($this->data['name']) . ", " . $this->data['ownerid'] . ", " . $this->data['creationdata'] . ", '')");
|
||||
$this->db->exec("INSERT INTO `guilds` (`name`, `" . $ownerid . "`, `" . $creationdata . "`, `description`) VALUES (" . $this->db->quote($this->data['name']) . ", " . $this->data['ownerid'] . ", " . $this->data['creationdata'] . ", '')");
|
||||
// ID of new group
|
||||
$this->data['id'] = $this->db->lastInsertId();
|
||||
}
|
||||
@ -204,7 +204,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Guild ID.
|
||||
*
|
||||
*
|
||||
* @return int Guild ID.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
*/
|
||||
@ -220,7 +220,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Guild name.
|
||||
*
|
||||
*
|
||||
* @return string Guild's name.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
*/
|
||||
@ -236,11 +236,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sets guild's name.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Guild::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param string $name Name.
|
||||
*/
|
||||
public function setName($name)
|
||||
@ -250,7 +250,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns owning player of this player.
|
||||
*
|
||||
*
|
||||
* @version 0.1.0
|
||||
* @return OTS_Player Owning player.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
@ -270,11 +270,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Assigns guild to owner.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Guild::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player $owner Owning player.
|
||||
* @throws E_OTS_NotLoaded If given <var>$owner</var> object is not loaded.
|
||||
*/
|
||||
@ -285,27 +285,27 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
public function hasMember(OTS_Player $player) {
|
||||
global $db;
|
||||
|
||||
|
||||
if(!$player || !$player->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$player_rank = $player->getRank();
|
||||
if(!$player_rank->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach($this->getGuildRanksList() as $rank) {
|
||||
if($rank->getId() == $player_rank->getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Guild creation data.
|
||||
*
|
||||
*
|
||||
* @return int Guild creation data.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
*/
|
||||
@ -321,11 +321,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sets guild creation data.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Guild::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param int $creationdata Guild creation data.
|
||||
*/
|
||||
public function setCreationData($creationdata)
|
||||
@ -335,15 +335,15 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Reads custom field.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Reads field by it's name. Can read any field of given record that exists in database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.8
|
||||
* @param string $field Field name.
|
||||
* @return string Field value.
|
||||
@ -363,19 +363,19 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Writes custom field.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Write field by it's name. Can write any field of given record that exists in database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: You should use this method only for fields that are not provided in standard setters/getters (SVN fields). This method runs SQL query each time you call it so it highly overloads used resources.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: Make sure that you pass $value argument of correct type. This method determinates whether to quote field value. It is safe - it makes you sure that no unproper queries that could lead to SQL injection will be executed, but it can make your code working wrong way. For example: $object->setCustomField('foo', '1'); will quote 1 as as string ('1') instead of passing it as a integer.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @param string $field Field name.
|
||||
* @param mixed $value Field value.
|
||||
@ -395,7 +395,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$value = $this->db->quote($value);
|
||||
}
|
||||
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('guilds') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('guilds') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,15 +426,15 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* List of ranks in guild.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In difference to {@link OTS_Guild::getGuildRanks() getGuildRanks() method} this method returns filtered {@link OTS_GuildRanks_List OTS_GuildRanks_List} object instead of array of {@link OTS_GuildRank OTS_GuildRank} objects. It is more effective since OTS_GuildRanks_List doesn't perform all rows loading at once.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note: Returned object is only prepared, but not initialised. When using as parameter in foreach loop it doesn't matter since it will return it's iterator, but if you will wan't to execute direct operation on that object you will need to call {@link OTS_Base_List::rewind() rewind() method} first.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.4
|
||||
* @since 0.0.5
|
||||
* @return OTS_GuildRanks_List List of ranks from current guild.
|
||||
@ -460,11 +460,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns list of invited players.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own {@link IOTS_GuildAction invitations drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setInvitesDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return array List of invited players.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no invites driver assigned.
|
||||
@ -487,11 +487,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Invites player to guild.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own {@link IOTS_GuildAction invitations drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setInvitesDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player to be invited.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no invites driver assigned.
|
||||
@ -514,11 +514,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Deletes invitation for player to guild.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own {@link IOTS_GuildAction invitations drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setInvitesDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player to be un-invited.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no invites driver assigned.
|
||||
@ -541,11 +541,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Finalise invitation.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own {@link IOTS_GuildAction invitations drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setInvitesDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player to be joined.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no invites driver assigned.
|
||||
@ -568,11 +568,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns list of players that requested membership.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own {@link IOTS_GuildAction requests drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setRequestsDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return array List of players.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no requests driver assigned.
|
||||
@ -595,11 +595,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Requests membership in guild for player player.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own {@link IOTS_GuildAction requests drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setRequestsDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player that requested membership.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no requests driver assigned.
|
||||
@ -622,11 +622,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Deletes request from player.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own {@link IOTS_GuildAction requests drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setRequestsDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player to be rejected.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no requests driver assigned.
|
||||
@ -649,11 +649,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Accepts player.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own {@link IOTS_GuildAction requests drivers} and assign it using {@link OTS_Guild::setInvitesDriver() setRequestsDriver() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player Player to be accepted.
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
* @throws E_OTS_NoDriver If there is no requests driver assigned.
|
||||
@ -676,7 +676,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Deletes guild.
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @since 0.0.5
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
@ -690,7 +690,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// deletes row from database
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('guilds') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('guilds') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
|
||||
// resets object handle
|
||||
unset($this->data['id']);
|
||||
@ -698,11 +698,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns ranks iterator.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* There is no need to implement entire Iterator interface since we have {@link OTS_GuildRanks_List ranks list class} for it.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @since 0.0.5
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
@ -716,7 +716,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns number of ranks within.
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @since 0.0.5
|
||||
* @throws E_OTS_NotLoaded If guild is not loaded.
|
||||
@ -730,7 +730,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @since 0.1.0
|
||||
* @param string $name Property name.
|
||||
@ -773,7 +773,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @version 0.1.0
|
||||
* @since 0.1.0
|
||||
* @param string $name Property name.
|
||||
@ -812,11 +812,11 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Returns string representation of object.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If any display driver is currently loaded then it uses it's method. Else it returns guild name.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @since 0.1.0
|
||||
* @return string String representation of object.
|
||||
|
@ -106,13 +106,13 @@ class OTS_GuildRank extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
if( isset($this->data['id']) )
|
||||
{
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('guild_ranks') . ' SET ' . $this->db->fieldName('guild_id') . ' = ' . $this->db->quote($this->data['guild_id']) . ', ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('level') . ' = ' . $this->data['level'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE ' . $this->db->tableName('guild_ranks') . ' SET ' . $this->db->fieldName('guild_id') . ' = ' . $this->db->quote($this->data['guild_id']) . ', ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('level') . ' = ' . $this->data['level'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
// creates new rank
|
||||
else
|
||||
{
|
||||
// INSERT query on database
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('guild_ranks') . ' (' . $this->db->fieldName('guild_id') . ', ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('level') . ') VALUES (' . $this->data['guild_id'] . ', ' . $this->db->quote($this->data['name']) . ', ' . $this->data['level'] . ')');
|
||||
$this->db->exec('INSERT INTO ' . $this->db->tableName('guild_ranks') . ' (' . $this->db->fieldName('guild_id') . ', ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('level') . ') VALUES (' . $this->data['guild_id'] . ', ' . $this->db->quote($this->data['name']) . ', ' . $this->data['level'] . ')');
|
||||
// ID of new rank
|
||||
$this->data['id'] = $this->db->lastInsertId();
|
||||
}
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
/**
|
||||
* Wrapper for house information.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Unlike other {@link OTS_Base_DAO OTS_Base_DAO} child classes, OTS_House bases not only on database, but also loads some additional info from XML DOM node. It can't be load - it is always initialised with {@link http://www.php.net/manual/en/ref.dom.php DOMElement} object. Saving will only update database row - won't change XML data. Same about using {@link OTS_House::delete() delete() method}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.3
|
||||
* @property OTS_Player $owner House owner.
|
||||
@ -38,23 +38,23 @@ class OTS_House extends OTS_Row_DAO
|
||||
{
|
||||
/**
|
||||
* House rent info.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $data = array();
|
||||
|
||||
|
||||
//private $columns = array('id', 'name', 'owner', 'paid', 'warnings', 'rent', 'beds');
|
||||
|
||||
/**
|
||||
* Information handler.
|
||||
*
|
||||
*
|
||||
* @var DOMElement
|
||||
*/
|
||||
private $element;
|
||||
|
||||
/**
|
||||
* Tiles list.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $tiles = array();
|
||||
@ -67,7 +67,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function find($name)
|
||||
{
|
||||
// finds player's ID
|
||||
@ -83,7 +83,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
public function setElement(DOMElement $element) {
|
||||
$this->element = $element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if object is loaded.
|
||||
*
|
||||
@ -96,11 +96,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Allows object serialisation.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return array List of properties that should be saved.
|
||||
*/
|
||||
public function __sleep()
|
||||
@ -110,7 +110,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Saves info in database.
|
||||
*
|
||||
*
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function save()
|
||||
@ -118,7 +118,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
// inserts new record
|
||||
if( empty($this->data) )
|
||||
{
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('houses') . ' (' . $this->db->fieldName('id') . ', ' . $this->db->fieldName('owner') . ', ' . $this->db->fieldName('paid') . ', ' . $this->db->fieldName('warnings') . ') VALUES (' . $this->getId() . ', ' . $this->data['owner'] . ', ' . $this->data['paid'] . ', ' . $this->data['warnings'] . ')');
|
||||
$this->db->exec('INSERT INTO ' . $this->db->tableName('houses') . ' (' . $this->db->fieldName('id') . ', ' . $this->db->fieldName('owner') . ', ' . $this->db->fieldName('paid') . ', ' . $this->db->fieldName('warnings') . ') VALUES (' . $this->getId() . ', ' . $this->data['owner'] . ', ' . $this->data['paid'] . ', ' . $this->data['warnings'] . ')');
|
||||
}
|
||||
// updates previous one
|
||||
else
|
||||
@ -129,13 +129,13 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Deletes house info from database.
|
||||
*
|
||||
*
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// deletes row from database
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('houses') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('houses') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
|
||||
// resets object handle
|
||||
$this->data = array();
|
||||
@ -143,7 +143,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns house's ID.
|
||||
*
|
||||
*
|
||||
* @return int House ID.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
@ -160,7 +160,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Return house's name.
|
||||
*
|
||||
*
|
||||
* @return string House name.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
@ -169,7 +169,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['name'])) {
|
||||
return $this->data['name'];
|
||||
}
|
||||
|
||||
|
||||
if($this->element) {
|
||||
return $this->element->getAttribute('name');
|
||||
}
|
||||
@ -177,7 +177,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns town ID in which house is located.
|
||||
*
|
||||
*
|
||||
* @return int Town ID.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
@ -192,18 +192,18 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['townid'])) {
|
||||
return $this->data['townid'];
|
||||
}
|
||||
|
||||
|
||||
if($this->element) {
|
||||
return (int) $this->element->getAttribute('townid');
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns town name.
|
||||
*
|
||||
*
|
||||
* @return string Town name.
|
||||
* @throws E_OTS_NotLoaded When map file is not loaded to fetch towns names.
|
||||
*/
|
||||
@ -214,7 +214,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns house rent cost.
|
||||
*
|
||||
*
|
||||
* @return int Rent cost.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
@ -225,7 +225,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns house size.
|
||||
*
|
||||
*
|
||||
* @return int House size.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
@ -236,7 +236,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns entry position.
|
||||
*
|
||||
*
|
||||
* @return OTS_MapCoords Entry coordinations on map.
|
||||
*/
|
||||
public function getEntry()
|
||||
@ -248,12 +248,12 @@ class OTS_House extends OTS_Row_DAO
|
||||
if( isset($this->data['owner'])) {
|
||||
return $this->data['owner'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns current house owner.
|
||||
*
|
||||
*
|
||||
* @return OTS_Player|null Player that currently owns house (null if there is no owner).
|
||||
*/
|
||||
public function getOwner()
|
||||
@ -273,11 +273,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets house owner.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_House::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param OTS_Player $player House owner to be set.
|
||||
* @throws E_OTS_NotLoaded If given <var>$player</var> object is not loaded.
|
||||
*/
|
||||
@ -288,7 +288,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns paid date.
|
||||
*
|
||||
*
|
||||
* @return int|false Date timestamp until which house is rent (false if none).
|
||||
*/
|
||||
public function getPaid()
|
||||
@ -306,11 +306,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets paid date.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_House::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param int $paid Sets paid timestamp to passed one.
|
||||
*/
|
||||
public function setPaid($paid)
|
||||
@ -320,7 +320,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns house warnings.
|
||||
*
|
||||
*
|
||||
* @version 0.1.2
|
||||
* @return int|false Warnings text (false if none).
|
||||
*/
|
||||
@ -339,11 +339,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Sets house warnings.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_House::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.2
|
||||
* @param int $warnings Sets house warnings.
|
||||
*/
|
||||
@ -356,10 +356,10 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['bid'])) {
|
||||
return $this->data['bid'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function setBid($bid) {
|
||||
$this->data['bid'] = $bid;
|
||||
}
|
||||
@ -368,10 +368,10 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['bid_end'])) {
|
||||
return $this->data['bid_end'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function setBidEnd($bid_end) {
|
||||
$this->data['bid_end'] = $bid_end;
|
||||
}
|
||||
@ -380,7 +380,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['last_bid'])) {
|
||||
return $this->data['last_bid'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -392,16 +392,16 @@ class OTS_House extends OTS_Row_DAO
|
||||
if(isset($this->data['highest_bidder'])) {
|
||||
return $this->data['highest_bidder'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function setHighestBidder($highest_bidder) {
|
||||
$this->data['highest_bidder'] = $highest_bidder;
|
||||
}
|
||||
/**
|
||||
* Adds tile to house.
|
||||
*
|
||||
*
|
||||
* @param OTS_MapCoords $tile Tile to be added.
|
||||
*/
|
||||
public function addTile(OTS_MapCoords $tile)
|
||||
@ -411,11 +411,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns tiles list.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This returns list of coords of tiles used by this house on map. It will succeed only if house object was created during map loading with houses file opened to assign loaded tiles.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return array List of tiles.
|
||||
*/
|
||||
public function getTiles()
|
||||
@ -425,7 +425,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @param string $name Property name.
|
||||
* @return mixed Property value.
|
||||
* @throws E_OTS_NotLoaded When atempt to read info about map while map not being loaded.
|
||||
@ -476,7 +476,7 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @param string $name Property name.
|
||||
* @param mixed $value Property value.
|
||||
* @throws E_OTS_NotLoaded If passed parameter for owner field won't be loaded.
|
||||
@ -505,11 +505,11 @@ class OTS_House extends OTS_Row_DAO
|
||||
|
||||
/**
|
||||
* Returns string representation of object.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If any display driver is currently loaded then it uses it's method. Otherwise just returns house ID.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @since 0.1.3
|
||||
* @return string String representation of object.
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
/**
|
||||
* List of players.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.3
|
||||
*/
|
||||
@ -23,16 +23,16 @@ class OTS_Players_List extends OTS_Base_List
|
||||
*/
|
||||
public function deletePlayer(OTS_Player $player)
|
||||
{
|
||||
$this->db->query('DELETE FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $player->getId() );
|
||||
$this->db->exec('DELETE FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $player->getId() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list parameters.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method is called at object creation.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.0.5
|
||||
* @since 0.0.5
|
||||
*/
|
||||
@ -44,11 +44,11 @@ class OTS_Players_List extends OTS_Base_List
|
||||
|
||||
/**
|
||||
* Returns string representation of object.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* If any display driver is currently loaded then it uses it's method.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @since 0.1.0
|
||||
* @return string String representation of object.
|
||||
|
@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
class Spells {
|
||||
private static $spellsList = null;
|
||||
private static $lastError = '';
|
||||
|
||||
|
||||
// 1 - attack, 2 - healing, 3 - summon, 4 - supply, 5 - support
|
||||
public static function loadGroup($tGroup) {
|
||||
switch ($tGroup) {
|
||||
@ -22,24 +22,24 @@ class Spells {
|
||||
case "healing":
|
||||
return 2;
|
||||
case "summon":
|
||||
return 3;
|
||||
return 3;
|
||||
case "supply":
|
||||
return 4;
|
||||
case "support":
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
|
||||
try { $db->query('DELETE FROM `' . TABLE_PREFIX . 'spells`;'); } catch(PDOException $error) {}
|
||||
|
||||
|
||||
try { $db->exec('DELETE FROM `' . TABLE_PREFIX . 'spells`;'); } catch(PDOException $error) {}
|
||||
|
||||
if($show) {
|
||||
echo '<h2>Reload spells.</h2>';
|
||||
echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>';
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
self::$spellsList = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
|
||||
}
|
||||
@ -47,21 +47,21 @@ class Spells {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//add conjure spells
|
||||
$conjurelist = self::$spellsList->getConjuresList();
|
||||
if($show) {
|
||||
echo "<h3>Conjure:</h3>";
|
||||
}
|
||||
|
||||
|
||||
foreach($conjurelist as $spellname) {
|
||||
$spell = self::$spellsList->getConjure($spellname);
|
||||
$name = $spell->getName();
|
||||
|
||||
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
@ -89,21 +89,21 @@ class Spells {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add instant spells
|
||||
$instantlist = self::$spellsList->getInstantsList();
|
||||
if($show) {
|
||||
echo "<h3>Instant:</h3>";
|
||||
}
|
||||
|
||||
|
||||
foreach($instantlist as $spellname) {
|
||||
$spell = self::$spellsList->getInstant($spellname);
|
||||
$name = $spell->getName();
|
||||
|
||||
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
@ -118,7 +118,7 @@ class Spells {
|
||||
'conjure_count' => 0,
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
|
||||
if($show) {
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
@ -129,13 +129,13 @@ class Spells {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add runes
|
||||
$runeslist = self::$spellsList->getRunesList();
|
||||
if($show) {
|
||||
echo "<h3>Runes:</h3>";
|
||||
}
|
||||
|
||||
|
||||
foreach($runeslist as $spellname) {
|
||||
$spell = self::$spellsList->getRune($spellname);
|
||||
|
||||
@ -156,7 +156,7 @@ class Spells {
|
||||
'item_id' => $spell->getID(),
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
|
||||
if($show) {
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
@ -167,14 +167,14 @@ class Spells {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function getSpellsList() {
|
||||
return self::$spellsList;
|
||||
}
|
||||
|
||||
|
||||
public static function getLastError() {
|
||||
return self::$lastError;
|
||||
}
|
||||
|
@ -16,21 +16,21 @@ class Weapons {
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
global $config, $db;
|
||||
|
||||
|
||||
try {
|
||||
$db->query("DELETE FROM `myaac_weapons`;");
|
||||
$db->exec("DELETE FROM `myaac_weapons`;");
|
||||
} catch (PDOException $error) {
|
||||
}
|
||||
|
||||
|
||||
$file_path = $config['data_path'] . 'weapons/weapons.xml';
|
||||
if (!file_exists($file_path)) {
|
||||
self::$error = 'Cannot load file ' . $file_path;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$xml = new DOMDocument;
|
||||
$xml->load($file_path);
|
||||
|
||||
|
||||
foreach ($xml->getElementsByTagName('wand') as $weapon) {
|
||||
self::parseNode($weapon, $show);
|
||||
}
|
||||
@ -40,18 +40,18 @@ class Weapons {
|
||||
foreach ($xml->getElementsByTagName('distance') as $weapon) {
|
||||
self::parseNode($weapon, $show);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function parseNode($node, $show = false) {
|
||||
global $config, $db;
|
||||
|
||||
|
||||
$id = (int)$node->getAttribute('id');
|
||||
$vocations_ids = array_flip($config['vocations']);
|
||||
$level = (int)$node->getAttribute('level');
|
||||
$maglevel = (int)$node->getAttribute('maglevel');
|
||||
|
||||
|
||||
$vocations = array();
|
||||
foreach($node->getElementsByTagName('vocation') as $vocation) {
|
||||
$show = $vocation->getAttribute('showInDescription');
|
||||
@ -60,10 +60,10 @@ class Weapons {
|
||||
else {
|
||||
$voc_id = $vocations_ids[$vocation->getAttribute('name')];
|
||||
}
|
||||
|
||||
|
||||
$vocations[$voc_id] = strlen($show) == 0 || $show != '0';
|
||||
}
|
||||
|
||||
|
||||
$exist = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'weapons` WHERE `id` = ' . $id);
|
||||
if($exist->rowCount() > 0) {
|
||||
if($show) {
|
||||
@ -74,7 +74,7 @@ class Weapons {
|
||||
$db->insert(TABLE_PREFIX . 'weapons', array('id' => $id, 'level' => $level, 'maglevel' => $maglevel, 'vocations' => json_encode($vocations)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum` ADD `post_html` TINYINT(1) NOT NULL DEFAULT 0 AFTER `post_smile`;");
|
||||
$db->exec("ALTER TABLE `" . TABLE_PREFIX . "forum` ADD `post_html` TINYINT(1) NOT NULL DEFAULT 0 AFTER `post_smile`;");
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX . "forum_boards` WHERE `name` LIKE " . $db->quote('News') . " LIMIT 1;");
|
||||
if($query->rowCount() == 0) {
|
||||
@ -11,4 +11,4 @@ $query = $query->fetch();
|
||||
$id = $query['id'];
|
||||
|
||||
// update all forum threads with is_html = 1
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `post_html` = 1 WHERE `section` = " . $id . " AND `id` = `first_post`;");
|
||||
$db->exec("UPDATE `" . TABLE_PREFIX . "forum` SET `post_html` = 1 WHERE `section` = " . $id . " AND `id` = `first_post`;");
|
@ -120,9 +120,9 @@ if(isset($todo) && $todo == 'save')
|
||||
'leader_name' => $player->getName()
|
||||
));
|
||||
|
||||
/*$db->query('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "the Leader", 3)');
|
||||
$db->query('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Vice-Leader", 2)');
|
||||
$db->query('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Member", 1)');*/
|
||||
/*$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "the Leader", 3)');
|
||||
$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Vice-Leader", 2)');
|
||||
$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Member", 1)');*/
|
||||
}
|
||||
else {
|
||||
sort($array_of_player_nig);
|
||||
|
Loading…
x
Reference in New Issue
Block a user