[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 #!/usr/bin/env php 2 <?php 3 // 4 // Created on: <27-Feb-2004 13:12:40 wy> 5 // 6 // SOFTWARE NAME: eZ publish 7 // SOFTWARE RELEASE: 3.9.0 8 // BUILD VERSION: 17785 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 28 set_time_limit( 0 ); 29 30 include_once ( 'lib/ezutils/classes/ezcli.php' ); 31 include_once ( 'kernel/classes/ezscript.php' ); 32 33 $cli =& eZCLI::instance(); 34 $endl = $cli->endlineString(); 35 36 $script =& eZScript::instance( array( 'description' => ( "eZ publish add order email.\n\n" . 37 "Fetch email value from eZShopAccountHandler and insert into table ezorder\n" . 38 "This script only need to be run when updating from eZ publish 3.3 to eZ publish 3.4\n" . 39 "\n" . 40 "addorderemail.php"), 41 'use-session' => true, 42 'use-modules' => true, 43 'use-extensions' => true ) ); 44 45 $script->startup(); 46 47 $options = $script->getOptions( "[db-user:][db-password:][db-database:][db-driver:][sql]", 48 "", 49 array( 'db-host' => "Database host", 50 'db-user' => "Database user", 51 'db-password' => "Database password", 52 'db-database' => "Database name", 53 'db-driver' => "Database driver", 54 'sql' => "Display sql queries" 55 ) ); 56 $script->initialize(); 57 58 $dbUser = $options['db-user'] ? $options['db-user'] : false; 59 $dbPassword = $options['db-password'] ? $options['db-password'] : false; 60 $dbHost = $options['db-host'] ? $options['db-host'] : false; 61 $dbName = $options['db-database'] ? $options['db-database'] : false; 62 $dbImpl = $options['db-driver'] ? $options['db-driver'] : false; 63 $showSQL = $options['sql'] ? true : false; 64 $siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false; 65 66 if ( $siteAccess ) 67 { 68 changeSiteAccessSetting( $siteaccess, $siteAccess ); 69 } 70 71 function changeSiteAccessSetting( &$siteaccess, $optionData ) 72 { 73 global $isQuiet; 74 $cli =& eZCLI::instance(); 75 if ( file_exists( 'settings/siteaccess/' . $optionData ) ) 76 { 77 $siteaccess = $optionData; 78 if ( !$isQuiet ) 79 $cli->notice( "Using siteaccess $siteaccess for adding order email" ); 80 } 81 else 82 { 83 if ( !$isQuiet ) 84 $cli->notice( "Siteaccess $optionData does not exist, using default siteaccess" ); 85 } 86 } 87 88 print( "Starting add email into table ezorder\n" ); 89 90 //eZDebug::setHandleType( EZ_HANDLE_FROM_PHP ); 91 92 include_once ( "lib/ezutils/classes/ezmodule.php" ); 93 // eZModule::setGlobalPathList( array( "kernel" ) ); 94 include_once ( 'lib/ezutils/classes/ezexecution.php' ); 95 include_once ( "lib/ezutils/classes/ezdebug.php" ); 96 include_once ( 'kernel/classes/ezorder.php' ); 97 98 $db =& eZDB::instance(); 99 100 if ( $dbHost or $dbName or $dbUser or $dbImpl ) 101 { 102 $params = array(); 103 if ( $dbHost !== false ) 104 $params['server'] = $dbHost; 105 if ( $dbUser !== false ) 106 { 107 $params['user'] = $dbUser; 108 $params['password'] = ''; 109 } 110 if ( $dbPassword !== false ) 111 $params['password'] = $dbPassword; 112 if ( $dbName !== false ) 113 $params['database'] = $dbName; 114 $db =& eZDB::instance( $dbImpl, $params, true ); 115 eZDB::setInstance( $db ); 116 } 117 118 $db->setIsSQLOutputEnabled( $showSQL ); 119 120 $orderArray = eZOrder::fetchList(); 121 $orderCount = count( $orderArray ); 122 123 print( $endl . $orderCount . " order email will be updated" . $endl ); 124 // Fetch the shop account handler 125 include_once ( 'kernel/classes/ezshopaccounthandler.php' ); 126 $accountHandler =& eZShopAccountHandler::instance(); 127 128 $i = 0; 129 $dotMax = 70; 130 $dotCount = 0; 131 $limit = 50; 132 133 foreach ( array_keys ( $orderArray ) as $key ) 134 { 135 $order =& $orderArray[$key]; 136 137 $email = $accountHandler->email( $order ); 138 $order->setAttribute( 'email', $email ); 139 $order->store(); 140 ++$i; 141 ++$dotCount; 142 if ( $dotCount >= $dotMax or $i >= $orderCount ) 143 { 144 $dotCount = 0; 145 $percent = (float)( ($i*100.0) / $orderCount ); 146 print( " " . $percent . "%" . $endl ); 147 } 148 } 149 150 print( $endl . "done" . $endl ); 151 152 $script->shutdown(); 153 154 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |