function userGroups_PrintPagesWithGroups($level = 0, $parentID = 0, $alt = true) { global $wpdb; $groups = new userGroups(); $query = "SELECT * FROM " . $wpdb->posts; //added «OR post_type='page'» for wordpress 2.1 compatibility $query .= " WHERE (post_status='static' OR post_type='page') AND post_parent='{$parentID}';"; $results = $wpdb->get_results($query); if (isset($results)) { foreach ($results as $result) { if ($alt) { $style = 'class=\'alternate\''; } else { $style = ''; } $spacer = ""; for ($cont = 0; $cont < $level; $cont++) { $spacer .= "-"; } echo "<tr " . $style . "><td>{$spacer} " . $result->post_title . "</td><td>"; $pageGroups = $groups->getAllGroupsWithPage($result->ID); if (isset($pageGroups) && count($pageGroups) > 0) { $hasGroups = false; foreach ($pageGroups as $grp) { if ($grp->exc_read || $grp->exc_write) { $perms = " ("; if ($grp->exc_read) { $perms .= "R"; } if ($grp->exc_write) { $perms .= "W"; } $perms .= ")"; echo "- " . $grp->name . "{$perms}<br />"; $hasGroups = true; } } if (!$hasGroups) { echo "(no groups)"; } } else { echo "(no groups)"; } echo "</td><td " . $style . "><a class=\"edit\" href='" . $_SERVER['PHP_SELF'] . "?page=wp-group-restriction/manage_groups&mode=edit&id=" . $result->ID . "'>Edit</a></td></tr>"; ?> <?php $alt = !$alt; $alt = userGroups_PrintPagesWithGroups($level + 1, $result->ID, $alt); } } return $alt; }
function userGroups_PrintGroupMembers() { $groups = new userGroups(); $results = $groups->getGroups(); $alt = true; if (isset($results) && count($results) > 0) { echo "\n<table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">"; echo "\n\t<tr class=\"thead\">"; echo "\n\t\t<th>Group Name</th>\n\t\t<th>Members</th>\n\t\t<th> </th>"; echo "\n\t</tr>"; foreach ($results as $result) { if ($alt) { $style = 'class=\'alternate\''; } else { $style = ''; } $alt = !$alt; echo "<tr " . $style . "><td>" . $result->name . "</td><td>"; $members = $groups->getGroupMembers($result->id); if (isset($members) && count($members) > 0) { $number = count($members); if ($number == 1) { echo "(1 user)<br />"; } else { echo "({$number} users)<br />"; } foreach ($members as $member) { echo "- " . $member->name . "<br />"; } } else { echo "(no users)"; } echo "</td><td " . $style . "><a class=\"edit\" href='" . $_SERVER['PHP_SELF'] . "?page=wp-group-restriction/group_members&mode=edit&id=" . $result->id . "'>Edit</a></td></tr>"; } echo "\n</table>"; } else { //No groups available... echo "<p><strong>No groups available.</strong></p>"; } }
</h2> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr class="thead"> <th><?php _e('Group Name'); ?> </th> <th><?php _e('Pages'); ?> </th> <th> </th> </tr> <?php $groups = new userGroups(); $results = $groups->getGroups(); $i = 0; if (isset($results)) { foreach ($results as $result) { if ($i % 2 == 0) { $style = 'class=\'alternate\''; } else { $style = ''; } echo "<tr {$style}><td>" . $result->name . "</td><td>"; $paginas = $groups->getGroupPages($result->id); if (isset($paginas) && count($paginas) > 0) { foreach ($paginas as $pagina) { $perms = " ("; if ($pagina->exc_read) {
/** * Deletes refereces to a resource * To be used by other plugins * * @param string $plugin_name - name of the plugin calling this method * @param int $resource - resource identifier (optional if not specified all resources from this plugin will be deleted) * @param string $permission - permission of the resource (optional if not specified resources with all permissions this plugin will be deleted) * @return boolean True if the item has been deleted, false otherwise **/ function ugDeleteResource($plugin_name, $resource = "", $permission = "") { global $table_prefix, $wpdb; $table = $table_prefix . "ug_GroupsGeneric"; if (!isset($plugin_name)) { return false; } $arg = ""; if ($resource != "") { $arg .= "AND id_resource='{$resource}' "; } if ($permission != "") { $arg .= "AND permission='{$permission}' "; } if (userGroups::tableExists($table)) { $delete = "DELETE FROM {$table} WHERE plugin_name='{$plugin_name}' {$arg};"; $results = $wpdb->query($delete); return $results != ''; } else { return false; } }
break; } break; } ?> <div class="wrap"> <h2><?php _e('Existing Groups'); if ($mode != "edit") { ?> (<a href="#new">add new</a>)<?php } ?> </h2> <?php $groups = new userGroups(); $results = $groups->getGroups(true); $i = 0; if (isset($results) && count($results) > 0) { ?> <script type="text/javascript"> function DelConfirm(name){ var message= 'You are about to delete the group "'+name+'", do you wish to continue?'; return confirm(message); } </script> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr class="thead"> <th><?php _e('Name'); ?>