PHP Class Kimai_Database_Mysql

Author: th
Author: sl
Author: Kevin Papst
显示文件 Open project: kimai/kimai Class Usage Examples

Protected Properties

Property Type Description
$conn MySQL
$kga Kimai_Config Kimai Global Array

Public Methods

Method Description
__construct ( Kimai_Config &$kga, boolean $autoConnect = true ) Instantiate a new database layer.
activity_create ( array $data, array $activityGroups ) : integer Adds a new activity
activity_delete ( array $activityID ) : boolean deletes an activity
activity_edit ( array $activityID, array $data, array $activityGroups ) : boolean Edits an activity by replacing its data by the new array
activity_get_data ( array $activityID ) : array Returns the data of a certain activity
activity_get_groupIDs ( integer $activityID ) : array returns all the group ids of the given activity
activity_get_groups ( array $activityID ) : array returns all the groups of the given activity
activity_get_projectIds ( integer $activityID ) : array returns all the project ids to which the activity was assigned
activity_get_projects ( integer $activityId ) : array returns all the projects to which the activity was assigned
allFittingFixedRates ( $projectID, $activityID ) : array | boolean Query the database for all fitting fixed rates for the given user, project and activity.
allFittingRates ( $userID, $projectID, $activityID ) : array | boolean Query the database for all fitting rates for the given user, project and activity.
assignActivityToProjectsForGroup ( integer $activityID, array $projectIDs, integer $group ) : boolean associates an Activity with a collection of Projects in the context of a user group.
assignProjectToActivitiesForGroup ( integer $projectID, array $activityIDs, integer $group ) : boolean associates a Project with a collection of Activities in the context of a user group.
assign_activityToGroups ( integer $activityID, array $groupIDs ) : boolean Assigns an activity to 1-n groups by adding entries to the cross table
assign_activityToProjects ( integer $activityID, array $projectIDs ) : boolean Assigns an activity to 1-n projects by adding entries to the cross table
assign_customerToGroups ( integer $customerID, array $groupIDs ) : boolean Assigns a customer to 1-n groups by adding entries to the cross table
assign_groupToActivities ( array $groupID, array $activityIDs ) : boolean Assigns a group to 1-n activities by adding entries to the cross table (counterpart to assign_activityToGroups)
assign_groupToCustomers ( array $groupID, array $customerIDs ) : boolean Assigns a group to 1-n customers by adding entries to the cross table (counterpart to assign_customerToGroups)
assign_groupToProjects ( array $groupID, array $projectIDs ) : boolean Assigns a group to 1-n projects by adding entries to the cross table (counterpart to assign_projectToGroups)
assign_projectToActivities ( integer $projectID, array $activityIDs ) : boolean Assigns 1-n activities to a project by adding entries to the cross table
assign_projectToGroups ( integer $projectID, array $groupIDs ) : boolean Assigns a project to 1-n groups by adding entries to the cross table
checkMembershipPermission ( integer $userId, array $objectGroups, string $permission, string $requiredFor = 'all' ) : boolean Check if a user is allowed to access an object for a given action.
checkUserInternal ( $kimai_user ) A drop-in function to replace checkuser() and be compatible with none-cookie environments.
clean_data ( array $data ) : array Prepare all values of the array so it's save to put them into an sql query.
configuration_edit ( array $data ) : boolean Edits a configuration variables by replacing the data by the new array
connect ( string $host, string $database, string $username, string $password, boolean $utf8 = true ) Connect to the database.
customer_create ( array $data ) : integer Add a new customer to the database.
customer_delete ( integer $customerID ) : boolean deletes a customer
customer_edit ( integer $customerID, array $data ) : boolean Edits a customer by replacing his data by the new array
customer_get_data ( integer $customerID ) : array Returns the data of a customer
customer_get_groupIDs ( integer $customerID ) : array returns all IDs of the groups of the given customer
customer_loginSetKey ( $customerId, $keymai ) Save a new secure key for a customer to the database. This key is stored in the clients cookie and used to reauthenticate the customer.
customer_nameToID ( integer $name ) : integer return ID of specific user named 'XXX'
getActivityTable ( ) : string
getConnectionHandler ( ) Return the connection handler used to connect to the database.
getCustomerTable ( ) : string
getExpenseTable ( ) : string
getGroupMemberships ( integer $userId ) : array Get the groups in which the user is a member in.
getGroupsUsersTable ( ) : string
getLastError ( ) : string
getNonManagableAssignedElementIds ( string $parentSubject, string $subject, integer $parentId, integer $group ) : array computes an array of (project- or activity-) ids for Project-Activity-Assignments that are unmanage-able for the given group.
getPreferencesTable ( ) : string
getProjectTable ( ) : string
getRatesTable ( ) : string
getStatuses ( ) : array Return all available status entries.
getTablePrefix ( ) : string
getTimeSheetTable ( ) : string
getUserByApiKey ( string $apikey ) : string | null Returns a username for the given $apikey.
getUserTable ( ) : string
get_DBversion ( ) : array returns the version of the installed Kimai database to compare it with the package version
get_activities ( array $groups = null ) : array | boolean Get all available activities.
get_activities_by_customer ( integer $customer_ID ) : array returns list of activities used with specified customer
get_activities_by_project ( integer $projectID, array $groups = null ) : array Get an array of activities, which should be displayed for a specific project.
get_activity_budget ( $projectID, $activityID ) : array | boolean Read activity budgets
get_best_fitting_fixed_rate ( $projectID, $activityID ) : boolean Query the database for the best fitting fixed rate for the given user, project and activity.
get_best_fitting_rate ( $userID, $projectID, $activityID ) : boolean Query the database for the best fitting rate for the given user, project and activity.
get_budget_used ( integer $projectID, integer $activityID ) : integer get the whole budget used for the activity
get_current_recordings ( integer $userID ) : array Returns a list of IDs of all current recordings.
get_current_timer ( ) : array returns time of currently running activity recording as array
get_customer_config ( integer $userID ) : array returns configuration for specified customer
get_customer_watchable_users ( integer $customer ) : array
get_customers ( array $groups = null ) : array returns list of customers in a group as array
get_duration ( integer $start, integer $end, null $users = null, null $customers = null, null $projects = null, null $activities = null, null $filterCleared = null ) : integer returns time summary of current timesheet
get_fixed_rate ( $projectID, $activityID ) : boolean Read fixed rate from database.
get_groups ( integer $trash ) : array returns array of all groups [0]=> array(6) { ["groupID"] => string(1) "1" ["groupName"] => string(5) "admin" ["userID"] => string(9) "1234" ["trash"] => string(1) "0" ["count_users"] => string(1) "2" } [1]=> array(6) { ["groupID"] => string(1) "2" ["groupName"] => string(4) "Test" ["userID"] => string(9) "12345" ["trash"] => string(1) "0" ["count_users"] => string(1) "1" }
get_latest_running_entry ( ) : array Return the latest running entry with all information required for the buzzer.
get_projects ( array $groups = null ) : array returns list of projects for specific group as array
get_projects_by_customer ( integer $customerID, array $groups = null ) : array returns list of projects for specific group and specific customer as array
get_rate ( $userID, $projectID, $activityID ) : boolean Read rate from database.
get_seq ( integer $user ) : string returns the key for the session of a specific user
get_status ( array $statusIds ) : array return status names
get_statuses ( ) : array returns array of all status with the status id as key
get_timeSheet ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null, boolean $limit = false, boolean $reverse_order = false, integer $filterCleared = null, integer $startRows, integer $limitRows, boolean $countOnly = false ) : array returns timesheet for specific user as multidimensional array
get_time_activities ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array returns list of time summary attached to activity ID's within specific timeframe as array
get_time_customers ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array returns list of time summary attached to customer ID's within specific timeframe as array
get_time_projects ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array returns list of time summary attached to project ID's within specific timeframe as array
get_time_users ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, null $activities = null ) : array returns assoc. array where the index is the ID of a user and the value the time this user has accumulated in the given time with respect to the filtersettings
get_user_config ( integer $userID ) : array returns configuration data for specified user
get_user_watchable_users ( integer $user ) : array returns list of users the given user can watch
get_users ( integer $trash, array $groups = null ) : array returns array of all users [userID] => 23103741 [name] => admin [mail] => 0 [active] => 0
getjointime ( integer $userID ) : integer returns the date of the first timerecord of a user (when did the user join?) this is needed for the datepicker
globalRole_find ( $filter ) : array | boolean
globalRole_get_data ( $globalRoleID ) : array | boolean
global_role_allows ( integer $roleID, string $permission ) : boolean Check if a global role gives permission for a specific action.
global_role_create ( $data ) : boolean | integer
global_role_delete ( $globalRoleID ) : boolean
global_role_edit ( $globalRoleID, $data ) : boolean
global_roles ( ) : array | boolean
group_count_users ( array $groupID ) : integer Returns the number of users in a certain group
group_create ( array $data ) : integer Adds a new group
group_delete ( array $groupID ) : boolean deletes a group
group_edit ( array $groupID, array $data ) : boolean Edits a group by replacing its data by the new array
group_get_data ( array $groupID ) : array Returns the data of a certain group
initializeConfig ( Kimai_Config $config ) Prefills the Config (and inherited settings) object with configuration data.
isConnected ( ) : boolean
isValidActivityId ( integer $activityId ) : boolean checks if given $activityId exists in the db
isValidProjectId ( integer $projectId ) : boolean checks if given $projectId exists in the db
is_customer_name ( string $name ) : boolean checks if a customer with this name exists
is_watchable_user ( integer $user, integer $userID ) : boolean Checks if a user (given by user ID) can be accessed by another user (given by user array):
loginUpdateBan ( $userId, boolean $resetTime = false ) Update the ban status of a user. This increments the ban counter.
membershipRole_find ( $filter ) : array | boolean
membershipRole_get_data ( $membershipRoleID ) : array | boolean
membership_role_allows ( integer $roleID, string $permission ) : boolean Check if a membership role gives permission for a specific action.
membership_role_create ( $data ) : boolean | integer
membership_role_delete ( $membershipRoleID ) : boolean
membership_role_edit ( $membershipRoleID, $data ) : object
membership_roles ( ) : array | boolean
project_activity_edit ( integer $projectID, integer $activityID, array $data ) : boolean update the data for activity per project, which is budget, approved and effort
project_create ( array $data ) : integer Adds a new project
project_delete ( array $projectID ) : boolean deletes a project
project_edit ( integer $projectID, array $data ) : boolean Edits a project by replacing its data by the new array
project_get_activities ( integer $projectID ) : array returns all the activities which were assigned to a project
project_get_activityIDs ( integer $projectID ) : array returns all the activity ids which were assigned to a project
project_get_data ( integer $projectID ) : array Returns the data of a certain project
project_get_groupIDs ( array $projectID ) : array returns all the groups of the given project
queryAll ( string $query ) : array Return all rows for the given sql query.
remove_fixed_rate ( $projectID, $activityID ) : boolean Remove fixed rate from database.
remove_rate ( $userID, $projectID, $activityID ) : boolean Remove rate from database.
save_fixed_rate ( $projectID, $activityID, $rate ) : boolean Save fixed rate to database.
save_rate ( $userID, $projectID, $activityID, $rate ) : boolean Save rate to database.
save_timeframe ( string $timeframeBegin, string $timeframeEnd, string $user ) : boolean saves timeframe of user in database (table conf)
setGroupMemberships ( integer $userId, array $groups = null ) : false | null Set the groups in which the user is a member in.
startRecorder ( integer $projectID, $activityID, $user ) : integer starts timesheet record
status_create ( array $status ) : boolean add a new status
status_delete ( array $statusID ) : boolean deletes a status
status_edit ( array $statusID, array $data ) : boolean Edits a status by replacing its data by the new array
status_get_data ( array $statusID ) : array Returns the data of a certain status
status_timeSheetEntryCount ( integer $statusID ) : integer Returns the number of time sheet entries with a certain status
stopRecorder ( integer $id ) : boolean Performed when the stop buzzer is hit.
timeEntry_create ( array $data ) : boolean | integer create time sheet entry
timeEntry_delete ( integer $id ) : object delete time sheet entry
timeEntry_edit ( integer $id, array $data ) : boolean edit time sheet entry
timeEntry_edit_activity ( integer $timeEntryID, integer $activityID ) : object Just edit the activity for an entry. This is used for changing the activity of a running entry.
timeEntry_edit_project ( integer $timeEntryID, integer $projectID ) : object Just edit the project for an entry. This is used for changing the project of a running entry.
timeSheet_get_data ( integer $timeEntryID ) : array Returns the data of a certain time record
timeSheet_whereClausesFromFilters ( array $users, array $customers, array $projects, array $activities = [] ) : array Creates an array of clauses which can be joined together in the WHERE part of a sql query. The clauses describe whether a line should be included depending on the filters set.
transaction_begin ( ) : boolean
transaction_end ( ) : boolean
transaction_rollback ( ) : boolean
userIDToName ( string $id ) : integer return name of a user with specific ID
user_create ( array $data ) : boolean | integer Adds a new user
user_delete ( integer $userID, boolean $moveToTrash = false ) : boolean deletes a user
user_edit ( integer $userID, array $data ) : boolean Edits a user by replacing his data and preferences by the new array
user_get_data ( string $userID ) : array Returns the data of a certain user
user_get_membership_role ( integer $userID, integer $groupID ) : integer | boolean Returns the membership roleID the user has in the given group.
user_get_preferences ( array $keys, integer $userId = null ) : array Get several preferences for a user. If no user ID is given the current user is used.
user_get_preferences_by_prefix ( string $prefix, integer $userId = null ) : array Get several preferences for a user which have a common prefix. The returned preferences are striped off the prefix.
user_loginSetKey ( $userId, $keymai ) Save a new secure key for a user to the database. This key is stored in the users cookie and used to reauthenticate the user.
user_name2id ( integer $name ) : string | boolean return ID of specific user by name
user_set_preferences ( array $data, string $prefix = '', integer $userId = null ) : boolean Save one or more preferences for a user. If no user ID is given the current user is used.

