GroupAction.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
00032 class GroupAction extends Action
00033 {
00034 var $group;
00035 var $defaultSubAction = 'edit';
00036
00037
00038 function GroupAction()
00039 {
00040 if ( !$this->userIsAdmin() )
00041 die('you are not an admin');
00042
00043 if ( $this->getRequestId() != 0 )
00044 {
00045 $this->group = new Group( $this->getRequestId() );
00046 $this->group->load();
00047 $this->setTemplateVar( 'groupid',$this->group->groupid );
00048 }
00049 }
00050
00051
00052
00053 function delete()
00054 {
00055 if ( $this->hasRequestVar('confirm') )
00056 {
00057 $this->group->delete();
00058
00059 $this->addNotice('group',$this->group->name,'DELETED','ok');
00060 }
00061 else
00062 {
00063 $this->addNotice('group',$this->group->name,'NOT_DELETED','ok');
00064 }
00065 }
00066
00067
00068
00069 function remove()
00070 {
00071 $this->setTemplateVars( $this->group->getProperties() );
00072 }
00073
00074
00075
00076 function save()
00077 {
00078 if ( $this->getRequestVar('name') != '' )
00079 {
00080 $this->group->name = $this->getRequestVar('name');
00081
00082 $this->group->save();
00083
00084 $this->addNotice('group',$this->group->name,'SAVED','ok');
00085 }
00086 else
00087 {
00088 $this->addValidationError('name');
00089 $this->callSubAction('edit');
00090 }
00091 }
00092
00093
00094 function add()
00095 {
00096 }
00097
00098
00099 function addgroup()
00100 {
00101 if ( $this->getRequestVar('name') != '')
00102 {
00103 $this->group = new Group();
00104 $this->group->name = $this->getRequestVar('name');
00105 $this->group->add();
00106 $this->addNotice('group',$this->group->name,'ADDED','ok');
00107 $this->callSubAction('listing');
00108 }
00109 else
00110 {
00111 $this->addValidationError('name');
00112 $this->callSubAction('add');
00113 }
00114 }
00115
00116
00117 function adduser()
00118 {
00119 $this->setTemplateVar('users',$this->group->getOtherUsers());
00120 }
00121
00122
00127 function addusertogroup()
00128 {
00129 $userid = $this->getRequestVar('userid');
00130
00131 if ( is_array($userid))
00132 {
00133
00134 foreach( $userid as $uid )
00135 {
00136 $this->group->addUser( $uid );
00137 }
00138 $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OR_NOTICE_OK,array('count'=>count($userid)));
00139 }
00140 elseif( intval($userid) > 0 )
00141 {
00142
00143 $this->group->addUser( intval($userid) );
00144 $this->addNotice('group',$this->group->name,'USER_ADDED_TO_GROUP',OK_NOTICE_OK,array('count'=>'1'));
00145 }
00146 else
00147 {
00148
00149 $this->addNotice('group',$this->group->name,'NOTHING_DONE',OR_NOTICE_WARN);
00150 }
00151 }
00152
00153
00154
00158 function deluser()
00159 {
00160 $this->group->delUser( intval($this->getRequestVar('userid')) );
00161
00162 $this->addNotice('group',$this->group->name,'DELETED',OR_NOTICE_OK);
00163 }
00164
00165
00166
00170 function listing()
00171 {
00172 $list = array();
00173
00174 foreach( Group::getAll() as $id=>$name )
00175 {
00176 $list[$id] = array();
00177 $list[$id]['url' ] = Html::url('main','group',$id,array(REQ_PARAM_TARGETSUBACTION=>'edit'));
00178 $list[$id]['name'] = $name;
00179 }
00180
00181 $this->setTemplateVar('el', $list);
00182 }
00183
00184
00185 function edit()
00186 {
00187 $this->setTemplateVars( $this->group->getProperties() );
00188 }
00189
00190
00191
00195 function memberships()
00196 {
00197 }
00198
00199
00200
00205 function users()
00206 {
00207
00208
00209 $userliste = array();
00210
00211 foreach( $this->group->getUsers() as $userid=>$name )
00212 {
00213 $userliste[$userid] = array('name' => $name,
00214 'delete_url' => Html::url('group','deluser',$this->getRequestId(),array('userid'=>$userid)));
00215 }
00216 $this->setTemplateVar('memberships',$userliste);
00217 }
00218
00219
00220
00221
00222
00226 function rights()
00227 {
00228 $rights = $this->group->getAllAcls();
00229
00230 $projects = array();
00231
00232 foreach( $rights as $acl )
00233 {
00234 if ( !isset($projects[$acl->projectid]))
00235 {
00236 $projects[$acl->projectid] = array();
00237 $p = new Project($acl->projectid);
00238 $p->load();
00239 $projects[$acl->projectid]['projectname'] = $p->name;
00240 $projects[$acl->projectid]['rights' ] = array();
00241 }
00242
00243 $right = array();
00244
00245 if ( $acl->languageid > 0 )
00246 {
00247 $language = new Language($acl->languageid);
00248 $language->load();
00249 $right['languagename'] = $language->name;
00250 }
00251 else
00252 {
00253 $right['languagename'] = lang('ALL_LANGUAGES');
00254 }
00255
00256
00257 $o = new Object($acl->objectid);
00258 $o->objectLoad();
00259 $right['objectname'] = $o->name;
00260 $right['objectid' ] = $o->objectid;
00261 $right['objecttype'] = $o->getType();
00262
00263 if ( $acl->groupid > 0 )
00264 {
00265 $group = new Group($acl->groupid);
00266 $group->load();
00267 $right['groupname'] = $group->name;
00268 }
00269 else
00270 {
00271
00272 }
00273
00274 $right['bits'] = $acl->getProperties();
00275
00276 $projects[$acl->projectid]['rights'][] = $right;
00277 }
00278
00279 $this->setTemplateVar('projects' ,$projects );
00280
00281 $this->setTemplateVar('show',Acl::getAvailableRights() );
00282 }
00283
00284
00285
00292 function checkMenu( $menu )
00293 {
00294 switch( $menu )
00295 {
00296 case 'users':
00297
00298 return count($this->group->getUsers()) > 0;
00299 case 'adduser':
00300
00301
00302 return count($this->group->getOtherUsers()) > 0;
00303 default:
00304 return true;
00305 }
00306 }
00307 }