-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpninit.php
129 lines (113 loc) · 4.46 KB
/
pninit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Zikula Application Framework
*
* @copyright (c) 2001, Zikula Development Team
* @link http://www.zikula.org
* @version $Id$
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_System_Modules
* @subpackage Admin_Messages
*/
/**
* initialise the Admin module
* This function is only ever called once during the lifetime of a particular
* module instance
* @author Mark West
* @return bool true if initialisation succcesful, false otherwise
*/
function Admin_Messages_init()
{
if (!DBUtil::createTable('message')) {
return false;
}
// Set a default value for a module variable
ModUtil::setVar('Admin_Messages', 'itemsperpage', 25);
ModUtil::setVar('Admin_Messages', 'allowsearchinactive', false);
// create the default data for the modules module
Admin_Messages_defaultdata();
// Initialisation successful
return true;
}
/**
* upgrade the module from an old version
*
* This function must consider all the released versions of the module!
* If the upgrade fails at some point, it returns the last upgraded version.
*
* @author Mark West
* @param string $oldVersion version number string to upgrade from
* @return mixed true on success, last valid version string or false if fails
*/
function Admin_Messages_upgrade($oldversion)
{
// Upgrade dependent on old version number
switch ($oldversion)
{
case '2.0':
case '2.1':
Admin_Messages_migrateLanguage();
case '2.2':
// future upgrade routines
}
// Update successful
return true;
}
/**
* delete the Admin module
* This function is only ever called once during the lifetime of a particular
* module instance
* @author Mark West
* @return bool true if deletetion succcesful, false otherwise
*/
function Admin_Messages_delete()
{
if (!DBUtil::dropTable('message')) {
return false;
}
ModUtil::delVar('Admin_Messages');
// Deletion successful
return true;
}
/**
* create the default data for the modules module
*
* This function is only ever called once during the lifetime of a particular
* module instance
*
* @author Mark West
* @return bool false
*/
function Admin_Messages_defaultdata()
{
$dom = ZLanguage::getModuleDomain('Admin_Messages');
$record = array();
$record['title'] = __('This site is powered by Zikula!', $dom);
$record['content'] = __('<p><a href="http://www.zikula.org">Zikula</a> is a content management system (CMS) and application framework. It is secure and stable, and is a good choice for sites with a large volume of traffic.</p><p>With Zikula:</p><ul><li>you can customise all aspects of the site\'s appearance through themes, with support for CSS style sheets, JavaScript, Flash and all other modern web development technologies;</li><li>you can mark content as being suitable for either a single language or for all languages, and can control all aspects of localisation and internationalisation of your site and pages;</li><li>you can be sure that your pages will display properly in all browsers, thanks to Zikula\'s full compliance with W3C HTML standards;</li><li>you get a standard application-programming interface (API) that lets you easily augment your site\'s functionality through modules, blocks and other extensions;</li><li>you can get help and support from the Zikula community of webmasters and developers at <a href="http://www.zikula.org">zikula.org</a>.</li></ul><p>Enjoy using Zikula!</p><p><strong>The Zikula team</strong></p><p><em>Note: Zikula is Free Open Source Software (FOSS) licensed under the GNU General Public License.</em></p>', $dom);
$record['date'] = time();
$record['expire'] = '0';
$record['active'] = '1';
$record['view'] = '1';
$record['language'] = '';
DBUtil::insertObject($record, 'message', 'mid');
}
function Admin_Messages_migrateLanguage()
{
$obj = DBUtil::selectObjectArray('message');
if (count($obj) == 0) {
// nothing to do
return;
}
foreach ($obj as $message)
{
if (empty($message['language'])) {
continue;
}
$l2 = ZLanguage::translateLegacyCode($message['language']);
if ($l2) {
$message['language'] = $l2;
DBUtil::updateObject($message, 'message', '', 'mid', true);
}
}
return;
}