Alpha Framework alpha--model
[ class tree: alpha--model ] [ index: alpha--model ] [ all elements ]

Source for file RightsObject.inc

Documentation is available at RightsObject.inc

  1. <?php
  2.  
  3. require_once $config->get('sysRoot').'alpha/model/AlphaDAO.inc';
  4. require_once $config->get('sysRoot').'alpha/model/PersonObject.inc';
  5.  
  6. /**
  7.  *
  8.  * The group level rights object for the application permissions
  9.  * 
  10.  * @package alpha::model
  11.  * @since 1.0
  12.  * @author John Collins <dev@alphaframework.org>
  13.  * @version $Id: RightsObject.inc 1463 2011-12-08 21:15:48Z johnc $
  14.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  15.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  16.  *  All rights reserved.
  17.  * 
  18.  *  <pre>
  19.  *  Redistribution and use in source and binary forms, with or
  20.  *  without modification, are permitted provided that the
  21.  *  following conditions are met:
  22.  * 
  23.  *  * Redistributions of source code must retain the above
  24.  *    copyright notice, this list of conditions and the
  25.  *    following disclaimer.
  26.  *  * Redistributions in binary form must reproduce the above
  27.  *    copyright notice, this list of conditions and the
  28.  *    following disclaimer in the documentation and/or other
  29.  *    materials provided with the distribution.
  30.  *  * Neither the name of the Alpha Framework nor the names
  31.  *    of its contributors may be used to endorse or promote
  32.  *    products derived from this software without specific
  33.  *    prior written permission.
  34.  *   
  35.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  36.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  37.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  38.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  40.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  42.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  43.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  45.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  46.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  47.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  48.  *  </pre>
  49.  *  
  50.  */
  51. class RightsObject extends AlphaDAO {    
  52.     /**
  53.      * The name of the rights
  54.      * 
  55.      * @var String 
  56.      * @since 1.0
  57.      */
  58.     protected $name;
  59.     
  60.     /**
  61.      * A Relation containing all of the PersonObjects that have these rights
  62.      *
  63.      * @var Relation 
  64.      * @since 1.0
  65.      */
  66.     protected $members;
  67.         
  68.     /**
  69.      * An array of data display labels for the class properties
  70.      * 
  71.      * @var array 
  72.      * @since 1.0
  73.      */
  74.     protected $dataLabels = array("OID"=>"Rights Group ID#","name"=>"Rights Group Name","members"=>"Rights Group Members");
  75.     
  76.     /**
  77.      * The name of the database table for the class
  78.      * 
  79.      * @var string 
  80.      * @since 1.0
  81.      */
  82.     const TABLE_NAME = 'Rights';
  83.     
  84.     /**
  85.      * Trace logger
  86.      * 
  87.      * @var Logger 
  88.      * @since 1.1
  89.      */
  90.     private static $logger null;
  91.     
  92.     /**
  93.      * Constructor
  94.      * 
  95.      * @since 1.0
  96.      */
  97.     public function __construct({
  98.         self::$logger new Logger('BlacklistedClientObject');
  99.         
  100.         // ensure to call the parent constructor
  101.         parent::__construct();
  102.         $this->name = new String();
  103.         
  104.         // add unique key to name field
  105.         $this->markUnique('name');
  106.         
  107.         $this->members = new Relation();
  108.         $this->markTransient('members');
  109.         $this->setupRels();
  110.     }
  111.     
  112.     /**
  113.      * Get the group members Relation
  114.      *
  115.      * @return Relation 
  116.      * @since 1.0
  117.      */
  118.     public function getMembers({
  119.         return $this->members;
  120.     }
  121.     
  122.     /**
  123.      * Set up the transient attributes for the rights group after it has loaded
  124.      * 
  125.      * @since 1.0
  126.      */
  127.     protected function after_load_callback({
  128.         $this->setupRels();
  129.     }
  130.     
  131.     /**
  132.      * Set up the transient attributes for the rights group after it has loaded
  133.      * 
  134.      * @since 1.0
  135.      */
  136.     protected function after_loadByAttribute_callback({
  137.         $this->setupRels();
  138.     }
  139.     
  140.     /**
  141.      * Sets up the Relation definitions on this BO
  142.      * 
  143.      * @since 1.0
  144.      */
  145.     private function setupRels({
  146.         // set up MANY-TO-MANY relation person2rights
  147.         $this->members->setRelatedClass('PersonObject''left');
  148.         $this->members->setRelatedClassDisplayField('email''left');
  149.         $this->members->setRelatedClass('RightsObject''right');
  150.         $this->members->setRelatedClassDisplayField('name''right');
  151.         $this->members->setRelationType('MANY-TO-MANY');
  152.         $this->members->setValue($this->getID());
  153.     }
  154. }
  155.  
  156. ?>

Documentation generated on Tue, 13 Dec 2011 20:27:26 +0000 by phpDocumentor 1.4.3