Example #1
0
 public function setBehaviour($behaviour)
 {
     if (!in_array($behaviour, array('ignore', 'cascade'))) {
         throw $this->exception('Unknonw join behaviour')->addMoreInfo('behaviour', $behaviour)->addMoreInfo('supported', array('ignore', 'cascade'));
     }
     $this->model->addHook('beforeInsert', array($this, 'insertInForeingTable'));
     $this->model->addHook('beforeUpdate', array($this, 'updateInForeingTable'));
     $this->model->addHook('afterDelete', array($this, 'deleteInForeignTable'));
     $this->behaviour = $behaviour;
     return $this;
 }
Example #2
0
 /**
  * This method "cooks" related model.
  *
  * @param SQL_Model $m
  * @param bool $as_array
  * @param bool $limit
  * @param int $offset
  * @param bool $order
  * @param bool $desc
  * @return array|SQL_Model
  */
 function prepareRelated(\SQL_Model $m, $as_array = false, $limit = false, $offset = 0, $order = false, $desc = true)
 {
     if ($limit) {
         $m->setLimit($limit, $offset);
     }
     if ($order) {
         $m->setOrder($order, $desc);
     }
     if ($as_array) {
         return $m->getRows();
     }
     return $m;
 }
Example #3
0
File: HasOne.php Project: atk4/atk4
 /**
  * @param SQL_Model $model
  * @return DB_dsql
  */
 public function getExpression($model)
 {
     $refModel = $this->getModel();
     if (is_string($refModel)) {
         $refModel = $this->app->normalizeClassName($refModel, 'Model');
     }
     $refModel = $this->add($refModel);
     /** @type SQL_Model $refModel */
     $other = $model->dsql()->getField($this->getForeignFieldName());
     if ($this->table()) {
         $other = $model->dsql()->expr($this->table() . '.' . $this->getForeignFieldName());
     }
     return $refModel->dsql()->field($refModel->title_field)->where($refModel->id_field, $other);
 }
Example #4
0
File: Many.php Project: atk4/atk4
 public function ref($mode = null)
 {
     if (!$this->owner->loaded()) {
         throw $this->exception('Model must be loaded before traversing reference');
     }
     if ($mode == 'model') {
         /** @type SQL_Model $m */
         $m = $this->add($this->model_name);
         return $m->addCondition($this->their_field, $this->owner->get($this->our_field));
     }
     $this->restoreConditions();
     $this->model->unload();
     return $this->model->addCondition($this->their_field, $this->owner->get($this->our_field));
 }
Example #5
0
 /**
  * Prepare create-table action
  *
  * @param SQL_Model $model
  *
  * @return void
  */
 function createTable(\SQL_Model $model)
 {
     if ($this->is_default_id_field) {
         // default ID field
         $type = 'integer';
         $auto = 'auto_increment';
     } else {
         // custom ID field
         $field = $model->getElement($model->id_field);
         $type = $this->mapFieldType($field);
         $auto = '';
     }
     // register action
     $this->actions['create-table'] = array('template' => $this->templates['create-table'], 'tags' => array('table' => $model->table, 'field' => $model->id_field, 'type' => $type, 'auto_incr' => $auto, 'engine' => $this->engine));
 }
Example #6
0
 function init()
 {
     parent::init();
     $this->addField('name');
     $this->hasMany('Rule');
     $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']);
 }
Example #7
0
 function init()
 {
     parent::init();
     $this->addField("session_id");
     $this->addField("data")->type("text");
     $this->addField("timestamp")->type("text");
 }
Example #8
0
 function init()
 {
     parent::init();
     $this->hasOne('Industry');
     $this->hasOne('Company');
     $this->hasOne('Department');
     $this->hasOne('Category');
     $this->addField('type')->enum(['routine', 'activity rule', 'task rule']);
     $this->addField('name');
     $this->addField('is_template')->type('boolean')->defaultValue(false);
     $this->addField('applicable_on')->type('text');
     $this->addField('is_done')->type('boolean')->defaultValue(false);
     $this->addField('auto_status')->type('text');
     $this->addField('moderated_by')->enum(['SVC Admin', 'Company Owner', 'Manager', 'Self', 'None']);
     $this->addField('is_mandatory')->type('boolean');
     $this->addField('applicable')->enum(['daily', 'weekly']);
     $this->addField('is_self_addable')->type('boolean');
     $this->addField('cross_check')->type('Number');
     // $this->containsMany('cross_check_options',function($m){
     // 	$m->addField('name');
     // 	$m->addField('gMarks')->type('text');
     // });
     $this->hasMany('RuleOption');
     $this->hasMany('gMarks');
     $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']);
 }
