| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * Announcement functions
|
|---|
| 4 | *
|
|---|
| 5 | * PHP version 5
|
|---|
| 6 | *
|
|---|
| 7 | * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
|
|---|
| 8 | * modify it under the terms of the GNU General Public License as
|
|---|
| 9 | * published by the Free Software Foundation, either version 3 of
|
|---|
| 10 | * the License, or (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 14 | * FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License along
|
|---|
| 17 | * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
|
|---|
| 18 | *
|
|---|
| 19 | * @category Content Management System
|
|---|
| 20 | * @package HotaruCMS
|
|---|
| 21 | * @author Nick Ramsay <admin@hotarucms.org>
|
|---|
| 22 | * @copyright Copyright (c) 2010, Hotaru CMS
|
|---|
| 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|---|
| 24 | * @link http://www.hotarucms.org/
|
|---|
| 25 | */
|
|---|
| 26 | class Announcements
|
|---|
| 27 | {
|
|---|
| 28 | /**
|
|---|
| 29 | * Displays an announcement at the top of the screen
|
|---|
| 30 | *
|
|---|
| 31 | * @param string $announcement - optional
|
|---|
| 32 | * @return array
|
|---|
| 33 | */
|
|---|
| 34 | public function checkAnnouncements($h, $announcement = '')
|
|---|
| 35 | {
|
|---|
| 36 | $announcements = array();
|
|---|
| 37 |
|
|---|
| 38 | if (SITE_OPEN == "false") {
|
|---|
| 39 | array_push(
|
|---|
| 40 | $announcements,
|
|---|
| 41 | $h->lang['main_announcement_site_closed']
|
|---|
| 42 | );
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | // "All plugins are currently disabled."
|
|---|
| 46 | if (!$h->numActivePlugins()) {
|
|---|
| 47 | array_push(
|
|---|
| 48 | $announcements,
|
|---|
| 49 | $h->lang['main_announcement_plugins_disabled']
|
|---|
| 50 | );
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | // if using the announcement parameter, then add to non-admin pages only:
|
|---|
| 54 | if ($announcement && !$h->isAdmin) {
|
|---|
| 55 | array_push($announcements, $announcement);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | // get the announcement set in the Admin Maintenance page:
|
|---|
| 59 | require_once(LIBS . 'Maintenance.php');
|
|---|
| 60 | $maintenance = new Maintenance();
|
|---|
| 61 | $maintenance->getSiteAnnouncement($h);
|
|---|
| 62 | if ($h->vars['admin_announcement_enabled']) {
|
|---|
| 63 | array_push($announcements, urldecode($h->vars['admin_announcement']));
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | // Plugins can add announcements with this:
|
|---|
| 67 | $h->vars['hotaru_announcements'] = $announcements;
|
|---|
| 68 | $h->pluginHook('hotaru_announcements');
|
|---|
| 69 | $announcements = $h->vars['hotaru_announcements'];
|
|---|
| 70 |
|
|---|
| 71 | if (!is_array($announcements)) {
|
|---|
| 72 | return false;
|
|---|
| 73 | } else {
|
|---|
| 74 | return $announcements;
|
|---|
| 75 | }
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | /**
|
|---|
| 80 | * Returns an announcement for display at the top of Admin
|
|---|
| 81 | *
|
|---|
| 82 | * @return array|false - array of announcements
|
|---|
| 83 | */
|
|---|
| 84 | public function checkAdminAnnouncements($h)
|
|---|
| 85 | {
|
|---|
| 86 | // Check if the install file has been deleted:
|
|---|
| 87 |
|
|---|
| 88 | $announcements = array();
|
|---|
| 89 |
|
|---|
| 90 | if (SITEID == 1) {
|
|---|
| 91 | // Check if install file has been deleted
|
|---|
| 92 | $filename = INSTALL . 'install.php';
|
|---|
| 93 | if (file_exists($filename)) {
|
|---|
| 94 | array_push($announcements, $h->lang['admin_announcement_delete_install']);
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | // Check if install file has not been run
|
|---|
| 98 | $hotaru_version = $h->db->get_var($h->db->prepare($sql, 'hotaru_version'));
|
|---|
| 99 | if (version_compare($h->version, $hotaru_version, '>')) {
|
|---|
| 100 | array_push($announcements, $h->lang['admin_announcement_run_install']);
|
|---|
| 101 | }
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | // Site is currently undergoing maintenance
|
|---|
| 105 | if (SITE_OPEN == "false") {
|
|---|
| 106 | array_push($announcements, $h->lang['admin_announcement_site_closed']);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // Please enter a site email address
|
|---|
| 110 | if (SITE_EMAIL == "email@example.com") {
|
|---|
| 111 | array_push($announcements, $h->lang['admin_announcement_change_site_email']);
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | // "Go to Plugin Management to enable some plugins"
|
|---|
| 115 | if (!$h->numActivePlugins()) {
|
|---|
| 116 | array_push($announcements, $h->lang['admin_announcement_plugins_disabled']);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | // Plugins can add announcements with this:
|
|---|
| 120 | $h->vars['admin_announcements'] = $announcements;
|
|---|
| 121 | $h->pluginHook('admin_announcements');
|
|---|
| 122 | $announcements = $h->vars['admin_announcements'];
|
|---|
| 123 |
|
|---|
| 124 | if (!is_array($announcements)) {
|
|---|
| 125 | return false;
|
|---|
| 126 | } else {
|
|---|
| 127 | return $announcements;
|
|---|
| 128 | }
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 | ?>
|
|---|