Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. <?php
  2. if($_POST){
  3. /*
  4. $grpTitle = $_POST['grpTitle'];
  5. $grpDescription = $_POST['grpDescription'];
  6. // Create the group
  7. $wpdb->insert(EMC_GROUP_TABLE, array('gTitle' => $grpTitle, 'gDescription' => $grpDescription),
  8. array('%s', '%s'));
  9. $grpID = $wpdb->insert_id;
  10. // Insert the selected members
  11. $grpMember = $_POST['grpMember'];
  12. $gmCt = count($grpMember);
  13. for($gm = 0; $gm < $gmCt; ++$gm){
  14. $wpdb->insert(EMC_USERS_TABLE, array('groupID' => $grpID, 'userID' => $grpMember[$gm], 'cuType'=>2),
  15. array('%d', '%d', '%d'));
  16. }
  17. // Insert the selected Admins
  18. $grpAdmins = $_POST['grpAdmins'];
  19. $aCt = count(grpAdmins);
  20. for($am = 0; $am < $aCt; ++$am){
  21. $wpdb->insert(EMC_USERS_TABLE, array('groupID' => $grpID, 'userID' => $grpAdmins[$am], 'cuType'=>1),
  22. array('%d', '%d', '%d'));
  23. }
  24. $grpInclude = $_POST['grpInclude'];
  25. $giCt = count($grpInclude);
  26. for($g = 0; $g < $giCt; ++$g){
  27. $wpdb->insert(EMC_POSTS_TABLE, array('groupID' => $grpID, 'post_id' => $grpInclude[$g]),
  28. array('%d', '%d', '%d'));
  29. }
  30. echo '<div id="message" class="updated fade" style="padding:10px;">Your group has been created.</div>';
  31. */
  32. }
  33. ?>
  34. <style type="text/css">
  35. .ui-widget{font-family:auto;}
  36. .ui-widget th{font-weight:bold;}
  37. .tab1{width:24% !important;display:block-inline !important;float:left !important;padding:2px;font-family:inherit;}
  38. .panel1{background:none !important;border:none !important;}
  39. .grpSelAll{text-decoration:underline !important;}
  40. .grpSelAll:hover{text-decoration:none !important;}
  41. </style>
  42. <div class="wrap" style="width:65% !important;">
  43. <h2><span class="dashicons dashicons-welcome-add-page" style="display:inline-block;padding-top:5px;"></span>&nbsp;Update This Group</h2>
  44. <div class="form-wrap">
  45. <form method="post">
  46. <div id="tabs" class="panel1">
  47. <ul class="panel1">
  48. <li class="tab1"><a href="#tabs-1">Main Properties</a></li>
  49. <li class="tab1"><a href="#tabs-2">Group Members</a></li>
  50. <li class="tab1"><a href="#tabs-3">Page/Post Permissions</a></li>
  51. <li class="tab1"><a href="#tabs-4">Group Administrators</a></li>
  52. </ul>
  53. <div id="tabs-1" class="group-panel panel1">
  54. <h2>Main Properties</h2>
  55.  
  56. <div class="form-field">
  57. <h3>
  58. <label for="grpTitle">Group Title</label>
  59. <input type="text" name="grpTitle" id="grpTitle" required />
  60. </h3>
  61. </div>
  62. <div class="clearfix"></div>
  63. <h3>
  64. <label for="grpDescription">Group Description</label>
  65. <textarea rows="6" style="width:100%;" name="grpDescription" id="grpDescription"></textarea>
  66. </h3>
  67. </div>
  68. <div id="tabs-2" class="group-panel panel1">
  69. <h2>Group Members</h2>
  70. <?php
  71. // Grab all users with the proper permissions from WP (not admins)
  72. $uc = new EM_Collaboration_Users;
  73. $u = $uc->get_wp_allowed_users();
  74. $uCt = count($u);
  75. if($uCt > 0){
  76. echo '<table id="section-groups" class="wp-list-table widefat">
  77. <thead>
  78. <tr>
  79. <th>Name</th>
  80. <th>Email</th>
  81. <th>Type</th>
  82. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpMember" title="Click to Select/De-Select All">Group Member</a></th>
  83. </tr>
  84. </thead>
  85. <tbody>';
  86. for($i=0;$i<$uCt;++$i){
  87. $un = new WP_User($u[$i]->ID);
  88. $uL = $un->roles[0];
  89. echo '<tr>
  90. <td>' . $u[$i]->display_name . '</td>
  91. <td>' . $u[$i]->user_email . '</td>
  92. <td>' . ucwords($uL) . '</td>
  93. <td style="text-align:center;"><input type="checkbox" id="grpMember' . $u[$i]->ID . '" name="grpMember[]" value="' . $u[$i]->ID . '" /></td>
  94. </tr>';
  95. }
  96. echo ' </tbody>
  97. <tfoot>
  98. <tr>
  99. <th>Name</th>
  100. <th>Email</th>
  101. <th>Type</th>
  102. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpMember" title="Click to Select/De-Select All">Group Member</a></th>
  103. </tr>
  104. </tfoot>
  105. </table>';
  106. }else{
  107. echo '<p class="error" style="padding:10px;">There are no users with the correct permissions.<br />You will not be able to create this group until you have at least 1 user with proper permissions.</p>';
  108. }
  109. ?>
  110. </div>
  111. <div id="tabs-3" class="group-panel panel1" style="background:none !important;border:none !important;">
  112. <h2>Page/Post Permissions</h2>
  113. <?php
  114. $pc = new EM_Collaboration_Posts();
  115. $pub_posts = $pc->get_allowed_public_posts();
  116. $ppCt = count($pub_posts);
  117. if($ppCt > 0){
  118. echo '<table id="section-groups" class="wp-list-table widefat">
  119. <thead>
  120. <tr>
  121. <th>Title</th>
  122. <th>Type</th>
  123. <th>Status</th>
  124. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpInclude" title="Click to Select/De-Select All">Include In Group?</a></th>
  125. </tr>
  126. </thead>
  127. <tbody>';
  128. for($p=0;$p<$ppCt;++$p){
  129. echo '<tr>';
  130. echo '<td>' . $pub_posts[$p]['POST'] . '</td>
  131. <td>' . ucwords($pub_posts[$p]['TYPE']) . '</td>
  132. <td>' . ucwords($pub_posts[$p]['STATUS']) . '</td>
  133. <td style="text-align:center;"><input type="checkbox" id="grpInclude' . $pub_posts[$p]['ID'] . '" name="grpInclude[]" value="' . $pub_posts[$p]['ID'] . '" /></td>';
  134. echo '</tr>';
  135. }
  136. echo ' </tbody>
  137. <tfoot>
  138. <tr>
  139. <th>Title</th>
  140. <th>Type</th>
  141. <th>Status</th>
  142. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpInclude" title="Click to Select/De-Select All">Include In Group?</a></th>
  143. </tr>
  144. </tfoot>
  145. </table>';
  146. }else{
  147. echo '<p class="error" style="padding:10px;">There are no public posts/pages yet.</p>';
  148. }
  149. ?>
  150. </div>
  151. <div id="tabs-4" class="group-panel panel1" style="background:none !important;border:none !important;">
  152. <h2>Group Administrators</h2>
  153. <?php
  154. // Grab all administrators from WP
  155. $a = $uc->get_wp_admins();
  156. $aCt = count($a);
  157. if($aCt > 0){
  158. echo '<table id="section-groups" class="wp-list-table widefat">
  159. <thead>
  160. <tr>
  161. <th>Name</th>
  162. <th>Email</th>
  163. <th>Joined On</th>
  164. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpAdmins" title="Click to Select/De-Select All">Group Admin</a></th>
  165. </tr>
  166. </thead>
  167. <tbody>';
  168. for($i=0;$i<$aCt;++$i){
  169. echo '<tr>';
  170. echo ' <td>' . $a[$i]->display_name . '</td>';
  171. echo ' <td>' . $a[$i]->user_email . '</td>';
  172. echo ' <td>' . date('m/d/Y H:i:s', strtotime($a[$i]->user_registered)) . '</td>';
  173. echo ' <td style="text-align:center;"><input type="checkbox" id="grpAdmins' . $a[$i]->ID . '" name="grpAdmins[]" value="' . $a[$i]->ID . '" /></td>';
  174. echo '</tr>';
  175. }
  176. echo ' </tbody>
  177. <tfoot>
  178. <tr>
  179. <th>Name</th>
  180. <th>Email</th>
  181. <th>Joined On</th>
  182. <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpAdmins" title="Click to Select/De-Select All">Group Admin</a></th>
  183. </tr>
  184. </tfoot>
  185. </table>';
  186. }else{
  187. echo '<p class="error" style="padding:10px;">There are no administrators.</p>';
  188. }
  189. ?>
  190. </div>
  191. <div style="display:block;float:right;">
  192. <?php submit_button('Update This Group', 'primary large'); ?>
  193. </div>
  194. </div>
  195. </form>
  196. </div>
  197. </div>
  198. <script>
  199. jQuery(function() {
  200. jQuery("#tabs").tabs();
  201. jQuery('.grpSelAll').on('click', function(e){
  202. e.preventDefault();
  203. var $which = jQuery(this).attr('data-rel');
  204. var checkBoxes = jQuery("input[id^=" + $which + "]");
  205. checkBoxes.prop("checked", !checkBoxes.prop("checked"));
  206. });
  207. });
  208. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement