You are here

function og_block in Organic groups 5.7

Same name and namespace in other branches
  1. 5.8 og.module \og_block()
  2. 5 og.module \og_block()
  3. 5.2 og.module \og_block()
  4. 5.3 og.module \og_block()
  5. 6.2 og.module \og_block()
  6. 6 og.module \og_block()

Implementation of hook_block().

File

./og.module, line 2374

Code

function og_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Group details');

    // $blocks[1] used to be the album block. We do not change the numbers to not confuse people who update.
    $blocks[2]['info'] = t('Group members');
    $blocks[3]['info'] = t('New groups');

    // Now provided by og_views. Please don't reuse this number 4
    // $blocks[4]['info'] = t('My groups');
    $blocks[5]['info'] = t('Group notifications');
    $blocks[6]['info'] = t('Group network');

    // Auto-enable the group blocks for fresh installations.
    $blocks[0]['status'] = 1;
    $blocks[0]['weight'] = -2;
    $blocks[5]['status'] = 1;
    $blocks[5]['weight'] = -1;
    return $blocks;
  }
  elseif ($op == 'view') {
    switch ($delta) {
      case 0:
        return og_block_details();
      case 2:
        return og_block_subscribers();
      case 3:
        return og_block_new();
      case 5:
        return og_block_notifications();
      case 6:
        return og_block_users_network();
    }
  }
  elseif ($op == 'configure') {
    switch ($delta) {
      case 2:
        $items['og_block_cnt'] = array(
          '#type' => 'textfield',
          '#title' => t('Maximum number of members to show'),
          '#default_value' => variable_get("og_block_cnt_{$delta}", 10),
          '#size' => 5,
        );
        $items['og_block_subscribers_is_admin'] = array(
          '#type' => 'checkboxes',
          '#title' => t('Group roles'),
          '#default_value' => variable_get("og_block_subscribers_is_admin", array(
            'members',
            'admins',
          )),
          '#options' => array(
            'members' => t('Standard members'),
            'admins' => t('Administrators'),
          ),
          '#description' => t('You may specify which types of group members appear in the listing.'),
        );
        return $items;
      case 3:
        return array(
          'og_block_cnt' => array(
            '#type' => 'textfield',
            '#title' => t('Maximum number of groups to show'),
            '#default_value' => variable_get("og_block_cnt_{$delta}", 10),
            '#size' => 5,
            '#maxlength' => 255,
          ),
        );
    }
  }
  elseif ($op == 'save') {
    switch ($delta) {
      case 2:
        if (isset($edit['og_block_subscribers_is_admin'])) {
          variable_set("og_block_subscribers_is_admin", array_filter($edit['og_block_subscribers_is_admin']));
        }
        if (isset($edit['og_block_cnt'])) {
          variable_set("og_block_cnt_{$delta}", $edit['og_block_cnt']);
        }
        break;
      case 3:
        if (isset($edit['og_block_cnt'])) {
          variable_set("og_block_cnt_{$delta}", $edit['og_block_cnt']);
        }
        break;
    }
  }
}