Annotation of FreeBSD/tinderbox2/webui/module/moduleConfig.php, revision 1.1.2.1
1.1.2.1 ! as 1: <?php
! 2: #-
! 3: # Copyright (c) 2005 Oliver Lehmann <oliver@FreeBSD.org>
! 4: # All rights reserved.
! 5: #
! 6: # Redistribution and use in source and binary forms, with or without
! 7: # modification, are permitted provided that the following conditions
! 8: # are met:
! 9: # 1. Redistributions of source code must retain the above copyright
! 10: # notice, this list of conditions and the following disclaimer
! 11: # 2. Redistributions in binary form must reproduce the above copyright
! 12: # notice, this list of conditions and the following disclaimer in the
! 13: # documentation and/or other materials provided with the distribution.
! 14: #
! 15: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
! 16: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 17: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 18: # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
! 19: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 20: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 21: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 22: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 23: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 24: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 25: # SUCH DAMAGE.
! 26: #
! 27: # $MCom: portstools/tinderbox/webui/module/moduleConfig.php,v 1.4 2007/10/13 02:28:47 ade Exp $
! 28: #
! 29:
! 30: require_once 'module/module.php';
! 31: require_once 'module/moduleUsers.php';
! 32:
! 33: class moduleConfig extends module {
! 34:
! 35: function moduleConfig() {
! 36: $this->module();
! 37: $this->moduleUsers = new moduleUsers();
! 38: }
! 39:
! 40: function _array_sort_and_assign( $sort_me, $tpl_key ) {
! 41: if( is_array( $sort_me ) && count( $sort_me ) > 0 ) {
! 42: foreach( $sort_me as $res )
! 43: $sort[] = $res[$tpl_key.'_name'];
! 44: array_multisort( $sort, SORT_ASC, $sort_me );
! 45: $this->template_assign( $tpl_key.'_data', $sort_me );
! 46: $this->template_assign( 'no_'.$tpl_key.'_list', false );
! 47: } else {
! 48: $this->template_assign( 'no_'.$tpl_key.'_list', true );
! 49: }
! 50: }
! 51:
! 52: function display_config() {
! 53: if( !$this->moduleUsers->is_logged_in() ) {
! 54: return $this->template_parse( 'please_login.tpl' );
! 55: } else if( ! $this->moduleUsers->checkWwwAdmin() ) {
! 56: $this->TinderboxDS->addError( permission_denied );
! 57: return $this->template_parse( 'config.tpl' );
! 58: }
! 59: $builds = $this->TinderboxDS->getAllBuilds();
! 60: $jails = $this->TinderboxDS->getAllJails();
! 61: $ports_trees = $this->TinderboxDS->getAllPortsTrees();
! 62: $config_options = $this->TinderboxDS->getAllConfig();
! 63:
! 64: foreach( $jails as $jail ) {
! 65: $jail_id = $jail->getId();
! 66: $all_jails[$jail_id] = array( 'jail_name' => $jail->getName(),
! 67: 'jail_arch' => $jail->getArch(),
! 68: 'jail_tag' => $jail->getTag(),
! 69: 'jail_last_built' => prettyDatetime($jail->getLastBuilt()),
! 70: 'jail_update_cmd' => $jail->getUpdateCmd(),
! 71: 'jail_description' => $jail->getDescription(),
! 72: 'jail_src_mount' => $jail->getSrcMount() );
! 73: };
! 74:
! 75: foreach( $ports_trees as $ports_tree ) {
! 76: $ports_tree_id = $ports_tree->getId();
! 77: $all_ports_trees[$ports_tree_id] = array( 'ports_tree_name' => $ports_tree->getName(),
! 78: 'ports_tree_last_built' => prettyDatetime( $ports_tree->getLastBuilt() ),
! 79: 'ports_tree_update_cmd' => $ports_tree->getUpdateCmd(),
! 80: 'ports_tree_description' => $ports_tree->getDescription(),
! 81: 'ports_tree_cvsweb_url' => $ports_tree->getCVSwebURL(),
! 82: 'ports_tree_ports_mount' => $ports_tree->getPortsMount() );
! 83: };
! 84:
! 85: foreach( $builds as $build ) {
! 86: $build_id = $build->getId();
! 87: $all_builds[$build_id] = array( 'build_name' => $build->getName(),
! 88: 'build_description' => $build->getDescription(),
! 89: 'jail_name' => $all_jails[$build->getJailId()]['jail_name'],
! 90: 'ports_tree_name' => $all_ports_trees[$build->getPortsTreeId()]['ports_tree_name'] );
! 91: };
! 92:
! 93: foreach( $config_options as $config_option ) {
! 94: $all_config_options[] = array( 'config_option_name' => $config_option->getName(),
! 95: 'config_option_value' => $config_option->getValue() );
! 96: };
! 97:
! 98: $this->_array_sort_and_assign( $all_jails, 'jail' );
! 99: $this->_array_sort_and_assign( $all_ports_trees, 'ports_tree' );
! 100: $this->_array_sort_and_assign( $all_builds, 'build' );
! 101: $this->_array_sort_and_assign( $all_config_options, 'config_option' );
! 102:
! 103: return $this->template_parse( 'config.tpl' );
! 104: }
! 105:
! 106: }
! 107: ?>