source: branches/1.4/libs/Announcements.php @ 1958

Revision 1958, 3.9 KB checked in by shibuya246, 3 years ago (diff)

[Branch 1.4] add check for new version of hotaru files present, but no upgrade script run yet

Line 
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 */
26class 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                // Check if install file has been deleted
91                $filename = INSTALL . 'install.php';
92                if (file_exists($filename)) {
93                        array_push($announcements, $h->lang['admin_announcement_delete_install']);
94                }
95
96                // Check if install file has not been run
97                $sql = "SELECT miscdata_value FROM " . TABLE_MISCDATA . " WHERE miscdata_key = %s";
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                // Site is currently undergoing maintenance
104                if (SITE_OPEN == "false") {
105                        array_push($announcements, $h->lang['admin_announcement_site_closed']);
106                }
107               
108                // Please enter a site email address
109                if (SITE_EMAIL == "email@example.com") {
110                        array_push($announcements, $h->lang['admin_announcement_change_site_email']);   
111                }
112               
113                // "Go to Plugin Management to enable some plugins"
114                if (!$h->numActivePlugins()) {
115                        array_push($announcements, $h->lang['admin_announcement_plugins_disabled']);   
116                }
117               
118                // Plugins can add announcements with this:
119                $h->vars['admin_announcements'] = $announcements;
120                $h->pluginHook('admin_announcements');
121                $announcements = $h->vars['admin_announcements'];
122               
123                if (!is_array($announcements)) {
124                        return false;
125                } else {
126                        return $announcements;
127                }
128        }
129}
130?>
Note: See TracBrowser for help on using the repository browser.