Protected Methods

Method Description
getConfigurationData ( ) : array Returns all configuration variables
rowExists ( string $table, array $filter ) : boolean checks if a given db row based on the $idColumn & $id exists
user_get_preference ( string $key, integer $userId = null ) : string Get a preference for a user. If no user ID is given the current user is used.

Private Methods

Method Description
logLastError ( string $scope )
name2id ( string $table, string $endColumn, string $filterColumn, integer $value ) : string | boolean Query a table for an id by giving the name of an entry.

Method Details

__construct() public method

The provided kimai global array will be stored as a reference.
public __construct ( Kimai_Config &$kga, boolean $autoConnect = true )
$kga Kimai_Config
$autoConnect boolean

activity_create() public method

Adds a new activity
Author: th
public activity_create ( array $data, array $activityGroups ) : integer
$data array name, comment and other data of the new activity
$activityGroups array
return integer the activityID of the new project, false on failure

activity_delete() public method

deletes an activity
Author: th
public activity_delete ( array $activityID ) : boolean
$activityID array activityID of the activity
return boolean true on success, false on failure

activity_edit() public method

Edits an activity by replacing its data by the new array
Author: th
public activity_edit ( array $activityID, array $data, array $activityGroups ) : boolean
$activityID array activityID of the project to be edited
$data array name, comment and other new data of the activity
$activityGroups array
return boolean true on success, false on failure

