Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Control Privacy

Editing Open file Service/Callback.php add following function:

Code Block

public function getGlobalPrivacySettings()
        return array(
            'todo.default_privacy_setting' => array(
                'phrase' => _p('todo')

Edit file add.html.php, add following code

Code Block
{if Phpfox::isModule('privacy')}
     <div class="table form-group-flow">
            <div class="table_left">
                {_p var='privacy'}:
            <div class="table_right">
                {module name='privacy.form' privacy_name='privacy' privacy_info='control_who_can_see_this_todo' default_privacy='todo_.default_privacy_setting'}


  • control_who_can_see_this_todo is a phrase that you must be added on phrase.json
  • todo_.default_privacy_setting is an unique var_name use used in callback

Back to file Controller/AddController.php, modify it as following code

Code Block
$iItemId  = \Phpfox::getLib('database')->insert(\Phpfox::getT('todolist_task'),[
    'user_id'=> \Phpfox::getUserId(), // get current user id
    'name'=> $vals['name'],
    'time_stamp'=>time(),  // creatation time
    'time_update'=>time(), // last modification time
    'privacy'=>$aVals>$vals['privacy'], // modify this line...
    'task_status'=>0, // mark task is in-complete
//...and this condition statement
if ($vals['privacy'] == '4') {
    Privacy_Service_Process\Phpfox::instancegetService('privacy.process')->add('todo', $iItemId,
        (isset($aVals['privacy_list']) ? $aVals['privacy_list'] : array()));

Now your todo list item has it own privacy. We move to controller view open Controller/ViewController.php to check if user have has the permission to view it.

We add following code, right below get after getting todo-list detail:

Code Block
    $aItem  = $browseService->getForBrowse($id);
    if (\Phpfox::isModule('privacy')) {
        \Privacy_Service_Privacy\Phpfox::instancegetService('privacy')->check('todo', $aItem['task_id'], $aItem['user_id'], $aItem['privacy'],


  • todo: is your app alias
  • $aItem['task_id']: your todo list ID
  • $aItem['user_id']: user ID of todo list owner
  • $aItem&['privacy']: privacy of this todo list
  • $aItem&:['is_friend']: are viewing user and creator user friends?

We have following value for privacy:

  • 0: Public everyone can view
  • 1: Friends Only friend can view
  • 2: Friends of Friends Friends and Friends of Friends can view
  • 3: Only Me Only owner can view
  • 4: Custom Owner can define a list of users can view


We have to modify function getForBrowse to get more information if missing.