You are here

function mostpopular_services_admin_form_add_service in Drupal Most Popular 7

1 string reference to 'mostpopular_services_admin_form_add_service'
mostpopular_services_admin_form in ./mostpopular.services.inc
Renders a form for configuring the blocks and services.

File

./mostpopular.services.inc, line 174
Provides an admin GUI for configuring services.

Code

function mostpopular_services_admin_form_add_service(&$form, &$form_state) {
  $type = $form_state['values']['add_service']['service'];
  list($module, $delta) = explode('|', $type);
  if (!empty($module) && !empty($delta)) {

    // Load the defaults for this service.
    $service = mostpopular_service_info($module, $delta);

    // Attach the service to the last block
    $blocks = $form_state['blocks'];
    $block = reset(array_reverse($blocks));
    if ($service && $block) {
      $service += array(
        'bid' => $block->bid,
        'enabled' => 0,
        'status' => MOSTPOPULAR_SERVICE_STATUS_DISABLED,
        'title' => $service['name'],
        'weight' => 0,
      );

      // Save the service
      mostpopular_service_save($service);
    }
  }
  $form['rebuild'] = TRUE;
}