* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /** * Default stage type for Scoutle. */ define('SCOUTLE_STAGE', 'dynamic180'); /** * The type of host system reported to Scoutle. */ define('SCOUTLE_HOST', 'drupal'); /** * Help text for the module. * @return HTML help text for the scoutle module. */ function scoutle_help($path, $arg) { switch ($path) { case 'admin/help#scoutle': return '

' . t('Support for the Scoutle social networking service. It enables the use of Scoutle stages that can be embedded in websites which connect blogs to other related blogs. In order to embed a stage, the website has to be registered with a scout on Scoutle, which will give you the scout hash necessary for configuring the stage.') . '

'; case 'admin/settings/scoutle': return '

' . t('Configure the stage for Scoutle. The scout hash should be available at Scoutle if this website has been registered.') . '

'; } } /** * Valid permissions for the module. * @return An array of valid permissions for the scoutle module. */ function scoutle_permission() { return array( 'administer scoutle' => array( 'title' => t('Administer Scoutle'), 'description' => t('Administer the settings for the Scoutle stage.'), ), 'access scoutle stage' => array( 'title' => t('Access Scoutle stage'), 'description' => t('View the Scoutle stage.'), ), ); } /** * Return the blocks available from the scoutle module. * @return available blocks */ function scoutle_block_info() { $blocks['stage'] = array( 'info' => t('Scoutle stage'), 'cache' => DRUPAL_CACHE_GLOBAL, ); return $blocks; } /** * Generate HTML for a Scoutle block. * @param delta the block to return * @return a Scoutle block */ function scoutle_block_view($delta = '') { if ($delta != 'stage' || !user_access('access scoutle stage')) { return NULL; } $hash = urlencode(variable_get('scoutle_hash', '')); $stage = urlencode(variable_get('scoutle_stage', SCOUTLE_STAGE)); $host = SCOUTLE_HOST; // identifies type of host to Scoutle $message = t('Connect with me at Scoutle.com'); // for missing JavaScript if ($hash == '') { return NULL; // do not output widget } $block['subject'] = ''; if ($stage == 'static') { $block['content'] = <<{$message} EOT; } else { $block['content'] = << EOT; } return $block; } /** * Form for configuring the scoutle module. * @return Form for configuring the settings. */ function scoutle_admin() { $stage_options = array( 'dynamic180' => t('Dynamic stage (180x240)'), 'dynamic125' => t('Dynamic stage (125x220)'), 'classic' => t('Classic stage'), 'mini' => t('Mini stage'), 'static' => t('Static stage (not recommended)'), ); $form['scoutle_hash'] = array( '#type' => 'textfield', '#title' => t('Scout Hash'), '#default_value' => variable_get('scoutle_hash', ''), '#size' => 32, '#maxlength' => 32, '#description' => t('The hash associated with the Scoutle scout.'), '#required' => TRUE, ); $form['scoutle_stage'] = array( '#type' => 'radios', '#title' => t('Type of stage'), '#options' => $stage_options, '#default_value' => variable_get('scoutle_stage', SCOUTLE_STAGE), '#description' => t('The type of stage to embed within this website.'), '#required' => TRUE, ); return system_settings_form($form); } /** * Validate form input when configuring settings for the scoutle module. * @see scoutle_admin() */ function scoutle_admin_validate($form, &$form_state) { $hash = $form_state['values']['scoutle_hash']; $stage = $form_state['values']['scoutle_stage']; if (strlen($hash) != 32 || !preg_match('/^([a-f]|[0-9])*$/', $hash)) { form_set_error('scoutle_hash', t('You must select a valid hash associated with a scout.')); } if (!in_array($stage, array('dynamic180', 'dynamic125', 'classic', 'mini', 'static'))) { form_set_error('scoutle_stage', t('You must set a valid type for the stage.')); } } /** * Defines the menu settings for the scoutle module. * @return the menu settings. */ function scoutle_menu() { $items = array(); $items['admin/config/services/scoutle'] = array( 'title' => 'Scoutle', 'description' => 'Configure the settings for the Scoutle stage.', 'page callback' => 'drupal_get_form', 'page arguments' => array('scoutle_admin'), 'access arguments' => array('administer scoutle'), 'type' => MENU_NORMAL_ITEM, ); return $items; }