PageRenderTime 23ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/genobio/admin/index.php

https://github.com/severnaya99/Sg-2010
PHP | 285 lines | 249 code | 36 blank | 0 comment | 25 complexity | 695c9f1fd0ef33d077d238f2536840ec MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0
  1. <?php
  2. include('../../../mainfile.php');
  3. include('../../../include/cp_functions.php');
  4. include('../include/functions.php');
  5. include('../include/forms.php');
  6. if( is_file(XOOPS_ROOT_PATH."/modules/genobio/language/".$GLOBALS['xoopsConfig']['language']."/admin.php") ){
  7. include_once XOOPS_ROOT_PATH."/modules/genobio/language/".$GLOBALS['xoopsConfig']['language']."/admin.php";
  8. }else{
  9. include_once XOOPS_ROOT_PATH."/modules/genobio/language/english/admin.php";
  10. }
  11. xoops_cp_header();
  12. switch($_REQUEST['op']) {
  13. case "members":
  14. switch ($_REQUEST['fct'])
  15. {
  16. case "edit":
  17. adminMenu(3);
  18. edit_members_form();
  19. break;
  20. case "new":
  21. adminMenu(6);
  22. edit_members_form();
  23. break;
  24. case "delete":
  25. $id = intval($_REQUEST['id']);
  26. $membershandler = xoops_getmodulehandler('members','genobio');
  27. $member = $membershandler->get($id);
  28. if ($membershandler->delete($member))
  29. redirect_header('index.php', 3, 'Member Item Delete Successfully');
  30. else
  31. redirect_header('index.php', 3, 'Member Item Delete Unsuccessfully');
  32. break;
  33. exit;
  34. case "save":
  35. $id = intval($_REQUEST['id']);
  36. $membershandler = xoops_getmodulehandler('members','genobio');
  37. if ($id>0)
  38. $member = $membershandler->get($id);
  39. else
  40. $member = $membershandler->create();
  41. $member->setVar('category_id', intval($_REQUEST['category_id']));
  42. $member->setVar('uid', intval($_REQUEST['uid']));
  43. $member->setVar('domain', $_REQUEST['domain']);
  44. $member->setVar('domains', $_REQUEST['domains']);
  45. $member->setVar('display_name', $_REQUEST['display_name']);
  46. $member->setVar('display_picture', $_REQUEST['display_picture']);
  47. $member->setVar('member_sex', $_REQUEST['member_sex']);
  48. if ($membershandler->insert($member)) {
  49. if ($id == 0) {
  50. $profilesshandler = xoops_getmodulehandler('profiles','genobio');
  51. $profile = $profilesshandler->create();
  52. $profile->setVar('member_id', $member->getVar('member_id'));
  53. $profile->setVar('nickname', $_REQUEST['display_name']);
  54. @$profilesshandler->insert($profile);
  55. redirect_header('index.php', 3, 'New Member Item Created Successfully');
  56. exit(0);
  57. }
  58. redirect_header('index.php', 3, 'Member Item Updated Successfully');
  59. } else {
  60. redirect_header('index.php', 3, 'Member Item Updated Unsuccessfully');
  61. }
  62. exit;
  63. break;
  64. default:
  65. adminMenu(3);
  66. sel_members_form();
  67. }
  68. break;
  69. case "sibblings":
  70. switch ($_REQUEST['fct'])
  71. {
  72. case "edit":
  73. adminMenu(2);
  74. edit_sibblings_form();
  75. break;
  76. case "new":
  77. adminMenu(5);
  78. edit_sibblings_form();
  79. break;
  80. case "delete":
  81. $id = intval($_REQUEST['id']);
  82. $sibblingshandler = xoops_getmodulehandler('sibblings','genobio');
  83. $sibblings = $sibblingshandler->get($id);
  84. if ($sibblingshandler->delete($sibblings))
  85. redirect_header('index.php', 3, 'Sibblings Item Delete Successfully');
  86. else
  87. redirect_header('index.php', 3, 'Sibblings Item Delete Unsuccessfully');
  88. break;
  89. exit;
  90. case "save":
  91. $id = intval($_REQUEST['id']);
  92. $sibblingshandler = xoops_getmodulehandler('sibblings','genobio');
  93. if ($id>0)
  94. $sibblings = $sibblingshandler->get($id);
  95. else
  96. $sibblings = $sibblingshandler->create();
  97. $sibblings->setVar('members_group', $_REQUEST['members_group']);
  98. $sibblings->setVar('nickname', $_REQUEST['nickname']);
  99. $sibblings->setVar('bio', $_REQUEST['bio']);
  100. $sibblings->setVar('history', $_REQUEST['history']);
  101. $sibblings->setVar('activities', $_REQUEST['activities']);
  102. $sibblings->setVar('toys', $_REQUEST['toys']);
  103. if ($sibblingshandler->insert($sibblings)) {
  104. $profileshandler = xoops_getmodulehandler('profiles','genobio');
  105. foreach($_REQUEST['members_group'] as $key => $id) {
  106. $profile = $profileshandler->get($id);
  107. $profile->setVar('member_siblings_id', $sibblings->getVar('sibblings_id'));
  108. @$profileshandler->insert($profile);
  109. }
  110. redirect_header('index.php', 3, 'Sibblings Item Updated Successfully');
  111. } else
  112. redirect_header('index.php', 3, 'Sibblings Item Updated Unsuccessfully');
  113. exit;
  114. break;
  115. default:
  116. adminMenu(2);
  117. sel_sibblings_form();
  118. }
  119. break;
  120. case "categories":
  121. switch ($_REQUEST['fct'])
  122. {
  123. case "edit":
  124. adminMenu(4);
  125. edit_categories_form();
  126. break;
  127. case "new":
  128. adminMenu(7);
  129. edit_categories_form();
  130. break;
  131. case "delete":
  132. $id = intval($_REQUEST['id']);
  133. $categorieshandler = xoops_getmodulehandler('categories','genobio');
  134. $categories = $categorieshandler->get($id);
  135. if ($categorieshandler->delete($categories))
  136. redirect_header('index.php', 3, 'Category Item Delete Successfully');
  137. else
  138. redirect_header('index.php', 3, 'Category Item Delete Unsuccessfully');
  139. break;
  140. exit;
  141. case "save":
  142. $id = intval($_REQUEST['id']);
  143. $categorieshandler = xoops_getmodulehandler('categories','genobio');
  144. if ($id>0)
  145. $categories = $categorieshandler->get($id);
  146. else
  147. $categories = $categorieshandler->create();
  148. $categories->setVar('category_name', $_REQUEST['category_name']);
  149. if ($categorieshandler->insert($categories))
  150. redirect_header('index.php', 3, 'Category Item Updated Successfully');
  151. else
  152. redirect_header('index.php', 3, 'Category Item Updated Unsuccessfully');
  153. exit;
  154. break;
  155. default:
  156. adminMenu(4);
  157. sel_categories_form();
  158. }
  159. break;
  160. case "profiles":
  161. switch ($_REQUEST['fct'])
  162. {
  163. default:
  164. adminMenu(2);
  165. edit_profiles_form();
  166. break;
  167. case "save":
  168. $id = intval($_REQUEST['id']);
  169. $profileshandler = xoops_getmodulehandler('profiles','genobio');
  170. if ($id>0)
  171. $profile = $profileshandler->get($id);
  172. else
  173. redirect_header('index.php', 2, _GB_NOID);
  174. $profile->setVar('member_father_id', $_REQUEST['member_father_id']);
  175. $profile->setVar('member_mother_id', $_REQUEST['member_mother_id']);
  176. $profile->setVar('member_siblings_id', $_REQUEST['member_siblings_id']);
  177. $profile->setVar('member_partner_id', $_REQUEST['member_partner_id']);
  178. $profile->setVar('nickname', $_REQUEST['nickname']);
  179. $profile->setVar('dob', $_REQUEST['dob']);
  180. $profile->setVar('dod', $_REQUEST['dod']);
  181. $profile->setVar('anniversary', $_REQUEST['anniversary']);
  182. $profile->setVar('dob_unix', strtotime($_REQUEST['dob']));
  183. $profile->setVar('dod_unix', strtotime($_REQUEST['dod']));
  184. $profile->setVar('anniversary_unix', strtotime($_REQUEST['anniversary']));
  185. $profile->setVar('height', $_REQUEST['height']);
  186. $profile->setVar('weight', $_REQUEST['weight']);
  187. $profile->setVar('colour_hair', $_REQUEST['colour_hair']);
  188. $profile->setVar('colour_eyes', $_REQUEST['colour_eyes']);
  189. $profile->setVar('bio', $_REQUEST['bio']);
  190. $profile->setVar('history', $_REQUEST['history']);
  191. $profile->setVar('education', $_REQUEST['education']);
  192. $profile->setVar('fellowship', $_REQUEST['fellowship']);
  193. $profile->setVar('earlyhistory', $_REQUEST['earlyhistory']);
  194. $profile->setVar('medical', $_REQUEST['medical']);
  195. $profile->setVar('achivements', $_REQUEST['achivements']);
  196. $profile->setVar('contributations', $_REQUEST['contributations']);
  197. $profile->setVar('awards', $_REQUEST['awards']);
  198. $profile->setVar('media', $_REQUEST['media']);
  199. $profile->setVar('publications', $_REQUEST['publications']);
  200. $profile->setVar('jobs', $_REQUEST['jobs']);
  201. $profile->setVar('spirtual', $_REQUEST['spirtual']);
  202. $profile->setVar('hates', $_REQUEST['hates']);
  203. $profile->setVar('likes', $_REQUEST['likes']);
  204. $profile->setVar('music', $_REQUEST['music']);
  205. $profile->setVar('thearts', $_REQUEST['thearts']);
  206. $profile->setVar('other', $_REQUEST['other']);
  207. @$profile->setDirty();
  208. if ($profileshandler->insert($profile, true)) {
  209. if (count($profile->getErrors())>0) {
  210. redirect_header('index.php?op=profiles&id='.$profile->getVar('member_id'), 3, 'The following form items are required.<br /><br />'.implode("<br />",$profile->getErrors()));
  211. exit(0);
  212. }
  213. @$profile->setDirty();
  214. $allowedMimeTypes = array('image/jpeg','image/gif','image/png','image/pjpeg','image/x-png',);
  215. $fupload = genobio_uploading('uploads/genobio', $allowedMimeTypes, "index.php?op=profiles&id=".$_REQUEST['id'], 0);
  216. $baby_photo = $fupload['path'];
  217. $fupload = genobio_uploading('uploads/genobio', $allowedMimeTypes, "index.php?op=profiles&id=".$_REQUEST['id'], 1);
  218. $midlife_photo = $fupload['path'];
  219. $fupload = genobio_uploading('uploads/genobio', $allowedMimeTypes, "index.php?op=profiles&id=".$_REQUEST['id'], 2);
  220. $elderly_photo = $fupload['path'];
  221. $fupload = genobio_uploading('uploads/genobio', $allowedMimeTypes, "index.php?op=profiles&id=".$_REQUEST['id'], 3);
  222. $current_photo = $fupload['path'];
  223. if (file_exists(XOOPS_ROOT_PATH.$baby_photo))
  224. $profile->setVar('baby_photo', $baby_photo);
  225. if (file_exists(XOOPS_ROOT_PATH.$midlife_photo))
  226. $profile->setVar('midlife_photo', $midlife_photo);
  227. if (file_exists(XOOPS_ROOT_PATH.$elderly_photo))
  228. $profile->setVar('elderly_photo', $elderly_photo);
  229. if (file_exists(XOOPS_ROOT_PATH.$current_photo))
  230. $profile->setVar('current_photo', $current_photo);
  231. if ($profileshandler->insert($profile, true))
  232. redirect_header('index.php?op=profiles&id='.$profile->getVar('member_id'), 3, 'Profile Item Updated Successfully');
  233. else
  234. redirect_header('index.php?op=profiles&id='.$profile->getVar('member_id'), 3, 'Profile Item Updated Unsuccessfully');
  235. } else
  236. redirect_header('index.php', 3, 'Profile Item Updated Unsuccessfully');
  237. exit;
  238. break;
  239. }
  240. break;
  241. default:
  242. adminMenu(0);
  243. sel_categories_form();
  244. sel_sibblings_form();
  245. sel_members_form();
  246. }
  247. footer_adminMenu();
  248. xoops_cp_footer();
  249. ?>