Example #1
0
 /**
  * init the class
  */
 public static function _init()
 {
     // auth config
     \Config::load('auth', true);
     // get the auth driver in use
     $drivers = \Config::get('auth.driver', array());
     is_array($drivers) or $drivers = array($drivers);
     // modify the model definition based on the driver used
     if (in_array('Simpleauth', $drivers)) {
         // remove properties not in use
         unset(static::$_properties['group_id']);
         unset(static::$_properties['previous_login']);
         unset(static::$_properties['user_id']);
         // remove relations
         static::$_eav = array();
         static::$_belongs_to = array();
         static::$_has_many = array();
         static::$_many_many = array();
         // remove observers
         unset(static::$_observers['Orm\\Observer_Self']);
         // simpleauth config
         \Config::load('simpleauth', true);
         // set the connection this model should use
         static::$_connection = \Config::get('simpleauth.db_connection');
         // set the write connection this model should use
         static::$_connection = \Config::get('simpleauth.db_write_connection');
         // set the models table name
         static::$_table_name = \Config::get('simpleauth.table_name', 'users');
     } elseif (in_array('Ormauth', $drivers)) {
         // remove properties not in use
         unset(static::$_properties['group']);
         unset(static::$_properties['profile_fields']);
         // ormauth config
         \Config::load('ormauth', true);
         // set the connection this model should use
         static::$_connection = \Config::get('ormauth.db_connection');
         // set the write connection this model should use
         static::$_connection = \Config::get('ormauth.db_write_connection');
         // set the models table name
         static::$_table_name = \Config::get('ormauth.table_name', 'users');
         // set the relations through table names
         static::$_many_many['roles']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_roles';
         static::$_many_many['permissions']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_permissions';
     }
     // model language file
     \Lang::load('auth_model_user', true);
 }
Example #2
0
File: post.php Project: vano00/blog
 public static function _init()
 {
     if (in_array('post', \Config::get('comment')) and \Module::load('comment')) {
         static::$_has_many = array_merge(static::$_has_many, ['comments' => ['model_to' => '\\Comment\\Model_Comment', 'key_from' => 'id', 'key_to' => 'post_id', 'cascade_save' => true, 'cascade_delete' => true], 'published_comments' => ['model_to' => '\\Comment\\Model_Comment', 'conditions' => array('where' => array(array('status', '=', 'published')))]]);
     }
 }