# \hhu\z\modelsAchievementsModel

Model to interact with Achievements-tables.

## Summary

Methods
Properties
Constants
__construct()
load()
factory()
getAchievementByUrl()
getAchievementById()
getUnachievedOnlyOnceAchievementsForSeminary()
getDeadlineAchievements()
getSeldomAchievements()
getAchievedAchievementsForCharacter()
getUnachhievedAchievementsForCharacter()
getAchievementsCountForSeminary()
getAchievementsForSeminary()
getCountRank()
getAchievementConditionsDate()
checkAchievementConditionDate()
addAchievementConditionDate()
editAchievementConditionDate()
deleteAchievementConditionDate()
getAchievementConditionsCharacter()
checkAchievementConditionCharacter()
getAchievementConditionCharacterProgress()
addAchievementConditionCharacter()
editAchievementConditionCharacter()
deleteAchievementConditionCharacter()
getAchievementConditionsQuest()
checkAchievementConditionQuest()
getAchievementConditionQuestProgress()
addAchievementConditionQuest()
editAchievementConditionQuest()
deleteAchievementConditionQuest()
getAchievementConditionsAchievement()
checkAchievementConditionAchievement()
getAchievementConditionAchievementProgress()
addAchievementConditionAchievement()
editAchievementConditionAchievement()
deleteAchievementConditionAchievement()
setAchievementAchieved()
hasCharacterAchievedAchievement()
getAchievementsConditions()
achievementTitleExists()
createAchievement()
moveAchievement()
editAchievement()
setUnachievedMediaForAchievement()
setAchievedMediaForAchievement()
deleteAchievement()
No public properties found
No constants found
No protected methods found
$db
N/A
loadDriver()
connect()
getClassName()
loadModels()
No private properties found
N/A

File
  models/AchievementsModel.inc
Package
  Default
Class hierarchy
  \nre\core\Model
  \nre\models\DatabaseModel
  \hhu\z\Model
  \hhu\z\models\AchievementsModel

## Tags

author | Oliver Hanraths oliver.hanraths@uni-duesseldorf.de

## Properties

### $db

    $db : \nre\models\DatabaseDriver

Database connection

#### Type

\nre\models\DatabaseDriver

#

Inherited from
  \nre\models\DatabaseModel

## Tags

static |

## Methods

### __construct()

    __construct()

Construct a new AchievementsModel.

TODO Catch exception

#

## Tags

None found

### load()

    load(string  $modelName)

Load the class of a Model.

#### Parameters

string | $modelName | Name of the Model to load

#### Throws

\nre\exceptions\ModelNotFoundException
\nre\exceptions\ModelNotValidException

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### factory()

    factory(string  $modelName)

Instantiate a Model (Factory Pattern).

#### Parameters

string | $modelName | Name of the Model to instantiate

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### getAchievementByUrl()

    getAchievementByUrl(integer  $seminaryId, string  $achievementUrl) : array

Get an Achievement by its URL.

#### Parameters

integer | $seminaryId | ID of Seminary
string | $achievementUrl | URL-title of Achievement

#### Returns

array —

Achievement data

#

## Tags

None found

### getAchievementById()

    getAchievementById(integer  $achievementId) : array

Get an Achievement by its ID.

#### Parameters

integer | $achievementId | ID of Achievement

#### Returns

array —

Achievement data

#

## Tags

None found

### getUnachievedOnlyOnceAchievementsForSeminary()

    getUnachievedOnlyOnceAchievementsForSeminary(integer  $seminaryId) : array

Get all not yet achieved Achievements for a Seminary that can only be achieved once (only by one Character).

#### Parameters

integer | $seminaryId | ID of Seminary

#### Returns

array —

Achievements data

#

## Tags

None found

### getDeadlineAchievements()

    getDeadlineAchievements(integer  $seminaryId) : array

Get all Achievements that have a deadline.

#### Parameters

integer | $seminaryId | ID of Seminary

#### Returns

array —

Achievements data

#

## Tags

None found

### getSeldomAchievements()

    getSeldomAchievements(integer  $seminaryId, integer  $count, boolean  $alsoWithDeadline = true) : array

Get seldom Achievements.

#### Parameters

integer | $seminaryId | ID of Seminary
integer | $count | Number of Achievements to retrieve
boolean | $alsoWithDeadline | Include Achievements with deadline (optional)

#### Returns

array —

List of seldom Achievements

#

## Tags

None found

### getAchievedAchievementsForCharacter()

    getAchievedAchievementsForCharacter(integer  $characterId, boolean  $alsoWithDeadline = true) : array

Get all achieved Achievements for a Character.

#### Parameters

integer | $characterId | ID of Character
boolean | $alsoWithDeadline | Include Achievements with deadline (optional)

#### Returns

array —

Achievements data

#

## Tags

None found

