PageRenderTime 60ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/db_mapping/HiveMail_122.php

https://github.com/axxtel/agilebill
PHP | 360 lines | 236 code | 69 blank | 55 comment | 9 complexity | 8d752161d7d1488249bb385c7f86d6c7 MD5 | raw file
  1. <?php
  2. /**
  3. * AgileBill - Open Billing Software
  4. *
  5. * This body of work is free software; you can redistribute it and/or
  6. * modify it under the terms of the Open AgileBill License
  7. * License as published at http://www.agileco.com/agilebill/license1-4.txt
  8. *
  9. * For questions, help, comments, discussion, etc., please join the
  10. * Agileco community forums at http://forum.agileco.com/
  11. *
  12. * @link http://www.agileco.com/
  13. * @copyright 2004-2008 Agileco, LLC.
  14. * @license http://www.agileco.com/agilebill/license1-4.txt
  15. * @author Tony Landis <tony@agileco.com>
  16. * @package AgileBill
  17. * @version 1.4.93
  18. */
  19. ################################################################################
  20. ### Database Map for: HiveMail 1.2.2 through 1.3
  21. ### Last Update: 12-17-2003
  22. ################################################################################
  23. class map_HIVEMAIL_122
  24. {
  25. ############################################################################
  26. ### Define the settings for this database map
  27. ############################################################################
  28. function map_HIVEMAIL_122 ()
  29. {
  30. $this->map =
  31. Array (
  32. 'map' => 'HiveMail_122',
  33. 'db_type' => 'mysql',
  34. 'notes' => 'This is for HiveMail 1.2.2 through 1.3',
  35. 'group_type' => 'db-status', // db, db-status, status, none
  36. ### Define the group fields in the target db
  37. 'group_map' =>
  38. Array
  39. (
  40. 'table' => 'hive_usergroup',
  41. 'id' => 'usergroupid',
  42. 'name' => 'title'
  43. ),
  44. ### Define the account mapping properties
  45. 'account_map_field' => 'hive_user',
  46. 'account_status_field' => 'usergroupid',
  47. 'account_default_status' => '2',
  48. 'account_sync_field'=>
  49. Array
  50. (
  51. 'delete' => '1'
  52. ),
  53. 'account_fields' =>
  54. Array
  55. (
  56. 'id' =>
  57. Array
  58. (
  59. 'map_field' => 'userid'
  60. ),
  61. 'date_orig' =>
  62. Array
  63. (
  64. 'map_field' => 'regdate'
  65. ),
  66. 'date_last' =>
  67. Array
  68. (
  69. 'map_field' => 'lastactivity'
  70. ),
  71. 'date_expire' =>
  72. Array
  73. (
  74. 'map_field' => false
  75. ),
  76. 'language_id' =>
  77. Array
  78. (
  79. 'map_field' => false
  80. ),
  81. 'country_id' =>
  82. Array
  83. (
  84. 'map_field' => false
  85. ),
  86. 'username' =>
  87. Array
  88. (
  89. 'map_field' => 'username'
  90. ),
  91. 'password' =>
  92. Array
  93. (
  94. 'map_field' => 'password'
  95. ),
  96. 'misc' =>
  97. Array
  98. (
  99. 'map_field' => false
  100. ),
  101. 'first_name' =>
  102. Array
  103. (
  104. 'map_field' => 'realname',
  105. ),
  106. 'last_name' =>
  107. Array
  108. (
  109. 'map_field' => false,
  110. ),
  111. 'middle_name' =>
  112. Array
  113. (
  114. 'map_field' => false
  115. ),
  116. 'company' =>
  117. Array
  118. (
  119. 'map_field' => false
  120. ),
  121. 'status' =>
  122. Array
  123. (
  124. 'map_field' => false
  125. ),
  126. 'email' =>
  127. Array
  128. (
  129. 'map_field' => 'altemail'
  130. ),
  131. 'email_type' =>
  132. Array
  133. (
  134. 'map_field' => false
  135. )
  136. ),
  137. ### Define any extra fields for account table in the target db:
  138. 'extra_field' =>
  139. Array
  140. (
  141. Array
  142. (
  143. 'name' => 'cols',
  144. 'value' => 'a:6:{i:0;s:8:"priority";i:1;s:6:"attach";i:2;s:4:"from";i:3;s:7:"subject";i:4;s:8:"datetime";i:5;s:4:"size";}',
  145. 'add' => 1,
  146. 'edit' => 0
  147. ),
  148. Array
  149. (
  150. 'name' => 'font',
  151. 'value' => 'Verdana|10|Regular|Black|None',
  152. 'add' => 1,
  153. 'edit' => 0
  154. ),
  155. Array
  156. (
  157. 'name' => 'sendread',
  158. 'value' => '1',
  159. 'add' => 1,
  160. 'edit' => 0
  161. ),
  162. Array
  163. (
  164. 'name' => 'skinid',
  165. 'value' => '1',
  166. 'add' => 1,
  167. 'edit' => 0
  168. ),
  169. Array
  170. (
  171. 'name' => 'options',
  172. 'value' => '879818066',
  173. 'add' => 1,
  174. 'edit' => 0
  175. )
  176. )
  177. );
  178. }
  179. ########################################################################
  180. ### Syncronize all accounts & groups
  181. ########################################################################
  182. function sync($id, $file)
  183. {
  184. $db_map = new db_mapping;
  185. $this = $db_map->MAP_sync ($id, $file, $this);
  186. }
  187. ########################################################################
  188. ### Create a new account in the target DB
  189. ########################################################################
  190. function account_add($account_id)
  191. {
  192. $db_map = new db_mapping;
  193. $db_map->MAP_account_add ($account_id, $this);
  194. ### Sync the groups for this account:
  195. if( $this->map['group_type'] != 'none' &&
  196. $this->map['group_type'] != 'add_remove' )
  197. $remote_account_id = $this->account_group_sync( $account_id );
  198. ### Create the alias record:
  199. $dbm = new db_mapping;
  200. $db2 = $dbm->DB_connect(false, $this->map['map']);
  201. eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($this->map['map']) .';' );
  202. $sql = "SELECT username FROM " .
  203. $db_prefix . "hive_user WHERE
  204. userid = " .
  205. $db2->qstr($remote_account_id);
  206. $result = $db2->Execute($sql);
  207. $remote_username = $result->fields['username'];
  208. $sql = "INSERT INTO " .
  209. $db_prefix . "hive_alias SET
  210. userid = " .
  211. $db2->qstr($remote_account_id) . ",
  212. alias = " .
  213. $db2->qstr($remote_username);
  214. $group_result = $db2->Execute($sql);
  215. }
  216. ########################################################################
  217. ### Edit an existing account in the target DB
  218. ########################################################################
  219. function account_edit($account_id, $old_username)
  220. {
  221. $db_map = new db_mapping;
  222. $remote_account_id = $db_map->MAP_account_edit ($account_id, $old_username, $this);
  223. ### Update the groups in the remote db
  224. if( $this->map['group_type'] != 'none' )
  225. $this->account_group_sync($account_id);
  226. }
  227. ########################################################################
  228. ### Delete an existing account from the target DB
  229. ########################################################################
  230. function account_delete($account_id, $username)
  231. {
  232. $db_map = new db_mapping;
  233. $remote_account_id = $db_map->MAP_account_delete ($account_id, $username, $this);
  234. ### Update the remote account:
  235. $dbm = new db_mapping;
  236. $db2 = $dbm->DB_connect(false, $this->map['map']);
  237. eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($this->map['map']) .';' );
  238. $sql = "DELETE FROM " .
  239. $db_prefix . "hive_alias WHERE userid = " .
  240. $db2->qstr($remote_account_id);
  241. $group_result = $db2->Execute($sql);
  242. }
  243. ########################################################################
  244. ### Export / Update all accounts / groups to the target DB
  245. ########################################################################
  246. function account_import($remote_account_id)
  247. {
  248. $db_map = new db_mapping;
  249. $db_map->MAP_account_import ($remote_account_id, $this);
  250. }
  251. ########################################################################
  252. ### Create the cookie/session for login sync
  253. ########################################################################
  254. function login($account_id)
  255. {
  256. return;
  257. }
  258. ########################################################################
  259. ### Delete the cookie/session on account logout
  260. ########################################################################
  261. function logout($account_id)
  262. {
  263. return;
  264. }
  265. ########################################################################
  266. ### Syncronize the groups for a specific account in the remote DB
  267. ########################################################################
  268. function account_group_sync($account_id)
  269. {
  270. if ( $this->map['group_type'] == 'db')
  271. {
  272. $db_map = new db_mapping;
  273. return $db_map->MAP_account_group_sync_db ($account_id, $this);
  274. }
  275. elseif ( $this->map['group_type'] == 'status')
  276. {
  277. $db_map = new db_mapping;
  278. return $db_map->MAP_account_group_sync_status ($account_id, $this);
  279. }
  280. elseif ( $this->map['group_type'] == 'db-status')
  281. {
  282. $db_map = new db_mapping;
  283. return $db_map->MAP_account_group_sync_db_status ($account_id, $this);
  284. }
  285. else
  286. {
  287. return false;
  288. }
  289. }
  290. }
  291. ?>