POT
POT
POT
Main menu

Download

Forum

SVN

Class: OTS_Guild

Source Location: /classes/OTS_Guild.php

Class OTS_Guild

Class Overview

Implements interfaces:

  • IteratorAggregate (internal interface)
  • Countable (internal interface)

OTServ guild abstraction.

OTServ guild abstraction.

Located in /classes/OTS_Guild.php [line 33]

OTS_Base_DAO
   |
   --OTS_Row_DAO
      |
      --OTS_Guild
Author(s):
API Tags:
Property:  string $read: Guild name.
Property:  OTS_Player $owner: Guild founder.
Property:  int $creationData: Guild creation data (mostly timestamp).
Property-read:  int $id: Guild ID.
Property-read:  bool $loaded: Loaded state.
Property-read:  OTS_GuildRanks_List $guildRanksList: Ranks in this guild.
Property-read:  array $invites: List of invited players.
Property-read:  array $requests: List of players that requested invites.
Property-write:  IOTS_GuildAction $invitesDriver: Invitations handler.
Property-write:  IOTS_GuildAction $requestsDriver: Membership requests handler.

Information Tags:
Tutorial:  Guilds
Version:  0.0.4
Version:  0.1.4
Since:  0.0.4

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From OTS_Base_DAO

OTS_Base_DAO::$db

Inherited From OTS_Row_DAO

OTS_Row_DAO::__construct()
Handles automatic loading for record.
OTS_Row_DAO::find()
Loads row by it's name.
OTS_Row_DAO::load()
Loads row by it's ID.

Inherited From OTS_Base_DAO

OTS_Base_DAO::__construct()
Sets database connection handler.
OTS_Base_DAO::__clone()
Creates clone of object.
OTS_Base_DAO::__set_state()
Magic PHP5 method.
OTS_Base_DAO::__sleep()
Magic PHP5 method.
OTS_Base_DAO::__wakeup()
Magic PHP5 method.

[ Top ]
Method Summary
void   acceptInvite()   Finalise invitation.
void   acceptRequest()   Accepts player.
int   count()   Returns number of ranks within.
void   delete()   Deletes guild.
void   deleteInvite()   Deletes invitation for player to guild.
void   deleteRequest()   Deletes request from player.
void   find()   Loads guild by it's name.
int   getCreationData()   Guild creation data.
string   getCustomField()   Reads custom field.
array   getGuildRanks()  
OTS_GuildRanks_List   getGuildRanksList()   List of ranks in guild.
int   getId()   Guild ID.
Iterator   getIterator()   Returns ranks iterator.
string   getName()   Guild name.
OTS_Player   getOwner()   Returns owning player of this player.
void   invite()   Invites player to guild.
bool   isLoaded()   Checks if object is loaded.
array   listInvites()   Returns list of invited players.
array   listRequests()   Returns list of players that requested membership.
void   load()   Loads guild with given id.
void   request()   Requests membership in guild for player player.
void   save()   Saves guild in database.
void   setCreationData()   Sets guild creation data.
void   setCustomField()   Writes custom field.
void   setInvitesDriver()   Assigns invites handler.
void   setName()   Sets guild's name.
void   setOwner()   Assigns guild to owner.
void   setRequestsDriver()   Assigns requests handler.
void   __clone()   Creates clone of object.
mixed   __get()   Magic PHP5 method.
void   __set()   Magic PHP5 method.
array   __sleep()   Magic PHP5 method.
string   __toString()   Returns string representation of object.

[ Top ]
Methods
acceptInvite  [line 512]

  void acceptInvite( OTS_Player $player  )

Finalise invitation.

Finalise invitation. OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own invitations drivers and assign it using setInvitesDriver() method.

Parameters:
OTS_Player   $player:  Player to be joined.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no invites driver assigned.
Since:  0.0.4

[ Top ]
acceptRequest  [line 620]

  void acceptRequest( OTS_Player $player  )

Accepts player.

Accepts player. OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own requests drivers and assign it using setRequestsDriver() method.

Parameters:
OTS_Player   $player:  Player to be accepted.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no requests driver assigned.
Since:  0.0.4

[ Top ]
count  [line 685]

  int count( )

Returns number of ranks within.

Returns number of ranks within.


API Tags:
Return:  Count of ranks.
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Since:  0.0.5

Implementation of:
Countable::count

[ Top ]
delete  [line 644]

  void delete( )

