@@ -305,7 +305,6 @@ public static function install(){
305305 // Setup default groups
306306 Capsule::table (static ::getSchemaTable ('group ' )->name )->insert ([
307307 [
308- 'id ' => 1 ,
309308 'name ' => 'User ' ,
310309 'is_default ' => GROUP_DEFAULT_PRIMARY ,
311310 'can_delete ' => 0 ,
@@ -315,7 +314,6 @@ public static function install(){
315314 'icon ' => 'fa fa-user '
316315 ],
317316 [
318- 'id ' => 2 ,
319317 'name ' => 'Administrator ' ,
320318 'is_default ' => GROUP_NOT_DEFAULT ,
321319 'can_delete ' => 0 ,
@@ -325,7 +323,6 @@ public static function install(){
325323 'icon ' => 'fa fa-flag '
326324 ],
327325 [
328- 'id ' => 3 ,
329326 'name ' => 'Zerglings ' ,
330327 'is_default ' => GROUP_NOT_DEFAULT ,
331328 'can_delete ' => 1 ,
@@ -336,60 +333,54 @@ public static function install(){
336333 ]
337334 ]);
338335
336+ // Get default groups id's.
337+ $ user = Capsule::table (static ::getSchemaTable ('group ' )->name )->where ('name ' , '= ' , 'User ' )->first ()['id ' ];
338+ $ admin = Capsule::table (static ::getSchemaTable ('group ' )->name )->where ('name ' , '= ' , 'Administrator ' )->first ()['id ' ];
339339
340340 // Setup default authorizations
341341 Capsule::table (static ::getSchemaTable ('authorize_group ' )->name )->insert ([
342342 [
343- 'id ' => 1 ,
344- 'group_id ' => 1 ,
343+ 'group_id ' => $ user ,
345344 'hook ' => 'uri_dashboard ' ,
346345 'conditions ' => 'always() '
347346 ],
348347 [
349- 'id ' => 2 ,
350- 'group_id ' => 2 ,
348+ 'group_id ' => $ admin ,
351349 'hook ' => 'uri_dashboard ' ,
352350 'conditions ' => 'always() '
353351 ],
354352 [
355- 'id ' => 3 ,
356- 'group_id ' => 2 ,
353+ 'group_id ' => $ admin ,
357354 'hook ' => 'uri_users ' ,
358355 'conditions ' => 'always() '
359356 ],
360357 [
361- 'id ' => 4 ,
362- 'group_id ' => 1 ,
358+ 'group_id ' => $ user ,
363359 'hook ' => 'uri_account_settings ' ,
364360 'conditions ' => 'always() '
365361 ],
366362 [
367- 'id ' => 5 ,
368- 'group_id ' => 1 ,
363+ 'group_id ' => $ user ,
369364 'hook ' => 'update_account_setting ' ,
370365 'conditions ' => 'equals(self.id, user.id)&&in(property,[\"email\",\"locale\",\"password\"]) '
371366 ],
372367 [
373- 'id ' => 6 ,
374- 'group_id ' => 2 ,
368+ 'group_id ' => $ admin ,
375369 'hook ' => 'update_account_setting ' ,
376- 'conditions ' => '!in_group(user.id,2 )&&in(property,[\"email\",\"display_name\",\"title\",\"locale\",\"flag_password_reset\",\"flag_enabled\"]) '
370+ 'conditions ' => '!in_group(user.id, ' . $ admin . ' )&&in(property,[\"email\",\"display_name\",\"title\",\"locale\",\"flag_password_reset\",\"flag_enabled\"]) '
377371 ],
378372 [
379- 'id ' => 7 ,
380- 'group_id ' => 2 ,
373+ 'group_id ' => $ admin ,
381374 'hook ' => 'view_account_setting ' ,
382375 'conditions ' => 'in(property,[\"user_name\",\"email\",\"display_name\",\"title\",\"locale\",\"flag_enabled\",\"groups\",\"primary_group_id\"]) '
383376 ],
384377 [
385- 'id ' => 8 ,
386- 'group_id ' => 2 ,
378+ 'group_id ' => $ admin ,
387379 'hook ' => 'delete_account ' ,
388- 'conditions ' => '!in_group(user.id,2 ) '
380+ 'conditions ' => '!in_group(user.id, ' . $ admin . ' ) '
389381 ],
390382 [
391- 'id ' => 9 ,
392- 'group_id ' => 2 ,
383+ 'group_id ' => $ admin ,
393384 'hook ' => 'create_account ' ,
394385 'conditions ' => 'always() '
395386 ]
0 commit comments