ApplicationDelegate.php 3.16 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
<?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();
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    $table = $query['-table'];
    // wenn relationship dann kein sort fuer table notwendig, @ verhindert error message in log
    if ( !@$query['-relationship'] ) {
      if ( !$_POST AND !@$query['-sort'] ) {
        // Sortierung aendern Common
        if ( $table == 'list_reiter' ) $query['-sort'] = 'reiter';
        if ( $table == 'mpi_ablage' )  $query['-sort'] = 'zeitstempel DESC';
        if ( $table == 'mpi_users' )   $query['-sort'] = 'zeitstempel DESC';
        // Sortierung aendern individuell
        if ( $table == 'list_gefahr' )    $query['-sort'] = 'hsatz';
        if ( $table == 'list_lgk' )       $query['-sort'] = 'priority';
        if ( $table == 'view_gefahr' )    $query['-sort'] = 'kategorie, substanz';
        if ( $table == 'view_chemAll' )   $query['-sort'] = 'substanz, gruppe';
        if ( $table == 'view_ablageAll' ) $query['-sort'] = 'zeitstempel DESC';
      }
/*
    } else {
      // Sortierung relationship's - wird aber leider in section nicht beachtet, besser ueber __sql__ in relationship,
      // aber dann evtl. wieder zeitprobleme (z.B. dateiablage)
      if ( !$_POST AND @$query['-relationship'] AND !@$query['-related:sort'] ) {
        $relation = $query['-relationship'];
        //if ( $relation == 'mengenfluss' ) $query['-related:sort'] = 'zeitstempel DESC';
        //if ( $relation == 'wartung' )     $query['-related:sort'] = 'naechste';
        //if ( $relation == 'notiz' )       $query['-related:sort'] = 'zeitstempel DESC';
      }
*/
    }
Gerd Schachtschneider's avatar
Gerd Schachtschneider committed
67
68
69
70
  }

}
?>