Exemplo n.º 1
0
 public static function getDefaultMetadata()
 {
     $metadata = parent::getDefaultMetadata();
     $metadata[__CLASS__] = array('members' => array('name'), 'relations' => array('group' => array(RedBeanModel::HAS_MANY_BELONGS_TO, 'Group'), 'groups' => array(RedBeanModel::HAS_MANY, 'Group'), 'users' => array(RedBeanModel::MANY_MANY, 'User')), 'rules' => array(array('name', 'required'), array('name', 'unique'), array('name', 'type', 'type' => 'string'), array('name', 'length', 'min' => 2, 'max' => 64)), 'defaultSortAttribute' => 'name');
     return $metadata;
 }
Exemplo n.º 2
0
 public static function getDefaultMetadata()
 {
     // User is going to have a Person bean.
     // As far as Php is concerned User is not a
     // Person - because it isn't inheriting it,
     // but the RedBeanModel essentially uses the
     // Php inheritance to accumulate the data
     // it needs in the getDefaultMetadata() methods
     // to connect everything up in the database
     // in the same order as the inheritance.
     // By getting the person metadata from Person
     // and mixing it into the metadata for User
     // and the construction of User overriding
     // to create and connect the Person bean,
     // the User effectively is a Person from
     // a data point of view.
     $personMetadata = Person::getDefaultMetadata();
     $metadata = parent::getDefaultMetadata();
     $metadata['Person'] = $personMetadata['Person'];
     $metadata[__CLASS__] = array('members' => array('hash', 'language', 'locale', 'timeZone', 'username', 'serializedAvatarData', 'isActive', 'lastLoginDateTime', 'isRootUser', 'hideFromSelecting', 'isSystemUser', 'hideFromLeaderboard'), 'relations' => array('currency' => array(static::HAS_ONE, 'Currency'), 'groups' => array(static::MANY_MANY, 'Group'), 'manager' => array(static::HAS_ONE, 'User', static::NOT_OWNED, static::LINK_TYPE_SPECIFIC, 'manager'), 'role' => array(static::HAS_MANY_BELONGS_TO, 'Role'), 'emailBoxes' => array(static::HAS_MANY, 'EmailBox'), 'emailAccounts' => array(static::HAS_MANY, 'EmailAccount'), 'emailSignatures' => array(static::HAS_MANY, 'EmailSignature', static::OWNED)), 'foreignRelations' => array('Dashboard', 'Portlet'), 'rules' => array(array('hash', 'type', 'type' => 'string'), array('hash', 'length', 'min' => 60, 'max' => 60), array('language', 'type', 'type' => 'string'), array('language', 'length', 'max' => 10), array('locale', 'type', 'type' => 'string'), array('locale', 'length', 'max' => 10), array('timeZone', 'type', 'type' => 'string'), array('timeZone', 'length', 'max' => 64), array('timeZone', 'UserDefaultTimeZoneDefaultValueValidator'), array('timeZone', 'ValidateTimeZone'), array('username', 'required'), array('username', 'unique'), array('username', 'UsernameLengthValidator', 'on' => 'createUser, editUser'), array('username', 'type', 'type' => 'string'), array('username', 'match', 'pattern' => '/^[^A-Z]+$/', 'message' => 'Username must be lowercase.'), array('username', 'length', 'max' => 64), array('username', 'filter', 'filter' => 'trim'), array('serializedAvatarData', 'type', 'type' => 'string'), array('isActive', 'readOnly'), array('isActive', 'boolean'), array('isRootUser', 'readOnly'), array('isRootUser', 'boolean'), array('hideFromSelecting', 'boolean'), array('isSystemUser', 'readOnly'), array('isSystemUser', 'boolean'), array('hideFromLeaderboard', 'boolean'), array('lastLoginDateTime', 'type', 'type' => 'datetime')), 'elements' => array('currency' => 'CurrencyDropDown', 'language' => 'LanguageStaticDropDown', 'locale' => 'LocaleStaticDropDown', 'role' => 'Role', 'timeZone' => 'TimeZoneStaticDropDown'), 'defaultSortAttribute' => 'lastName', 'noExport' => array('hash'), 'noApiExport' => array('hash'), 'noAudit' => array('serializedAvatarData'), 'indexes' => array('permitable_id' => array('members' => array('permitable_id'), 'unique' => false)));
     return $metadata;
 }