Advertisement
withremote

phpactiverecord channel model

Feb 24th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. class Channel extends Activerecord\Model {
  4.  
  5.  
  6.  
  7.     /**
  8.      * |-----------------------------------------------------------------------
  9.      * | Channels Setup
  10.      * |-----------------------------------------------------------------------
  11.      * |
  12.      */
  13.  
  14.     public static $table_name = 'channels';
  15.     public static $primary_key = 'channel';
  16.  
  17.     /**
  18.      * |-----------------------------------------------------------------------
  19.      * | Channels Validation
  20.      * |-----------------------------------------------------------------------
  21.      * |
  22.      */
  23.  
  24.     static $validates_presence_of = array();
  25.  
  26.     static $validates_numericality_of = array();
  27.  
  28.     static $validates_inclusion_of = array();
  29.  
  30.     static $validates_uniqueness_of = array();
  31.  
  32.  
  33.     /**
  34.      * Initialize static variables
  35.      */
  36.     static function int()
  37.     {
  38.         self::$validates_uniqueness_of = array(
  39.             array('channel'),
  40.             array('title'),
  41.             array('slug')
  42.         );
  43.  
  44.         self::$validates_presence_of = array(
  45.             array('channel'),
  46.             array('slug'),
  47.             array('title'),
  48.             array('section')
  49.         );
  50.  
  51.         self::$validates_inclusion_of = array(
  52.             array('section', 'in' => unserialize(self::getSections()))
  53.         );
  54.  
  55.         self::$validates_numericality_of = array(
  56.             array('channel', 'only_integer' => true)
  57.         );
  58.     }
  59.  
  60.     /**
  61.      * Get section names from CI config
  62.      *
  63.      * @return string
  64.      */
  65.     static function getSections()
  66.     {
  67.  
  68.         require dirname(dirname(dirname(__FILE__))) . '/config/prtv.php';
  69.         return serialize(array_keys($config['allowedChannelSections']));
  70.  
  71.     }
  72. }
  73.  
  74. Channel::int();
  75.  
  76. /* End of file Channel.php */
  77. /* Location: ./xx/xx/models/ar/Channel.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement