home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / system / domodsql.php < prev    next >
Encoding:
PHP Script  |  2003-12-21  |  2.4 KB  |  93 lines

  1. <?php /* SYSTEM $Id: domodsql.php,v 1.8 2003/12/21 11:52:23 gregorerhardt Exp $ */
  2. ##
  3. ## Activate or move a module entry
  4. ##
  5. $cmd = dPgetParam( $_GET, 'cmd', '0' );
  6. $mod_id = intval( dPgetParam( $_GET, 'mod_id', '0' ) );
  7. $mod_directory = dPgetParam( $_GET, 'mod_directory', '0' );
  8.  
  9. $obj = new CModule();
  10. if ($mod_id) {
  11.     $obj->load( $mod_id );
  12. } else {
  13.     $obj->mod_directory = $mod_directory;
  14. }
  15.  
  16. $ok = @include_once( "{$AppUI->cfg['root_dir']}/modules/$obj->mod_directory/setup.php" );
  17.  
  18. if (!$ok) {
  19.     if ($obj->mod_type != 'core') {
  20.         $AppUI->setMsg( 'Module setup file could not be found', UI_MSG_ERROR );
  21.         $AppUI->redirect();
  22.     }
  23. }
  24. $setupclass = $config['mod_setup_class'];
  25. if (! $setupclass) {
  26.   if ($obj->mod_type != 'core') {
  27.     $AppUI->setMsg('Module does not have a valid setup class defined', UI_MSG_ERROR);
  28.     $AppUI->redirect();
  29.   }
  30. }
  31. else
  32.   $setup = new $setupclass();
  33.  
  34. switch ($cmd) {
  35.     case 'moveup':
  36.     case 'movedn':
  37.         $obj->move( $cmd );
  38.         $AppUI->setMsg( 'Module re-ordered', UI_MSG_OK );
  39.         break;
  40.     case 'toggle':
  41.     // just toggle the active state of the table entry
  42.         $obj->mod_active = 1 - $obj->mod_active;
  43.         $obj->store();
  44.         $AppUI->setMsg( 'Module state changed', UI_MSG_OK );
  45.         break;
  46.     case 'toggleMenu':
  47.     // just toggle the active state of the table entry
  48.         $obj->mod_ui_active = 1 - $obj->mod_ui_active;
  49.         $obj->store();
  50.         $AppUI->setMsg( 'Module menu state changed', UI_MSG_OK );
  51.         break;
  52.     case 'install':
  53.     // do the module specific stuff
  54.         $AppUI->setMsg( $setup->install() );
  55.         $obj->bind( $config );
  56.     // add to the installed modules table
  57.         $obj->install();
  58.         $AppUI->setMsg( 'Module installed', UI_MSG_OK );
  59.         break;
  60.     case 'remove':
  61.     // do the module specific stuff
  62.         $AppUI->setMsg( $setup->remove() );
  63.     // remove from the installed modules table
  64.         $obj->remove();
  65.         $AppUI->setMsg( 'Module removed', UI_MSG_ALERT );
  66.         break;
  67.     case 'upgrade':
  68.         if ( $setup->upgrade( $obj->mod_version ) )    // returns true if upgrade succeeded
  69.         {
  70.             $obj->bind( $config );
  71.             $obj->store();
  72.             $AppUI->setMsg( 'Module upgraded', UI_MSG_OK );
  73.         }
  74.         else
  75.         {
  76.             $AppUI->setMsg( 'Module not upgraded', UI_MSG_ERROR );
  77.         }
  78.         break;
  79.     case 'configure':
  80.         if ( $setup->configure() )     //returns true if configure succeeded
  81.         {
  82.         }
  83.         else {
  84.             $AppUI->setMsg( 'Module configuration failed', UI_MSG_ERROR );
  85.         }
  86.         break;
  87.     default:
  88.         $AppUI->setMsg( 'Unknown Command', UI_MSG_ERROR );
  89.         break;
  90. }
  91. $AppUI->redirect();
  92. ?>
  93.