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 1341 2011-03-17 15:02:02Z 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.      * Constructor
  86.      * 
  87.      * @since 1.0
  88.      */
  89.     public function __construct({
  90.         // ensure to call the parent constructor
  91.         parent::__construct();
  92.         $this->name = new String();
  93.         
  94.         // add unique key to name field
  95.         $this->markUnique('name');
  96.         
  97.         $this->members = new Relation();
  98.         $this->markTransient('members');
  99.         $this->setupRels();
  100.     }
  101.     
  102.     /**
  103.      * Get the group members Relation
  104.      *
  105.      * @return Relation 
  106.      * @since 1.0
  107.      */
  108.     public function getMembers({
  109.         return $this->members;
  110.     }
  111.     
  112.     /**
  113.      * Set up the transient attributes for the rights group after it has loaded
  114.      * 
  115.      * @since 1.0
  116.      */
  117.     protected function after_load_callback({
  118.         $this->setupRels();
  119.     }
  120.     
  121.     /**
  122.      * Set up the transient attributes for the rights group after it has loaded
  123.      * 
  124.      * @since 1.0
  125.      */
  126.     protected function after_loadByAttribute_callback({
  127.         $this->setupRels();
  128.     }
  129.     
  130.     /**
  131.      * Sets up the Relation definitions on this BO
  132.      * 
  133.      * @since 1.0
  134.      */
  135.     private function setupRels({
  136.         // set up MANY-TO-MANY relation person2rights
  137.         $this->members->setRelatedClass('PersonObject''left');
  138.         $this->members->setRelatedClassDisplayField('email''left');
  139.         $this->members->setRelatedClass('RightsObject''right');
  140.         $this->members->setRelatedClassDisplayField('name''right');
  141.         $this->members->setRelationType('MANY-TO-MANY');
  142.         $this->members->setValue($this->getID());
  143.     }
  144. }
  145.  
  146. ?>

Documentation generated on Thu, 17 Mar 2011 16:44:46 +0000 by phpDocumentor 1.4.3