fork download
  1. <?php
  2. /**
  3. Plugin Name: Villa Portal - Babon Multimedia
  4. Plugin URI: http://www.babonmultimedia.com/
  5. Description: Villa Portal
  6. Version: 0.5 - Beta
  7. Author: GusDeCooL
  8. Author URI: http://www.gusdecool.com/
  9. License: GPL - Ga Pake Lama, langsung pake aja.
  10. */
  11.  
  12. define('VP_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
  13. define('VP_DIRPATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/');
  14.  
  15. // Set Master Class
  16. include VP_DIRPATH.'includes/inc.villaportal.php'; // Include Core Class
  17. $path = array('url'=>VP_URLPATH, 'dir'=>VP_DIRPATH);
  18. $linkpage = array('property'=>'?page=vp-property');
  19. // $vp = new VillaPortal($path, $linkpage); // Set Core Class
  20.  
  21. add_action('admin_menu', 'my_plugin_menu');
  22. function my_plugin_menu() {
  23. //session_start();
  24. global $vp;
  25. add_menu_page('Babon Villa Portal', 'Babon VP', 'manage_options', 'vp-property', 'pageProperty');
  26. add_submenu_page('vp-property', 'Property', 'Property', 'manage_options', 'vp-property', 'pageProperty');
  27. add_submenu_page('vp-property', 'Country', 'Country', 'manage_options', 'vp-config-country', 'pageConfigLocation');
  28. add_submenu_page('vp-property', 'Facilities', 'Facilities', 'manage_options', 'vp-config-facility', 'pageConfigFacility');
  29.  
  30. if( is_admin() ) global $plugin_page;
  31. if($plugin_page == 'vp-property' or $plugin_page == 'vp-config-country' or $plugin_page == 'vp-config-facility' and is_admin() ){
  32. $vp->registerCSS();
  33. $vp->registerScript();
  34. }
  35. }
  36.  
  37. function pageProperty() {
  38. global $vp;
  39. $vp->urlAdmin = '/wp-admin/admin.php?page=vp-property';
  40. $show = $_GET['show'];
  41. $action = $_GET['action'];
  42. $propertyId = $_GET['id'];
  43. $vp->loadExtention( 'Property', array($propertyId) );
  44.  
  45. switch ($show) {
  46. // &show=propertylist
  47. default:
  48. $data['title'] = 'List Property';
  49. $data['content'] = $vp->propertyList('propertylist.php', 'propertylist-wrap.php');
  50.  
  51. $vp->parser('wrap.php', $data);
  52. break;
  53.  
  54. // Do Action
  55. case 'action':
  56. switch ($action) {
  57. default:
  58. header("Location: $vp->urlAdmin");
  59. break;
  60. case 'delete':
  61. $vp->propertyDelete();
  62. break;
  63. case 'update':
  64. if ($_POST){
  65. if ($vp->propertyIdentifier){ // property exist do update
  66. if(!$vp->propertyUpdate($_POST)) {
  67. die('Error Property Update');
  68. }
  69. }else{
  70. $vp->propertyInsert($_POST);
  71. }
  72. }
  73. break;
  74. }
  75. header('refresh:1;url='.$vp->linkpage['property']);
  76. break;
  77.  
  78. // &show=propertyedit
  79. case 'propertyedit':
  80. if ($vp->propertyIdentifier) { // Mode Update
  81. $data['title'] = 'Edit Location';
  82. } else { // Mode Insert
  83. $data['title'] = 'Add Location';
  84. }
  85.  
  86. $data['content'] = $vp->propertyEdit('property-form.php');
  87. $vp->parser('wrap.php', $data);
  88. break;
  89.  
  90. // Show Property with its room
  91. case 'property':
  92. $data['title'] = 'Show Property';
  93. $data['content'] = '';
  94. if ($vp->propertyIdentifier) {
  95. $data['content'] .= $vp->getProperty('property.php');
  96. } else {
  97. header("Location: $vp->urlAdmin");
  98. }
  99.  
  100. $vp->parser('wrap.php', $data);
  101. $vp->showRoom('roomlist.php', 'roomlist-wrap.php');
  102. $vp->showFacility();
  103. break;
  104.  
  105. case 'roomaction':
  106. include VP_DIRPATH.'includes/inc.room.php'; // Include Room Class
  107. $url_property = $vp->urlAdmin.'&show=property&id='.$vp->propertyIdentifier;
  108. $room = new Room($url_property);
  109.  
  110. switch($_GET['roomaction']){
  111. case 'create':
  112. // Show create form
  113. if ($room->identifier) {
  114. $data['title'] = 'Add Room';
  115. }else{
  116. $data['title'] = 'Edit Room';
  117. }
  118.  
  119. $data['content'] = $vp->parseChunk('room-form.php', $room->data);
  120. $vp->parser('wrap.php', $data);
  121. break;
  122.  
  123. case 'doedit':
  124. if ($_POST){
  125. $_POST['property_id'] = $vp->propertyIdentifier;
  126. if($room->identifier) { // Do Update
  127. $vp->db->update('vm_room', $_POST, 'id='.$room->identifier);
  128. }else{ // Do Insert
  129. $vp->db->insert('vm_room', $_POST);
  130. }
  131. }
  132. header('Location: '.$room->url_property);
  133. break;
  134.  
  135. case 'dodelete':
  136. if($_GET['roomid'] != '' && $_GET['id'] != '') {
  137. $vp->room_delete($_GET['roomid']);
  138. }
  139. header('Location: '.$room->url_property);
  140. break;
  141. }
  142. break;
  143.  
  144. case 'roomprice':
  145. $vp->loadExtention('Room');
  146. switch ($_GET['roomprice']) {
  147. default:
  148. $data['title'] = 'Rate Setup';
  149. $data['content'] = $vp->listRate();
  150. $vp->parser('wrap.php', $data);
  151. $_SESSION['linkBack'] = $_SERVER['REQUEST_URI'];
  152. break;
  153.  
  154. case 'update':
  155. switch ($_POST['method']) {
  156. case 'date':
  157. unset($_POST['method']);
  158. $_SESSION['rateDate'] = $_POST['year'].'-'.$_POST['month'];
  159. break;
  160.  
  161. case 'rate':
  162. unset($_POST['method']);
  163. $vp->room->roomUpdate($_POST);
  164. break;
  165. }
  166. header('refresh:1;url='.$_SESSION['linkBack']);
  167. break;
  168. }
  169. break;
  170. }
  171. }
  172.  
  173. function pageConfigLocation() {
  174. global $vp;
  175. $mode = $_GET['mode'];
  176.  
  177. switch ($mode) {
  178. case 'savelocation':
  179. $vp->saveLocation('?page=vp-config-country');
  180. break;
  181.  
  182. case 'deletelocation':
  183. $vp->deleteLocation($_GET['id'], '?page=vp-config-country');
  184. break;
  185.  
  186. case 'addlocation':
  187. ?>
  188. <div class="wrap">
  189. <div class="icon32" id="icon-tools"><br></div>
  190. <h2>Add Location</h2>
  191. <?php $vp->formAddLocation('?page=vp-config-country&mode=savelocation'); ?>
  192. </div>
  193. <?php
  194. break;
  195.  
  196. default:
  197. ?>
  198. <div class="wrap">
  199. <div class="icon32" id="icon-tools"><br></div>
  200. <h2>Location Manager</h2>
  201. <a class="button-primary" href="?page=vp-config-country&mode=addlocation&do=add">Add Country</a>
  202. <?php $vp->listLocation(); ?>
  203. </div>
  204. <?php
  205. break;
  206. }
  207.  
  208. print($return);
  209. }
  210.  
  211. function pageConfigFacility() {
  212. global $vp;
  213. $vp->urlAdmin = '/wp-admin/admin.php?page=vp-config-facility';
  214. $table_name = 'vm_facility';
  215. DBAPI::$debug = false;
  216. switch ($_POST['action']) {
  217. case 'insert':
  218. unset( $_POST['action'] );
  219. $insertData = $_POST['insert'];
  220. if ( $vp->db->countRow($table_name, null, "name='$insertData'") == 0 ) { // This data is not in database
  221. $data = array('name'=>$insertData);
  222. $vp->db->insert($table_name, $data);
  223. }
  224. break;
  225.  
  226. case 'update':
  227. unset( $_POST['action'] );
  228. foreach ($_POST['update'] as $key=>$value) {
  229. $data['name'] = $value['name'];
  230. $vp->db->update($table_name, $data, 'id='.$key);
  231. }
  232. break;
  233.  
  234. default:
  235. break;
  236. }
  237.  
  238. if ($_GET['action'] == 'delete' && $_GET['id'] != '' ) {
  239. $vp->db->delete($table_name, 'id='.$_GET['id']);
  240. header('Location: '.$vp->urlAdmin);
  241. }
  242. ?>
  243. <div class="wrap">
  244. <div class="icon32" id="icon-tools"><br></div>
  245. <h2>Facility Manager</h2>
  246. <?php $vp->configListFacility(); ?>
  247.  
  248. <form action="" method="post">
  249. <input type="hidden" name="action" value="insert" />
  250. <p>
  251. <input type="text" name="insert" value="" />
  252. </p>
  253. <p>
  254. <input type="submit" value="insert" class="button-primary" />
  255. </p>
  256. </form>
  257. </div>
  258. <?php
  259. }
  260. ?>
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty