Renaming users
authorBen Klang <ben@alkaloid.net>
Thu, 26 Jan 2006 23:14:04 +0000 (23:14 +0000)
committerBen Klang <ben@alkaloid.net>
Thu, 26 Jan 2006 23:14:04 +0000 (23:14 +0000)
git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@263 06cd67b6-e706-0410-b29e-9de616bca6e9

usermgr/add.php [new file with mode: 0644]
usermgr/delete.php [new file with mode: 0644]
usermgr/edit.php [new file with mode: 0644]
usermgr/list.php [new file with mode: 0644]
usermgr/save.php [new file with mode: 0644]

diff --git a/usermgr/add.php b/usermgr/add.php
new file mode 100644 (file)
index 0000000..16f3f3b
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+/**
+ * $Id$
+ *
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file LICENSE for license information (GPL). If you
+ * did not receive this file, see http://www.horde.org/licenses/gpl.php.
+ */
+@define('SHOUT_BASE', dirname(__FILE__) . '/..');
+
+require SHOUT_BASE . '/users/edit.php';
\ No newline at end of file
diff --git a/usermgr/delete.php b/usermgr/delete.php
new file mode 100644 (file)
index 0000000..5d742e4
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * $Id$
+ *
+ * Copyright 2005-2006 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file LICENSE for license information (GPL). If you
+ * did not receive this file, see http://www.horde.org/licenses/gpl.php.
+ *
+ * @package shout
+ */
+@define('SHOUT_BASE', dirname(__FILE__) . '/..');
+//require_once 'Horde/Variables.php';
+
+$context = Util::getFormData('context');
+$extension = Util::getFormData('extension');
+
+$res = $shout->deleteUser($context, $extension);
+
+if (!$res) {
+    echo "Failed!";
+    print_r($res);
+}
+$notification->push("User Deleted.");
+$notification->notify();
+require SHOUT_TEMPLATES . '/common-footer.inc';
\ No newline at end of file
diff --git a/usermgr/edit.php b/usermgr/edit.php
new file mode 100644 (file)
index 0000000..321dbe6
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * $Id$
+ *
+ * Copyright 2005-2006 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file LICENSE for license information (GPL). If you
+ * did not receive this file, see http://www.horde.org/licenses/gpl.php.
+ *
+ * @package shout
+ */
+@define('SHOUT_BASE', dirname(__FILE__) . '/..');
+require_once SHOUT_BASE . '/lib/base.php';
+require_once SHOUT_BASE . '/lib/User.php';
+require_once 'Horde/Variables.php';
+
+$RENDERER = &new Horde_Form_Renderer();
+
+$empty = '';
+$beendone = 0;
+$wereerrors = 0;
+
+$vars = &Variables::getDefaultVariables($empty);
+$formname = $vars->get('formname');
+
+$title = _("FIXME " . __FILE__.":".__LINE__);
+
+$UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars);
+
+$UserDetailsFormValid = $UserDetailsForm->validate($vars, true);
+
+if (!$UserDetailsFormValid) {
+    $UserDetailsForm->open($RENDERER, $vars, 'users.php', 'post');
+    $vars->set('section', $section);
+    $UserDetailsForm->preserveVarByPost($vars, "section");
+    // $UserDetailsForm->preserve($vars);
+    $RENDERER->beginActive($UserDetailsForm->getTitle());
+    $RENDERER->renderFormActive($UserDetailsForm, $vars);
+    $RENDERER->submit();
+    $RENDERER->end();
+    $UserDetailsForm->close($RENDERER);
+} else {
+
+//     require WHUPS_TEMPLATES . '/common-header.inc';
+//     require WHUPS_TEMPLATES . '/menu.inc';
+    $info = array();
+    $UserDetailsForm->getInfo($vars, $info);
+
+    $name = $info['name'];
+    $curextension = $info['curextension'];
+    $newextension = $info['newextension'];
+    $email = $info['email'];
+    $pin = $info['pin'];
+
+
+    $limits = $shout->getLimits($context, $curextension);
+
+    $userdetails = array("newextension" => $newextension,
+                "name" => $name,
+                "pin" => $pin,
+                "email" => $email);
+
+    $i = 1;
+    $userdetails['telephonenumbers'] = array();
+    while ($i <= $limits['telephonenumbersmax']) {
+        $tmp = $info['telephone'.$i];
+        if (!empty($tmp)) {
+            $userdetails['telephonenumbers'][] = $tmp;
+        }
+        $i++;
+    }
+
+    $userdetails['dialopts'] = array();
+    if ($info['moh']) {
+        $userdetails['dialopts'][] = 'm';
+    }
+    if ($info['transfer']) {
+        $userdetails['dialopts'][] = 't';
+    }
+}
\ No newline at end of file
diff --git a/usermgr/list.php b/usermgr/list.php
new file mode 100644 (file)
index 0000000..4dbd7cc
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+/**
+ * $Id$
+ *
+ * Copyright 2005-2006 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package shout
+ */
+
+if (!isset($SHOUT_RUNNING) || !$SHOUT_RUNNING) {
+    header('Location: /');
+    exit();
+}
+
+$users = &$shout->getUsers($context);
+ksort($users);
+require SHOUT_TEMPLATES . "/users/userlist.inc";
\ No newline at end of file
diff --git a/usermgr/save.php b/usermgr/save.php
new file mode 100644 (file)
index 0000000..7ebe387
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * $Id$
+ *
+ * Copyright 2005-2006 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file LICENSE for license information (GPL). If you
+ * did not receive this file, see http://www.horde.org/licenses/gpl.php.
+ *
+ * @package shout
+ */
+@define('SHOUT_BASE', dirname(__FILE__) . '/..');
+require_once SHOUT_BASE . '/lib/User.php';
+require_once 'Horde/Variables.php';
+
+$RENDERER = &new Horde_Form_Renderer();
+
+$vars = &Variables::getDefaultVariables();
+$formname = $vars->get('formname');
+
+$UserDetailsForm = &Horde_Form::singleton('UserDetailsForm', $vars);
+$UserDetailsFormValid = $UserDetailsForm->validate($vars, true);
+if (!$UserDetailsFormValid) {
+    # FIXME Handle invalid forms gracefully
+    echo "Invalid Form!";
+}
+
+$name = Util::getFormData('name');
+$curextension = Util::getFormData('curextension');
+$newextension = Util::getFormData('newextension');
+$email = Util::getFormData('email');
+$pin = Util::getFormData('pin');
+
+
+$limits = $shout->getLimits($context, $curextension);
+
+$userdetails = array("newextension" => $newextension,
+              "name" => $name,
+              "pin" => $pin,
+              "email" => $email);
+
+$i = 1;
+$userdetails['telephonenumbers'] = array();
+while ($i <= $limits['telephonenumbersmax']) {
+    $tmp = Util::getFormData("telephone$i");
+    if (!empty($tmp)) {
+        $userdetails['telephonenumbers'][] = $tmp;
+    }
+    $i++;
+}
+
+$userdetails['dialopts'] = array();
+if (Util::getFormData('moh')) {
+    $userdetails['dialopts'][] = 'm';
+}
+if (Util::getFormData('transfer')) {
+    $userdetails['dialopts'][] = 't';
+}
+
+// $res = $shout->saveUser($context, $curextension, $userdetails);
+// if (is_a($res, 'PEAR_Error')) {
+//     print $res->getMessage();
+// }
\ No newline at end of file