activity_get_data() public method

Returns the data of a certain activity
Author: th
public activity_get_data ( array $activityID ) : array
$activityID array activityID of the project
return array the activity's data (name, comment etc) as array, false on failure

activity_get_groupIDs() public method

returns all the group ids of the given activity
Author: sl
public activity_get_groupIDs ( integer $activityID ) : array
$activityID integer ID of the activity
return array contains the groupIDs of the groups or false on error

activity_get_groups() public method

returns all the groups of the given activity
Author: th
public activity_get_groups ( array $activityID ) : array
$activityID array activityID of the project
return array contains the groupIDs of the groups or false on error

activity_get_projectIds() public method

returns all the project ids to which the activity was assigned
Author: th
public activity_get_projectIds ( integer $activityID ) : array
$activityID integer activityID of the project
return array contains the IDs of the projects or false on error

activity_get_projects() public method

returns all the projects to which the activity was assigned
Author: th
public activity_get_projects ( integer $activityId ) : array
$activityId integer activityId of the project
return array contains the IDs of the projects or false on error

allFittingFixedRates() public method

Query the database for all fitting fixed rates for the given user, project and activity.
Author: sl
public allFittingFixedRates ( $projectID, $activityID ) : array | boolean
$projectID
$activityID
return array | boolean

allFittingRates() public method

Query the database for all fitting rates for the given user, project and activity.
Author: sl
public allFittingRates ( $userID, $projectID, $activityID ) : array | boolean
$userID
$projectID
$activityID
return array | boolean

assignActivityToProjectsForGroup() public method

Projects that are currently associated with the Activity but not mentioned in the specified id collection, will get un-assigned. The fundamental difference to assign_activityToProjects(activityID, projectIDs) is that this method is aware of potentially existing assignments that are invisible and thus unmanagable to the user as the user lacks access to the Projects. It is implicitly assumed that the user has access to the Activity and the Projects designated by the method parameters.
public assignActivityToProjectsForGroup ( integer $activityID, array $projectIDs, integer $group ) : boolean
$activityID integer the id of the Activity to associate
$projectIDs array the array of Project ids to associate
$group integer the user's group id
return boolean