### getUnachhievedAchievementsForCharacter()

    getUnachhievedAchievementsForCharacter(integer  $seminaryId, integer  $characterId, boolean  $includeOnlyOnce = false, boolean  $alsoWithDeadline = true) : array

Get all not yet achieved Achievements for a Character.

#### Parameters

integer | $seminaryId | ID of Seminary
integer | $characterId | ID of Character
boolean | $includeOnlyOnce | Include Achievements that can only be achieved by one Character
boolean | $alsoWithDeadline | Include milestone Achievements

#### Returns

array —

Achievements data

#

## Tags

None found

### getAchievementsCountForSeminary()

    getAchievementsCountForSeminary(integer  $seminaryId, boolean  $includeOnlyOnce = false, boolean  $alsoWithDeadline = true) : integer

Get the amount of Achievement for a Seminary.

#### Parameters

integer | $seminaryId | ID of Seminary
boolean | $includeOnlyOnce | Include Achievements that can only be achieved by one Character
boolean | $alsoWithDeadline | Include milestone Achievements

#### Returns

integer —

Count of Achievements

#

## Tags

None found

### getAchievementsForSeminary()

    getAchievementsForSeminary(integer  $seminaryId) : array

Get all Achievements for a Seminary.

#### Parameters

integer | $seminaryId | ID of Seminary

#### Returns

array —

List of Achievements

#

## Tags

None found

### getCountRank()

    getCountRank(integer  $seminaryId,   $count) : integer

Get the rank for the number of achieved Achievements.

#### Parameters

integer | $seminaryId | ID of Seminary
| $count |

#### Returns

integer —

Rank of Achievements count

#

## Tags

None found

### getAchievementConditionsDate()

    getAchievementConditionsDate(integer  $achievementId) : array

Get all date conditions for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement

#### Returns

array —

Date conditions

#

## Tags

None found

### checkAchievementConditionDate()

    checkAchievementConditionDate(string  $select) : boolean

Check a date condition.

#### Parameters

string | $select | SELECT-string with date-functions

#### Returns

boolean —

Result

#

## Tags

None found

### addAchievementConditionDate()

    addAchievementConditionDate(integer  $userId, integer  $achievementId, string  $select)

Add a new date condition.

#### Parameters

integer | $userId | ID of creating user
integer | $achievementId | ID of Achievement to add condition to
string | $select | SELECT-string for condition

#

## Tags

None found

### editAchievementConditionDate()

    editAchievementConditionDate(integer  $conditionId, string  $select)

Edit a date condition.

#### Parameters

integer | $conditionId | ID of condition to edit
string | $select | New SELECT-string for condition

#

## Tags

None found

### deleteAchievementConditionDate()

    deleteAchievementConditionDate(integer  $conditionId)

Delete a date condition.

#### Parameters

integer | $conditionId | ID of condition to delete

#

## Tags

None found

### getAchievementConditionsCharacter()

    getAchievementConditionsCharacter(integer  $achievementId) : array

Get all Character conditions for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement

#### Returns

array —

Character conditions

#

## Tags

None found

### checkAchievementConditionCharacter()

    checkAchievementConditionCharacter(string  $field, integer  $value, integer  $characterId) : boolean

Check a Character condition.

#### Parameters

string | $field | Field to check
integer | $value | The value the field has to match
integer | $characterId | ID of Character

#### Returns

boolean —

Result

#

## Tags

None found

### getAchievementConditionCharacterProgress()

    getAchievementConditionCharacterProgress(string  $field, integer  $value, integer  $characterId) : float

Get the progress for a Character condition.

#### Parameters

string | $field | Field to check
integer | $value | The value the field has to match
integer | $characterId | ID of Character

#### Returns

float —

Percentage progress

#

## Tags

None found

### addAchievementConditionCharacter()

    addAchievementConditionCharacter(integer  $userId, integer  $achievementId, string  $field, string  $value)

Add a new Character condition.

#### Parameters

integer | $userId | ID of creating user
integer | $achievementId | ID of Achievement to add condition to
string | $field | Field to match
string | $value | Value to match

#

## Tags

None found

### editAchievementConditionCharacter()

    editAchievementConditionCharacter(integer  $conditionId, string  $field, string  $value)

Edit a Character condition.

#### Parameters

integer | $conditionId | ID of condition to edit
string | $field | Field to match
string | $value | Value to match

#

## Tags

None found

### deleteAchievementConditionCharacter()

    deleteAchievementConditionCharacter(integer  $conditionId)

Delete a Character condition.

#### Parameters

integer | $conditionId | ID of condition to delete

#

## Tags

None found

### getAchievementConditionsQuest()

    getAchievementConditionsQuest(integer  $achievementId) : array

Get all Quest conditions for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement

#### Returns

array —

Quest conditions

#

## Tags

None found

