38 lines
1.1 KiB
PHP
Executable File
38 lines
1.1 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
/**
|
|
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
|
*
|
|
* @license http://www.horde.org/licenses/bsd BSD
|
|
* @package Content
|
|
*/
|
|
|
|
if (file_exists(__DIR__ . '/../../content/lib/Application.php')) {
|
|
$baseDir = __DIR__ . '/../';
|
|
} else {
|
|
require_once 'PEAR/Config.php';
|
|
$baseDir = PEAR_Config::singleton()
|
|
->get('horde_dir', null, 'pear.horde.org') . '/content/';
|
|
}
|
|
require_once $baseDir . 'lib/Application.php';
|
|
Horde_Registry::appInit('content', array('cli' => true));
|
|
|
|
$options = array(
|
|
new Horde_Argv_Option('-m', '--object-id', array('type' => 'int')),
|
|
);
|
|
$parser = new Horde_Argv_Parser(array('optionList' => $options));
|
|
list($opts, $positional) = $parser->parseArgs();
|
|
|
|
if (!$opts->object_id) {
|
|
throw new InvalidArgumentException('object_id is required');
|
|
}
|
|
|
|
$m = new Content_ObjectMapper($injector->getInstance('Horde_Db_Adapter'));
|
|
if ($m->delete($opts->object_id)) {
|
|
echo 'Deleted object with id ' . $opts->object_id . ".\n";
|
|
exit(0);
|
|
} else {
|
|
echo 'Object #' . $opts->object_id . " not found.\n";
|
|
exit(1);
|
|
}
|