assignProjectToActivitiesForGroup() public method

Activities that are currently associated with the Project but not mentioned in the specified id collection, will get un-assigned. The fundamental difference to assign_projectToActivities($projectID, $activityIDs) is that this method is aware of potentially existing assignments that are invisible and thus unmanagable to the user as the user lacks access to the Activities. It is implicitly assumed that the user has access to the Project and the Activities designated by the method parameters.
public assignProjectToActivitiesForGroup ( integer $projectID, array $activityIDs, integer $group ) : boolean
$projectID integer the id of the Project to associate
$activityIDs array the array of Activity ids to associate
$group integer the user's group id
return boolean

assign_activityToGroups() public method

Assigns an activity to 1-n groups by adding entries to the cross table
Author: ob/th
public assign_activityToGroups ( integer $activityID, array $groupIDs ) : boolean
$activityID integer activityID of the project to which the groups will be assigned
$groupIDs array contains one or more groupIDs
return boolean true on success, false on failure

assign_activityToProjects() public method

Assigns an activity to 1-n projects by adding entries to the cross table
Author: ob/th
public assign_activityToProjects ( integer $activityID, array $projectIDs ) : boolean
$activityID integer id of the activity to which projects will be assigned
$projectIDs array contains one or more projectIDs
return boolean true on success, false on failure

assign_customerToGroups() public method

Assigns a customer to 1-n groups by adding entries to the cross table
Author: ob/th
public assign_customerToGroups ( integer $customerID, array $groupIDs ) : boolean
$customerID integer id of the customer to which the groups will be assigned
$groupIDs array contains one or more groupIDs
return boolean true on success, false on failure

assign_groupToActivities() public method

Assigns a group to 1-n activities by adding entries to the cross table (counterpart to assign_activityToGroups)
Author: ob
public assign_groupToActivities ( array $groupID, array $activityIDs ) : boolean
$groupID array groupID of the group to which the activities will be assigned
$activityIDs array contains one or more activityIDs
return boolean true on success, false on failure

assign_groupToCustomers() public method

Assigns a group to 1-n customers by adding entries to the cross table (counterpart to assign_customerToGroups)
Author: ob/th
public assign_groupToCustomers ( array $groupID, array $customerIDs ) : boolean
$groupID array ID of the group to which the customers will be assigned
$customerIDs array contains one or more IDs of customers
return boolean true on success, false on failure

assign_groupToProjects() public method

Assigns a group to 1-n projects by adding entries to the cross table (counterpart to assign_projectToGroups)
Author: ob
public assign_groupToProjects ( array $groupID, array $projectIDs ) : boolean
$groupID array groupID of the group to which the projects will be assigned
$projectIDs array contains one or more project IDs
return boolean true on success, false on failure

assign_projectToActivities() public method

Assigns 1-n activities to a project by adding entries to the cross table
Author: sl
public assign_projectToActivities ( integer $projectID, array $activityIDs ) : boolean
$projectID integer id of the project to which activities will be assigned
$activityIDs array contains one or more activityIDs
return boolean true on success, false on failure

assign_projectToGroups() public method

Assigns a project to 1-n groups by adding entries to the cross table
Author: ob/th
public assign_projectToGroups ( integer $projectID, array $groupIDs ) : boolean
$projectID integer ID of the project to which the groups will be assigned
$groupIDs array contains one or more groupIDs
return boolean true on success, false on failure

checkMembershipPermission() public method

Check if a user is allowed to access an object for a given action.
public checkMembershipPermission ( integer $userId, array $objectGroups, string $permission, string $requiredFor = 'all' ) : boolean
$userId integer the ID of the user
$objectGroups array list of group IDs of the object to check
$permission string name of the permission to check for
$requiredFor string (all|any) whether the permission must be present for all groups or at least one
return boolean

checkUserInternal() public method

A drop-in function to replace checkuser() and be compatible with none-cookie environments.
Author: th/kp
public checkUserInternal ( $kimai_user )

clean_data() public method

The conversion to utf8 is done here as well, if configured. This method is public since ki_expenses private database layers use it.
public clean_data ( array $data ) : array
$data array Array which values are being prepared.
return array The same array, except all values are being escaped correctly.

configuration_edit() public method

Edits a configuration variables by replacing the data by the new array
Author: ob
public configuration_edit ( array $data ) : boolean
$data array variables array
return boolean true on success, false on failure

connect() public method

Connect to the database.
public connect ( string $host, string $database, string $username, string $password, boolean $utf8 = true )
$host string
$database string
$username string
$password string
$utf8 boolean

customer_create() public method

Add a new customer to the database.
Author: th
public customer_create ( array $data ) : integer
$data array name, address and other data of the new customer
return integer the customerID of the new customer, false on failure

customer_delete() public method

deletes a customer
Author: th
public customer_delete ( integer $customerID ) : boolean
$customerID integer id of the customer
return boolean true on success, false on failure

customer_edit() public method

Edits a customer by replacing his data by the new array
Author: ob/th
public customer_edit ( integer $customerID, array $data ) : boolean
$customerID integer id of the customer to be edited
$data array name, address and other new data of the customer
return boolean true on success, false on failure

customer_get_data() public method

Returns the data of a customer
Author: th
public customer_get_data ( integer $customerID ) : array
$customerID integer id of the customer
return array the customer's data, false on failure

customer_get_groupIDs() public method

returns all IDs of the groups of the given customer
Author: th
public customer_get_groupIDs ( integer $customerID ) : array
$customerID integer id of the customer
return array contains the groupIDs of the groups or false on error

customer_loginSetKey() public method

Save a new secure key for a customer to the database. This key is stored in the clients cookie and used to reauthenticate the customer.
Author: sl
public customer_loginSetKey ( $customerId, $keymai )
$customerId
$keymai

customer_nameToID() public method

