[commits] [Wiki] changed: RemoveUserData

Wiki Guest wikiguest at horde.org
Fri Jan 3 17:28:53 UTC 2014


guest [84.227.80.182]  Fri, 03 Jan 2014 17:28:53 +0000

Modified page: http://wiki.horde.org/RemoveUserData
New Revision:  17
Change log:  added a non-interactive version of horde-remove-user-data

@@ -1,14 +1,66 @@
  + Removing User Data

  Starting with version 5.1.5, Horde includes a  
{{horde-remove-user-data}} script that can be run on the command line.

-The examples below are for older Horde versions.
+++ Modifying the default script to remove interactivity
+You may want to call the {{horde-remove-user-data}} script from  
another script, providing a user to delete as an argument.
+In order to do this, you need to use a modified version of the script.
+<code>#!/usr/bin/env php
+<?php
+/**
+ * This script will delete all user data for a given user.
+ *
+ * Copyright 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    Michael Slusarz <slusarz at horde.org>
+ * @category  Horde
+ * @copyright 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,
+    'user_admin' => true
+));
+
+$config=getopt("u");
+$user=$config["u"];
+$app = null;
+
+$cli->writeln();
+
+try {
+    $registry->removeUserData($user, $app);
+    $cli->message('Data removed.', 'cli.success');
+} catch (Horde_Exception $e) {
+    $cli->fatal($e->getMessage());
+}
+</code>
+
+You would call the script like this:
+{{horde-remove-user-data user at domain.com}}
+
+
+
+##red|The examples below are for older Horde versions.##

  ++ Using the removeUserData APIs of Horde 5

-<code>
-#!/usr/bin/env php
+<code>#!/usr/bin/env php
  <?php

  if (file_exists(__DIR__ . '/../lib/Application.php')) {
      $baseDir = __DIR__;
@@ -37,10 +89,9 @@
  ++ Using the removeUserData APIs

  From dom.lalot at gmail com

-<code>
-#!/usr/bin/env php
+<code>#!/usr/bin/env php
  <?php
  @define('AUTH_HANDLER', true);
  @define('HORDE_BASE', dirname(__FILE__));
  # require_once HORDE_BASE . '/lib/base.php';



More information about the commits mailing list