Since phpFox version 4.6.0, in Browse Users
page (Admincp
), admin can view item statistic information of users. So, we prepared this document for instructions to help you can integrate your app with this feature.
- Add a callback function name
getUserStatsForAdmin
- Example
Code Block | ||||
---|---|---|---|---|
| ||||
/**
* @param $iUserId user id of selected user
* @return array|bool
*/
public function getUserStatsForAdmin($iUserId)
{
if (!$iUserId) {
return false;
}
$iIncomplete = db()->select('COUNT(*)')
->from(':todolist_task')
->where([
'user_id' => (int)$iUserId,
'task_status' => 0
])
->execute('getField');
$iComplete = db()->select('COUNT(*)')
->from(':todolist_task')
->where([
'user_id' => (int)$iUserId,
'task_status' => 1
])
->execute('getField');
return [
'merge_result' => true,
'result' => [
[
//Name of the item
'total_name' => _p('incomplete_tasks'),
//Total count
'total_value' => $iIncomplete,
'type' => 'item'
],
[
'total_name' => _p('complete_tasks'),
'total_value' => $iComplete,
'type' => 'item'
]
]
];
}
|
...