return ID of specific user named 'XXX'
public customer_nameToID ( integer $name ) : integer
$name integer name of user in table users
return integer id of the customer

getActivityTable() public method

public getActivityTable ( ) : string
return string tablename including prefix

getConfigurationData() protected method

Returns all configuration variables
protected getConfigurationData ( ) : array
return array with the options from the configuration table

getConnectionHandler() public method

This is currently required for extensions to access the database without connecting again.

getCustomerTable() public method

public getCustomerTable ( ) : string
return string tablename including prefix

getExpenseTable() public method

public getExpenseTable ( ) : string
return string tablename including prefix

getGroupMemberships() public method

Get the groups in which the user is a member in.
public getGroupMemberships ( integer $userId ) : array
$userId integer id of the user
return array list of group ids

getGroupsUsersTable() public method

public getGroupsUsersTable ( ) : string
return string tablename including prefix

getLastError() public method

public getLastError ( ) : string
return string

getNonManagableAssignedElementIds() public method

This method supports Project-Activity-Assignments as seen from both end points. The returned array contains the ids of all those Projects or Activities that are assigned to Activities or Projects but cannot be seen by the user that looks at the assignments.
public getNonManagableAssignedElementIds ( string $parentSubject, string $subject, integer $parentId, integer $group ) : array
$parentSubject string a string designating the parent in the assignment, must be one of "project" or "activity"
$subject string a string designating the child in the assignment, must be one of "project" or "activity"
$parentId integer the id of the parent
$group integer the id of the user's group
return array the array of ids of those child Projects or Activities that are assigned to the parent Activity or Project but are invisible to the user

getPreferencesTable() public method

public getPreferencesTable ( ) : string
return string tablename including prefix

getProjectTable() public method

public getProjectTable ( ) : string
return string tablename including prefix

getRatesTable() public method

public getRatesTable ( ) : string
return string tablename including prefix

getStatuses() public method

Return all available status entries.
public getStatuses ( ) : array
return array

getTablePrefix() public method

public getTablePrefix ( ) : string
return string

getTimeSheetTable() public method

public getTimeSheetTable ( ) : string
return string tablename including prefix

getUserByApiKey() public method

Returns a username for the given $apikey.
public getUserByApiKey ( string $apikey ) : string | null
$apikey string
return string | null

getUserTable() public method

public getUserTable ( ) : string
return string tablename including prefix

get_DBversion() public method

returns the version of the installed Kimai database to compare it with the package version
Author: th [0] => version number (x.x.x) [1] => revision number
public get_DBversion ( ) : array
return array

get_activities() public method

This is either a list of all or a list of all for the given groups.
public get_activities ( array $groups = null ) : array | boolean
$groups array
return array | boolean

get_activities_by_customer() public method

returns list of activities used with specified customer
Author: sl
public get_activities_by_customer ( integer $customer_ID ) : array
$customer_ID integer filter for only this ID of a customer
return array

get_activities_by_project() public method

Those are activities which were assigned to the project or which are assigned to no project. Two joins can occur: The JOIN is for filtering the activities by groups. The LEFT JOIN gives each activity row the project id which it has been assigned to via the projects_activities table or NULL when there is no assignment. So we only take rows which have NULL or the project id in that column.
Author: sl
public get_activities_by_project ( integer $projectID, array $groups = null ) : array
$projectID integer
$groups array
return array

get_activity_budget() public method

Read activity budgets
Author: mo
public get_activity_budget ( $projectID, $activityID ) : array | boolean
$projectID
$activityID
return array | boolean

get_best_fitting_fixed_rate() public method

Query the database for the best fitting fixed rate for the given user, project and activity.
Author: sl
public get_best_fitting_fixed_rate ( $projectID, $activityID ) : boolean
$projectID
$activityID
return boolean

get_best_fitting_rate() public method

Query the database for the best fitting rate for the given user, project and activity.
Author: sl
public get_best_fitting_rate ( $userID, $projectID, $activityID ) : boolean
$userID
$projectID
$activityID
return boolean

get_budget_used() public method

get the whole budget used for the activity
public get_budget_used ( integer $projectID, integer $activityID ) : integer
$projectID integer
$activityID integer
return integer

get_current_recordings() public method

Returns a list of IDs of all current recordings.
Author: sl
public get_current_recordings ( integer $userID ) : array
$userID integer ID of user in table users
return array with all IDs of current recordings. This array will be empty if there are none.

get_current_timer() public method

result is meant as params for the stopwatch if the window is reloaded
returns:
[all] start time of entry in unix seconds (forgot why I named it this way, sorry ...)
[hour]
[min]
[sec]
Author: th
public get_current_timer ( ) : array
return array

get_customer_config() public method

returns configuration for specified customer
public get_customer_config ( integer $userID ) : array
$userID integer
return array

get_customer_watchable_users() public method

public get_customer_watchable_users ( integer $customer ) : array
$customer integer
return array

get_customers() public method

returns list of customers in a group as array
Author: th
public get_customers ( array $groups = null ) : array
$groups array ID of group in table groups or "all" for all groups
return array

get_duration() public method

returns time summary of current timesheet
Author: th
public get_duration ( integer $start, integer $end, null $users = null, null $customers = null, null $projects = null, null $activities = null, null $filterCleared = null ) : integer
$start integer start of timeframe in unix seconds
$end integer end of timeframe in unix seconds
$users null
$customers null
$projects null
$activities null
$filterCleared null
return integer

get_fixed_rate() public method

Read fixed rate from database.
Author: sl
public get_fixed_rate ( $projectID, $activityID ) : boolean
$projectID
$activityID
return boolean

get_groups() public method

returns array of all groups [0]=> array(6) { ["groupID"] => string(1) "1" ["groupName"] => string(5) "admin" ["userID"] => string(9) "1234" ["trash"] => string(1) "0" ["count_users"] => string(1) "2" } [1]=> array(6) { ["groupID"] => string(1) "2" ["groupName"] => string(4) "Test" ["userID"] => string(9) "12345" ["trash"] => string(1) "0" ["count_users"] => string(1) "1" }
Author: th
public get_groups ( integer $trash ) : array
$trash integer
return array