Deletes guild.

Deletes guild.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Since:  0.0.5

[ Top ]
deleteInvite  [line 485]

  void deleteInvite( OTS_Player $player  )

Deletes invitation for player to guild.

Deletes invitation for player to guild. OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own invitations drivers and assign it using setInvitesDriver() method.

Parameters:
OTS_Player   $player:  Player to be un-invited.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no invites driver assigned.
Since:  0.0.4

[ Top ]
deleteRequest  [line 593]

  void deleteRequest( OTS_Player $player  )

Deletes request from player.

Deletes request from player. OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own requests drivers and assign it using setRequestsDriver() method.

Parameters:
OTS_Player   $player:  Player to be rejected.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no requests driver assigned.
Since:  0.0.4

[ Top ]
find  [line 134]

  void find( string $name  )

Loads guild by it's name.

Loads guild by it's name.

Parameters:
string   $name:  Guild's name.

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Since:  0.0.4

Redefinition of:
OTS_Row_DAO::find()
Loads row by it's name.

[ Top ]
getCreationData  [line 271]

  int getCreationData( )

Guild creation data.

Guild creation data.


API Tags:
Return:  Guild creation data.
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4

[ Top ]
getCustomField  [line 312]

  string getCustomField( string $field  )

Reads custom field.

Reads custom field. Reads field by it's name. Can read any field of given record that exists in database.

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.

Parameters:
string   $field:  Field name.

API Tags:
Return:  Field value.
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Throws:  PDOException On PDO operation error.

[ Top ]
getGuildRanks  [line 366]

  array getGuildRanks( )


API Tags:
Return:  List of ranks.
Deprecated:  0.0.5 Use getGuildRanksList().
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.4
Since:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.

[ Top ]
getGuildRanksList  [line 402]

  OTS_GuildRanks_List getGuildRanksList( )

List of ranks in guild.

List of ranks in guild. In difference to getGuildRanks() method this method returns filtered OTS_GuildRanks_List object instead of array of OTS_GuildRank objects. It is more effective since OTS_GuildRanks_List doesn't perform all rows loading at once.

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 rewind() method first.


API Tags:
Return:  List of ranks from current guild.
Access:  public

Information Tags:
Version:  0.1.4
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.5
Since:  0.0.4

[ Top ]
getId  [line 190]

  int getId( )

Guild ID.

Guild ID.


API Tags:
Return:  Guild ID.
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4

[ Top ]
getIterator  [line 671]

  Iterator getIterator( )

Returns ranks iterator.

Returns ranks iterator. There is no need to implement entire Iterator interface since we have ranks list class for it.


API Tags:
Return:  List of ranks.
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Since:  0.0.5

Implementation of:
IteratorAggregate::getIterator

[ Top ]
getName  [line 206]

  string getName( )

Guild name.

Guild name.


API Tags:
Return:  Guild's name.
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4

[ Top ]
getOwner  [line 238]

  OTS_Player getOwner( )

Returns owning player of this player.

Returns owning player of this player.


API Tags:
Return:  Owning player.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Throws:  PDOException On PDO operation error.

[ Top ]
invite  [line 458]

  void invite( OTS_Player $player  )

Invites player to guild.

Invites player to guild. OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own invitations drivers and assign it using setInvitesDriver() method.

Parameters:
OTS_Player   $player:  Player to be invited.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no invites driver assigned.
Since:  0.0.4

[ Top ]
isLoaded  [line 151]

  bool isLoaded( )

Checks if object is loaded.

Checks if object is loaded.


API Tags:
Return:  Load state.
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

[ Top ]
listInvites  [line 431]

  array listInvites( )

Returns list of invited players.

Returns list of invited players. OTServ and it's database doesn't provide such feature like guild invitations. In order to use this mechanism you have to write own invitations drivers and assign it using setInvitesDriver() method.


API Tags:
Return:  List of invited players.
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no invites driver assigned.
Since:  0.0.4

[ Top ]
listRequests  [line 539]

  array listRequests( )

Returns list of players that requested membership.

Returns list of players that requested membership. OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own requests drivers and assign it using setRequestsDriver() method.


API Tags:
Return:  List of players.
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no requests driver assigned.
Since:  0.0.4

[ Top ]
load  [line 121]

  void load( int $id  )

Loads guild with given id.

Loads guild with given id.

Parameters:
int   $id:  Guild's ID.

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Since:  0.0.4