### checkAchievementConditionQuest()

    checkAchievementConditionQuest(string  $field, boolean  $count, integer  $value, integer  $status, string  $groupby, integer  $questId, integer  $characterId) : boolean

Check a Quest condition.

#### Parameters

string | $field | Field to check
boolean | $count | Conut field-value
integer | $value | The value the field has to match
integer | $status | Status of Quest or NULL
string | $groupby | Field to group or NULL
integer | $questId | ID of related Quest or NULL
integer | $characterId | ID of Character

#### Returns

boolean —

Result

#

## Tags

None found

### getAchievementConditionQuestProgress()

    getAchievementConditionQuestProgress(string  $field, boolean  $count, integer  $value, integer  $status, string  $groupby, integer  $questId, integer  $characterId) : float

Get the progress for a Quest condition.

#### Parameters

string | $field | Field to check
boolean | $count | Conut field-value
integer | $value | The value the field has to match
integer | $status | Status of Quest or NULL
string | $groupby | Field to group or NULL
integer | $questId | ID of related Quest or NULL
integer | $characterId | ID of Character

#### Returns

float —

Percentage progress

#

## Tags

None found

### addAchievementConditionQuest()

    addAchievementConditionQuest(integer  $userId, integer  $achievementId, string  $field, boolean  $count, string  $value, integer  $questId = null, integer  $status = null, string  $groupby = null)

Add a new Quest condition.

#### Parameters

integer | $userId | ID of creating user
integer | $achievementId | ID of Achievement to add condition to
string | $field | Field to match
boolean | $count | Count the value
string | $value | Value to match
integer | $questId | ID of Quest (optional)
integer | $status | Quest status (optional)
string | $groupby | Field to group by (optional)

#

## Tags

None found

### editAchievementConditionQuest()

    editAchievementConditionQuest(integer  $conditionId, string  $field, boolean  $count, string  $value, integer  $questId = null, integer  $status = null, string  $groupby = null)

Edit a Quest condition.

#### Parameters

integer | $conditionId | ID of condition to edit
string | $field | Field to match
boolean | $count | Count the value
string | $value | Value to match
integer | $questId | ID of Quest (optional)
integer | $status | Quest status (optional)
string | $groupby | Field to group by (optional)

#

## Tags

None found

### deleteAchievementConditionQuest()

    deleteAchievementConditionQuest(integer  $conditionId)

Delete a Quest condition.

#### Parameters

integer | $conditionId | ID of condition to delete

#

## Tags

None found

### getAchievementConditionsAchievement()

    getAchievementConditionsAchievement(integer  $achievementId) : array

Get all Metaachievement conditions for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement

#### Returns

array —

Metaachievement conditions

#

## Tags

None found

### checkAchievementConditionAchievement()

    checkAchievementConditionAchievement(string  $field, boolean  $count, integer  $value, string  $groupby, integer  $metaAchievementId, integer  $characterId) : boolean

Check a Metaachievement condition.

#### Parameters

string | $field | Field to check
boolean | $count | Conut field-value
integer | $value | The value the field has to match
string | $groupby | Field to group or NULL
integer | $metaAchievementId | ID of related Achievement or NULL
integer | $characterId | ID of Character

#### Returns

boolean —

Result

#

## Tags

None found

### getAchievementConditionAchievementProgress()

    getAchievementConditionAchievementProgress(string  $field, boolean  $count, integer  $value, string  $groupby, integer  $metaAchievementId, integer  $characterId) : float

Get the progress for a Metaachievement condition.

#### Parameters

string | $field | Field to check
boolean | $count | Conut field-value
integer | $value | The value the field has to match
string | $groupby | Field to group or NULL
integer | $metaAchievementId | ID of related Achievement or NULL
integer | $characterId | ID of Character

#### Returns

float —

Percentage progress

#

## Tags

None found

### addAchievementConditionAchievement()

    addAchievementConditionAchievement(integer  $userId, integer  $achievementId, string  $field, boolean  $count, string  $value, integer  $metaAchievementId = null, string  $groupby = null)

Add a new Achievement condition.

#### Parameters

integer | $userId | ID of creating user
integer | $achievementId | ID of Achievement to add condition to
string | $field | Field to match
boolean | $count | Count the value
string | $value | Value to match
integer | $metaAchievementId | ID of Meta-Achievement (optional)
string | $groupby | Field to group by (optional)

#

## Tags

None found

### editAchievementConditionAchievement()

    editAchievementConditionAchievement(integer  $conditionId, string  $field, boolean  $count, string  $value, integer  $metaAchievementId = null, string  $groupby = null)

Edit a Achievement condition.

#### Parameters

integer | $conditionId | ID of condition to edit
string | $field | Field to match
boolean | $count | Count the value
string | $value | Value to match
integer | $metaAchievementId | ID of Achievement (optional)
string | $groupby | Field to group by (optional)

