ModelAction.class.php
gehe zur Dokumentation dieser Datei00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00062 class ModelAction extends Action
00063 {
00064 var $defaultSubAction = 'listing';
00065 var $model;
00066
00067
00068 function ModelAction()
00069 {
00070 if ( $this->getRequestId() != 0 )
00071 {
00072 $this->model = new Model( $this->getRequestId() );
00073 $this->model->load();
00074 }
00075
00076 $this->project = Session::getProject();
00077 }
00078
00079
00080 function add()
00081 {
00082 }
00083
00084
00085 function addmodel()
00086 {
00087 $model = new Model();
00088 $model->projectid = $this->project->projectid;
00089 $model->name = $this->getRequestVar('name');
00090 $model->add();
00091
00092
00093 if ( empty($model->name) )
00094 {
00095
00096 $model->name = lang('GLOBAL_MODEL').' '.$model->modelid;
00097 $model->save();
00098 }
00099 }
00100
00101
00102
00107 function remove()
00108 {
00109 $this->model->load();
00110
00111 $this->setTemplateVar( 'name',$this->model->name );
00112 }
00113
00114
00115 function delete()
00116 {
00117 if ( $this->getRequestVar('confirm') == '1' )
00118 {
00119 $this->model->delete();
00120 }
00121 }
00122
00123
00124
00125
00126 function save()
00127 {
00128 if ( $this->getRequestVar('name') != '' )
00129 {
00130 $this->model->name = $this->getRequestVar('name');
00131 $this->model->save();
00132 $this->addNotice('model',$this->model->name,'SAVED','ok');
00133 }
00134 else
00135 {
00136 $this->addNotice('model',$this->model->name,'NOT_SAVED','error');
00137 }
00138
00139
00140
00141 }
00142
00143
00144 function setdefault()
00145 {
00146 if ( !$this->userIsAdmin() ) exit();
00147
00148 $this->model->setDefault();
00149
00150 $this->callSubAction('listing');
00151 }
00152
00153
00154 function listing()
00155 {
00156 global $conf_php;
00157 $actModel = Session::getProjectModel();
00158
00159
00160
00161 $list = array();
00162 foreach( $this->project->getModelIds() as $id )
00163 {
00164 $m = new Model( $id );
00165 $m->load();
00166
00167 $list[$id]['name'] = $m->name;
00168
00169 if ( $this->userIsAdmin() )
00170 $list[$id]['url' ] = Html::url('main','model',$id,
00171 array(REQ_PARAM_TARGETSUBACTION=>'edit') );
00172
00173 if ( ! $m->isDefault && $this->userIsAdmin() )
00174 $list[$id]['default_url'] = Html::url('model','setdefault',$id);
00175
00176 if ( $actModel->modelid != $m->modelid )
00177 $list[$id]['select_url' ] = Html::url('index','model',$id);
00178 }
00179 $this->setTemplateVar( 'el',$list );
00180 $this->setTemplateVar( 'add',$this->userIsAdmin() );
00181
00182 $this->forward('model_list');
00183 }
00184
00185
00190 function edit()
00191 {
00192 $this->model->load();
00193
00194 $this->setTemplateVars( $this->model->getProperties() );
00195 }
00196
00197
00198 function checkmenu( $menu )
00199 {
00200 switch( $menu )
00201 {
00202 case 'remove':
00203 $actModel = Session::getProjectModel();
00204 return
00205 $this->userIsAdmin() &&
00206 count( $this->model->getAll() ) >= 2 &&
00207 $actModel->modelid != $this->model->modelid;
00208
00209 case 'add':
00210 return
00211 $this->userIsAdmin();
00212
00213 default:
00214 return true;
00215 }
00216 }
00217 }