PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/AutoUpdate/Update1_2_9To1_2_10.php

https://github.com/jwigal/emcommdb
PHP | 727 lines | 520 code | 160 blank | 47 comment | 127 complexity | 7ab8e4782bce4239349ed19954e222ea MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*******************************************************************************
  3. *
  4. * filename : Update1_2_9To1_2_10.php
  5. * description : Update MySQL database from 1.2.9 To 1.2.10
  6. *
  7. * http://www.churchdb.org/
  8. *
  9. * Contributors:
  10. * 2007 Ed Davis
  11. *
  12. * Copyright Contributors
  13. *
  14. * ChurchInfo is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This file best viewed in a text editor with tabs stops set to 4 characters
  20. *
  21. ******************************************************************************/
  22. $sVersion = '1.2.10';
  23. for (; ; ) { // This is not a loop but a section of code to be
  24. // executed once. If an error occurs running a query the
  25. // remaining code section is skipped and all table
  26. // modifications are "un-done" at the end.
  27. // The idea here is that upon failure the users database
  28. // is restored to the previous version.
  29. // **************************************************************************
  30. // Make a backup copy of config_cfg before making changes to the table. This
  31. // makes it possible to recover from an error.
  32. $sSQL = "DROP TABLE IF EXISTS `tempconfig_tcfg`";
  33. RunQuery($sSQL, TRUE);
  34. $sSQL = "CREATE TABLE `tempconfig_tcfg` (
  35. `cfg_id` int(11) NOT NULL default '0',
  36. `cfg_name` varchar(50) NOT NULL default '',
  37. `cfg_value` text,
  38. `cfg_type` enum('text','number','date','boolean','textarea') NOT NULL default 'text',
  39. `cfg_default` text NOT NULL,
  40. `cfg_tooltip` text NOT NULL,
  41. `cfg_section` varchar(50) NOT NULL default '',
  42. PRIMARY KEY (`cfg_id`),
  43. UNIQUE KEY `tcfg_name` (`cfg_name`),
  44. KEY `cfg_id` (`cfg_id`)
  45. ) ENGINE=MyISAM";
  46. RunQuery($sSQL, TRUE);
  47. $sSQL = "INSERT INTO `tempconfig_tcfg`
  48. SELECT `cfg_id`,`cfg_name`,`cfg_value`,`cfg_type`,`cfg_default`,`cfg_tooltip`,`cfg_section`
  49. FROM `config_cfg` ORDER BY `cfg_id`";
  50. RunQuery($sSQL, TRUE);
  51. // Make a backup copy of list_lst before making changes to the table. This
  52. // makes it possible to recover from an error.
  53. $sSQL = "DROP TABLE IF EXISTS `templist_tlst`";
  54. RunQuery($sSQL, TRUE);
  55. $sSQL = "CREATE TABLE IF NOT EXISTS `templist_tlst` (
  56. `lst_ID` mediumint(8) unsigned NOT NULL default '0',
  57. `lst_OptionID` mediumint(8) unsigned NOT NULL default '0',
  58. `lst_OptionSequence` tinyint(3) unsigned NOT NULL default '0',
  59. `lst_OptionName` varchar(50) NOT NULL default ''
  60. ) ENGINE=MyISAM";
  61. RunQuery($sSQL, TRUE);
  62. $sSQL = "INSERT INTO `templist_tlst`
  63. SELECT `lst_ID`,`lst_OptionID`,`lst_OptionSequence`,`lst_OptionName`
  64. FROM `list_lst` ORDER BY `lst_id`, `lst_OptionID`";
  65. RunQuery($sSQL, TRUE);
  66. // Make a backup copy of userconfig_ucfg before making changes to the table. This
  67. // makes it possible to recover from an error.
  68. $sSQL = "DROP TABLE IF EXISTS `tempuserconfig_tucfg`";
  69. RunQuery($sSQL, TRUE);
  70. $sSQL = "CREATE TABLE IF NOT EXISTS `tempuserconfig_tucfg` (
  71. `ucfg_per_id` mediumint(9) unsigned NOT NULL,
  72. `ucfg_id` int(11) NOT NULL default '0',
  73. `ucfg_name` varchar(50) NOT NULL default '',
  74. `ucfg_value` text,
  75. `ucfg_type` enum('text','number','date','boolean','textarea') NOT NULL default 'text',
  76. `ucfg_tooltip` text NOT NULL,
  77. `ucfg_permission` enum('FALSE','TRUE') NOT NULL default 'FALSE',
  78. PRIMARY KEY (`ucfg_per_ID`,`ucfg_id`)
  79. ) ENGINE=MyISAM";
  80. RunQuery($sSQL, TRUE);
  81. $sSQL = "INSERT INTO `tempuserconfig_tucfg`
  82. SELECT `ucfg_per_id`,`ucfg_id`,`ucfg_name`,`ucfg_value`, `ucfg_type`, `ucfg_tooltip`, `ucfg_permission`
  83. FROM `userconfig_ucfg` ORDER BY `ucfg_per_ID`, `ucfg_id`";
  84. RunQuery($sSQL, TRUE);
  85. // Make a backup copy of person_custom_master before making changes to the table. This
  86. // makes it possible to recover from an error.
  87. $sSQL = "DROP TABLE IF EXISTS `temp_person_custom_master`";
  88. RunQuery($sSQL, TRUE);
  89. $sSQL = "CREATE TABLE IF NOT EXISTS `temp_person_custom_master` (
  90. `custom_Order` smallint(6) NOT NULL default '0',
  91. `custom_Field` varchar(5) NOT NULL default '',
  92. `custom_Name` varchar(40) NOT NULL default '',
  93. `custom_Special` mediumint(8) unsigned default NULL,
  94. `custom_Side` enum('left','right') NOT NULL default 'left',
  95. `type_ID` tinyint(4) NOT NULL default '0'
  96. ) ENGINE=MyISAM";
  97. RunQuery($sSQL, TRUE);
  98. $sSQL = "INSERT INTO `temp_person_custom_master`
  99. SELECT `custom_Order`, `custom_Field`, `custom_Name`, `custom_Special`, `custom_Side`, `type_ID`
  100. FROM `person_custom_master` ";
  101. RunQuery($sSQL, TRUE);
  102. // ********************************************************
  103. // ********************************************************
  104. // Begin modifying tables now that backups are available
  105. // The $bStopOnError argument to RunQuery can now be changed from
  106. // TRUE to FALSE now that backup copies of all tables are available
  107. $sSQL = "DROP TABLE IF EXISTS `menuconfig_mcf`";
  108. if (!RunQuery($sSQL, FALSE))
  109. break;
  110. $sSQL = "CREATE TABLE `menuconfig_mcf` (
  111. `mid` int(11) NOT NULL auto_increment,
  112. `name` varchar(20) NOT NULL,
  113. `parent` varchar(20) NOT NULL,
  114. `ismenu` tinyint(1) NOT NULL,
  115. `content` varchar(100) NOT NULL,
  116. `uri` varchar(255) NOT NULL,
  117. `statustext` varchar(255) NOT NULL,
  118. `security_grp` varchar(50) NOT NULL,
  119. `session_var` varchar(50) default NULL,
  120. `session_var_in_text` tinyint(1) NOT NULL,
  121. `session_var_in_uri` tinyint(1) NOT NULL,
  122. `url_parm_name` varchar(50) default NULL,
  123. `active` tinyint(1) NOT NULL,
  124. `sortorder` tinyint(3) NOT NULL,
  125. PRIMARY KEY (`mid`)
  126. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=81 ";
  127. if (!RunQuery($sSQL, FALSE))
  128. break;
  129. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (1, 'ROOT', '', 1, '".gettext('Main')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 0)";
  130. if (!RunQuery($sSQL, FALSE))
  131. break;
  132. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (2, 'main', 'root', 1, '".gettext('Main')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  133. if (!RunQuery($sSQL, FALSE))
  134. break;
  135. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (3, 'logoff', 'main', 0, '".gettext('Log Off')."', 'Default.php?Logoff=True', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  136. if (!RunQuery($sSQL, FALSE))
  137. break;
  138. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (4, 'chgpassword', 'main', 0, '".gettext('Change My Password')."', 'UserPasswordChange.php', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  139. if (!RunQuery($sSQL, FALSE))
  140. break;
  141. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (5, 'chgsetting', 'main', 0, '".gettext('Change My Settings')."', 'SettingsIndividual.php', '', 'bAll', NULL, 0, 0, NULL, 1, 0)";
  142. if (!RunQuery($sSQL, FALSE))
  143. break;
  144. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (6, 'admin', 'root', 1, '".gettext('Admin')."', '', '', 'bAdmin', NULL, 0, 0, NULL, 1, 2)";
  145. if (!RunQuery($sSQL, FALSE))
  146. break;
  147. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (7, 'editusers', 'admin', 0, '".gettext('Edit Users')."', 'UserList.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 1)";
  148. if (!RunQuery($sSQL, FALSE))
  149. break;
  150. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (8, 'addnewuser', 'admin', 0, '".gettext('Add New User')."', 'UserEditor.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 2)";
  151. if (!RunQuery($sSQL, FALSE))
  152. break;
  153. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (9, 'custompersonfld', 'admin', 0, '".gettext('Edit Custom Person Fields')."', 'PersonCustomFieldsEditor.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 3)";
  154. if (!RunQuery($sSQL, FALSE))
  155. break;
  156. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (10, 'donationfund', 'admin', 0, '".gettext('Edit Donation Funds')."', 'DonationFundEditor.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 4)";
  157. if (!RunQuery($sSQL, FALSE))
  158. break;
  159. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (11, 'dbbackup', 'admin', 0, '".gettext('Backup Database')."', 'BackupDatabase.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 5)";
  160. if (!RunQuery($sSQL, FALSE))
  161. break;
  162. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (12, 'cvsimport', 'admin', 0, '".gettext('CSV Import')."', 'CSVImport.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 6)";
  163. if (!RunQuery($sSQL, FALSE))
  164. break;
  165. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (13, 'accessreport', 'admin', 0, '".gettext('Access report')."', 'AccessReport.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 7)";
  166. if (!RunQuery($sSQL, FALSE))
  167. break;
  168. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (14, 'generalsetting', 'admin', 0, '".gettext('Edit General Settings')."', 'SettingsGeneral.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 8)";
  169. if (!RunQuery($sSQL, FALSE))
  170. break;
  171. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (15, 'reportsetting', 'admin', 0, '".gettext('Edit Report Settings')."', 'SettingsReport.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 9)";
  172. if (!RunQuery($sSQL, FALSE))
  173. break;
  174. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (16, 'userdefault', 'admin', 0, '".gettext('Edit User Default Settings')."', 'SettingsUser.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 10)";
  175. if (!RunQuery($sSQL, FALSE))
  176. break;
  177. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (17, 'envelopmgr', 'admin', 0, '".gettext('Envelope Manager')."', 'ManageEnvelopes.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 11)";
  178. if (!RunQuery($sSQL, FALSE))
  179. break;
  180. if (! $bRegistered) {
  181. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (18, 'register', 'admin', 0, '".gettext('Please select this option to register ChurchInfo after configuring.')."', 'Register.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 12)";
  182. } else {
  183. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (18, 'register', 'admin', 0, '".gettext('Update registration')."', 'Register.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 12)";
  184. }
  185. if (!RunQuery($sSQL, FALSE))
  186. break;
  187. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (19, 'people', 'root', 1, '".gettext('People/Families')."', '', 'People/Families', 'bAll', NULL, 0, 0, NULL, 1, 3)";
  188. if (!RunQuery($sSQL, FALSE))
  189. break;
  190. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (20, 'newperson', 'people', 0, '".gettext('Add New Person')."', 'PersonEditor.php', '', 'bAddRecords', NULL, 0, 0, NULL, 1, 1)";
  191. if (!RunQuery($sSQL, FALSE))
  192. break;
  193. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (21, 'viewperson', 'people', 0, '".gettext('View All Persons')."', 'SelectList.php?mode=person', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  194. if (!RunQuery($sSQL, FALSE))
  195. break;
  196. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (22, 'classes', 'people', 0, '".gettext('Classification Manager')."', 'OptionManager.php?mode=classes', '', 'bMenuOptions', NULL, 0, 0, NULL, 1, 3)";
  197. if (!RunQuery($sSQL, FALSE))
  198. break;
  199. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (23, 'separator1', 'people', 0, '---------------------------', '', '', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  200. if (!RunQuery($sSQL, FALSE))
  201. break;
  202. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (24, 'volunteeropportunity', 'people', 0, '".gettext('Edit volunteer opportunities')."', 'VolunteerOpportunityEditor.php', '', 'bAll', NULL, 0, 0, NULL, 1, 5)";
  203. if (!RunQuery($sSQL, FALSE))
  204. break;
  205. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (25, 'separator2', 'people', 0, '---------------------------', '', '', 'bAll', NULL, 0, 0, NULL, 1, 6)";
  206. if (!RunQuery($sSQL, FALSE))
  207. break;
  208. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (26, 'newfamily', 'people', 0, '".gettext('Add New Family')."', 'FamilyEditor.php', '', 'bAddRecords', NULL, 0, 0, NULL, 1, 7)";
  209. if (!RunQuery($sSQL, FALSE))
  210. break;
  211. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (27, 'viewfamily', 'people', 0, '".gettext('View All Families')."', 'SelectList.php?mode=family', '', 'bAll', NULL, 0, 0, NULL, 1, 8)";
  212. if (!RunQuery($sSQL, FALSE))
  213. break;
  214. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (28, 'familygeotools', 'people', 0, '".gettext('Family Geographic Utilties')."', 'GeoPage.php', '', 'bAll', NULL, 0, 0, NULL, 1, 9)";
  215. if (!RunQuery($sSQL, FALSE))
  216. break;
  217. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (29, 'familymap', 'people', 0, '".gettext('Family Map')."', 'MapUsingGoogle.php?GroupID=-1', '', 'bAll', NULL, 0, 0, NULL, 1, 10)";
  218. if (!RunQuery($sSQL, FALSE))
  219. break;
  220. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (30, 'rolemanager', 'people', 0, '".gettext('Family Roles Manager')."', 'OptionManager.php?mode=famroles', '', 'bMenuOptions', NULL, 0, 0, NULL, 1, 11)";
  221. if (!RunQuery($sSQL, FALSE))
  222. break;
  223. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (31, 'events', 'root', 1, '".gettext('Events')."', '', 'Events', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  224. if (!RunQuery($sSQL, FALSE))
  225. break;
  226. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (32, 'listevent', 'events', 0, '".gettext('List Church Events')."', 'ListEvents.php', 'List Church Events', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  227. if (!RunQuery($sSQL, FALSE))
  228. break;
  229. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (33, 'addevent', 'events', 0, '".gettext('Add Church Event')."', 'EventNames.php', 'Add Church Event', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  230. if (!RunQuery($sSQL, FALSE))
  231. break;
  232. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (34, 'eventype', 'events', 0, '".gettext('List Event Types')."', 'EventNames.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 3)";
  233. if (!RunQuery($sSQL, FALSE))
  234. break;
  235. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (83, 'eventcheckin', 'events', 0, '".gettext('Check-in and Check-out')."', 'Checkin.php', '', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  236. if (!RunQuery($sSQL, FALSE))
  237. break;
  238. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (35, 'deposit', 'root', 1, '".gettext('Deposit')."', '', '', 'bFinance', NULL, 0, 0, NULL, 1, 5)";
  239. if (!RunQuery($sSQL, FALSE))
  240. break;
  241. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (36, 'newdeposit', 'deposit', 0, '".gettext('Create New Deposit')."', 'DepositSlipEditor.php?DepositType=Bank', '', 'bFinance', NULL, 0, 0, NULL, 1, 1)";
  242. if (!RunQuery($sSQL, FALSE))
  243. break;
  244. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (37, 'viewdeposit', 'deposit', 0, '".gettext('View All Deposits')."', 'FindDepositSlip.php', '', 'bFinance', NULL, 0, 0, NULL, 1, 2)";
  245. if (!RunQuery($sSQL, FALSE))
  246. break;
  247. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (38, 'depositreport', 'deposit', 0, '".gettext('Deposit Reports')."', 'FinancialReports.php', '', 'bFinance', NULL, 0, 0, NULL, 1, 3)";
  248. if (!RunQuery($sSQL, FALSE))
  249. break;
  250. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (39, 'separator3', 'deposit', 0, '---------------------------', '', '', 'bFinance', NULL, 0, 0, NULL, 1, 4)";
  251. if (!RunQuery($sSQL, FALSE))
  252. break;
  253. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (40, 'depositslip', 'deposit', 0, '".gettext('Edit Deposit Slip')."', 'DepositSlipEditor.php', '', 'bFinance', 'iCurrentDeposit', 1, 1, 'DepositSlipID', 1, 5)";
  254. if (!RunQuery($sSQL, FALSE))
  255. break;
  256. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (41, 'cart', 'root', 1, '".gettext('Cart')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 6)";
  257. if (!RunQuery($sSQL, FALSE))
  258. break;
  259. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (42, 'viewcart', 'cart', 0, '".gettext('List Cart Items')."', 'CartView.php', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  260. if (!RunQuery($sSQL, FALSE))
  261. break;
  262. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (43, 'emptycart', 'cart', 0, '".gettext('Empty Cart')."', 'CartView.php?Action=EmptyCart', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  263. if (!RunQuery($sSQL, FALSE))
  264. break;
  265. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (44, 'carttogroup', 'cart', 0, '".gettext('Empty Cart to Group')."', 'CartToGroup.php', '', 'bManageGroups', NULL, 0, 0, NULL, 1, 3)";
  266. if (!RunQuery($sSQL, FALSE))
  267. break;
  268. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (45, 'carttofamily', 'cart', 0, '".gettext('Empty Cart to Family')."', 'CartToFamily.php', '', 'bAddRecords', NULL, 0, 0, NULL, 1, 4)";
  269. if (!RunQuery($sSQL, FALSE))
  270. break;
  271. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (46, 'carttoevent', 'cart', 0, '".gettext('Empty Cart to Event')."', 'CartToEvent.php', 'Empty Cart contents to Event', 'bAll', NULL, 0, 0, NULL, 1, 5)";
  272. if (!RunQuery($sSQL, FALSE))
  273. break;
  274. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (47, 'report', 'root', 1, '".gettext('Data/Reports')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 7)";
  275. if (!RunQuery($sSQL, FALSE))
  276. break;
  277. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (48, 'cvsexport', 'report', 0, '".gettext('CSV Export Records')."', 'CSVExport.php', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  278. if (!RunQuery($sSQL, FALSE))
  279. break;
  280. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (49, 'querymenu', 'report', 0, '".gettext('Query Menu')."', 'QueryList.php', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  281. if (!RunQuery($sSQL, FALSE))
  282. break;
  283. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (50, 'reportmenu', 'report', 0, '".gettext('Reports Menu')."', 'ReportList.php', '', 'bAll', NULL, 0, 0, NULL, 1, 3)";
  284. if (!RunQuery($sSQL, FALSE))
  285. break;
  286. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (51, 'groups', 'root', 1, '".gettext('Groups')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 8)";
  287. if (!RunQuery($sSQL, FALSE))
  288. break;
  289. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (52, 'listgroups', 'groups', 0, '".gettext('List Groups')."', 'GroupList.php', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  290. if (!RunQuery($sSQL, FALSE))
  291. break;
  292. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (53, 'newgroup', 'groups', 0, '".gettext('Add a New Group')."', 'GroupEditor.php', '', 'bManageGroups', NULL, 0, 0, NULL, 1, 2)";
  293. if (!RunQuery($sSQL, FALSE))
  294. break;
  295. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (54, 'editgroup', 'groups', 0, '".gettext('Edit Group Types')."', 'OptionManager.php?mode=grptypes', '', 'bMenuOptions', NULL, 0, 0, NULL, 1, 3)";
  296. if (!RunQuery($sSQL, FALSE))
  297. break;
  298. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (55, 'assigngroup', 'group', 0, '".gettext('Group Assignment Helper')."', 'SelectList.php?mode=groupassign', '', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  299. if (!RunQuery($sSQL, FALSE))
  300. break;
  301. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (56, 'properties', 'root', 1, '".gettext('Properties')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 9)";
  302. if (!RunQuery($sSQL, FALSE))
  303. break;
  304. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (57, 'peopleproperty', 'properties', 0, '".gettext('People Properties')."', 'PropertyList.php?Type=p', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  305. if (!RunQuery($sSQL, FALSE))
  306. break;
  307. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (58, 'familyproperty', 'properties', 0, '".gettext('Family Properties')."', 'PropertyList.php?Type=f', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  308. if (!RunQuery($sSQL, FALSE))
  309. break;
  310. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (59, 'groupproperty', 'properties', 0, '".gettext('Group Properties')."', 'PropertyList.php?Type=g', '', 'bAll', NULL, 0, 0, NULL, 1, 3)";
  311. if (!RunQuery($sSQL, FALSE))
  312. break;
  313. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (60, 'propertytype', 'properties', 0, '".gettext('Property Types')."', 'PropertyTypeList.php', '', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  314. if (!RunQuery($sSQL, FALSE))
  315. break;
  316. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (64, 'help', 'root', 1, '".gettext('Help')."', '', '', 'bAll', NULL, 0, 0, NULL, 1, 127)";
  317. if (!RunQuery($sSQL, FALSE))
  318. break;
  319. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (65, 'about', 'help', 0, '".gettext('About ChurchInfo')."', 'Help.php?page=About', '', 'bAll', NULL, 0, 0, NULL, 1, 1)";
  320. if (!RunQuery($sSQL, FALSE))
  321. break;
  322. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (66, 'wiki', 'help', 0, '".gettext('Wiki Documentation')."', 'JumpToWiki.php', '', 'bAll', NULL, 0, 0, NULL, 1, 2)";
  323. if (!RunQuery($sSQL, FALSE))
  324. break;
  325. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (67, 'helppeople', 'help', 0, '".gettext('People')."', 'Help.php?page=People', '', 'bAll', NULL, 0, 0, NULL, 1, 3)";
  326. if (!RunQuery($sSQL, FALSE))
  327. break;
  328. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (68, 'helpfamily', 'help', 0, '".gettext('Families')."', 'Help.php?page=Family', '', 'bAll', NULL, 0, 0, NULL, 1, 4)";
  329. if (!RunQuery($sSQL, FALSE))
  330. break;
  331. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (69, 'helpgeofeature', 'help', 0, '".gettext('Geographic features')."', 'Help.php?page=Geographic', '', 'bAll', NULL, 0, 0, NULL, 1, 5)";
  332. if (!RunQuery($sSQL, FALSE))
  333. break;
  334. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (70, 'helpgroups', 'help', 0, '".gettext('Groups')."', 'Help.php?page=Groups', '', 'bAll', NULL, 0, 0, NULL, 1, 6)";
  335. if (!RunQuery($sSQL, FALSE))
  336. break;
  337. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (71, 'helpfinance', 'help', 0, '".gettext('Finances')."', 'Help.php?page=Finances', '', 'bAll', NULL, 0, 0, NULL, 1, 7)";
  338. if (!RunQuery($sSQL, FALSE))
  339. break;
  340. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (72, 'helpreports', 'help', 0, '".gettext('Reports')."', 'Help.php?page=Reports', '', 'bAll', NULL, 0, 0, NULL, 1, 8)";
  341. if (!RunQuery($sSQL, FALSE))
  342. break;
  343. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (73, 'helpadmin', 'help', 0, '".gettext('Administration')."', 'Help.php?page=Admin', '', 'bAll', NULL, 0, 0, NULL, 1, 9)";
  344. if (!RunQuery($sSQL, FALSE))
  345. break;
  346. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (74, 'helpcart', 'help', 0, '".gettext('Cart')."', 'Help.php?page=Cart', '', 'bAll', NULL, 0, 0, NULL, 1, 10)";
  347. if (!RunQuery($sSQL, FALSE))
  348. break;
  349. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (75, 'helpproperty', 'help', 0, '".gettext('Properties')."', 'Help.php?page=Properties', '', 'bAll', NULL, 0, 0, NULL, 1, 11)";
  350. if (!RunQuery($sSQL, FALSE))
  351. break;
  352. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (76, 'helpnotes', 'help', 0, '".gettext('Notes')."', 'Help.php?page=Notes', '', 'bAll', NULL, 0, 0, NULL, 1, 12)";
  353. if (!RunQuery($sSQL, FALSE))
  354. break;
  355. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (77, 'helpcustomfields', 'help', 0, '".gettext('Custom Fields')."', 'Help.php?page=Custom', '', 'bAll', NULL, 0, 0, NULL, 1, 13)";
  356. if (!RunQuery($sSQL, FALSE))
  357. break;
  358. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (78, 'helpclassification', 'help', 0, '".gettext('Classifications')."', 'Help.php?page=Class', '', 'bAll', NULL, 0, 0, NULL, 1, 14)";
  359. if (!RunQuery($sSQL, FALSE))
  360. break;
  361. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (79, 'helpcanvass', 'help', 0, '".gettext('Canvass Support')."', 'Help.php?page=Canvass', '', 'bAll', NULL, 0, 0, NULL, 1, 15)";
  362. if (!RunQuery($sSQL, FALSE))
  363. break;
  364. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (80, 'helpevents', 'help', 0, '".gettext('Events')."', 'Help.php?page=Events', '', 'bAll', NULL, 0, 0, NULL, 1, 16)";
  365. if (!RunQuery($sSQL, FALSE))
  366. break;
  367. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (81, 'menusetup', 'admin', '0', '".gettext('Menu Options')."', 'MenuSetup.php', '', 'bAdmin', NULL , 0, 0, NULL , 1, 13)";
  368. if (!RunQuery($sSQL, FALSE))
  369. break;
  370. $sSQL = "INSERT INTO `menuconfig_mcf` VALUES (82, 'customfamilyfld', 'admin', 0, '".gettext('Edit Custom Family Fields')."', 'FamilyCustomFieldsEditor.php', '', 'bAdmin', NULL, 0, 0, NULL, 1, 3)";
  371. if (!RunQuery($sSQL, FALSE))
  372. break;
  373. $sSQL = "ALTER TABLE `config_cfg` ADD `cfg_category` VARCHAR( 20 ) NULL AFTER `cfg_section` ";
  374. if (!RunQuery($sSQL, FALSE))
  375. break;
  376. $sSQL = "INSERT INTO `config_cfg` VALUES (61, 'iEventPeriodStartHr', '7', 'number', '7', 'Church Event Valid Period Start Hour (0-23)', 'General', '')";
  377. if (!RunQuery($sSQL, FALSE))
  378. break;
  379. $sSQL = "INSERT INTO `config_cfg` VALUES (62, 'iEventPeriodEndHr', '18', 'number', '18', 'Church Event Valid Period End Hour (0-23, must be greater than iEventStartHr)', 'General', '')";
  380. if (!RunQuery($sSQL, FALSE))
  381. break;
  382. $sSQL = "INSERT INTO `config_cfg` VALUES (63, 'iEventPeriodIntervalMin', '15', 'number', '15', 'Event Period interval (in minutes)', 'General', '')";
  383. if (!RunQuery($sSQL, FALSE))
  384. break;
  385. $sSQL = "INSERT INTO `config_cfg` VALUES (64, 'sDistanceUnit', 'miles', 'text', 'miles', 'Unit used to measure distance, miles or km.', 'General', '')";
  386. if (!RunQuery($sSQL, FALSE))
  387. break;
  388. $sSQL = "DROP TABLE IF EXISTS `family_custom`";
  389. if (!RunQuery($sSQL, FALSE))
  390. break;
  391. $sSQL = "CREATE TABLE `family_custom` (
  392. `fam_ID` mediumint(9) NOT NULL default '0',
  393. PRIMARY KEY (`fam_ID`)
  394. ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
  395. if (!RunQuery($sSQL, FALSE))
  396. break;
  397. $sSQL = "DROP TABLE IF EXISTS `family_custom_master`";
  398. if (!RunQuery($sSQL, FALSE))
  399. break;
  400. $sSQL = "CREATE TABLE `family_custom_master` (
  401. `fam_custom_Order` smallint(6) NOT NULL default '0',
  402. `fam_custom_Field` varchar(5) NOT NULL default '',
  403. `fam_custom_Name` varchar(40) NOT NULL default '',
  404. `fam_custom_Special` mediumint(8) unsigned default NULL,
  405. `fam_custom_Side` enum('left','right') NOT NULL default 'left',
  406. `fam_custom_FieldSec` tinyint(4) NOT NULL default '1',
  407. `type_ID` tinyint(4) NOT NULL default '0'
  408. ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
  409. if (!RunQuery($sSQL, FALSE))
  410. break;
  411. $sSQL = "INSERT INTO `list_lst` VALUES (5, 1, 1, 'bAll')";
  412. if (!RunQuery($sSQL, FALSE))
  413. break;
  414. $sSQL = "INSERT INTO `list_lst` VALUES (5, 2, 2, 'bAdmin')";
  415. if (!RunQuery($sSQL, FALSE))
  416. break;
  417. $sSQL = "INSERT INTO `list_lst` VALUES (5, 3, 3, 'bAddRecords')";
  418. if (!RunQuery($sSQL, FALSE))
  419. break;
  420. $sSQL = "INSERT INTO `list_lst` VALUES (5, 4, 4, 'bEditRecords')";
  421. if (!RunQuery($sSQL, FALSE))
  422. break;
  423. $sSQL = "INSERT INTO `list_lst` VALUES (5, 5, 5, 'bDeleteRecords')";
  424. if (!RunQuery($sSQL, FALSE))
  425. break;
  426. $sSQL = "INSERT INTO `list_lst` VALUES (5, 6, 6, 'bMenuOptions')";
  427. if (!RunQuery($sSQL, FALSE))
  428. break;
  429. $sSQL = "INSERT INTO `list_lst` VALUES (5, 7, 7, 'bManageGroups')";
  430. if (!RunQuery($sSQL, FALSE))
  431. break;
  432. $sSQL = "INSERT INTO `list_lst` VALUES (5, 8, 8, 'bFinance')";
  433. if (!RunQuery($sSQL, FALSE))
  434. break;
  435. $sSQL = "INSERT INTO `list_lst` VALUES (5, 9, 9, 'bNotes')";
  436. if (!RunQuery($sSQL, FALSE))
  437. break;
  438. $sSQL = "INSERT INTO `list_lst` VALUES (5, 10, 10, 'bCommunication')";
  439. if (!RunQuery($sSQL, FALSE))
  440. break;
  441. $sSQL = "INSERT INTO `list_lst` VALUES (5, 11, 11, 'bCanvasser')";
  442. if (!RunQuery($sSQL, FALSE))
  443. break;
  444. $sSQL = "ALTER TABLE `userconfig_ucfg` ADD `ucfg_cat` VARCHAR( 20 ) NOT NULL AFTER `ucfg_permission` ";
  445. if (!RunQuery($sSQL, FALSE))
  446. break;
  447. $sSQL = "UPDATE `userconfig_ucfg` SET `ucfg_cat` = 'SECURITY' WHERE `userconfig_ucfg`.`ucfg_per_id` =0 AND `userconfig_ucfg`.`ucfg_id` =5 ";
  448. if (!RunQuery($sSQL, FALSE))
  449. break;
  450. $sSQL = "UPDATE `userconfig_ucfg` SET `ucfg_cat` = 'SECURITY' WHERE `userconfig_ucfg`.`ucfg_per_id` =0 AND `userconfig_ucfg`.`ucfg_id` =6 ";
  451. if (!RunQuery($sSQL, FALSE))
  452. break;
  453. $sSQL = "INSERT INTO `userconfig_ucfg` VALUES ('', '10', 'bAddEvent', '0', 'boolean', 'Allow user to add new event', 'FALSE', 'SECURITY')";
  454. if (!RunQuery($sSQL, FALSE))
  455. break;
  456. $sSQL = "INSERT INTO `userconfig_ucfg` VALUES ('', '11', 'bSeePrivacyData', '0', 'boolean', 'Allow user to see member privacy data, e.g. Birth Year, Age.', 'FALSE', 'SECURITY')";
  457. if (!RunQuery($sSQL, FALSE))
  458. break;
  459. $sSQL = "ALTER TABLE `person_custom_master` ADD `custom_FieldSec` TINYINT( 4 ) NOT NULL AFTER `custom_Side` ;";
  460. if (!RunQuery($sSQL, FALSE))
  461. break;
  462. if (mysql_num_rows(RunQuery("SELECT * FROM person_custom_master"))> 0) {
  463. $sSQL = "UPDATE `person_custom_master` SET `custom_FieldSec` = '1'";
  464. if (!RunQuery($sSQL, FALSE))
  465. break;
  466. }
  467. $sSQL = "ALTER TABLE `event_attend` ADD `checkin_date` datetime";
  468. if (!RunQuery($sSQL, FALSE))
  469. break;
  470. $sSQL = "ALTER TABLE `event_attend` ADD `checkin_id` int(11)";
  471. if (!RunQuery($sSQL, FALSE))
  472. break;
  473. $sSQL = "ALTER TABLE `event_attend` ADD `checkout_date` datetime";
  474. if (!RunQuery($sSQL, FALSE))
  475. break;
  476. $sSQL = "ALTER TABLE `event_attend` ADD `checkout_id` int(11)";
  477. if (!RunQuery($sSQL, FALSE))
  478. break;
  479. $queryText = <<<EOD
  480. SELECT per_ID as AddToCart,CONCAT('<a
  481. href=PersonView.php?PersonID=',per_ID,'>',per_FirstName,'
  482. ',per_LastName,'</a>') AS Name,
  483. CONCAT(per_BirthMonth,'/',per_BirthDay,'/',per_BirthYear) AS 'Birth Date',
  484. YEAR(CURRENT_DATE) - per_BirthYear - 1 AS 'Age'
  485. FROM person_per
  486. WHERE
  487. DATE_ADD(CONCAT(per_BirthYear,'-',per_BirthMonth,'-',per_BirthDay),INTERVAL
  488. ~min~ YEAR) <= CURDATE()
  489. AND
  490. DATE_ADD(CONCAT(per_BirthYear,'-',per_BirthMonth,'-',per_BirthDay),INTERVAL
  491. (~max~ + 1) YEAR) >= CURDATE()
  492. EOD;
  493. $sSQL = "UPDATE `query_qry` SET `qry_SQL` = '" .
  494. mysql_real_escape_string($queryText) .
  495. "' WHERE `query_qry`.`qry_ID` = 4 ";
  496. if (!RunQuery($sSQL, FALSE))
  497. break;
  498. $sSQL = "ALTER IGNORE TABLE `event_attend` ADD UNIQUE (`event_id`, `person_id`) ";
  499. if (!RunQuery($sSQL, FALSE))
  500. break;
  501. $sSQL = "INSERT INTO `queryparameteroptions_qpo` VALUES ('', '15', 'Email', 'per_Email') ";
  502. if (!RunQuery($sSQL, FALSE))
  503. break;
  504. $sSQL = "INSERT INTO `queryparameteroptions_qpo` VALUES ('', '15', 'WorkEmail', 'per_WorkEmail') ";
  505. if (!RunQuery($sSQL, FALSE))
  506. break;
  507. $queryText = <<<EOD
  508. Enter any part of the following: Name, City, State, Zip, Home Phone, Email, or Work Email.
  509. EOD;
  510. $sSQL = "UPDATE `queryparameters_qrp` SET `qrp_Description` ='" .
  511. mysql_real_escape_string($queryText) .
  512. "' WHERE `queryparameters_qrp`.`qrp_ID` = 14 ";
  513. if (!RunQuery($sSQL, FALSE))
  514. break;
  515. $queryText = <<<EOD
  516. SELECT per_ID as AddToCart, CONCAT('<a href=PersonView.php?PersonID=',per_ID,'>',per_FirstName,' ',per_MiddleName,' ',per_LastName,'</a>') AS Name,
  517. per_City as City, per_State as State,
  518. per_Zip as ZIP, per_HomePhone as HomePhone, per_Email as Email, per_WorkEmail as WorkEmail
  519. FROM person_per
  520. WHERE ~searchwhat~ LIKE '%~searchstring~%'
  521. EOD;
  522. $sSQL = "UPDATE `query_qry` SET `qry_SQL` = '" .
  523. mysql_real_escape_string($queryText) .
  524. "' WHERE `query_qry`.`qry_ID` = 15 ";
  525. if (!RunQuery($sSQL, FALSE))
  526. break;
  527. $queryText = <<<EOD
  528. Search by any part of Name, City, State, Zip, Home Phone, Email, or Work Email.
  529. EOD;
  530. $sSQL = "UPDATE `query_qry` SET `qry_Description` = '" .
  531. mysql_real_escape_string($queryText) .
  532. "' WHERE `query_qry`.`qry_ID` = 15 ";
  533. if (!RunQuery($sSQL, FALSE))
  534. break;
  535. // If we got this far it means all queries ran without error. It is okay to update
  536. // the version information.
  537. $sSQL = "INSERT INTO `version_ver` (`ver_version`, `ver_date`) VALUES ('".$sVersion."',NOW())";
  538. RunQuery($sSQL, FALSE); // False means do not stop on error
  539. break;
  540. } // End of for
  541. $sError = mysql_error();
  542. $sSQL_Last = $sSQL;
  543. // Let's check if MySQL database is in sync with PHP code
  544. $sSQL = 'SELECT * FROM version_ver ORDER BY ver_ID DESC';
  545. $aRow = mysql_fetch_array(RunQuery($sSQL));
  546. extract($aRow);
  547. if ($ver_version == $sVersion) {
  548. // We're good. Clean up by dropping the
  549. // temporary tables
  550. $sSQL = "DROP TABLE IF EXISTS `tempconfig_tcfg`, `templist_tlst`, ";
  551. $sSQL .= "`tempuserconfig_tucfg`, `temp_person_custom_master`";
  552. RunQuery($sSQL, TRUE);
  553. } else {
  554. // An error occured. Clean up by restoring
  555. // tables to their original condition by using
  556. // the temporary tables.
  557. $sSQL = "DROP TABLE IF EXISTS `config_cfg`, `list_lst`, ";
  558. $sSQL .= "`userconfig_ucfg`, `person_custom_master`";
  559. RunQuery($sSQL, TRUE);
  560. $sSQL = "RENAME TABLE `tempconfig_tcfg` TO `config_cfg`, ";
  561. $sSQL .= " `templist_tlst` TO `list_lst`, ";
  562. $sSQL .= " `tempuserconfig_tucfg` TO `userconfig_ucfg`, ";
  563. $sSQL .= " `temp_person_custom_master` TO `person_custom_master`";
  564. RunQuery($sSQL, TRUE);
  565. }
  566. $sSQL = $sSQL_Last;
  567. ?>