Source for file Location.php

Documentation is available at Location.php

  1. <?php
  2. /**
  3.  * EndDevice.php
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This program is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU General Public License as published
  9.  * by the Free Software Foundation.
  10.  *
  11.  * @package                     FreeNAC
  12.  * @author                      Hector Ortiz (FreeNAC Core Team)
  13.  * @copyright                   2007 FreeNAC
  14.  * @license                     http://www.gnu.org/copyleft/gpl.html   GNU Public License Version 2
  15.  * @version                     SVN: $Id$
  16.  * @link                        http://www.freenac.net
  17.  */
  18.  
  19. class Location extends Common
  20. {
  21.    private $props array();
  22.  
  23.    public function __construct($id)
  24.    {
  25.       parent::__construct();
  26.       $id mysql_real_escape_string($id);
  27.       if (is_numeric($id))
  28.       {
  29.          $query=<<<EOF
  30. SELECT     l.id, 
  31.     l.name, 
  32.     b.id AS building_id, 
  33.     b.name AS building_name 
  34.     FROM location l 
  35.     LEFT JOIN building b 
  36.     ON l.building_id=b.id 
  37.     WHERE l.id='$id';
  38. EOF;
  39.          $this->logger->debug($query,3);
  40.          if ($temp mysql_fetch_one($query))
  41.          {
  42.             $this->props=$temp
  43.          }
  44.       }
  45.    }
  46.  
  47.    /**
  48.    * Universal Accessor Method
  49.    * We are redirecting all unresolved method calls to this handler,
  50.    * so that we can emulate arbitraty accessor methods.
  51.    * With this trick, the user can add new fields to the system tables
  52.    * and will be able to access them in the policy as
  53.    * $system->getDBFieldName() without haveing to change this class
  54.    * @throws            If the db field does not exist, Log Error and Deny as default action
  55.    * @return mixed      Property
  56.    */
  57.    public function __call($methodName$parameters
  58.    {
  59.       # If methodname starts with get
  60.       if (substr($methodName,0,3== "get"
  61.       {
  62.          $dbfieldname substr($methodName,3);
  63.          foreach(array_keys($this->propsas $key
  64.          {
  65.             if (strtolower($key== strtolower($dbfieldname)) 
  66.             {
  67.                return $this->props[$key];
  68.             }
  69.          }
  70.       }
  71.       $this->logger->debug("Field $methodName doesn't exist",2);
  72.    }
  73.  
  74.    /**
  75.    * Return all properties assigned to this system. This method is here only for debugging purposes, please delete it after
  76.    * @return array      All properties present
  77.    */
  78.    public function getAllProps()
  79.    {
  80.       return $this->props;
  81.    }
  82. }
  83.  
  84. ?>

Documentation generated on Mon, 17 Nov 2008 01:10:40 +0100 by phpDocumentor 1.4.0