public static function display_groups($options) { //if(!self::can_i('view','Group','Groups'))return ''; $owner_id = isset($options['owner_id']) && $options['owner_id'] ? (int) $options['owner_id'] : false; $owner_table = isset($options['owner_table']) && $options['owner_table'] ? $options['owner_table'] : false; //default to true. $can_create = $can_edit = $can_view = $can_delete = true; if ($options && isset($options['bypass_security'])) { // do nothing? } else { if (isset($options) && isset($options['owner_table']) && $options['owner_table'] && isset($options['title']) && $options['title']) { global $plugins; if (isset($plugins[$options['owner_table']])) { $can_create = $can_edit = $can_view = $can_delete = false; // default to false if permissions exist. $can_view = $plugins[$options['owner_table']]->can_i('view', $options['title']); $can_edit = $plugins[$options['owner_table']]->can_i('edit', $options['title']); $can_create = $plugins[$options['owner_table']]->can_i('create', $options['title']); $can_delete = $plugins[$options['owner_table']]->can_i('delete', $options['title']); } } } if (!$can_view) { return; } //$html = ''; if ($owner_id && $owner_table) { // we have all that we need to display some groups!! yey!! // get a list of all groups. $fieldset_data = array(); $responsive_summary = array(); $group_items = self::get_groups($owner_table); foreach ($group_items as $key => $group_item) { $group_id = $group_item['group_id']; $sql = "SELECT * FROM `" . _DB_PREFIX . "group_member` gm WHERE `group_id` = {$group_id} AND `owner_id` = '" . mysql_real_escape_string($owner_id) . "' AND owner_table = '" . mysql_real_escape_string($owner_table) . "'"; $res = query($sql); if (mysql_num_rows($res)) { $group_items[$key]['checked'] = true; $responsive_summary[] = htmlspecialchars($group_item['name']); } mysql_free_result($res); } if (isset($options['title']) && $options['title']) { $fieldset_data['heading'] = array('title' => $options['title'], 'type' => 'h3', 'responsive' => array('summary' => implode(', ', $responsive_summary))); } ob_start(); //<div class="content_box_wheader"> ?> <table class="tableclass tableclass_full tableclass_form"> <tbody> <?php if (isset($options['description']) && $options['description']) { ?> <tr> <td colspan="2"> <?php echo $options['description']; ?> </td> </tr> <?php } foreach ($group_items as $group_item) { $group_id = $group_item['group_id']; ?> <tr id="group_<?php echo $group_id; ?> "> <th class="width1"<?php if (self::can_i('edit', 'Groups')) { ?> data-settings-url="<?php echo module_group::link_open($group_id, false); ?> " <?php } ?> > <?php if ($can_edit) { ?> <input type="hidden" name="group_module[<?php echo $owner_table; ?> ][<?php echo $group_id; ?> ]" value="<?php echo htmlspecialchars($owner_id); ?> "> <input type="checkbox" name="used_group_module[<?php echo $owner_table; ?> ][<?php echo $group_id; ?> ]" id="groupchk<?php echo $owner_table . $group_id; ?> " value="<?php echo htmlspecialchars($owner_id); ?> " <?php echo isset($group_item['checked']) && $group_item['checked'] ? ' checked' : ''; ?> > <?php } else { ?> <input type="checkbox" name="group" value="<?php echo htmlspecialchars($owner_id); ?> " <?php echo isset($group_item['checked']) && $group_item['checked'] ? ' checked' : ''; ?> disabled=""> <?php } ?> </th> <td> <label for="groupchk<?php echo $owner_table . $group_id; ?> "><?php echo htmlspecialchars($group_item['name']); ?> </label> </td> </tr> <?php } if ($can_create && module_security::is_page_editable() && get_display_mode() != 'mobile') { $group_id = 'new'; ?> <tr id="group_<?php echo $group_id; ?> "> <th class="width1"> <input type="hidden" name="group_module[<?php echo $owner_table; ?> ][<?php echo $group_id; ?> ]" value="<?php echo htmlspecialchars($owner_id); ?> "> <input type="checkbox" name="used_group_module[<?php echo $owner_table; ?> ][<?php echo $group_id; ?> ]" id="groupchk<?php echo $owner_table . $group_id; ?> " value="<?php echo htmlspecialchars($owner_id); ?> "> </th> <td> <label for="groupchk<?php echo $owner_table . $group_id; ?> "></label> <input type="text" name="group_module_name[<?php echo $owner_table; ?> ][<?php echo $group_id; ?> ]" autocomplete="off"> </td> </tr> <?php } ?> </tbody> </table> <?php //</div> $fieldset_data['elements_before'] = ob_get_clean(); echo module_form::generate_fieldset($fieldset_data); } //print $html; }
?> </th> </tr> </thead> <tbody> <?php $c = 0; foreach ($groups as $group) { ?> <tr class="<?php echo $c++ % 2 ? "odd" : "even"; ?> "> <td class="row_action"> <?php echo module_group::link_open($group['group_id'], true); ?> </td> <td> <?php echo $group['owner_table']; ?> </td> <td> <?php echo $group['count']; ?> </td> </tr> <?php }