[ Index ] |
|
Code source de Horde 3.1.3 |
1 #!/usr/bin/php 2 <?php 3 /** 4 * $Horde: horde/scripts/remove_prefs.php,v 1.3.10.7 2006/04/18 16:25:31 jan Exp $ 5 * 6 * This script removes a pref from users' settings. Helps when a setting is 7 * to be moved from locked = false, to locked = true and there have already 8 * been prefs set by the users. 9 */ 10 11 /** 12 ** Set this to true if you want DB modifications done. 13 **/ 14 $live = false; 15 16 // No auth. 17 @define('AUTH_HANDLER', true); 18 19 // Find the base file path of Horde. 20 @define('HORDE_BASE', dirname(__FILE__) . '/..'); 21 22 // Do CLI checks and environment setup first. 23 require_once HORDE_BASE . '/lib/core.php'; 24 require_once 'Horde/CLI.php'; 25 26 // Make sure no one runs this from the web. 27 if (!Horde_CLI::runningFromCLI()) { 28 exit("Must be run from the command line\n"); 29 } 30 31 // Load the CLI environment - make sure there's no time limit, init 32 // some variables, etc. 33 Horde_CLI::init(); 34 $cli = &new Horde_CLI(); 35 36 require_once HORDE_BASE . '/lib/base.php'; 37 require_once 'Horde/DataTree.php'; 38 require_once 'Horde/Group.php'; 39 require_once 'Horde/Share.php'; 40 41 /* Make sure there's no compression. */ 42 ob_end_clean(); 43 44 45 $scope = $cli->prompt(_("Enter value for pref_scope:")); 46 $name = $cli->prompt(_("Enter value for pref_name:")); 47 48 /* Open the database. */ 49 $db = &DB::connect($conf['sql']); 50 if (is_a($db, 'PEAR_Error')) { 51 var_dump($db); exit; 52 } 53 54 // Set DB portability options. 55 switch ($db->phptype) { 56 case 'mssql': 57 $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM); 58 break; 59 default: 60 $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS); 61 } 62 63 if ($live) { 64 $sql = 'DELETE FROM horde_prefs WHERE pref_scope = ? AND pref_name = ?'; 65 $values = array($scope, $name); 66 $result = $db->getAll($sql, $values); 67 if (is_a($result, 'PEAR_Error')) { 68 var_dump($result); 69 } elseif (empty($result)) { 70 $cli->writeln(sprintf(_("No preference \"%s\" found in scope \"%s\"."), $name, $scope)); 71 } else { 72 $cli->writeln(sprintf(_("Preferences \"%s\" deleted in scope \"%s\"."), $name, $scope)); 73 } 74 } else { 75 $sql = 'SELECT * FROM horde_prefs WHERE pref_scope = ? AND pref_name = ?'; 76 $values = array($scope, $name); 77 $result = $db->getAll($sql, $values); 78 if (empty($result)) { 79 $cli->writeln(sprintf(_("No preference \"%s\" found in scope \"%s\"."), $name, $scope)); 80 } else { 81 var_dump($result); 82 } 83 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |