// TODO: for time page we may limit the day to today only.
 
 // Use custom fields plugin if it is enabled.
 // TODO: for time page we may limit the day to today only.
 
 // Use custom fields plugin if it is enabled.
 $cl_start = trim($request->getParameter('browser_time'));
 $cl_finish = trim($request->getParameter('browser_time'));
 // Custom field.
 $cl_start = trim($request->getParameter('browser_time'));
 $cl_finish = trim($request->getParameter('browser_time'));
 // Custom field.
   if ($request->isPost()) {
     $cl_billable = $request->getParameter('billable');
     $_SESSION['billable'] = (int) $cl_billable;
   if ($request->isPost()) {
     $cl_billable = $request->getParameter('billable');
     $_SESSION['billable'] = (int) $cl_billable;
 $_SESSION['task'] = $cl_task;
 
 // Obtain uncompleted record. Assumtion is that only 1 uncompleted record is allowed.
 $_SESSION['task'] = $cl_task;
 
 // Obtain uncompleted record. Assumtion is that only 1 uncompleted record is allowed.
-if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) {
-    $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
+    $active_clients = ttGroupHelper::getActiveClients(true);
     $form->addInput(array('type'=>'combobox',
       'onchange'=>'fillProjectDropdown(this.value);',
       'name'=>'client',
     $form->addInput(array('type'=>'combobox',
       'onchange'=>'fillProjectDropdown(this.value);',
       'name'=>'client',
-  if (in_array('cl', explode(',', $user->plugins))) {
-    $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+  if ($user->isPluginEnabled('cl')) {
+    $active_clients = ttGroupHelper::getActiveClients(true);
     // We need an array of assigned project ids to do some trimming. 
     foreach($project_list as $project)
       $projects_assigned_to_user[] = $project['id'];
     // We need an array of assigned project ids to do some trimming. 
     foreach($project_list as $project)
       $projects_assigned_to_user[] = $project['id'];
   $form->addInput(array('type'=>'combobox',
     'name'=>'task',
     'style'=>'width: 250px;',
   $form->addInput(array('type'=>'combobox',
     'name'=>'task',
     'style'=>'width: 250px;',
-if (in_array('iv', explode(',', $user->plugins)))
-  $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls));
+if ($user->isPluginEnabled('iv'))
+  $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable,'enable'=>$enable_controls));
 $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click.
 $form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>''));  // User current time, which gets filled in on button click.
 $enable_start = $uncompleted ? false : true;
 if (!$uncompleted)
 $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click.
 $form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>''));  // User current time, which gets filled in on button click.
 $enable_start = $uncompleted ? false : true;
 if (!$uncompleted)
-  $form->addInput(array('type'=>'submit','name'=>'btn_start','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.start'),'enable'=>$enable_start));
+  $form->addInput(array('type'=>'submit','name'=>'btn_start','onclick'=>'browser_time.value=get_time()','value'=>$i18n->get('label.start'),'enable'=>$enable_start));
-  $form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.finish'),'enable'=>!$enable_start));
+  $form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->get('label.finish'),'enable'=>!$enable_start));
 
 // If we have custom fields - add controls for them.
 if ($custom_fields && $custom_fields->fields[0]) {
   // Only one custom field is supported at this time.
   if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) {
     $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1));
 
 // If we have custom fields - add controls for them.
 if ($custom_fields && $custom_fields->fields[0]) {
   // Only one custom field is supported at this time.
   if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) {
     $form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1));
     $form->addInput(array('type'=>'combobox','name'=>'cf_1',
       'style'=>'width: 250px;',
       'value'=>$cl_cf_1,
       'data'=>$custom_fields->options,
     $form->addInput(array('type'=>'combobox','name'=>'cf_1',
       'style'=>'width: 250px;',
       'value'=>$cl_cf_1,
       'data'=>$custom_fields->options,
-// Determine lock date. Time entries earlier than lock date cannot be created or modified.
-$lock_interval = $user->lock_interval;
-$lockdate = 0;
-if ($lock_interval > 0) {
-  $lockdate = new DateAndTime();
-  $lockdate->decDay($lock_interval);
-}
-
-    if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client)
-      $err->add($i18n->getKey('error.client'));
+    if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client)
+      $err->add($i18n->get('error.client'));
-      if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']);
+      if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->get('error.field'), $custom_fields->fields[0]['label']);
       $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
       if ($selected_date->after($browser_today))
       $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
       if ($selected_date->after($browser_today))
-      if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish))
-        $err->add($i18n->getKey('error.overlap'));
+      if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish))
+        $err->add($i18n->get('error.overlap'));
-        'user_id' => $user->getActiveUser(),
+        'user_id' => $user->getUser(),
+        'group_id' => $user->getGroup(),
+        'org_id' => $user->org_id,
       if ($id && $custom_fields && $cl_cf_1) {
         if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
           $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cl_cf_1);
       if ($id && $custom_fields && $cl_cf_1) {
         if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
           $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cl_cf_1);
           $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cl_cf_1, null);
       }
 
           $result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cl_cf_1, null);
       }
 
     }
   }
   if ($request->getParameter('btn_stop')) {
     // Stop button clicked. We need to finish an uncompleted record in progress.
     }
   }
   if ($request->getParameter('btn_stop')) {
     // Stop button clicked. We need to finish an uncompleted record in progress.
 
     // Can we complete this record?
     if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time
 
     // Can we complete this record?
     if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time
-      && !ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap
+      && !ttTimeHelper::overlaps($user->getUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap
         'client'=>$record['client_id'],
         'project'=>$record['project_id'],
         'task'=>$record['task_id'],
         'client'=>$record['client_id'],
         'project'=>$record['project_id'],
         'task'=>$record['task_id'],
     } else {
       // Cannot complete, redirect for manual edit.
       header('Location: time_edit.php?id='.$record['id']);
     } else {
       // Cannot complete, redirect for manual edit.
       header('Location: time_edit.php?id='.$record['id']);
 $smarty->assign('week_total', $week_total);
 
 $smarty->assign('uncompleted', $uncompleted);
 
 
 
 $smarty->assign('week_total', $week_total);
 
 $smarty->assign('uncompleted', $uncompleted);
 
 
 
-$smarty->assign('time_records', ttTimeHelper::getRecords($user->getActiveUser(), $cl_date));
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date));
+$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date));
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="fillDropdowns()"');
 $smarty->assign('timestring', $selected_date->toString($user->date_format));
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="fillDropdowns()"');
 $smarty->assign('timestring', $selected_date->toString($user->date_format));
 $smarty->assign('content_page_name', 'mobile/timer.tpl');
 $smarty->display('mobile/index.tpl');
 $smarty->assign('content_page_name', 'mobile/timer.tpl');
 $smarty->display('mobile/index.tpl');