Example #9
0
 function init()
 {
     parent::init();
     $this->addField('name')->caption('Volume Name')->mandatory(true)->sortable(true);
     $this->addField('dirname')->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true);
     /*
     		// @todo there is no implementation of total_space and used_space
     		$this->addField('total_space')
             ->caption('Total space')
             ->hint('Volume size limit (bytes)')
             ->type('int')
             ->mandatory(true)
             ->defaultValue('1000000000')
             ->sortable(true)
             ;
     		$this->addField('used_space')
             ->caption('Used space')
             ->hint('Space used by files (bytes)')
             ->type('int')
             ->mandatory(true)
             ->defaultValue(0)
             ->display(array('form'=>'Readonly'))
             ->sortable(true)
             ;
     */
     $this->addField('stored_files_cnt')->caption('Files')->hint('Count of files in volume')->type('int')->mandatory(true)->defaultValue(0)->display(array('form' => 'Readonly'))->sortable(true);
     $this->addField('enabled')->caption('Writable')->hint('Be sure to check this one!')->type('boolean')->mandatory(true)->defaultValue(false)->sortable(true);
 }
Example #10
0
 function init()
 {
     parent::init();
     $this->hasOne('dokku_alt/Host');
     $this->addField('ts')->type('datetime')->defaultValue(date('Y-m-d H:i:s'));
     $this->addField('line');
 }
Example #11
0
 function init()
 {
     parent::init();
     $this->addField('email');
     $this->addField('password');
     $this->add('dynamic_model/Controller_AutoCreator_MySQL');
 }
Example #12
0
 function init()
 {
     parent::init();
     $this->hasOne('dokku_alt/DB', null, null, 'DB');
     $this->hasOne('dokku_alt/App', null, null, 'App');
     $this->addHook('beforeSave,beforeDelete', $this);
 }
Example #13
0
 function init()
 {
     parent::init();
     $this->addField('name')->caption('Volume Name')->mandatory(true)->sortable(true);
     $this->addField('dirname_field', 'dirname')->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true)->system(true);
     $this->addExpression('dirname')->set($this->dsql()->expr('CONCAT("websites/[0]/",[1])', [$this->app->current_website_name, $this->getElement('dirname_field')]))->caption('Folder')->hint('You can use absolute path too')->mandatory(true)->sortable(true);
     /*
     		// @todo there is no implementation of total_space and used_space
     		$this->addField('total_space')
             ->caption('Total space')
             ->hint('Volume size limit (bytes)')
             ->type('int')
             ->mandatory(true)
             ->defaultValue('1000000000')
             ->sortable(true)
             ;
     		$this->addField('used_space')
             ->caption('Used space')
             ->hint('Space used by files (bytes)')
             ->type('int')
             ->mandatory(true)
             ->defaultValue(0)
             ->display(array('form'=>'Readonly'))
             ->sortable(true)
             ;
     */
     $this->addField('stored_files_cnt')->caption('Files')->hint('Count of files in volume')->type('int')->mandatory(true)->defaultValue(0)->display(array('form' => 'Readonly'))->sortable(true);
     $this->addField('enabled')->caption('Writable')->hint('Be sure to check this one!')->type('boolean')->mandatory(true)->defaultValue(false)->sortable(true);
 }
Example #14
0
 function init()
 {
     parent::init();
     //fields
     $this->addField('name');
     $this->addField('ui_name');
     $this->addField('is_active')->type('boolean');
 }
Example #15
0
 function init()
 {
     parent::init();
     $this->addField('name')->caption('Your Name');
     $this->addField('ref')->system(true);
     $this->addField('descr')->caption('Suggestion or Feedback')->type('text');
     $this->addField('date')->system(true)->defaultValue(date('Y-m-d'));
 }
Example #16
0
 function init()
 {
     parent::init();
     $this->addField('content');
     $this->addField('block_id');
     $this->addField('is_deleted');
     //->type('boolean');
 }
Example #17
0
 function init()
 {
     parent::init();
     $this->hasOne('dokku_alt/App');
     $this->addField('is_redirect')->type('boolean');
     $this->addField('name');
     $this->addHook('afterSave,afterDelete', [$this, 'setDomains']);
 }