#

## Tags

None found

### deleteAchievementConditionAchievement()

    deleteAchievementConditionAchievement(integer  $conditionId)

Delete a Achievement condition.

#### Parameters

integer | $conditionId | ID of condition to delete

#

## Tags

None found

### setAchievementAchieved()

    setAchievementAchieved(integer  $achievementId, integer  $characterId)

Set an Achievement as achieved for a Character.

#### Parameters

integer | $achievementId | ID of Achievement
integer | $characterId | ID of Character

#

## Tags

None found

### hasCharacterAchievedAchievement()

    hasCharacterAchievedAchievement(integer  $achievementId, integer  $characterId) : boolean

Check if a Character has achieved an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement
integer | $characterId | ID of Character

#### Returns

boolean —

Whether Character has achieved the Achievement or not

#

## Tags

None found

### getAchievementsConditions()

    getAchievementsConditions() : array

Get all existing Achievements conditions.

#### Returns

array —

List of Achievements conditions

#

## Tags

None found

### achievementTitleExists()

    achievementTitleExists(integer  $seminaryId, string  $title,   $achievementId = null) : boolean

Check if an Achievement title already exists.

#### Parameters

integer | $seminaryId | ID of Seminary
string | $title | Achievement title to check
| $achievementId |

#### Returns

boolean —

Whether Achievement title exists or not

#

## Tags

None found

### createAchievement()

    createAchievement(integer  $userId, integer  $seminaryId, integer  $conditionId, string  $title, string  $description, boolean  $progress, boolean  $hidden, boolean  $onlyOnce, boolean  $allConditions, string  $deadline) : integer

Create a new Achievement for a Seminary.

#### Parameters

integer | $userId | ID of creating user
integer | $seminaryId | ID of Seminary
integer | $conditionId | ID of Achievement condition
string | $title | Title of new Achievement
string | $description | Description of new Achievement
boolean | $progress | Show progress
boolean | $hidden | Secret Achievement
boolean | $onlyOnce | Only achieveable by one user
boolean | $allConditions | Achievement must match all conditions
string | $deadline | Deadline for Achievement

#### Returns

integer —

ID of newly created Achievement

#

## Tags

None found

### moveAchievement()

    moveAchievement(array  $achievement, boolean  $up)

Move an Achievement up (decrement position) or down (increment position).

#### Parameters

array | $achievement | Achievement to move
boolean | $up | True for moving up, false for down

#

## Tags

None found

### editAchievement()

    editAchievement(integer  $achievementId, integer  $conditionId, string  $title, string  $description, boolean  $progress, boolean  $hidden, boolean  $onlyOnce, boolean  $allConditions, string  $deadline)

Edit an Achievement of a Seminary.

#### Parameters

integer | $achievementId | ID of Achievement to edit
integer | $conditionId | ID of Achievement condition
string | $title | New title of Achievement
string | $description | New description of Achievement
boolean | $progress | Show progress
boolean | $hidden | Secret Achievement
boolean | $onlyOnce | Only achieveable by one user
boolean | $allConditions | Achievement must match all conditions
string | $deadline | Deadline for Achievement

#

## Tags

None found

### setUnachievedMediaForAchievement()

    setUnachievedMediaForAchievement(integer  $achievementId, integer  $achievementsmediaId)

Set unachieved media for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement to set media for
integer | $achievementsmediaId | ID of achievementsmedia to set

#

## Tags

None found

### setAchievedMediaForAchievement()

    setAchievedMediaForAchievement(integer  $achievementId, integer  $achievementsmediaId)

Set achieved media for an Achievement.

#### Parameters

integer | $achievementId | ID of Achievement to set media for
integer | $achievementsmediaId | ID of achievementsmedia to set

#

## Tags

None found

### deleteAchievement()

    deleteAchievement(integer  $achievement)

Delete an Achievement.

#### Parameters

integer | $achievement | Achievement to delete

#

## Tags

None found

### loadDriver()

    loadDriver(string  $driverName)

Load the database driver.

#### Parameters

string | $driverName | Name of the database driver

#### Throws

\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### connect()

    connect(string  $driverName, array  $config)

Establish a connection to the database.

#### Parameters

string | $driverName | Name of the database driver
array | $config | Connection settings

#### Throws

\nre\exceptions\DatamodelException

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### getClassName()

    getClassName(string  $modelName) : string

Determine the classname for the given Model name.

#### Parameters

string | $modelName | Model name to get classname of

#### Returns

string —

Classname fore the Model name

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### loadModels()

    loadModels()

Load the Models of this Model.

#### Throws

\nre\exceptions\DatamodelException
\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException
\nre\exceptions\ModelNotValidException
\nre\exceptions\ModelNotFoundException

#

Inherited from
  \nre\core\Model

## Tags

None found

### AchievementsModel.inc