Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move command line utilities to the horde application
- Loading branch information
Showing
4 changed files
with
95 additions
and
85 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!@php_bin@ | ||
<?php | ||
/** | ||
* This script removes a preference from users' preferences. Helps when a | ||
* preference is to be moved from locked = false, to locked = true and there | ||
* have already been preferences set by the users. | ||
* | ||
* Copyright 2007-2013 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL-2). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl. | ||
* | ||
* @category Horde | ||
* @copyright 2007-2013 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl LGPL-2 | ||
* @package Horde | ||
*/ | ||
|
||
$baseFile = __DIR__ . '/../lib/Application.php'; | ||
if (file_exists($baseFile)) { | ||
require_once $baseFile; | ||
} else { | ||
require_once 'PEAR/Config.php'; | ||
require_once PEAR_Config::singleton() | ||
->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php'; | ||
} | ||
Horde_Registry::appInit('horde', array( | ||
'authentication' => 'none', | ||
'cli' => true | ||
)); | ||
|
||
$scope = $cli->prompt('Enter preference scope:'); | ||
$name = $cli->prompt('Enter preference name:'); | ||
$user = $cli->prompt('Enter preference user:'); | ||
|
||
$prefs_ob = $injector->getInstance('Horde_Core_Factory_Prefs')->create($scope, array( | ||
'user' => $user | ||
)); | ||
|
||
$value = $prefs_ob->getValue($name); | ||
|
||
if (is_null($value)) { | ||
$cli->message(sprintf('No preference "%s" found in scope "%s".', $name, $scope), 'cli.error'); | ||
} else { | ||
$cli->writeln(); | ||
$cli->writeln(sprintf('Name: %s', $name)); | ||
$cli->writeln(sprintf('Value: %s', $value)); | ||
$cli->writeln(); | ||
if ($cli->prompt($cli->red('Do you want to delete this preference?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y') { | ||
$prefs_ob->remove($name); | ||
$cli->message($cli->green('Preference deleted.'), 'cli.success'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!@php_bin@ | ||
<?php | ||
/** | ||
* Shell access to the configured Horde_Db database. | ||
* Runs the SQL statement provided on the command line. | ||
* | ||
* Copyright 2007-2013 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL-2). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl. | ||
* | ||
* @author Chuck Hagenbuch <chuck@horde.org> | ||
* @category Horde | ||
* @copyright 2007-2013 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl LGPL-2 | ||
* @package Horde | ||
*/ | ||
|
||
$baseFile = __DIR__ . '/../lib/Application.php'; | ||
if (file_exists($baseFile)) { | ||
require_once $baseFile; | ||
} else { | ||
require_once 'PEAR/Config.php'; | ||
require_once PEAR_Config::singleton() | ||
->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php'; | ||
} | ||
Horde_Registry::appInit('horde', array( | ||
'authentication' => 'none', | ||
'cli' => true | ||
)); | ||
|
||
$dbh = $injector->getInstance('Horde_Db_Adapter'); | ||
|
||
// read sql file for statements to run | ||
$statements = new Horde_Db_StatementParser($_SERVER['argv'][1]); | ||
foreach ($statements as $stmt) { | ||
$cli->writeln('Running:'); | ||
$cli->writeln(' ' . preg_replace('/\s+/', ' ', $stmt)); | ||
|
||
$dbh->execute($stmt); | ||
$cli->writeln(' ...done.'); | ||
} |