| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // |
|---|
| 4 | // Open Web Analytics - An Open Source Web Analytics Framework |
|---|
| 5 | // |
|---|
| 6 | // Copyright 2006 Peter Adams. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html |
|---|
| 9 | // |
|---|
| 10 | // Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | // See the License for the specific language governing permissions and |
|---|
| 14 | // limitations under the License. |
|---|
| 15 | // |
|---|
| 16 | // $Id$ |
|---|
| 17 | // |
|---|
| 18 | |
|---|
| 19 | require_once (OWA_BASE_DIR.'/owa_base.php'); |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * Install Abstract Class |
|---|
| 23 | * |
|---|
| 24 | * @author Peter Adams <peter@openwebanalytics.com> |
|---|
| 25 | * @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com> |
|---|
| 26 | * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 |
|---|
| 27 | * @category owa |
|---|
| 28 | * @package owa |
|---|
| 29 | * @version $Revision$ |
|---|
| 30 | * @since owa 1.0.0 |
|---|
| 31 | */ |
|---|
| 32 | class owa_install extends owa_base{ |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * Data access object |
|---|
| 36 | * |
|---|
| 37 | * @var object |
|---|
| 38 | */ |
|---|
| 39 | var $db; |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | * Version of string |
|---|
| 43 | * |
|---|
| 44 | * @var string |
|---|
| 45 | */ |
|---|
| 46 | var $version; |
|---|
| 47 | |
|---|
| 48 | /** |
|---|
| 49 | * Params array |
|---|
| 50 | * |
|---|
| 51 | * @var array |
|---|
| 52 | */ |
|---|
| 53 | var $params; |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Module name |
|---|
| 57 | * |
|---|
| 58 | * @var unknown_type |
|---|
| 59 | */ |
|---|
| 60 | var $module; |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * Constructor |
|---|
| 64 | * |
|---|
| 65 | * @return owa_install |
|---|
| 66 | */ |
|---|
| 67 | |
|---|
| 68 | function owa_install() { |
|---|
| 69 | |
|---|
| 70 | $this->owa_base(); |
|---|
| 71 | $this->db = &owa_coreAPI::dbSingleton(); |
|---|
| 72 | |
|---|
| 73 | return; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | /** |
|---|
| 77 | * Check to see if schema is installed |
|---|
| 78 | * |
|---|
| 79 | * @return boolean |
|---|
| 80 | */ |
|---|
| 81 | function checkForSchema() { |
|---|
| 82 | |
|---|
| 83 | $table_check = array(); |
|---|
| 84 | //$this->e->notice(print_r($this->tables, true)); |
|---|
| 85 | // test for existance of tables |
|---|
| 86 | foreach ($this->tables as $table) { |
|---|
| 87 | $this->e->notice('Testing for existance of table: '. $table); |
|---|
| 88 | $check = $this->db->get_results(sprintf("show tables like 'owa_%s'", $table)); |
|---|
| 89 | //$this->e->notice(print_r($check, true)); |
|---|
| 90 | |
|---|
| 91 | // if a table is missing add it to this array |
|---|
| 92 | if (empty($check)): |
|---|
| 93 | $table_check[] = $table; |
|---|
| 94 | $this->e->notice('Did not find table: '. $table); |
|---|
| 95 | else: |
|---|
| 96 | $this->e->notice('Table '. $table. ' already exists.'); |
|---|
| 97 | endif; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | if (!empty($table_check)): |
|---|
| 101 | //$this->e->notice(sprintf("Schema Check: Tables '%s' are missing.", implode(',', $table_check))); |
|---|
| 102 | $this->e->notice(sprintf("Schema Check: Tables to install: %s", print_r($table_check, true))); |
|---|
| 103 | |
|---|
| 104 | return $table_check; |
|---|
| 105 | else: |
|---|
| 106 | return false; |
|---|
| 107 | endif; |
|---|
| 108 | |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | ?> |
|---|