ApplicationDelegate.php 2.67 KB
Newer Older
Gerd Schachtschneider's avatar
Gerd Schachtschneider committed
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
 * A delegate class for the entire application to handle custom handling of 
 * some functions such as permissions and preferences.
 */
class conf_ApplicationDelegate {
  /**
   * Returns permissions array.  This method is called every time an action is 
   * performed to make sure that the user has permission to perform the action.
   * @param record A Dataface_Record object (may be null) against which we check
   *               permissions.
   * @see Dataface_PermissionsTool
   * @see Dataface_AuthenticationTool
   */

  function getPermissions(&$record) {
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUser();
    // if the user is null then nobody is logged in... no access. This will force a login prompt.
    if ( !isset($user) ) return Dataface_PermissionsTool::getRolePermissions('NO ACCESS');
    $role = $user->val('role');
    // specially role with lower permissions as READ ONLY
    if ( strpos($role,'VIEW GROUP ') !== false) return Dataface_PermissionsTool::getRolePermissions('NO ACCESS');
    return Dataface_PermissionsTool::getRolePermissions($role);
    // Returns all of the permissions for the user's current role.
  }

  function block__custom_javascripts() {
    echo '<script src="custom.js" type="text/javascript" language="javascript"></script>';
  }

  // Sortierung erfolgt fuer das erste Mal nicht uber sort in index.php,
  // daher die Einstellung besser hier. Aber dann ist diese nicht mehr global und
  // sollte dann nicht mehr verlinkt werden
  // Nachteil: Aenderungen muessen immer wieder nachgezogen werden

  function beforeHandleRequest() {
    $app = Dataface_Application::getInstance();  
    $query =& $app->getQuery();
    // Sortierung aendern Common
    if ( !$_POST AND $query['-table'] == 'list_reiter'    AND !@$query['-sort'] ) $query['-sort'] = 'reiter';
    if ( !$_POST AND $query['-table'] == 'mpi_ablage'     AND !@$query['-sort'] ) $query['-sort'] = 'zeitstempel DESC';
    if ( !$_POST and $query['-table'] == 'mpi_users'      AND !@$query['-sort'] ) $query['-sort'] = 'zeitstempel DESC';
    // Sortierung aendern individuell
    if ( !$_POST AND $query['-table'] == 'list_gefahr'    AND !@$query['-sort'] ) $query['-sort'] = 'hsatz';
    if ( !$_POST AND $query['-table'] == 'list_lgk'       AND !@$query['-sort'] ) $query['-sort'] = 'priority';
    if ( !$_POST AND $query['-table'] == 'view_gefahr'    AND !@$query['-sort'] ) $query['-sort'] = 'kategorie, substanz';
    if ( !$_POST AND $query['-table'] == 'view_chemAll'   AND !@$query['-sort'] ) $query['-sort'] = 'substanz, gruppe';
    if ( !$_POST AND $query['-table'] == 'view_ablageAll' AND !@$query['-sort'] ) $query['-sort'] = 'zeitstempel DESC';
  }

}
?>