| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        admin
 
     | 
  
  
    | 
      5
     | 
    
       * @package         modules
 
     | 
  
  
    | 
      6
     | 
    
       * @author          Ryan Djurovich, WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2009-2012, WebsiteBaker Org. e.V.
 
     | 
  
  
    | 
      8
     | 
    
       * @link			http://www.websitebaker2.org/
 
     | 
  
  
    | 
      9
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      10
     | 
    
       * @platform        WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      11
     | 
    
       * @requirements    PHP 5.2.2 and higher
 
     | 
  
  
    | 
      12
     | 
    
       * @version         $Id: index.php 1913 2013-06-07 03:43:44Z Luisehahne $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/index.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2013-06-07 05:43:44 +0200 (Fri, 07 Jun 2013) $
 
     | 
  
  
    | 
      15
     | 
    
       *
 
     | 
  
  
    | 
      16
     | 
    
       */
 
     | 
  
  
    | 
      17
     | 
    
      
 
     | 
  
  
    | 
      18
     | 
    
      // Print admin header
 
     | 
  
  
    | 
      19
     | 
    
      require('../../config.php');
     | 
  
  
    | 
      20
     | 
    
      require_once(WB_PATH.'/framework/class.admin.php');
 
     | 
  
  
    | 
      21
     | 
    
      $admin = new admin('Addons', 'modules');
     | 
  
  
    | 
      22
     | 
    
      
 
     | 
  
  
    | 
      23
     | 
    
      // Setup template object, parse vars to it, then parse it
 
     | 
  
  
    | 
      24
     | 
    
      // Create new template object
 
     | 
  
  
    | 
      25
     | 
    
      $template = new Template(dirname($admin->correct_theme_source('modules.htt')),'keep');
     | 
  
  
    | 
      26
     | 
    
      // $template->debug = true;
 
     | 
  
  
    | 
      27
     | 
    
      $template->set_file('page', 'modules.htt');
     | 
  
  
    | 
      28
     | 
    
      $template->set_block('page', 'main_block', 'main');
     | 
  
  
    | 
      29
     | 
    
      
 
     | 
  
  
    | 
      30
     | 
    
      // Insert values into module list
 
     | 
  
  
    | 
      31
     | 
    
      $template->set_block('main_block', 'module_list_block', 'module_list');
     | 
  
  
    | 
      32
     | 
    
      $result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' order by name");
     | 
  
  
    | 
      33
     | 
    
      if($result->numRows() > 0) {
     | 
  
  
    | 
      34
     | 
    
      	while ($addon = $result->fetchRow())
 
     | 
  
  
    | 
      35
     | 
    
      	{
     | 
  
  
    | 
      36
     | 
    
      		if ($admin->get_permission($addon['directory'],'module')==false) { continue;}
     | 
  
  
    | 
      37
     | 
    
      //echo $addon['directory'].'<br />';
 
     | 
  
  
    | 
      38
     | 
    
      		$template->set_var('VALUE', $addon['directory']);
     | 
  
  
    | 
      39
     | 
    
      		$template->set_var('NAME', $addon['name']);
     | 
  
  
    | 
      40
     | 
    
      		$template->parse('module_list', 'module_list_block', true);
     | 
  
  
    | 
      41
     | 
    
      	}
 
     | 
  
  
    | 
      42
     | 
    
      }
 
     | 
  
  
    | 
      43
     | 
    
      
 
     | 
  
  
    | 
      44
     | 
    
      // Insert modules which includes a install.php file to install list
 
     | 
  
  
    | 
      45
     | 
    
      $module_files = glob(WB_PATH . '/modules/*');
 
     | 
  
  
    | 
      46
     | 
    
      $template->set_block('main_block', 'install_list_block', 'install_list');
     | 
  
  
    | 
      47
     | 
    
      $template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
     | 
  
  
    | 
      48
     | 
    
      $template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
     | 
  
  
    | 
      49
     | 
    
      $template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
     | 
  
  
    | 
      50
     | 
    
      
 
     | 
  
  
    | 
      51
     | 
    
      $show_block = false;
 
     | 
  
  
    | 
      52
     | 
    
      foreach ($module_files as $index => $path)
 
     | 
  
  
    | 
      53
     | 
    
      {
     | 
  
  
    | 
      54
     | 
    
      	if ( $admin->get_permission(basename($path),'module')==false ) { continue;}
     | 
  
  
    | 
      55
     | 
    
      	if (is_dir($path)) {
     | 
  
  
    | 
      56
     | 
    
      //echo basename($path).'<br />';
 
     | 
  
  
    | 
      57
     | 
    
      		if (is_readable($path . '/install.php')) {
     | 
  
  
    | 
      58
     | 
    
      			$show_block = true;
 
     | 
  
  
    | 
      59
     | 
    
      			$template->set_var('INSTALL_VISIBLE', '');
     | 
  
  
    | 
      60
     | 
    
      			$template->set_var('VALUE', basename($path));
     | 
  
  
    | 
      61
     | 
    
      			$template->set_var('NAME', basename($path));
     | 
  
  
    | 
      62
     | 
    
      			$template->parse('install_list', 'install_list_block', true);
     | 
  
  
    | 
      63
     | 
    
      		}
 
     | 
  
  
    | 
      64
     | 
    
      
 
     | 
  
  
    | 
      65
     | 
    
      		if (is_readable($path . '/upgrade.php')) {
     | 
  
  
    | 
      66
     | 
    
      			$show_block = true;
 
     | 
  
  
    | 
      67
     | 
    
      			$template->set_var('UPGRADE_VISIBLE', '');
     | 
  
  
    | 
      68
     | 
    
      			$template->set_var('VALUE', basename($path));
     | 
  
  
    | 
      69
     | 
    
      			$template->set_var('NAME', basename($path));
     | 
  
  
    | 
      70
     | 
    
      			$template->parse('upgrade_list', 'upgrade_list_block', true);
     | 
  
  
    | 
      71
     | 
    
      		}
 
     | 
  
  
    | 
      72
     | 
    
      
 
     | 
  
  
    | 
      73
     | 
    
      		if (is_readable($path . '/uninstall.php')) {
     | 
  
  
    | 
      74
     | 
    
      			$show_block = true;
 
     | 
  
  
    | 
      75
     | 
    
      			$template->set_var('UNINSTALL_VISIBLE', '');
     | 
  
  
    | 
      76
     | 
    
      			$template->set_var('VALUE', basename($path));
     | 
  
  
    | 
      77
     | 
    
      			$template->set_var('NAME', basename($path));
     | 
  
  
    | 
      78
     | 
    
      			$template->parse('uninstall_list', 'uninstall_list_block', true);
     | 
  
  
    | 
      79
     | 
    
      		}
 
     | 
  
  
    | 
      80
     | 
    
      
 
     | 
  
  
    | 
      81
     | 
    
      	} else {
     | 
  
  
    | 
      82
     | 
    
      		unset($module_files[$index]);
 
     | 
  
  
    | 
      83
     | 
    
      	}
 
     | 
  
  
    | 
      84
     | 
    
      }
 
     | 
  
  
    | 
      85
     | 
    
      
 
     | 
  
  
    | 
      86
     | 
    
      // Insert permissions values
 
     | 
  
  
    | 
      87
     | 
    
      if($admin->get_permission('modules_install') != true) {
     | 
  
  
    | 
      88
     | 
    
      	$template->set_var('DISPLAY_INSTALL', 'hide');
     | 
  
  
    | 
      89
     | 
    
      }
 
     | 
  
  
    | 
      90
     | 
    
      if($admin->get_permission('modules_uninstall') != true) {
     | 
  
  
    | 
      91
     | 
    
      	$template->set_var('DISPLAY_UNINSTALL', 'hide');
     | 
  
  
    | 
      92
     | 
    
      }
 
     | 
  
  
    | 
      93
     | 
    
      if($admin->get_permission('modules_view') != true) {
     | 
  
  
    | 
      94
     | 
    
      	$template->set_var('DISPLAY_LIST', 'hide');
     | 
  
  
    | 
      95
     | 
    
      }
 
     | 
  
  
    | 
      96
     | 
    
      // only show block if there is something to show
 
     | 
  
  
    | 
      97
     | 
    
      if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
     | 
  
  
    | 
      98
     | 
    
      	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
     | 
  
  
    | 
      99
     | 
    
      }
 
     | 
  
  
    | 
      100
     | 
    
      
 
     | 
  
  
    | 
      101
     | 
    
      //$mLang = ModLanguage::getInstance();
 
     | 
  
  
    | 
      102
     | 
    
      //$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
 
     | 
  
  
    | 
      103
     | 
    
      $mLang = Translate::getinstance();
 
     | 
  
  
    | 
      104
     | 
    
      $mLang->enableAddon('admin\addons');
     | 
  
  
    | 
      105
     | 
    
      
 
     | 
  
  
    | 
      106
     | 
    
      /*-- insert all needed vars from language files ----------------------------------------*/
 
     | 
  
  
    | 
      107
     | 
    
      $template->set_var($mLang->getLangArray());
 
     | 
  
  
    | 
      108
     | 
    
      
 
     | 
  
  
    | 
      109
     | 
    
      // insert urls
 
     | 
  
  
    | 
      110
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      111
     | 
    
      					'ADMIN_URL' => ADMIN_URL,
 
     | 
  
  
    | 
      112
     | 
    
      					'WB_URL' => WB_URL,
 
     | 
  
  
    | 
      113
     | 
    
      					'THEME_URL' => THEME_URL,
 
     | 
  
  
    | 
      114
     | 
    
      					'FTAN' => $admin->getFTAN()
 
     | 
  
  
    | 
      115
     | 
    
      					)
 
     | 
  
  
    | 
      116
     | 
    
      				);
 
     | 
  
  
    | 
      117
     | 
    
      // Insert language text and messages
 
     | 
  
  
    | 
      118
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      119
     | 
    
      	'URL_TEMPLATES' => $admin->get_permission('templates') ?
     | 
  
  
    | 
      120
     | 
    
      		'<a href="' . ADMIN_URL . '/templates/index.php">' . $mLang->MENU_TEMPLATES . '</a>' : '<b>'.$mLang->MENU_TEMPLATES.'</b>',
 
     | 
  
  
    | 
      121
     | 
    
      	'URL_LANGUAGES' => $admin->get_permission('languages') ?
     | 
  
  
    | 
      122
     | 
    
      		'<a href="' . ADMIN_URL . '/languages/index.php">' . $mLang->MENU_LANGUAGES . '</a>' : '<b>'.$mLang->MENU_LANGUAGES.'</b>',
 
     | 
  
  
    | 
      123
     | 
    
      	'URL_ADVANCED' => $admin->get_permission('modules_advanced') ?
     | 
  
  
    | 
      124
     | 
    
      		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $mLang->TEXT_ADVANCED . '</a>' : '<b>'.$mLang->TEXT_ADVANCED.'</b>' ,
 
     | 
  
  
    | 
      125
     | 
    
      	'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
 
     | 
  
  
    | 
      126
     | 
    
      	)
 
     | 
  
  
    | 
      127
     | 
    
      );
 
     | 
  
  
    | 
      128
     | 
    
      
 
     | 
  
  
    | 
      129
     | 
    
      // Parse template object
 
     | 
  
  
    | 
      130
     | 
    
      $template->parse('main', 'main_block', false);
     | 
  
  
    | 
      131
     | 
    
      $template->pparse('output', 'page');
     | 
  
  
    | 
      132
     | 
    
      
 
     | 
  
  
    | 
      133
     | 
    
      // Print admin footer
 
     | 
  
  
    | 
      134
     | 
    
      $admin->print_footer();
 
     |