get_latest_running_entry() public method

Return the latest running entry with all information required for the buzzer.
Author: sl
public get_latest_running_entry ( ) : array
return array with all data

get_projects() public method

returns list of projects for specific group as array
Author: th
public get_projects ( array $groups = null ) : array
$groups array ID of user in database
return array

get_projects_by_customer() public method

returns list of projects for specific group and specific customer as array
Author: ob
public get_projects_by_customer ( integer $customerID, array $groups = null ) : array
$customerID integer customer id
$groups array list of group ids
return array

get_rate() public method

Read rate from database.
Author: sl
public get_rate ( $userID, $projectID, $activityID ) : boolean
$userID
$projectID
$activityID
return boolean

get_seq() public method

the key is both stored in the database (users table) and a cookie on the client. when the keys match the user is allowed to access the Kimai GUI. match test is performed via public function userCheck()
Author: th
public get_seq ( integer $user ) : string
$user integer ID of user in table users
return string

get_status() public method

return status names
public get_status ( array $statusIds ) : array
$statusIds array
return array

get_statuses() public method

returns array of all status with the status id as key
Author: mo
public get_statuses ( ) : array
return array

get_timeSheet() public method

returns timesheet for specific user as multidimensional array
Author: th
public get_timeSheet ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null, boolean $limit = false, boolean $reverse_order = false, integer $filterCleared = null, integer $startRows, integer $limitRows, boolean $countOnly = false ) : array
$start integer start of timeframe in unix seconds
$end integer end of timeframe in unix seconds
$users array
$customers array
$projects array
$activities array
$limit boolean
$reverse_order boolean
$filterCleared integer where -1 (default) means no filtering, 0 means only not cleared entries, 1 means only cleared entries
$startRows integer
$limitRows integer
$countOnly boolean
return array

get_time_activities() public method

returns list of time summary attached to activity ID's within specific timeframe as array
Author: sl
public get_time_activities ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array
$start integer start time in unix seconds
$end integer end time in unix seconds
$users array filter for only this ID of a user
$customers array filter for only this ID of a customer
$projects array filter for only this ID of a project
$activities array
return array

get_time_customers() public method

returns list of time summary attached to customer ID's within specific timeframe as array
Author: sl
public get_time_customers ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array
$start integer start of timeframe in unix seconds
$end integer end of timeframe in unix seconds
$users array filter for only this ID of a user
$customers array filter for only this ID of a customer
$projects array filter for only this ID of a project
$activities array
return array

get_time_projects() public method

returns list of time summary attached to project ID's within specific timeframe as array
Author: sl
public get_time_projects ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, array $activities = null ) : array
$start integer start time in unix seconds
$end integer end time in unix seconds
$users array filter for only this ID of a user
$customers array filter for only this ID of a customer
$projects array filter for only this ID of a project
$activities array
return array

get_time_users() public method

returns assoc. array where the index is the ID of a user and the value the time this user has accumulated in the given time with respect to the filtersettings
Author: sl
public get_time_users ( integer $start, integer $end, array $users = null, array $customers = null, array $projects = null, null $activities = null ) : array
$start integer from this timestamp
$end integer to this timestamp
$users array IDs of user in table users
$customers array IDs of customer in table customers
$projects array IDs of project in table projects
$activities null
return array

get_user_config() public method

returns configuration data for specified user
public get_user_config ( integer $userID ) : array
$userID integer
return array $this->kga

get_user_watchable_users() public method

returns list of users the given user can watch
Author: sl
public get_user_watchable_users ( integer $user ) : array
$user integer ID of user in table users
return array

get_users() public method

returns array of all users [userID] => 23103741 [name] => admin [mail] => 0 [active] => 0
Author: th
public get_users ( integer $trash, array $groups = null ) : array
$trash integer
$groups array list of group ids the users must be a member of
return array

getjointime() public method

returns the date of the first timerecord of a user (when did the user join?) this is needed for the datepicker
Author: th
public getjointime ( integer $userID ) : integer
$userID integer id of user
return integer unix seconds of first timesheet record

globalRole_find() public method

public globalRole_find ( $filter ) : array | boolean
$filter
return array | boolean

globalRole_get_data() public method

public globalRole_get_data ( $globalRoleID ) : array | boolean
$globalRoleID
return array | boolean

global_role_allows() public method

Check if a global role gives permission for a specific action.
public global_role_allows ( integer $roleID, string $permission ) : boolean
$roleID integer the ID of the global role
$permission string name of the action / permission
return boolean true if permissions is granted, false otherwise

global_role_create() public method

public global_role_create ( $data ) : boolean | integer
$data
return boolean | integer

global_role_delete() public method

public global_role_delete ( $globalRoleID ) : boolean
$globalRoleID
return boolean

global_role_edit() public method

public global_role_edit ( $globalRoleID, $data ) : boolean
$globalRoleID
$data
return boolean

global_roles() public method

public global_roles ( ) : array | boolean
return array | boolean

group_count_users() public method

Returns the number of users in a certain group
Author: th
public group_count_users ( array $groupID ) : integer
$groupID array groupID of the group
return integer the number of users in the group

group_create() public method

Adds a new group
Author: th
public group_create ( array $data ) : integer
$data array name and other data of the new group
return integer the groupID of the new group, false on failure

group_delete() public method

deletes a group
Author: th
public group_delete ( array $groupID ) : boolean
$groupID array groupID of the group
return boolean true on success, false on failure

group_edit() public method

Edits a group by replacing its data by the new array
Author: th
public group_edit ( array $groupID, array $data ) : boolean
$groupID array groupID of the group to be edited
$data array name and other new data of the group
return boolean true on success, false on failure

group_get_data() public method

