[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/system/ -> domodsql.php (source)

   1  <?php /* $Id: domodsql.php 121 2008-03-26 17:50:23Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/domodsql.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $perms = &$AppUI->acl();
   7  if (!$perms->checkModule('system', 'edit')) {
   8      $AppUI->redirect('m=public&a=access_denied');
   9  }
  10  
  11  ##
  12  ## Activate or move a module entry
  13  ##
  14  $cmd = w2PgetParam($_GET, 'cmd', '0');
  15  $mod_id = intval(w2PgetParam($_GET, 'mod_id', '0'));
  16  $mod_directory = w2PgetParam($_GET, 'mod_directory', '0');
  17  
  18  $obj = new CModule();
  19  if ($mod_id) {
  20      $obj->load($mod_id);
  21  } else {
  22      $obj->mod_directory = $mod_directory;
  23  }
  24  
  25  $ok = include_once(W2P_BASE_DIR . '/modules/' . $obj->mod_directory . '/setup.php');
  26  
  27  if (!$ok) {
  28      if ($obj->mod_type != 'core') {
  29          $AppUI->setMsg('Module setup file could not be found', UI_MSG_ERROR);
  30          if ($cmd == 'remove') {
  31              $q = new DBQuery;
  32              $q->setDelete('modules');
  33              $q->addWhere('mod_id = ' . (int)$mod_id);
  34              $q->exec();
  35              $q->clear();
  36              echo db_error();
  37              $AppUI->setMsg('Module has been removed from the modules list - please check your database for additional tables that may need to be removed', UI_MSG_ERROR);
  38          }
  39          $AppUI->redirect();
  40      }
  41  }
  42  $setupclass = $config['mod_setup_class'];
  43  if (!$setupclass) {
  44      if ($obj->mod_type != 'core') {
  45          $AppUI->setMsg('Module does not have a valid setup class defined', UI_MSG_ERROR);
  46          $AppUI->redirect();
  47      }
  48  } else {
  49      $setup = new $setupclass();
  50  }
  51  
  52  switch ($cmd) {
  53      case 'moveup':
  54      case 'movedn':
  55      case 'movefirst':
  56      case 'movelast':
  57          $obj->move($cmd);
  58          $AppUI->setMsg('Module re-ordered', UI_MSG_OK);
  59          break;
  60      case 'toggle':
  61          // just toggle the active state of the table entry
  62          $obj->mod_active = 1 - $obj->mod_active;
  63          $obj->store();
  64          $AppUI->setMsg('Module state changed', UI_MSG_OK);
  65          break;
  66      case 'toggleMenu':
  67          // just toggle the active state of the table entry
  68          $obj->mod_ui_active = 1 - $obj->mod_ui_active;
  69          $obj->store();
  70          $AppUI->setMsg('Module menu state changed', UI_MSG_OK);
  71          break;
  72      case 'install':
  73          // do the module specific stuff
  74          $AppUI->setMsg($setup->install());
  75          $obj->bind($config);
  76          // add to the installed modules table
  77          $obj->install();
  78          $AppUI->setMsg('Module installed', UI_MSG_OK, true);
  79          break;
  80      case 'remove':
  81          // do the module specific stuff
  82          $AppUI->setMsg($setup->remove());
  83          // remove from the installed modules table
  84          $obj->remove();
  85          $AppUI->setMsg('Module removed', UI_MSG_ALERT, true);
  86          break;
  87      case 'upgrade':
  88          if ($setup->upgrade($obj->mod_version)) // returns true if upgrade succeeded
  89              {
  90              $obj->bind($config);
  91              $obj->store();
  92              $AppUI->setMsg('Module upgraded', UI_MSG_OK);
  93          } else {
  94              $AppUI->setMsg('Module not upgraded', UI_MSG_ERROR);
  95          }
  96          break;
  97      case 'configure':
  98          if ($setup->configure()) //returns true if configure succeeded
  99              {
 100          } else {
 101              $AppUI->setMsg('Module configuration failed', UI_MSG_ERROR);
 102          }
 103          break;
 104      default:
 105          $AppUI->setMsg('Unknown Command', UI_MSG_ERROR);
 106          break;
 107  }
 108  $AppUI->redirect();
 109  ?>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7