install
[ class tree: install ] [ index: install ] [ all elements ]

Source for file install_cleanup.php

Documentation is available at install_cleanup.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package install
  5.  * @subpackage functions
  6.  */
  7.  
  8. // assign next step in installation process
  9. $gBitSmarty->assign'next_step'$step );
  10.  
  11. $schema $gBitInstaller->mPackages;
  12. ksort$schema );
  13. $gBitSmarty->assign_by_ref'schema'$schema );
  14.  
  15.  
  16.  
  17. // ===================== Post install table check =====================
  18. // $dbTables is the output of BitSystem::verifyInstalledPackages() in
  19. // install_inc.php and contains all tables that are not present in the database
  20. // - even tables of packages that are not installed
  21. $dbIntegrity install_check_database_integrity$dbTables );
  22.  
  23.  
  24.  
  25. // ===================== Permissions =====================
  26. // check all permissions, compare them to each other and see if there are old 
  27. // permissions and ones that need to be inserted
  28. $query "SELECT * FROM `".BIT_DB_PREFIX."users_permissions` ORDER BY `package` ASC";
  29. $result $gBitInstaller->mDb->query$query );
  30. while!$result->EOF {
  31.     foreach$result->fields as $r {
  32.         $bitPerms[$result->fields['perm_name']][$r;
  33.     }
  34.     if defined'ROLE_MODEL' ) ) {
  35.         $bitPerms[$result->fields['perm_name']]['sql']["DELETE FROM `".BIT_DB_PREFIX."users_role_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
  36.     else {
  37.         $bitPerms[$result->fields['perm_name']]['sql']["DELETE FROM `".BIT_DB_PREFIX."users_group_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
  38.     }
  39.     $bitPerms[$result->fields['perm_name']]['sql']["DELETE FROM `".BIT_DB_PREFIX."users_permissions` WHERE `perm_name`='".$result->fields['perm_name']."'";
  40.     $result->MoveNext();
  41. }
  42.  
  43. // we will make sure all the permission levels are what they should be. we will
  44. // update these without consulting the user. this is purely backend stuff, has
  45. // no outcome on the site itself but determines what the default permission
  46. // level is. the user can never modify these settings.
  47. foreacharray_keys$gBitInstaller->mPermHash as $perm {
  48.     // permission level is stored in [2]
  49.     $bindVars array();
  50.     if!empty$bitPerms[$perm&& $gBitInstaller->mPermHash[$perm][2!= $bitPerms[$perm][2{
  51.         $query "UPDATE `".BIT_DB_PREFIX."users_permissions` SET `perm_level` = ? WHERE `perm_name` = ?";
  52.         $bindVars[$gBitInstaller->mPermHash[$perm][2];
  53.         $bindVars[$perm;
  54.         $gBitInstaller->mDb->query$query$bindVars );
  55.     }
  56. }
  57.  
  58. // compare both perm arrays with each other and work out what permissions need
  59. // to be added and which ones removed
  60. $insPerms $delPerms array();
  61. foreacharray_keys$gBitInstaller->mPermHash as $perm {
  62.     if!in_array$permarray_keys$bitPerms ))) {
  63.         if$gBitInstaller->isInstalled$gBitInstaller->mPermHash[$perm][3)) {
  64.             $insPerms[$perm$gBitInstaller->mPermHash[$perm];
  65.         }
  66.     }
  67. }
  68.  
  69. foreacharray_keys$bitPerms as $perm {
  70.     if!in_array$permarray_keys$gBitInstaller->mPermHash ) ) ) {
  71.         $delPerms[$perm$bitPerms[$perm];
  72.     }
  73. }
  74. $gBitSmarty->assign'delPerms'$delPerms );
  75. $gBitSmarty->assign'insPerms'$insPerms );
  76.  
  77.  
  78.  
  79. // ===================== Services =====================
  80. // check if we have installed more than one service of any given type
  81. // DEPRECATED - this check never really made sense. The original purpose
  82. // of the services was to have multiple under the same identifier to
  83. // be able to invoke them all in one shot. Recent updates to the services
  84. // flattens the array so that there is one and only one service set per
  85. // service type. This could revert back with time. For now this is commented
  86. // out.
  87. /*
  88. $serviceList = array();
  89. if( !empty( $gLibertySystem->mServices ) ) {
  90.     foreach( $gLibertySystem->mServices as $service_name => $service ) {
  91.         if( count( $service ) > 1 ) {
  92.             $serviceList[$service_name] = $service;
  93.         }
  94.     }
  95. }
  96. */
  97.  
  98.  
  99.  
  100. // ===================== Process Form =====================
  101. // create missing tables if possible
  102. if!empty(  $_REQUEST['create_tables'&& !empty$dbIntegrity )) {
  103.     $gBitInstallDb &ADONewConnection$gBitDbType );
  104.  
  105.     if$gBitInstallDb->Connect$gBitDbHost$gBitDbUser$gBitDbPassword$gBitDbName )) {
  106.         $dict NewDataDictionary$gBitInstallDb );
  107.  
  108.         if!$gBitInstaller->mDb->getCaseSensitivity() ) {
  109.             $dict->connection->nameQuote '';
  110.         }
  111.  
  112.         if!empty$gDebug || !empty$_REQUEST['debug')) {
  113.             $gBitInstaller->debug();
  114.             $gBitInstallDb->debug 99;
  115.         }
  116.  
  117.         // If we use MySql check which storage engine to use
  118.         ifisset$_SESSION['use_innodb') ){
  119.             if$_SESSION['use_innodb'== TRUE {
  120.                 $build array('NEW''MYSQL' => 'ENGINE=INNODB');
  121.             else {
  122.                 $build array('NEW''MYSQL' => 'ENGINE=MYISAM');
  123.             }
  124.         else {
  125.             $build 'NEW';
  126.         }
  127.  
  128.         $tablePrefix $gBitInstaller->getTablePrefix();
  129.         foreach$dbIntegrity as $package => $info {
  130.             foreach$info['tables'as $table {
  131.                 $completeTableName $tablePrefix.$table['name'];
  132.                 $sql $dict->CreateTableSQL$completeTableName$gBitInstaller->mPackages[$package]['tables'][$table['name']]$build );
  133.                 // Uncomment this line to see the create sql
  134.                 //vd( $sql );
  135.                 if$sql {
  136.                     $dict->ExecuteSQLArray$sql );
  137.                 }
  138.             }
  139.         }
  140.     }
  141. }
  142.  
  143. // if any of the serviceList items have been unchecked, disable the appropriate packages
  144. if!empty(  $_REQUEST['resolve_conflicts') ) {
  145.     if!empty$gDebug || !empty$_REQUEST['debug') ) {
  146.         $gBitInstaller->debug();
  147.         $gBitInstallDb->debug 99;
  148.     }
  149.     // === Permissions
  150.     $fixedPermissions array();
  151.     $permMap array();
  152.     $permMap['basic'ANONYMOUS_TEAM_ID;
  153.     $permMap['registered'3;
  154.     $permMap['editors'2;
  155.     $permMap['admin'1;
  156.     if!empty$_REQUEST['perms') ) {
  157.         foreach$_REQUEST['perms'as $perm {
  158.             if!empty$delPerms[$perm)) {
  159.                 foreach$delPerms[$perm]['sql'as $sql {
  160.                     $gBitInstaller->mDb->query$sql );
  161.                 }
  162.                 $fixedPermissions[$delPerms[$perm];
  163.             }
  164.  
  165.             if!empty$insPerms[$perm)) {
  166.                 $gBitInstaller->mDb->query$insPerms[$perm]['sql');
  167.                 $fixedPermissions[$insPerms[$perm];
  168.                 if!empty$roleMap[$insPerms[$perm][2]] )) {
  169.                     if defined'ROLE_MODEL' ) ) {
  170.                         $gBitUser->assignPermissionToRole$perm$permMap[$insPerms[$perm][2]] );
  171.                     else {
  172.                         $gBitUser->assignPermissionToGroup$perm$permMap[$insPerms[$perm][2]] );
  173.                     }
  174.                 }
  175.             }
  176.         }
  177.     }
  178.     $gBitSmarty->assign'fixedPermissions'$fixedPermissions );
  179.  
  180.     // === Services
  181.     $deActivated array();
  182.     foreach$serviceList as $service {
  183.         foreacharray_keys$service as $package {
  184.             $packages !empty$_REQUEST['packages'$_REQUEST['packages'array();
  185.             if!in_array$package$packages )) {
  186.                 $gBitSystem->storeConfig'package_'.$package'n'KERNEL_PKG_NAME );
  187.                 $deActivated[$package;
  188.             }
  189.         }
  190.     }
  191.  
  192.     $gBitSmarty->assign'next_step'$step );
  193.     $gBitSmarty->assign'deActivated'$deActivated );
  194.     // display the confirmation page
  195.     $app '_done';
  196. elseif!empty(  $_REQUEST['skip') ) {
  197.     // if there were no conflicts, we move on to the next page
  198.     header"Location: ".$_SERVER['SCRIPT_NAME']."?step=".++$step );
  199.     die;
  200. }
  201.  
  202. // make sure everything is up to date after the above changes
  203. $dbTables $gBitInstaller->verifyInstalledPackages'all' );
  204. $dbIntegrity install_check_database_integrity$dbTables );
  205. $gBitSmarty->assign'dbIntegrity'$dbIntegrity );
  206.  
  207. // $gBitSmarty->assign( 'serviceList', $serviceList );
  208.  
  209.  
  210.  
  211. /**
  212.  * function - install_check_database_integrity
  213.  */
  214. function install_check_database_integrity$pDbTables {
  215.     global $gBitInstaller;
  216.     $ret array();
  217.     if!empty$pDbTables['missing'&& is_array$pDbTables['missing')) {
  218.         foreacharray_keys$pDbTables['missing'as $package {
  219.             // we can't use the 'installed' flag in $gBitInstaller->mPackages[$package] because that is set to 'not installed' as soon as a table is missing
  220.             ifcount$gBitInstaller->mPackages[$package]['tables'count$pDbTables['missing'][$package)) {
  221.                 // at least one table is missing
  222.                 $ret[$packagearray(
  223.                     'name'     => ucfirst$gBitInstaller->mPackages[$package]['name'),
  224.                     'required' => $gBitInstaller->mPackages[$package]['required'],
  225.                 );
  226.                 foreach$pDbTables['missing'][$packageas $table {
  227.                     $ret[$package]['tables'][$tablearray(
  228.                         'name' => $table,
  229.                         'sql'  => $gBitInstaller->mPackages[$package]['tables'][$table],
  230.                     );
  231.                 }
  232.             }
  233.         }
  234.     }
  235.     return $ret;
  236. }
  237. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:43 +0000 by phpDocumentor 1.5.0-lsces