Example #18
0
 function init()
 {
     parent::init();
     $this->addField('name')->caption('Name')->mandatory(true)->sortable(true);
     $this->addField('mime_type')->caption('MIME type')->mandatory(true)->sortable(true);
     $this->addField('extension')->caption('Filename extension')->mandatory(true)->sortable(true);
     $this->addField('allow')->caption('Allow')->hint('Be sure to check this one!')->type('boolean')->defaultValue(true)->mandatory(true)->sortable(true);
 }
Example #19
0
 function init()
 {
     parent::init();
     $this->hasOne('dokku_alt/App');
     $this->addField('name');
     $this->addField('value');
     $this->addHook('beforeInsert,beforeDelete,beforeModify', $this);
 }
 function init()
 {
     parent::init();
     $this->hasOne('RuleBook');
     $this->addField('name');
     $this->addField('gMarks')->type('text');
     $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']);
 }
Example #21
0
File: Type.php Project: xepan/xepan
 function init()
 {
     parent::init();
     $this->addField('name');
     $this->addField('mime_type');
     $this->addField('extension');
     // TODO: extension should be substituted when recording filename
 }
Example #22
0
 function init()
 {
     parent::init();
     $this->addField('page_id');
     $this->addField('language');
     $this->addField('meta_title');
     $this->addField('meta_keywords');
     $this->addField('meta_description');
 }
Example #23
0
 function init()
 {
     parent::init();
     //$this->hasOne('dokku_alt/App');
     $this->addField('type');
     $this->addField('fingerprint');
     $this->addField('publickey')->type('text')->caption('Public Key');
     $this->addField('privatekey')->type('text')->hint('Optional')->caption('Private Key');
 }
Example #24
0
 function init()
 {
     parent::init();
     $this->hasOne('Company');
     $this->hasOne('User');
     $this->hasOne('Rule');
     $this->addField('gmarks');
     $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']);
 }
 function init()
 {
     parent::init();
     $this->hasOne('xepan\\commerce\\Item_CustomField_Generic', 'customfield_generic_id');
     $this->hasOne('xepan\\commerce\\Item_CustomField_Value', 'customfield_value_id');
     $this->hasOne('xepan\\commerce\\Model_Store_TransactionRow', 'store_transaction_row_id');
     $this->addField('custom_name');
     $this->addField('custom_value');
 }
Example #26
0
 function init()
 {
     parent::init();
     $this->addField('name');
     $this->addField('type')->enum(['mongodb', 'mariadb', 'postrgresql', 'redis', 'memcache'])->mandatory(true);
     $this->addHook('beforeInsert,beforeDelete', $this);
     $this->hasOne('dokku_alt/Host');
     $this->hasMany('dokku_alt/DB_Link', null, null, 'DB_Link');
 }
Example #27
0
 function init()
 {
     parent::init();
     $this->addField('host');
     $this->addField('notes')->type('text');
     $this->addField('data')->type('text');
     $this->addField('is_secure')->type('boolean')->editable(false)->hint('Will use your current passkey to encrypt');
     $this->hasOne('User')->defaultValue($this->app->auth->model->id);
     $this->addHook('beforeUpdate', array($this, 'checkSecurity'));
 }
Example #28
0
 function init()
 {
     parent::init();
     $this->hasOne('User')->defaultValue($this->api->auth->model->id);
     $this->addField('subject');
     $this->addField('content')->type('text')->display(['form' => 'RichText']);
     $this->add('filestore/Field_Image', 'image_id')->caption('Default Image');
     $this->addField('created_at')->type('datetime')->defaultValue($this->api->now);
     $this->add('dynamic_model/Controller_AutoCreator', ['engine' => 'INNODB']);
 }
Example #29
0
 function defineFields()
 {
     parent::defineFields();
     $this->addField('title')->mandatory(true);
     $this->addField('keywords');
     $this->addField('inherit');
     $this->addField('descr')->type('text');
     $this->addField('example')->type('text');
     $this->addField('approved')->type('boolean');
 }
 function init()
 {
     parent::init();
     $this->addField('key')->system(true)->visible(true)->editable(true)->readonly(true)->sortable(true);
     $this->addField('tr_en')->sortable(true);
     $this->addField('tr_de')->sortable(true);
     $this->addField('tr_ru')->sortable(true);
     $this->addField('tr_lv')->sortable(true);
     // extend and add your language
 }