CRM_Utils_Check_Security - Represent messages as objects
authorTim Otten <totten@civicrm.org>
Mon, 10 Mar 2014 00:40:31 +0000 (17:40 -0700)
committerTim Otten <totten@civicrm.org>
Mon, 10 Mar 2014 00:40:31 +0000 (17:40 -0700)
CRM/Utils/Check/Message.php [new file with mode: 0644]
CRM/Utils/Check/Security.php

diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php
new file mode 100644 (file)
index 0000000..3f3cd2e
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2014
+ * $Id: $
+ *
+ */
+class CRM_Utils_Check_Message {
+  /**
+   * @var string
+   */
+  private $name;
+
+  /**
+   * @var string
+   */
+  private $message;
+
+  function __construct($name, $message) {
+    $this->name = $name;
+    $this->message = $message;
+  }
+
+  /**
+   * @return string
+   */
+  function getName() {
+    return $this->name;
+  }
+
+  /**
+   * @return string
+   */
+  function getMessage() {
+    return $this->message;
+  }
+
+  /**
+   * @return array
+   */
+  function toArray() {
+    return array(
+      'name' => $this->name,
+      'message' => $this->message,
+    );
+  }
+}
index 3e2b6716a0164a8020ab8d0147deb732f3a34c54..c6cd89ac2cf9467eabb0ce8aec1b108a916db4b0 100644 (file)
@@ -90,7 +90,7 @@ class CRM_Utils_Check_Security {
         $config->cleanup(0, FALSE);
 
         foreach ($this->checkAll() as $message) {
-          CRM_Core_Session::setStatus($message, ts('Security Warning'));
+          CRM_Core_Session::setStatus($message->getMessage(), ts('Security Warning'));
         }
       }
     }
@@ -160,7 +160,10 @@ class CRM_Utils_Check_Security {
           $msg = 'The <a href="%1">CiviCRM debug log</a> should not be downloadable.'
             . '<br />' .
             '<a href="%2">Read more about this warning</a>';
-          $messages[] = ts($msg, array(1 => $log_url, 2 => $docs_url));
+          $messages[] = new CRM_Utils_Check_Message(
+            'checkLogFileIsNotAccessible',
+            ts($msg, array(1 => $log_url, 2 => $docs_url))
+          );
         }
       }
     }
@@ -201,7 +204,10 @@ class CRM_Utils_Check_Security {
                 . '<br />' .
                 '<a href="%1">Read more about this warning</a>';
               $docs_url = $this->createDocUrl('checkUploadsAreNotAccessible');
-              $messages[] = ts($msg, array(1 => $docs_url));
+              $messages[] = new CRM_Utils_Check_Message(
+                'checkUploadsAreNotAccessible',
+                ts($msg, array(1 => $docs_url))
+              );
             }
           }
         }
@@ -245,7 +251,10 @@ class CRM_Utils_Check_Security {
           . '<br />' .
           '<a href="%3">Read more about this warning</a>';
         $docs_url = $this->createDocUrl('checkDirectoriesAreNotBrowseable');
-        $messages[] = ts($msg, array(1 => $publicDir, 2 => $publicDir, 3 => $docs_url));
+        $messages[] = new CRM_Utils_Check_Message(
+          'checkDirectoriesAreNotBrowseable',
+          ts($msg, array(1 => $publicDir, 2 => $publicDir, 3 => $docs_url))
+        );
       }
     }