Create a generic admin check login task.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 14 Jan 2011 19:27:47 +0000 (12:27 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 14 Jan 2011 23:24:28 +0000 (16:24 -0700)
Disable this login task if not an admin
Move logger check into login task

framework/Core/lib/Horde/Registry.php
horde/lib/LoginTasks/Task/AdminCheck.php [new file with mode: 0644]
horde/lib/LoginTasks/Task/TestScriptActive.php [deleted file]

index 19149b9..17474a5 100644 (file)
@@ -2107,16 +2107,6 @@ class Horde_Registry
         $this->loadPrefs();
 
         $this->setLanguageEnvironment(isset($options['language']) ? $options['language'] : null, $app);
-
-        /* If an admin, check for logger errors. */
-        if ($this->isAdmin()) {
-            // Do this to ensure Logger object was initialized.
-            $injector->getInstance('Horde_Log_Logger');
-
-            if ($error = $injector->getInstance('Horde_Core_Factory_Logger')->error) {
-                $injector->getInstance('Horde_Notification')->push($error, 'horde.warning');
-            }
-        }
     }
 
     /**
diff --git a/horde/lib/LoginTasks/Task/AdminCheck.php b/horde/lib/LoginTasks/Task/AdminCheck.php
new file mode 100644 (file)
index 0000000..3f74c61
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Login task to check various Horde configuration/setup values, and then
+ * report failures to an admin via the notification system.
+ *
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Horde
+ */
+class Horde_LoginTasks_Task_AdminCheck extends Horde_LoginTasks_Task
+{
+    /**
+     * The interval at which to run the task.
+     *
+     * @var integer
+     */
+    public $interval = Horde_LoginTasks::EVERY;
+
+    /**
+     * Display type.
+     *
+     * @var integer
+     */
+    public $display = Horde_LoginTasks::DISPLAY_NONE;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->active = $GLOBALS['registry']->isAdmin();
+    }
+
+    /**
+     * Perform all functions for this task.
+     */
+    public function execute()
+    {
+        /* Check if test script is active. */
+        if (empty($GLOBALS['conf']['testdisable'])) {
+            $GLOBALS['notification']->push(_("The test script is currently enabled. For security reasons, disable test scripts when you are done testing (see horde/docs/INSTALL)."), 'horde.warning');
+        }
+
+        /* Check that logger configuration is correct. */
+
+        // Ensure Logger object was initialized.
+        $GLOBALS['injector']->getInstance('Horde_Log_Logger');
+
+        if ($error = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Logger')->error) {
+            $GLOBALS['notification']->push($error, 'horde.warning');
+        }
+    }
+
+}
diff --git a/horde/lib/LoginTasks/Task/TestScriptActive.php b/horde/lib/LoginTasks/Task/TestScriptActive.php
deleted file mode 100644 (file)
index b7716fd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * Login task to check if the test script is active.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package  Horde
- */
-class Horde_LoginTasks_Task_TestScriptActive extends Horde_LoginTasks_Task
-{
-    /**
-     * The interval at which to run the task.
-     *
-     * @var integer
-     */
-    public $interval = Horde_LoginTasks::EVERY;
-
-    /**
-     * Display type.
-     *
-     * @var integer
-     */
-    public $display = Horde_LoginTasks::DISPLAY_NONE;
-
-    /**
-     * Perform all functions for this task.
-     */
-    public function execute()
-    {
-        if ($GLOBALS['registry']->isAdmin() &&
-            empty($GLOBALS['conf']['testdisable'])) {
-            $GLOBALS['notification']->push(_("The test script is currently enabled. For security reasons, disable test scripts when you are done testing (see horde/docs/INSTALL)."), 'horde.warning');
-        }
-    }
-
-}