public function testDeleteAccount() { $account = Model::Instance('provider.account'); $account->provider_id = 1; $account->name = "Test"; $account->notes = ""; $account->key = "junk"; $account->secret = "junk"; $account->save(); $accounts = filter('provider/account')->find(); $this->assertTrue(count($accounts) == 1); $accounts[0]->delete(); $accounts = filter('provider/account')->find(); $this->assertTrue(count($accounts) == 0); }
public function edit($id) { return array('account'=>Model::Instance('provider.account',$id)); }
private function build_default_fields() { $related=array(); foreach($this->model->related as $r) $related[$r->field]=$r; $result=array(); foreach($this->model->fields as $field) { $f=array(); $f['id']=$field->name; $f['label']=ucfirst($field->name); if (isset($related[$field->name])) { $f['type']='select'; $f['datasource']="model://".$related[$field->name]->model; $f['key']=$related[$field->name]->foreign_field; // we have to guess what the display name is ... // if you need more control, specify the fields manually. $model=Model::Instance($related[$field->name]->model); $names=explode('.',$related[$field->name]->model); $f['label']=ucfirst(array_pop($names)); if (isset($model->fields['name'])) $f['field']='name'; else if (isset($model->fields['title'])) $f['field']='title'; else foreach($model->fields as $field) { // grab the first string field if ($field->type==Field::STRING) $f['field']=$field->name; } } else $f['type']='text'; $f['value']=$field->value; $result[]=$f; } // vomit($result); return $result; }
public function __construct($admin = false) { $this->news = Model::Instance(); $this->content = ''; $this->admin = $admin; }