From a2600a6db1a8c24bfc46745cdd5c78fdfaf5e828 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 9 Mar 2014 17:40:31 -0700 Subject: [PATCH] CRM_Utils_Check_Security - Represent messages as objects --- CRM/Utils/Check/Message.php | 74 ++++++++++++++++++++++++++++++++++++ CRM/Utils/Check/Security.php | 17 +++++++-- 2 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 CRM/Utils/Check/Message.php diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php new file mode 100644 index 0000000000..3f3cd2e0a3 --- /dev/null +++ b/CRM/Utils/Check/Message.php @@ -0,0 +1,74 @@ +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, + ); + } +} diff --git a/CRM/Utils/Check/Security.php b/CRM/Utils/Check/Security.php index 3e2b6716a0..c6cd89ac2c 100644 --- a/CRM/Utils/Check/Security.php +++ b/CRM/Utils/Check/Security.php @@ -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 CiviCRM debug log should not be downloadable.' . '
' . 'Read more about this warning'; - $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 { . '
' . 'Read more about this warning'; $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 { . '
' . 'Read more about this warning'; $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)) + ); } } -- 2.25.1