Returns the data of a certain group
Author: th
public group_get_data ( array $groupID ) : array
$groupID array groupID of the group
return array the group's data (name, etc) as array, false on failure

initializeConfig() public method

Prefills the Config (and inherited settings) object with configuration data.
public initializeConfig ( Kimai_Config $config )
$config Kimai_Config

isConnected() public method

public isConnected ( ) : boolean
return boolean

isValidActivityId() public method

checks if given $activityId exists in the db
public isValidActivityId ( integer $activityId ) : boolean
$activityId integer
return boolean

isValidProjectId() public method

checks if given $projectId exists in the db
public isValidProjectId ( integer $projectId ) : boolean
$projectId integer
return boolean

is_customer_name() public method

checks if a customer with this name exists
Author: sl
public is_customer_name ( string $name ) : boolean
$name string
return boolean

is_watchable_user() public method

Checks if a user (given by user ID) can be accessed by another user (given by user array):
See also: get_watchable_users
Author: sl
public is_watchable_user ( integer $user, integer $userID ) : boolean
$user integer user to check for
$userID integer user to check if watchable
return boolean if watchable, false otherwiese

loginUpdateBan() public method

Optionally it sets the start time of the ban to the current time.
Author: sl
public loginUpdateBan ( $userId, boolean $resetTime = false )
$userId
$resetTime boolean

membershipRole_find() public method

public membershipRole_find ( $filter ) : array | boolean
$filter
return array | boolean

membershipRole_get_data() public method

public membershipRole_get_data ( $membershipRoleID ) : array | boolean
$membershipRoleID
return array | boolean

membership_role_allows() public method

Check if a membership role gives permission for a specific action.
public membership_role_allows ( integer $roleID, string $permission ) : boolean
$roleID integer the ID of the membership role
$permission string name of the action / permission
return boolean true if permissions is granted, false otherwise

membership_role_create() public method

public membership_role_create ( $data ) : boolean | integer
$data
return boolean | integer

membership_role_delete() public method

public membership_role_delete ( $membershipRoleID ) : boolean
$membershipRoleID
return boolean

membership_role_edit() public method

public membership_role_edit ( $membershipRoleID, $data ) : object
$membershipRoleID
$data
return object

membership_roles() public method

public membership_roles ( ) : array | boolean
return array | boolean

project_activity_edit() public method

update the data for activity per project, which is budget, approved and effort
public project_activity_edit ( integer $projectID, integer $activityID, array $data ) : boolean
$projectID integer
$activityID integer
$data array
return boolean

project_create() public method

Adds a new project
Author: th
public project_create ( array $data ) : integer
$data array name, comment and other data of the new project
return integer the ID of the new project, false on failure

project_delete() public method

deletes a project
Author: th
public project_delete ( array $projectID ) : boolean
$projectID array ID of the project
return boolean true on success, false on failure

project_edit() public method

Edits a project by replacing its data by the new array
Author: ob/th
public project_edit ( integer $projectID, array $data ) : boolean
$projectID integer id of the project to be edited
$data array name, comment and other new data of the project
return boolean true on success, false on failure

project_get_activities() public method

returns all the activities which were assigned to a project
Author: sl
public project_get_activities ( integer $projectID ) : array
$projectID integer ID of the project
return array contains the activityIDs of the activities or false on error

project_get_activityIDs() public method

returns all the activity ids which were assigned to a project
Author: sl
public project_get_activityIDs ( integer $projectID ) : array
$projectID integer ID of the project
return array contains the activityIDs of the activities or false on error

project_get_data() public method

Returns the data of a certain project
Author: th
public project_get_data ( integer $projectID ) : array
$projectID integer ID of the project
return array the project's data (name, comment etc) as array, false on failure

project_get_groupIDs() public method

returns all the groups of the given project
Author: th
public project_get_groupIDs ( array $projectID ) : array
$projectID array ID of the project
return array contains the groupIDs of the groups or false on error

queryAll() public method

Return all rows for the given sql query.
public queryAll ( string $query ) : array
$query string the sql query to execute
return array

remove_fixed_rate() public method

Remove fixed rate from database.
Author: sl
public remove_fixed_rate ( $projectID, $activityID ) : boolean
$projectID
$activityID
return boolean

remove_rate() public method

Remove rate from database.
Author: sl
public remove_rate ( $userID, $projectID, $activityID ) : boolean
$userID
$projectID
$activityID
return boolean

rowExists() protected method

checks if a given db row based on the $idColumn & $id exists
protected rowExists ( string $table, array $filter ) : boolean
$table string
$filter array
return boolean

save_fixed_rate() public method

Save fixed rate to database.
Author: sl
public save_fixed_rate ( $projectID, $activityID, $rate ) : boolean
$projectID
$activityID
$rate
return boolean

save_rate() public method

Save rate to database.
Author: sl
public save_rate ( $userID, $projectID, $activityID, $rate ) : boolean
$userID
$projectID
$activityID
$rate
return boolean

save_timeframe() public method

saves timeframe of user in database (table conf)
Author: th
public save_timeframe ( string $timeframeBegin, string $timeframeEnd, string $user ) : boolean
$timeframeBegin string unix seconds
$timeframeEnd string unix seconds
$user string ID of user
return boolean

setGroupMemberships() public method

Set the groups in which the user is a member in.
Author: sl
public setGroupMemberships ( integer $userId, array $groups = null ) : false | null
$userId integer id of the user
$groups array map from group ID to membership role ID
return false | null true on success, false on failure

startRecorder() public method

starts timesheet record
Author: th, sl
public startRecorder ( integer $projectID, $activityID, $user ) : integer
$projectID integer ID of project to record
$activityID
$user
return integer id of the new entry or false on failure

status_create() public method

add a new status
public status_create ( array $status ) : boolean
$status array
return boolean

status_delete() public method

deletes a status
Author: mo
public status_delete ( array $statusID ) : boolean
$statusID array statusID of the status
return boolean true on success, false on failure

status_edit() public method