Redefinition of:
OTS_Row_DAO::load()
Loads row by it's ID.

[ Top ]
request  [line 566]

  void request( OTS_Player $player  )

Requests membership in guild for player player.

Requests membership in guild for player player. OTServ and it's database doesn't provide such feature like membership requests. In order to use this mechanism you have to write own requests drivers and assign it using setRequestsDriver() method.

Parameters:
OTS_Player   $player:  Player that requested membership.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Throws:  E_OTS_NoDriver If there is no requests driver assigned.
Since:  0.0.4

[ Top ]
save  [line 166]

  void save( )

Saves guild in database.

Saves guild in database. If guild is not loaded to represent any existing group it will create new row for it.


API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Since:  0.0.4

[ Top ]
setCreationData  [line 290]

  void setCreationData( int $creationdata  )

Sets guild creation data.

Sets guild creation data. This method only updates object state. To save changes in database you need to use save() method to flush changed to database.

Parameters:
int   $creationdata:  Guild creation data.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

[ Top ]
setCustomField  [line 344]

  void setCustomField( string $field, mixed $value  )

Writes custom field.

Writes custom field. Write field by it's name. Can write any field of given record that exists in database.

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.

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.

Parameters:
string   $field:  Field name.
mixed   $value:  Field value.

API Tags:
Access:  public

Information Tags:
Version:  0.0.5
Version:  0.0.4
Throws:  E_OTS_NotLoaded If guild is not loaded.
Since:  0.0.4
Throws:  PDOException On PDO operation error.

[ Top ]
setInvitesDriver  [line 99]

  void setInvitesDriver( [IOTS_GuildAction $invites = null]  )

Assigns invites handler.

Assigns invites handler.

Parameters:
IOTS_GuildAction   $invites:  Invites driver (don't pass it to clear driver).

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

[ Top ]
setName  [line 225]

  void setName( string $name  )

Sets guild's name.

Sets guild's name. This method only updates object state. To save changes in database you need to use save() method to flush changed to database.

Parameters:
string   $name:  Name.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

[ Top ]
setOwner  [line 260]

  void setOwner( OTS_Player $owner  )

Assigns guild to owner.

Assigns guild to owner. This method only updates object state. To save changes in database you need to use save() method to flush changed to database.

Parameters:
OTS_Player   $owner:  Owning player.

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Throws:  E_OTS_NotLoaded If given $owner object is not loaded.
Since:  0.0.4

[ Top ]
setRequestsDriver  [line 109]

  void setRequestsDriver( [IOTS_GuildAction $requests = null]  )

Assigns requests handler.

Assigns requests handler.

Parameters:
IOTS_GuildAction   $requests:  Membership requests driver (don't pass it to clear driver).

API Tags:
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

[ Top ]
__clone  [line 77]

  void __clone( )

Creates clone of object.

Creates clone of object. Copy of object needs to have different ID. Also invites and requests drivers are copied and assigned to object's copy.


API Tags:
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.4
Since:  0.0.4

Redefinition of:
OTS_Base_DAO::__clone()
Creates clone of object.

[ Top ]
__get  [line 700]

  mixed __get( string $name  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.

API Tags:
Return:  Property value.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.4
Throws:  PDOException On PDO operation error.
Throws:  OutOfBoundsException For non-supported properties.
Since:  0.0.4
Since:  0.1.0

[ Top ]
__set  [line 743]

  void __set( string $name, mixed $value  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.
mixed   $value:  Property value.

API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.4
Throws:  OutOfBoundsException For non-supported properties.
Throws:  E_OTS_NotLoaded If passed parameter for owner field won't be loaded.
Since:  0.0.4
Since:  0.1.0

[ Top ]
__sleep  [line 63]

  array __sleep( )

Magic PHP5 method.

Magic PHP5 method. Allows object serialisation.


API Tags:
Return:  List of properties that should be saved.
Access:  public

Information Tags:
Version:  0.0.4
Since:  0.0.4

Redefinition of:
OTS_Base_DAO::__sleep()
Magic PHP5 method.

[ Top ]
__toString  [line 783]

  string __toString( )

Returns string representation of object.

Returns string representation of object. If any display driver is currently loaded then it uses it's method. Else it returns guild name.


API Tags:
Return:  String representation of object.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.4
Since:  0.0.4
Since:  0.1.0

[ Top ]