ProjectAction.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
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00089 class ProjectAction extends Action
00090 {
00091 var $project;
00092 var $defaultSubAction = 'listing';
00093
00094
00095 function ProjectAction()
00096 {
00097 if ( $this->getRequestId()!=0 )
00098 {
00099 $this->project = new Project( $this->getRequestId() );
00100 $this->project->load();
00101 }
00102
00103
00104 }
00105
00106
00107 function save()
00108 {
00109 if ( $this->getRequestVar('name') != '')
00110 {
00111 $this->project->name = $this->getRequestVar('name' );
00112 $this->project->target_dir = $this->getRequestVar('target_dir' );
00113 $this->project->ftp_url = $this->getRequestVar('ftp_url' );
00114 $this->project->ftp_passive = $this->getRequestVar('ftp_passive' );
00115 $this->project->cmd_after_publish = $this->getRequestVar('cmd_after_publish' );
00116 $this->project->content_negotiation = $this->getRequestVar('content_negotiation');
00117 $this->project->cut_index = $this->getRequestVar('cut_index' );
00118
00119 $this->addNotice('project',$this->project->name,'SAVED','ok');
00120 $this->project->save();
00121 }
00122 else
00123 {
00124 $this->addValidationError('name');
00125 $this->callSubAction('edit');
00126 }
00127 }
00128
00129
00130
00131 function add()
00132 {
00133 $this->setTemplateVar( 'projects',Project::getAll() );
00134 }
00135
00136
00141 function addproject()
00142 {
00143 if ( !$this->hasRequestVar('type') )
00144 {
00145 $this->addValidationError('type');
00146 $this->callSubAction('add');
00147 return;
00148 }
00149 else
00150 {
00151 switch( $this->getRequestVar('type') )
00152 {
00153 case 'empty':
00154 if ( !$this->hasRequestVar('name') )
00155 {
00156 $this->addValidationError('name');
00157 $this->callSubAction('add');
00158 return;
00159 }
00160 $this->project = new Project();
00161 $this->project->name = $this->getRequestVar('name');
00162 $this->project->add();
00163 break;
00164 case 'copy':
00165 $db = db_connection();
00166 $project = new Project($this->getRequestVar('projectid'));
00167 $project->load();
00168 $project->export($db->id);
00169 break;
00170 default:
00171 Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') );
00172 }
00173
00174 $this->addNotice('project',$this->project->name,'ADDED');
00175 }
00176 }
00177
00178
00183 function listing()
00184 {
00185 global $conf_php;
00186
00187
00188 $list = array();
00189
00190 foreach( Project::getAll() as $id=>$name )
00191 {
00192 $list[$id] = array();
00193 $list[$id]['url' ] = Html::url('main' ,'project',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit'));
00194 $list[$id]['use_url' ] = Html::url('index','project',$id);
00195 $list[$id]['name' ] = $name;
00196 }
00197 $this->setTemplateVar('el',$list);
00198
00199 $this->forward('project_list');
00200 }
00201
00202
00203 function select()
00204 {
00205 $user = Session::getUser();
00206 $projects = $user->projects;
00207
00208
00209 if ( $user->isAdmin )
00210 $projects = array_merge( array("-1"=>lang('ADMINISTRATION')),$projects );
00211
00212
00213 $list = array();
00214
00215 foreach( $projects as $id=>$name )
00216 {
00217 $list[$id] = array();
00218 $list[$id]['url' ] = Html::url('index','project',$id);
00219 $list[$id]['name'] = $name;
00220 }
00221 $this->setTemplateVar('el',$list);
00222
00223 $this->forward('project_select');
00224 }
00225
00226
00227 function edit()
00228 {
00229
00230 $this->setTemplateVars( $this->project->getProperties() );
00231
00232 $this->forward('project_edit');
00233
00234 }
00235
00236
00237 function remove()
00238 {
00239 $this->setTemplateVar( 'name',$this->project->name );
00240 }
00241
00242
00243 function delete()
00244 {
00245 if ( $this->getRequestVar('delete') != '' )
00246 {
00247
00248 $this->project->delete();
00249
00250 $this->setTemplateVar('tree_refresh',true);
00251 $this->addNotice('project',$this->project->name,'DELETED');
00252 }
00253 else
00254 {
00255 $this->addValidationError('delete');
00256 $this->callSubAction('remove');
00257 }
00258 }
00259
00260
00261
00262 function maintenance()
00263 {
00264 if ( $this->hasRequestVar('ok') )
00265 {
00266 $this->project->checkLostFiles();
00267 $this->addNotice('project',$this->project->name,'DONE');
00268 $this->setTemplateVar('done',true);
00269 }
00270 }
00271
00272
00273
00277 function export()
00278 {
00279 $db = db_connection();
00280 $this->setTemplateVar( 'dbid',$db->id );
00281
00282 global $conf;
00283 $dbids = array();
00284
00285 foreach( $conf['database'] as $dbname=>$dbconf )
00286 {
00287 if ( is_array($dbconf) && $dbconf['enabled'])
00288 $dbids[$dbname] = $dbconf['comment'];
00289 }
00290 $this->setTemplateVar( 'dbids',$dbids );
00291
00292
00293 if ( $this->hasRequestVar('ok') )
00294 {
00295 $this->project->export( $this->getRequestVar('dbid') );
00296
00297 $this->addNotice('project',$this->project->name,'DONE');
00298 $this->setTemplateVar('done',true);
00299 }
00300 }
00301
00302
00303
00308 function phpinfo()
00309 {
00310 phpinfo();
00311 }
00312 }