ObjectAction.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
00083
00084
00085
00086
00087
00088
00096 class ObjectAction extends Action
00097 {
00098 var $objectid;
00099
00100
00106 function addacl()
00107 {
00108 $acl = new Acl();
00109
00110 $acl->objectid = $this->getRequestId();
00111
00112
00113
00114 $o = new Object( $acl->objectid );
00115
00116 if ( !$o->hasRight( ACL_GRANT ) )
00117 die('uh?');
00118
00119
00120 switch( $this->getRequestVar('type') )
00121 {
00122 case 'user':
00123 $acl->userid = $this->getRequestVar('userid' );
00124
00125 if ( $acl->userid <= 0 )
00126 {
00127 $this->addValidationError('type' );
00128 $this->addValidationError('userid','');
00129 $this->callSubAction('aclform');
00130 return;
00131 }
00132 break;
00133 case 'group':
00134 $acl->groupid = $this->getRequestVar('groupid');
00135 if ( $acl->groupid <= 0 )
00136 {
00137 $this->addValidationError('type' );
00138 $this->addValidationError('groupid','');
00139 $this->callSubAction('aclform');
00140 return;
00141 }
00142 break;
00143 case 'all':
00144 break;
00145 default:
00146 $this->addValidationError('type');
00147 $this->callSubAction('aclform');
00148 return;
00149 }
00150
00151 $acl->languageid = $this->getRequestVar(REQ_PARAM_LANGUAGE_ID);
00152
00153 $acl->write = ( $this->hasRequestVar('write' ) );
00154 $acl->prop = ( $this->hasRequestVar('prop' ) );
00155 $acl->delete = ( $this->hasRequestVar('delete' ) );
00156 $acl->release = ( $this->hasRequestVar('release' ) );
00157 $acl->publish = ( $this->hasRequestVar('publish' ) );
00158 $acl->create_folder = ( $this->hasRequestVar('create_folder') );
00159 $acl->create_file = ( $this->hasRequestVar('create_file' ) );
00160 $acl->create_link = ( $this->hasRequestVar('create_link' ) );
00161 $acl->create_page = ( $this->hasRequestVar('create_page' ) );
00162 $acl->grant = ( $this->hasRequestVar('grant' ) );
00163 $acl->transmit = ( $this->hasRequestVar('transmit' ) );
00164
00165 $acl->add();
00166
00167 $this->addNotice('','','ADDED',OR_NOTICE_OK);
00168
00169 $o->setTimestamp();
00170 }
00171
00172
00173
00177 function rights()
00178 {
00179
00180 $o = Session::getObject();
00181 $o->objectLoadRaw();
00182 $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
00183 $this->setTemplateVar( 'type',$o->getType() );
00184
00185 $acllist = array();
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 foreach( $o->getAllAclIds() as $aclid )
00198 {
00199 $acl = new Acl( $aclid );
00200 $acl->load();
00201 $key = 'bu'.$acl->username.'g'.$acl->groupname.'a'.$aclid;
00202 $acllist[$key] = $acl->getProperties();
00203 $acllist[$key]['delete_url'] = Html::url($this->actionName,'delacl',$o->objectid,array('aclid'=>$aclid));
00204 }
00205 ksort( $acllist );
00206
00207 $this->setTemplateVar('acls',$acllist );
00208
00209 $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
00210 }
00211
00212
00213
00218 function inherit()
00219 {
00220 $log = array();
00221
00222 if ( ! $this->hasRequestVar('inherit') )
00223 {
00224 $this->addNotice('folder',$this->name,'NOTHING_DONE',OR_NOTICE_WARN);
00225 return;
00226 }
00227
00228
00229 $folder = $this->folder;
00230 $aclids = $folder->getAllAclIds();
00231
00232 $newAclList = array();
00233 foreach( $aclids as $aclid )
00234 {
00235 $acl = new Acl( $aclid );
00236 $acl->load();
00237 if ( $acl->transmit )
00238 $newAclList[] = $acl;
00239 }
00240 $log[] = 'inheriting '.count($newAclList).' acls';
00241
00242 $oids = $folder->getObjectIds();
00243
00244 foreach( $folder->getAllSubfolderIds() as $sfid )
00245 {
00246 $subfolder = new Folder( $sfid );
00247
00248 $oids = array_merge($oids,$subfolder->getObjectIds());
00249 }
00250
00251 foreach( $oids as $oid )
00252 {
00253 $object = new Object( $oid );
00254
00255
00256 foreach( $object->getAllAclIds() as $aclid )
00257 {
00258 $acl = new Acl( $aclid );
00259 $acl->objectid = $oid;
00260 $acl->delete();
00261 $log[] = 'removing acl '.$aclid.' for object '.$oid;
00262 }
00263
00264
00265 foreach( $newAclList as $newAcl )
00266 {
00267 $newAcl->objectid = $oid;
00268 $newAcl->add();
00269 $log[] = 'adding new acl '.$newAcl->aclid.' for object '.$oid;
00270 }
00271 }
00272
00273 $this->addNotice('folder',$this->name,'SAVED',OR_NOTICE_OK,array(),$log);
00274 }
00275
00276
00280 function aclform()
00281 {
00282 $o = Session::getObject();
00283 $o->objectLoadRaw();
00284
00285 $this->setTemplateVars( $o->getAssocRelatedAclTypes() );
00286 $this->setTemplateVar( 'show',$o->getRelatedAclTypes() );
00287
00288 $this->setTemplateVar('users' ,User::listAll() );
00289 $this->setTemplateVar('groups' ,Group::getAll() );
00290
00291 $languages = array(0=>lang('GLOBAL_ALL_LANGUAGES'));
00292 $languages += Language::getAll();
00293 $this->setTemplateVar('languages',$languages );
00294 $this->setTemplateVar('objectid' ,$o->objectid );
00295 $this->setTemplateVar('action' ,$this->actionName);
00296 }
00297
00298
00299
00305 function delacl()
00306 {
00307 $acl = new Acl($this->getRequestVar('aclid'));
00308 $acl->objectid = $this->getRequestId();
00309
00310
00311
00312 $o = new Object( $this->getRequestId() );
00313
00314 if ( !$o->hasRight( ACL_GRANT ) )
00315 die('ehm?');
00316
00317 $acl->delete();
00318
00319 $this->addNotice('','','DELETED',OR_NOTICE_OK);
00320 }
00321 }