/**
 * Get the users based on groups from the User Access Manager plugin
 * $meta_filter can be '', MAILUSERS_ACCEPT_NOTIFICATION_USER_META, or MAILUSERS_ACCEPT_MASS_EMAIL_USER_META
 */
function mailusers_get_recipients_from_itthinx_groups_group($itthinx_groups_ids, $exclude_id = '', $meta_filter = '')
{
    global $wpdb;
    $ids = array();
    //  Make sure we have an array
    if (!is_array($itthinx_groups_ids)) {
        $itthinx_groups_ids = array($itthinx_groups_ids);
    }
    //  No groups?  Return an empty array
    if (empty($itthinx_groups_ids)) {
        return array();
    }
    foreach ($itthinx_groups_ids as $key => $value) {
        $group = new Groups_Group($value);
        foreach ($group->__get('users') as $u) {
            $ids[] = $u->user->ID;
        }
    }
    //  Make sure the list of IDs accounts for the Email Users settings for email
    $ids = mailusers_get_recipients_from_ids($ids, $exclude_id, $meta_filter);
    return $ids;
}
예제 #2
0
 /**
  * Renders a list of the site's groups.
  * Attributes:
  * - "format" : one of "list" "div" "ul" or "ol" - "list" and "ul" are equivalent
  * - "list_class" : defaults to "groups"
  * - "item_class" : defaults to "name"
  * - "order_by"   : defaults to "name", also accepts "group_id"
  * - "order"      : default to "ASC", also accepts "asc", "desc" and "DESC"
  *
  * @param array $atts attributes
  * @param string $content not used
  * @return rendered groups
  */
 public static function groups_groups($atts, $content = null)
 {
     global $wpdb;
     $output = "";
     $options = shortcode_atts(array('format' => 'list', 'list_class' => 'groups', 'item_class' => 'name', 'order_by' => 'name', 'order' => 'ASC'), $atts);
     switch ($options['order_by']) {
         case 'group_id':
         case 'name':
             $order_by = $options['order_by'];
             break;
         default:
             $order_by = 'name';
     }
     switch ($options['order']) {
         case 'asc':
         case 'ASC':
         case 'desc':
         case 'DESC':
             $order = strtoupper($options['order']);
             break;
         default:
             $order = 'ASC';
     }
     $group_table = _groups_get_tablename("group");
     if ($groups = $wpdb->get_results("SELECT group_id FROM {$group_table} ORDER BY {$order_by} {$order}")) {
         switch ($options['format']) {
             case 'list':
             case 'ul':
                 $output .= '<ul class="' . esc_attr($options['list_class']) . '">';
                 break;
             case 'ol':
                 $output .= '<ol class="' . esc_attr($options['list_class']) . '">';
                 break;
             default:
                 $output .= '<div class="' . esc_attr($options['list_class']) . '">';
         }
         foreach ($groups as $group) {
             $group = new Groups_Group($group->group_id);
             switch ($options['format']) {
                 case 'list':
                 case 'ul':
                 case 'ol':
                     $output .= '<li class="' . esc_attr($options['item_class']) . '">' . $group->__get('name') . '</li>';
                     break;
                 default:
                     $output .= '<div class="' . esc_attr($options['item_class']) . '">' . $group->__get('name') . '</div>';
             }
         }
         switch ($options['format']) {
             case 'list':
             case 'ul':
                 $output .= '</ul>';
                 break;
             case 'ol':
                 $output .= '</ol>';
                 break;
             default:
                 $output .= '</div>';
         }
     }
     return $output;
 }