Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_POST){
- /*
- $grpTitle = $_POST['grpTitle'];
- $grpDescription = $_POST['grpDescription'];
- // Create the group
- $wpdb->insert(EMC_GROUP_TABLE, array('gTitle' => $grpTitle, 'gDescription' => $grpDescription),
- array('%s', '%s'));
- $grpID = $wpdb->insert_id;
- // Insert the selected members
- $grpMember = $_POST['grpMember'];
- $gmCt = count($grpMember);
- for($gm = 0; $gm < $gmCt; ++$gm){
- $wpdb->insert(EMC_USERS_TABLE, array('groupID' => $grpID, 'userID' => $grpMember[$gm], 'cuType'=>2),
- array('%d', '%d', '%d'));
- }
- // Insert the selected Admins
- $grpAdmins = $_POST['grpAdmins'];
- $aCt = count(grpAdmins);
- for($am = 0; $am < $aCt; ++$am){
- $wpdb->insert(EMC_USERS_TABLE, array('groupID' => $grpID, 'userID' => $grpAdmins[$am], 'cuType'=>1),
- array('%d', '%d', '%d'));
- }
- $grpInclude = $_POST['grpInclude'];
- $giCt = count($grpInclude);
- for($g = 0; $g < $giCt; ++$g){
- $wpdb->insert(EMC_POSTS_TABLE, array('groupID' => $grpID, 'post_id' => $grpInclude[$g]),
- array('%d', '%d', '%d'));
- }
- echo '<div id="message" class="updated fade" style="padding:10px;">Your group has been created.</div>';
- */
- }
- ?>
- <style type="text/css">
- .ui-widget{font-family:auto;}
- .ui-widget th{font-weight:bold;}
- .tab1{width:24% !important;display:block-inline !important;float:left !important;padding:2px;font-family:inherit;}
- .panel1{background:none !important;border:none !important;}
- .grpSelAll{text-decoration:underline !important;}
- .grpSelAll:hover{text-decoration:none !important;}
- </style>
- <div class="wrap" style="width:65% !important;">
- <h2><span class="dashicons dashicons-welcome-add-page" style="display:inline-block;padding-top:5px;"></span> Update This Group</h2>
- <div class="form-wrap">
- <form method="post">
- <div id="tabs" class="panel1">
- <ul class="panel1">
- <li class="tab1"><a href="#tabs-1">Main Properties</a></li>
- <li class="tab1"><a href="#tabs-2">Group Members</a></li>
- <li class="tab1"><a href="#tabs-3">Page/Post Permissions</a></li>
- <li class="tab1"><a href="#tabs-4">Group Administrators</a></li>
- </ul>
- <div id="tabs-1" class="group-panel panel1">
- <h2>Main Properties</h2>
- <div class="form-field">
- <h3>
- <label for="grpTitle">Group Title</label>
- <input type="text" name="grpTitle" id="grpTitle" required />
- </h3>
- </div>
- <div class="clearfix"></div>
- <h3>
- <label for="grpDescription">Group Description</label>
- <textarea rows="6" style="width:100%;" name="grpDescription" id="grpDescription"></textarea>
- </h3>
- </div>
- <div id="tabs-2" class="group-panel panel1">
- <h2>Group Members</h2>
- <?php
- // Grab all users with the proper permissions from WP (not admins)
- $uc = new EM_Collaboration_Users;
- $u = $uc->get_wp_allowed_users();
- $uCt = count($u);
- if($uCt > 0){
- echo '<table id="section-groups" class="wp-list-table widefat">
- <thead>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Type</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpMember" title="Click to Select/De-Select All">Group Member</a></th>
- </tr>
- </thead>
- <tbody>';
- for($i=0;$i<$uCt;++$i){
- $un = new WP_User($u[$i]->ID);
- $uL = $un->roles[0];
- echo '<tr>
- <td>' . $u[$i]->display_name . '</td>
- <td>' . $u[$i]->user_email . '</td>
- <td>' . ucwords($uL) . '</td>
- <td style="text-align:center;"><input type="checkbox" id="grpMember' . $u[$i]->ID . '" name="grpMember[]" value="' . $u[$i]->ID . '" /></td>
- </tr>';
- }
- echo ' </tbody>
- <tfoot>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Type</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpMember" title="Click to Select/De-Select All">Group Member</a></th>
- </tr>
- </tfoot>
- </table>';
- }else{
- 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>';
- }
- ?>
- </div>
- <div id="tabs-3" class="group-panel panel1" style="background:none !important;border:none !important;">
- <h2>Page/Post Permissions</h2>
- <?php
- $pc = new EM_Collaboration_Posts();
- $pub_posts = $pc->get_allowed_public_posts();
- $ppCt = count($pub_posts);
- if($ppCt > 0){
- echo '<table id="section-groups" class="wp-list-table widefat">
- <thead>
- <tr>
- <th>Title</th>
- <th>Type</th>
- <th>Status</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpInclude" title="Click to Select/De-Select All">Include In Group?</a></th>
- </tr>
- </thead>
- <tbody>';
- for($p=0;$p<$ppCt;++$p){
- echo '<tr>';
- echo '<td>' . $pub_posts[$p]['POST'] . '</td>
- <td>' . ucwords($pub_posts[$p]['TYPE']) . '</td>
- <td>' . ucwords($pub_posts[$p]['STATUS']) . '</td>
- <td style="text-align:center;"><input type="checkbox" id="grpInclude' . $pub_posts[$p]['ID'] . '" name="grpInclude[]" value="' . $pub_posts[$p]['ID'] . '" /></td>';
- echo '</tr>';
- }
- echo ' </tbody>
- <tfoot>
- <tr>
- <th>Title</th>
- <th>Type</th>
- <th>Status</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpInclude" title="Click to Select/De-Select All">Include In Group?</a></th>
- </tr>
- </tfoot>
- </table>';
- }else{
- echo '<p class="error" style="padding:10px;">There are no public posts/pages yet.</p>';
- }
- ?>
- </div>
- <div id="tabs-4" class="group-panel panel1" style="background:none !important;border:none !important;">
- <h2>Group Administrators</h2>
- <?php
- // Grab all administrators from WP
- $a = $uc->get_wp_admins();
- $aCt = count($a);
- if($aCt > 0){
- echo '<table id="section-groups" class="wp-list-table widefat">
- <thead>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Joined On</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpAdmins" title="Click to Select/De-Select All">Group Admin</a></th>
- </tr>
- </thead>
- <tbody>';
- for($i=0;$i<$aCt;++$i){
- echo '<tr>';
- echo ' <td>' . $a[$i]->display_name . '</td>';
- echo ' <td>' . $a[$i]->user_email . '</td>';
- echo ' <td>' . date('m/d/Y H:i:s', strtotime($a[$i]->user_registered)) . '</td>';
- echo ' <td style="text-align:center;"><input type="checkbox" id="grpAdmins' . $a[$i]->ID . '" name="grpAdmins[]" value="' . $a[$i]->ID . '" /></td>';
- echo '</tr>';
- }
- echo ' </tbody>
- <tfoot>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Joined On</th>
- <th style="text-align:center;"><a href="#" class="grpSelAll" data-rel="grpAdmins" title="Click to Select/De-Select All">Group Admin</a></th>
- </tr>
- </tfoot>
- </table>';
- }else{
- echo '<p class="error" style="padding:10px;">There are no administrators.</p>';
- }
- ?>
- </div>
- <div style="display:block;float:right;">
- <?php submit_button('Update This Group', 'primary large'); ?>
- </div>
- </div>
- </form>
- </div>
- </div>
- <script>
- jQuery(function() {
- jQuery("#tabs").tabs();
- jQuery('.grpSelAll').on('click', function(e){
- e.preventDefault();
- var $which = jQuery(this).attr('data-rel');
- var checkBoxes = jQuery("input[id^=" + $which + "]");
- checkBoxes.prop("checked", !checkBoxes.prop("checked"));
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement