Advertisement
Guest User

phpgrid.org custom event

a guest
Nov 27th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.25 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
  3. ?>
  4. <?php
  5. session_start();
  6.  
  7. if(!isset($_SESSION["userid"]))
  8. {
  9.   header("Location: index.php");
  10. }
  11. ?>
  12. <?php
  13. require_once "phpgrid/config.php";
  14.  
  15. $db_conf = array();
  16. $db_conf["type"] = "mysqli";
  17. $db_conf["server"] = PHPGRID_DBHOST;
  18. $db_conf["user"] = PHPGRID_DBUSER;
  19. $db_conf["password"] = PHPGRID_DBPASS;
  20. $db_conf["database"] = PHPGRID_DBNAME;
  21.  
  22. require_once "phpgrid/lib/inc/jqgrid_dist.php";
  23.  
  24. $g = new jqgrid($db_conf);
  25.  
  26. require_once "constring.php";
  27.  
  28. $myconnect = mysqli_connect($servername, $username, $password, $dbname) or die (mysqli_connect_error());
  29.  
  30.  
  31. //THE CUSTOM EVENT
  32. $e["on_insert"] = array("add_client", null, true);
  33. $g->set_events($e);
  34. function add_client($data)
  35. {
  36. $sqlhistory = "INSERT INTO history(subject,predicate) VALUES($data["params"]["userid"],'added');";
  37. mysqli_query($myconnect, $sqlhistory) or die (mysqli_error($myconnect));
  38. }
  39.  
  40.  
  41. $g->table = "user";
  42.  
  43. $col = array();
  44. $col["title"] = "No";
  45. $col["name"] = "id";
  46. $col["sorttype"] = int;
  47. $col["width"] = "32";
  48. $col["fixed"] = true;
  49. $cols[] = $col;
  50.  
  51. $col = array();
  52. $col["title"] = "User ID";
  53. $col["name"] = "userid";
  54. $col["editable"] = true;
  55. $col["editrules"] = array("required"=>true);
  56. $col["edittype"] = "textarea";
  57. $cols[] = $col;
  58.  
  59. $col = array();
  60. $col["title"] = "User Password";
  61. $col["name"] = "userpw";
  62. $col["editable"] = true;
  63. $col["editrules"] = array("required"=>true);
  64. $col["edittype"] = "password";
  65. $col["formatter"] = "password";
  66. $cols[] = $col;
  67.  
  68. $col = array();
  69. $col["title"] = "User Full Name";
  70. $col["name"] = "username";
  71. $col["editable"] = true;
  72. $col["editrules"] = array("required"=>true);
  73. $col["edittype"] = "textarea";
  74. $cols[] = $col;
  75.  
  76. $col = array();
  77. $col["title"] = "[System1]-Allow Turn On/Off SMS Auto Reply";
  78. $col["name"] = "privsystem1";
  79. $col["editable"] = true;
  80. $col["editrules"] = array("required"=>true);
  81. $col["edittype"] = "checkbox";
  82. $col["editoptions"] = array("value"=>"1:0");
  83. $col["width"] = "64";
  84. $col["fixed"] = true;
  85. $cols[] = $col;
  86.  
  87. $col = array();
  88. $col["title"] = "[System2]-Allow Changing SMS Auto Reply Text";
  89. $col["name"] = "privsystem2";
  90. $col["editable"] = true;
  91. $col["editrules"] = array("required"=>true);
  92. $col["edittype"] = "checkbox";
  93. $col["editoptions"] = array("value"=>"1:0");
  94. $col["width"] = "64";
  95. $col["fixed"] = true;
  96. $cols[] = $col;
  97.  
  98. $col = array();
  99. $col["title"] = "[System3]-Allow Sending SMS Test";
  100. $col["name"] = "privsystem3";
  101. $col["editable"] = true;
  102. $col["editrules"] = array("required"=>true);
  103. $col["edittype"] = "checkbox";
  104. $col["editoptions"] = array("value"=>"1:0");
  105. $col["width"] = "64";
  106. $col["fixed"] = true;
  107. $cols[] = $col;
  108.  
  109. $col = array();
  110. $col["title"] = "[System4]-Allow Seeing History System";
  111. $col["name"] = "privsystem4";
  112. $col["editable"] = true;
  113. $col["editrules"] = array("required"=>true);
  114. $col["edittype"] = "checkbox";
  115. $col["editoptions"] = array("value"=>"1:0");
  116. $col["width"] = "64";
  117. $col["fixed"] = true;
  118. $cols[] = $col;
  119.  
  120. $col = array();
  121. $col["title"] = "[SMS1]-Allow Replying SMS Manually";
  122. $col["name"] = "privsms1";
  123. $col["editable"] = true;
  124. $col["editrules"] = array("required"=>true);
  125. $col["edittype"] = "checkbox";
  126. $col["editoptions"] = array("value"=>"1:0");
  127. $col["width"] = "48";
  128. $col["fixed"] = true;
  129. $cols[] = $col;
  130.  
  131. $col = array();
  132. $col["title"] = "[User1]-Allow Adding New User Account";
  133. $col["name"] = "privuser1";
  134. $col["editable"] = true;
  135. $col["editrules"] = array("required"=>true);
  136. $col["edittype"] = "checkbox";
  137. $col["editoptions"] = array("value"=>"1:0");
  138. $col["width"] = "49";
  139. $col["fixed"] = true;
  140. $cols[] = $col;
  141.  
  142. $col = array();
  143. $col["title"] = "[User2]-Allow Editing User Account";
  144. $col["name"] = "privuser2";
  145. $col["editable"] = true;
  146. $col["editrules"] = array("required"=>true);
  147. $col["edittype"] = "checkbox";
  148. $col["editoptions"] = array("value"=>"1:0");
  149. $col["width"] = "49";
  150. $col["fixed"] = true;
  151. $cols[] = $col;
  152.  
  153. $col = array();
  154. $col["title"] = "[User3]-Allow Deleting User Account";
  155. $col["name"] = "privuser3";
  156. $col["editable"] = true;
  157. $col["editrules"] = array("required"=>true);
  158. $col["edittype"] = "checkbox";
  159. $col["editoptions"] = array("value"=>"1:0");
  160. $col["width"] = "49";
  161. $col["fixed"] = true;
  162. $cols[] = $col;
  163.  
  164. $col = array();
  165. $col["title"] = "[Feature1]-Allow Forwarding Received SMS To Email";
  166. $col["name"] = "privfeature1";
  167. $col["editable"] = true;
  168. $col["editrules"] = array("required"=>true);
  169. $col["edittype"] = "checkbox";
  170. $col["editoptions"] = array("value"=>"1:0");
  171. $col["width"] = "66";
  172. $col["fixed"] = true;
  173. $cols[] = $col;
  174.  
  175. $col = array();
  176. $col["title"] = "[Feature2]-Allow Forwarding Sent SMS To Email";
  177. $col["name"] = "privfeature2";
  178. $col["editable"] = true;
  179. $col["editrules"] = array("required"=>true);
  180. $col["edittype"] = "checkbox";
  181. $col["editoptions"] = array("value"=>"1:0");
  182. $col["width"] = "66";
  183. $col["fixed"] = true;
  184. $cols[] = $col;
  185.  
  186. $col = array();
  187. $col["title"] = "[Feature3]-Allow Forwarding System History To Email";
  188. $col["name"] = "privfeature3";
  189. $col["editable"] = true;
  190. $col["editrules"] = array("required"=>true);
  191. $col["edittype"] = "checkbox";
  192. $col["editoptions"] = array("value"=>"1:0");
  193. $col["width"] = "66";
  194. $col["fixed"] = true;
  195. $cols[] = $col;
  196.  
  197. $g->set_columns($cols);
  198.  
  199. $grid["rowNum"] = 20;
  200. $grid["sortname"] = 'id';
  201. $grid["sortorder"] = "asc";
  202. $grid["caption"] = "User";
  203. $grid["autowidth"] = true;
  204. $grid["add_options"] = array('width'=>'600');
  205. $grid["edit_options"] = array('width'=>'600');
  206. $grid["view_options"] = array('width'=>'600');
  207.  
  208. $g->set_options($grid);
  209.  
  210. if($_SESSION["privuser1"]=="0" AND $_SESSION["privuser2"]=="0" AND $_SESSION["privuser3"]=="0")
  211. {
  212.     $g->set_actions(array("add"=>false,"edit"=>false,"delete"=>false,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  213. } else if($_SESSION["privuser1"]=="0" AND $_SESSION["privuser2"]=="0" AND $_SESSION["privuser3"]=="1")
  214. {
  215.     $g->set_actions(array("add"=>false,"edit"=>false,"delete"=>true,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  216. } else if($_SESSION["privuser1"]=="0" AND $_SESSION["privuser2"]=="1" AND $_SESSION["privuser3"]=="0")
  217. {
  218.     $g->set_actions(array("add"=>false,"edit"=>true,"delete"=>false,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  219. } else if($_SESSION["privuser1"]=="1" AND $_SESSION["privuser2"]=="0" AND $_SESSION["privuser3"]=="0")
  220. {
  221.     $g->set_actions(array("add"=>true,"edit"=>false,"delete"=>false,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  222. } else if($_SESSION["privuser1"]=="0" AND $_SESSION["privuser2"]=="1" AND $_SESSION["privuser3"]=="1")
  223. {
  224.     $g->set_actions(array("add"=>false,"edit"=>true,"delete"=>true,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  225. } else if($_SESSION["privuser1"]=="1" AND $_SESSION["privuser2"]=="0" AND $_SESSION["privuser3"]=="1")
  226. {
  227.     $g->set_actions(array("add"=>true,"edit"=>false,"delete"=>true,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  228. } else if($_SESSION["privuser1"]=="1" AND $_SESSION["privuser2"]=="1" AND $_SESSION["privuser3"]=="0")
  229. {
  230.     $g->set_actions(array("add"=>true,"edit"=>true,"delete"=>false,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  231. } else if($_SESSION["privuser1"]=="1" AND $_SESSION["privuser2"]=="1" AND $_SESSION["privuser3"]=="1")
  232. {
  233.     $g->set_actions(array("add"=>true,"edit"=>true,"delete"=>true,"clone"=>false,"bulkedit"=>false,"view"=>true,"rowactions"=>false,"export"=>true,"autofilter" => true,"search"=>"simple","inlineadd"=>false,"showhidecolumns"=>true));
  234. }
  235.  
  236. // generate grid output, with unique grid name as 'list1'
  237. $out = $g->render("list1");
  238. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement