You are here

function og_block in Organic groups 6

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. 5.7 og.module \og_block()
  6. 6.2 og.module \og_block()

Implementation of hook_block().

File

./og.module, line 2387

Code

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

    // $blocks[1] used to be the album block. We do not change the numbers to not confuse people who update.
    // $blocks[2] used to be the group members block. This is now served by Views. We do not change the numbers to not confuse people who update.
    $blocks[3]['info'] = t('New groups');
    $blocks[3]['cache'] = BLOCK_CACHE_PER_USER;

    // Now provided by og_views. Please don't reuse this number 4
    // $blocks[4]['info'] = t('My groups');
    // Notification modules must now provide this.
    // $blocks[5]['info'] = t('Group notifications');
    // $blocks[5]['cache'] = BLOCK_NO_CACHE;
    // Now provided by og_views. Please don't reuse this number 6
    // $blocks[6]['info'] = t('Group network');
    // Auto-enable the group blocks for fresh installations.
    // TODOL: In order for this to work, you must rehash blocks during install which has been problematic.
    // $blocks[0]['status'] = 1;
    //     $blocks[0]['region'] = 'left';
    //     $blocks[0]['weight'] = -2;
    //     $blocks[5]['status'] = 1;
    //     $blocks[5]['region'] = 'left';
    //     $blocks[5]['weight'] = -1;
    return $blocks;
  }
  elseif ($op == 'view') {
    switch ($delta) {
      case 0:
        return og_block_details();
      case 3:
        return og_block_new();
    }
  }
  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;
    }
  }
}