ad4d6d1583e96e2401aa90bccd077c808c12336b.svn-base 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class tables_mpi_users { 

  function getPermissions($record) {
    $user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
    // first let's deal with the case that the user is not logged in.
    if ( !$user ) return Dataface_PermissionsTool::NO_ACCESS();
    $role = $user->val('role'); 
  //  if ( isAdmin($role) ) return Dataface_PermissionsTool::ALL();
    if ( $role == 'MANAGER' ) return Dataface_PermissionsTool::getRolePermissions('MANAGER');
    if ( $role == 'ADMIN' )   return Dataface_PermissionsTool::getRolePermissions('ADMIN');
 
    // Everybody else gets read only access to the table.
    // return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
    return Dataface_PermissionsTool::NO_ACCESS();
  }

  function email__renderCell( &$record ) {
    $mail = $record->strval('email');
    return '<a href="mailto:'.$mail.'">'.$mail.'</a>';
  }

  // Formatiere Zeitstempel auf Deutsch
  function zeitstempel__display(&$record)  {
    if ($record->strval('zeitstempel') == NULL) return;
    return date('d.m.Y', strtotime($record->strval('zeitstempel')));
  }

  function beforeSave(&$record) {
    $app = Dataface_Application::getInstance();
    $dn  = $app->_conf['_own']['dn'];
    $usr = $record->val('username');
    $record->setValue('email', $usr.'@'.$dn);
  }

}
?>