This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Developer manual/Models

From Group-Office Groupware and CRM Documentation
Revision as of 08:53, 9 September 2011 by Admin (Talk | contribs) (Created page with "Group-Office uses models to interact with the database. Group-Office models come with a lot of built in functionality such as: *Automatic handling of permissions with Access Con...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Group-Office uses models to interact with the database. Group-Office models come with a lot of built in functionality such as:

  • Automatic handling of permissions with Access Control Lists
  • Searchable with the Group-Office global search function
  • Models are linkable to eachother
  • Extendable with custom fields

Creating a model

Each model that interacts with the database must extend the GO_Base_Db_ActiveRecord class. The following code is the minimal required for a model:

class GO_Notes_Model_Note extends GO_Base_Db_ActiveRecord {
	
	/**
	 * Returns a static model of itself
	 * 
	 * @param String $className
	 * @return GO_Notes_Model_Note 
	 */
	public static function model($className=__CLASS__)
	{	
		return parent::model($className);
	}
	
	public function getLocalizedName(){
		return GO::t('note','notes');
	}
	
	public function aclField(){
		return 'category.acl_id';	
	}
	
	public function tableName(){
		return 'no_notes';
	}
}