/**
  * 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)
 {
     $user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
     if ($user and $user->val('role') == 'ADMIN') {
         return Dataface_PermissionsTool::getRolePermissions('ADMIN');
     } else {
         return Dataface_PermissionsTool::NO_ACCESS();
     }
 }
예제 #2
0
 /**
  * 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 (!isset($user)) {
         return Dataface_PermissionsTool::NO_ACCESS();
     }
     // if the user is null then nobody is logged in... no access.
     // This will force a login prompt.
     $role = $user->val('role');
     return Dataface_PermissionsTool::getRolePermissions($role);
     // Returns all of the permissions for the user's current role.
 }
예제 #3
0
파일: View.php 프로젝트: promoso/HVAC
 function Dataface_View($name, $sql = null)
 {
     import('Dataface/ViewRecord.php');
     $this->name = $name;
     $this->tablename = $name;
     if (is_array($sql)) {
         // The sql is parsed SQL
         $this->sql_data = $sql;
     } else {
         $this->sql = $sql;
     }
     $this->app =& Dataface_Application::getInstance();
     $this->_atts = array();
     $this->_atts['name'] =& $this->tablename;
     $this->_atts['label'] = isset($this->app->_tables[$this->tablename]) ? $this->app->_tables[$this->tablename] : $this->tablename;
     $this->_permissions = Dataface_PermissionsTool::getRolePermissions($this->app->_conf['default_table_role']);
 }
예제 #4
0
function getPermissions($record)
{
    $user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
    // If user is an admin defer to the application delegate class for
    // permissions
    if ($user and $user->val('role') == 'ADMIN') {
        return null;
    } elseif ($user and $user->val('role') == 'REGULAR') {
        return Dataface_PermissionsTool::getRolePermissions('REGULAR');
    }
    if ($user) {
        // User is logged in
        return Dataface_PermissionsTool::READ_ONLY();
    }
    // Defer to the application delegate class for all other users
    return null;
}
예제 #5
0
파일: jobs.php 프로젝트: gtoffoli/swete
 function getPermissions(&$record)
 {
     $user =& SweteTools::getUser();
     if (!isset($user)) {
         return null;
     }
     if (SweteTools::isAdmin()) {
         return null;
     }
     if (isset($record)) {
         $job = new SweteJob($record);
         if ($record->val("assigned_to") === $user->val('username')) {
             //error_log("job is assigned to ".$user->val('username'));
             return Dataface_PermissionsTool::getRolePermissions('ASSIGNEE');
         }
     }
     //default
     return null;
 }
예제 #6
0
 function getPermissions(&$record)
 {
     $user =& SweteTools::getUser();
     if (!isset($user)) {
         return null;
     }
     if (SweteTools::isAdmin()) {
         return null;
     }
     if (isset($record)) {
         require_once 'inc/SweteJob.class.php';
         require_once 'inc/SweteDb.class.php';
         if ($record->val('posted_by') === $user->val('username')) {
             //error_log($record->val("job_note_id")." note posted by ".$record->val('posted_by')   ." user ".$user->val('username'));
             return Dataface_PermissionsTool::getRolePermissions('OWNER');
         }
     }
     return Dataface_PermissionsTool::getRolePermissions('READ ONLY');
 }
예제 #7
0
파일: Table.php 프로젝트: promoso/HVAC
 function convertRolesToPermissions($roles)
 {
     if (is_array($roles)) {
         $perms = array();
         foreach ($roles as $role) {
             if (is_string($role)) {
                 $perms = array_merge($perms, Dataface_PermissionsTool::getRolePermissions($role));
             }
         }
         return $perms;
     } else {
         if (is_string($roles)) {
             return Dataface_PermissionsTool::getRolePermissions($roles);
         }
     }
     return $roles;
 }
예제 #8
0
 /**
  * 
  * Constructor for the relationship.
  *
  * @param $tablename The name of the source table.
  * @wparam $relationshipName The name of the relationship
  * @param An array of initializing values.  Usually produced by parsing the relationships.ini
  * 			file.
  *
  */
 function Dataface_Relationship($tablename, $relationshipName, &$values)
 {
     $this->app =& Dataface_Application::getInstance();
     $this->_name = $relationshipName;
     $this->_sourceTable =& Dataface_Table::loadTable($tablename);
     $this->_schema = array();
     $res = $this->_init($values);
     if (PEAR::isError($res)) {
         throw new Exception($res->getMessage());
     }
     if (!isset($this->_schema['permissions'])) {
         $app =& Dataface_Application::getInstance();
         $this->_schema['permissions'] = Dataface_PermissionsTool::getRolePermissions($app->_conf['default_relationship_role']);
     }
     $this->_permissions =& $this->_schema['permissions'];
 }