Edits a status by replacing its data by the new array
Author: mo
public status_edit ( array $statusID, array $data ) : boolean
$statusID array groupID of the status to be edited
$data array name and other new data of the status
return boolean true on success, false on failure

status_get_data() public method

Returns the data of a certain status
Author: mo
public status_get_data ( array $statusID ) : array
$statusID array ID of the group
return array the group's data (name) as array, false on failure

status_timeSheetEntryCount() public method

Returns the number of time sheet entries with a certain status
Author: mo
public status_timeSheetEntryCount ( integer $statusID ) : integer
$statusID integer ID of the status
return integer the number of timesheet entries with this status

stopRecorder() public method

Performed when the stop buzzer is hit.
Author: th, sl
public stopRecorder ( integer $id ) : boolean
$id integer id of the entry to stop
return boolean

timeEntry_create() public method

create time sheet entry
public timeEntry_create ( array $data ) : boolean | integer
$data array array with record data
return boolean | integer

timeEntry_delete() public method

delete time sheet entry
Author: th
public timeEntry_delete ( integer $id ) : object
$id integer -> ID of record
return object

timeEntry_edit() public method

edit time sheet entry
Author: th
public timeEntry_edit ( integer $id, array $data ) : boolean
$id integer ID of record
$data array array with new record data
return boolean

timeEntry_edit_activity() public method

Just edit the activity for an entry. This is used for changing the activity of a running entry.
public timeEntry_edit_activity ( integer $timeEntryID, integer $activityID ) : object
$timeEntryID integer id of the timesheet entry
$activityID integer id of the activity to change to
return object

timeEntry_edit_project() public method

Just edit the project for an entry. This is used for changing the project of a running entry.
public timeEntry_edit_project ( integer $timeEntryID, integer $projectID ) : object
$timeEntryID integer id of the timesheet entry
$projectID integer id of the project to change to
return object

timeSheet_get_data() public method

Returns the data of a certain time record
Author: th
public timeSheet_get_data ( integer $timeEntryID ) : array
$timeEntryID integer timeEntryID of the record
return array the record's data (time, activity id, project id etc) as array, false on failure

timeSheet_whereClausesFromFilters() public method

This method also makes the values SQL-secure.
public timeSheet_whereClausesFromFilters ( array $users, array $customers, array $projects, array $activities = [] ) : array
$users array list of IDs of users to include
$customers array list of IDs of customers to include
$projects array list of IDs of projects to include
$activities array list of IDs of activities to include
return array list of where clauses to include in the query

transaction_begin() public method

public transaction_begin ( ) : boolean
return boolean

transaction_end() public method

public transaction_end ( ) : boolean
return boolean

transaction_rollback() public method

public transaction_rollback ( ) : boolean
return boolean

userIDToName() public method

return name of a user with specific ID
Author: th
public userIDToName ( string $id ) : integer
$id string the user's userID
return integer

user_create() public method

Adds a new user
Author: th
public user_create ( array $data ) : boolean | integer
$data array username, email, and other data of the new user
return boolean | integer false on failure, otherwise the new user id

user_delete() public method

deletes a user
Author: th
public user_delete ( integer $userID, boolean $moveToTrash = false ) : boolean
$userID integer userID of the user
$moveToTrash boolean whether to delete user or move to trash
return boolean true on success, false on failure

user_edit() public method

Edits a user by replacing his data and preferences by the new array
Author: ob/th
public user_edit ( integer $userID, array $data ) : boolean
$userID integer userID of the user to be edited
$data array username, email, and other new data of the user
return boolean true on success, false on failure

user_get_data() public method

Returns the data of a certain user
Author: th
public user_get_data ( string $userID ) : array
$userID string ID of the user
return array the user's data (username, email-address, status etc) as array, false on failure

user_get_membership_role() public method

Returns the membership roleID the user has in the given group.
public user_get_membership_role ( integer $userID, integer $groupID ) : integer | boolean
$userID integer the ID of the user
$groupID integer the ID of the group
return integer | boolean membership roleID or false if user is not in the group

user_get_preference() protected method

Get a preference for a user. If no user ID is given the current user is used.
Author: sl
protected user_get_preference ( string $key, integer $userId = null ) : string
$key string name of the preference to fetch
$userId integer (optional) id of the user to fetch the preference for
return string value of the preference or null if there is no such preference

user_get_preferences() public method

Get several preferences for a user. If no user ID is given the current user is used.
Author: sl
public user_get_preferences ( array $keys, integer $userId = null ) : array
$keys array names of the preference to fetch in an array
$userId integer (optional) id of the user to fetch the preference for
return array with keys for every found preference and the found value

user_get_preferences_by_prefix() public method

If no user ID is given the current user is used.
Author: sl
public user_get_preferences_by_prefix ( string $prefix, integer $userId = null ) : array
$prefix string prefix all preferenc keys to fetch have in common
$userId integer (optional) id of the user to fetch the preference for
return array with keys for every found preference and the found value

user_loginSetKey() public method

Save a new secure key for a user to the database. This key is stored in the users cookie and used to reauthenticate the user.
Author: sl
public user_loginSetKey ( $userId, $keymai )
$userId
$keymai

user_name2id() public method

return ID of specific user by name
Author: th
public user_name2id ( integer $name ) : string | boolean
$name integer name of user in table users
return string | boolean

user_set_preferences() public method

The array has to assign every preference key a value to store. Example: array ( 'setting1' => 'value1', 'setting2' => 'value2'); A prefix can be specified, which will be prepended to every preference key.
Author: sl
public user_set_preferences ( array $data, string $prefix = '', integer $userId = null ) : boolean
$data array key/value pairs to store
$prefix string prefix for all preferences
$userId integer (optional) id of another user than the current
return boolean true on success, false on failure

Property Details

$conn protected_oe property

protected MySQL $conn
return MySQL

$kga protected_oe property

Kimai Global Array
protected Kimai_Config $kga
return Kimai_Config