1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
use Bitweaver\KernelTools;
/**
* @version $Header$
* @package install
* @subpackage functions
*/
// assign next step in installation process
$gBitSmarty->assign( 'next_step', $step );
// check if database version is up to date
if( version_compare( $gBitSystem->getBitVersion(), $gBitSystem->getVersion(), '==' )) {
$upToDate = TRUE;
$gBitSmarty->assign( 'upToDate', $upToDate );
}
// updating to version 2.1.0-beta
if( version_compare( '2.1.0-beta', $gBitSystem->getVersion(), '>' )) {
// get a list of all groups and their permissions
$listHash = [
'only_root_groups' => true,
'sort_mode' => !empty( $_REQUEST['sort_mode'] ) ? $_REQUEST['sort_mode'] : 'group_name_asc'
];
$allGroups = $gBitUser->getAllGroups( $listHash );
$allPerms = $gBitUser->getGroupPermissions( $_REQUEST );
$gBitSmarty->assign( 'allPerms', $allPerms );
$gBitSmarty->assign( 'allGroups', $allGroups );
$gBitSmarty->assign( 'version_210beta', TRUE );
$versionUpdate = TRUE;
// deal with assigning permissions to various groups
if( !empty( $_REQUEST['fix_version_210beta'] )) {
foreach( array_keys( $allGroups ) as $groupId ) {
foreach( array_keys( $allPerms ) as $perm ) {
if( !empty( $_REQUEST['perms'][$groupId][$perm] )) {
$gBitUser->assignPermissionToGroup( $perm, $groupId );
} else {
$gBitUser->removePermissionFromGroup( $perm, $groupId );
}
}
}
}
}
// ===================== Update version to current one =====================
// Only update the version when the form has been submitted
if( !empty( $_REQUEST['update_version'] )) {
if( !empty( $upToDate ) || !empty( $_REQUEST['skip'] )) {
// if we're already up to date, we'll simply move on to the next page
KernelTools::bit_redirect( $_SERVER['SCRIPT_NAME']."?step=".++$step );
} else {
// set the version of bitweaver in the database
if( $gBitSystem->storeVersion( NULL, $gBitSystem->getBitVersion() )) {
// display the confirmation page
$gBitSmarty->assign( 'next_step', $step + 1 );
$app = '_done';
}
}
}
|