diff -ruP drupal-6.2/includes/app.inc da/includes/app.inc --- drupal-6.2/includes/app.inc 1970-01-01 10:00:00.000000000 +1000 +++ da/includes/app.inc 2008-06-03 16:03:43.093750000 +1000 @@ -0,0 +1,312 @@ + 'User account', + 'page callback' => 'user_page', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + + $items['logout'] = array( + 'title' => 'Log out', + 'access callback' => 'user_is_logged_in', + 'page callback' => 'user_logout', + 'weight' => 10 + ); + } + + return $items; +} + +if (!app_module_exists('user')) { + define('USERNAME_MAX_LENGTH', 60); + define('EMAIL_MAX_LENGTH', 64); + + function user_is_anonymous() { + // Menu administrators can see items for anonymous when administering. + return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']); + } + + /** + * Access callback for path /user. + * + * Displays user profile if user is logged in, or login form for anonymous users. + */ + function user_page() { + global $user; + + return drupal_get_form('user_login'); + } + + /** + * Form builder; the main user login form. + * + * @ingroup forms + */ + function user_login(&$form_state) { + global $user; + + // If we are already logged on, go to the user page instead. + if ($user->uid) { + // Display login form: + $form['status'] = array('#value' => t('

You have successfully logged in.

')); + $form['admin-link'] = array('#value' => '

'.l('Go to admin page', 'admin').'

'); + $form['logout'] = array('#type' => 'submit', '#value' => t('Log Out') ); + $form['#validate'] = array('user_logout'); + } else { + // Display login form: + $form['name'] = array('#type' => 'textfield', + '#title' => t('Username'), + '#size' => 60, + '#maxlength' => USERNAME_MAX_LENGTH, + '#required' => TRUE, + '#attributes' => array('tabindex' => '1'), + ); + + $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal'))); + $form['pass'] = array('#type' => 'password', + '#title' => t('Password'), + '#description' => t('Enter the password that accompanies your username.'), + '#required' => TRUE, + '#attributes' => array('tabindex' => '2'), + ); + $form['#validate'] = user_login_default_validators(); + $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3')); + } + + return $form; + } + + /** + * Set up a series for validators which check for blocked/denied users, + * then authenticate against local database, then return an error if + * authentication fails. Distributed authentication modules are welcome + * to use hook_form_alter() to change this series in order to + * authenticate against their user database instead of the local users + * table. + * + * We use three validators instead of one since external authentication + * modules usually only need to alter the second validator. + * + * @see user_login_name_validate() + * @see user_login_authenticate_validate() + * @see user_login_final_validate() + * @return array + * A simple list of validate functions. + */ + function user_login_default_validators() { + return array('user_login_authenticate_validate', 'user_login_final_validate'); + } + + /** + * A validate handler on the login form. Check supplied username/password + * against local users table. If successful, sets the global $user object. + */ + function user_login_authenticate_validate($form, &$form_state) { + user_authenticate($form_state['values']); + } + + /** + * Try to log in the user locally. + * + * @param $form_values + * Form values with at least 'name' and 'pass' keys, as well as anything else + * which should be passed along to hook_user op 'login'. + * + * @return + * A $user object, if successful. + */ + function user_authenticate($form_values = array()) { + global $user; + + // Name and pass keys are required. + $user = new stdClass(); + if (!empty($form_values['name']) && !empty($form_values['pass'])) { + if ($form_values['name'] == variable_get('admin_username', '') && + md5($form_values['pass']) == variable_get('admin_password', 0)) { + $_SESSION['admin_authenticated'] = TRUE; + $user = drupal_admin_user(); + } else { + $user = array(); + } + user_authenticate_finalize($form_values); + return $user; + } + } + + /** + * Finalize the login process. Must be called when logging in a user. + * + * The function records a watchdog message about the new session, saves the + * login timestamp, calls hook_user op 'login' and generates a new session. + * + * $param $edit + * This array is passed to hook_user op login. + */ + function user_authenticate_finalize(&$edit) { + global $user; + watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); + // Update the user table timestamp noting user has logged in. + // This is also used to invalidate one-time login links. + $user->login = time(); + user_module_invoke('login', $edit, $user); + sess_regenerate(); + } + + /** + * A validate handler on the login form. Should be the last validator. Sets an + * error if user has not been authenticated yet. + */ + function user_login_final_validate($form, &$form_state) { + global $user; + + if (!$user->uid) { + form_set_error('name', t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password')))); + watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name'])); + } + } + + /** + * Invokes hook_user() in every module. + * + * We cannot use module_invoke() for this, because the arguments need to + * be passed by reference. + */ + function user_module_invoke($type, &$array, &$user, $category = NULL) { + foreach (module_list() as $module) { + $function = $module .'_user'; + if (function_exists($function)) { + $function($type, $array, $user, $category); + } + } + } + + function user_is_logged_in() { + return (bool)$GLOBALS['user']->uid; + } + + /** + * Determine whether the user has a given privilege. + * + * @param $string + * The permission, such as "administer nodes", being checked for. + * @param $account + * (optional) The account to check, if not given use currently logged in user. + * @param $reset + * (optional) Resets the user's permissions cache, which will result in a + * recalculation of the user's permissions. This is necessary to support + * dynamically added user roles. + * + * @return + * Boolean TRUE if the current user has the requested permission. + * + * All permission checks in Drupal should go through this function. This + * way, we guarantee consistent behavior, and ensure that the superuser + * can perform all actions. + */ + function user_access($string) { + // Without the user module, just check if logged on as administrator + if ($_SESSION['admin_authenticated'] == TRUE) { + return TRUE; + } else { + if (strstr($string, 'admin')) { + return FALSE; // TODO: needs to be FALSE to have any effect + } else { + return TRUE; + } + } + } + + /** + * Menu callback; logs the current user out, and redirects to the home page. + */ + function user_logout() { + global $user; + + watchdog('user', 'Session closed for %name.', array('%name' => $user->name)); + + // Destroy the current session: + session_destroy(); + module_invoke_all('user', 'logout', NULL, $user); + + // Load the anonymous user + $user = drupal_anonymous_user(); + + drupal_goto(); + } +} + +if (!app_module_exists('filter')) { + function filter_xss_bad_protocol($string, $decode = TRUE) { + static $allowed_protocols; + if (!isset($allowed_protocols)) { + $allowed_protocols = array_flip(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'))); + } + + // Get the plain text representation of the attribute value (i.e. its meaning). + if ($decode) { + $string = decode_entities($string); + } + + // Iteratively remove any invalid protocol found. + + do { + $before = $string; + $colonpos = strpos($string, ':'); + if ($colonpos > 0) { + // We found a colon, possibly a protocol. Verify. + $protocol = substr($string, 0, $colonpos); + // If a colon is preceded by a slash, question mark or hash, it cannot + // possibly be part of the URL scheme. This must be a relative URL, + // which inherits the (safe) protocol of the base document. + if (preg_match('![/?#]!', $protocol)) { + break; + } + // Per RFC2616, section 3.2.3 (URI Comparison) scheme comparison must be case-insensitive + // Check if this is a disallowed protocol. + if (!isset($allowed_protocols[strtolower($protocol)])) { + $string = substr($string, $colonpos + 1); + } + } + } while ($before != $string); + return check_plain($string); + } + + function filter_xss_admin($string) { return $string; } + function filter_access() { return TRUE; } + function filter_form() { return ''; } + function check_markup($text) { return $text; } +} + +?> \ No newline at end of file diff -ruP drupal-6.2/includes/bootstrap.inc da/includes/bootstrap.inc --- drupal-6.2/includes/bootstrap.inc 2008-02-12 01:36:21.000000000 +1100 +++ da/includes/bootstrap.inc 2008-06-03 16:09:16.515625000 +1000 @@ -373,7 +373,7 @@ if (!isset($files[$type])) { $files[$type] = array(); } - + if (!empty($filename) && file_exists($filename)) { $files[$type][$name] = $filename; } @@ -879,8 +879,12 @@ // We deny access if the only matching records in the {access} table have // status 0 (deny). If any have status 1 (allow), or if there are no // matching records, we allow access. - $sql = "SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) AND status = %d"; - return db_result(db_query_range($sql, $type, $mask, 0, 0, 1)) && !db_result(db_query_range($sql, $type, $mask, 1, 0, 1)); + if (db_table_exists('access')) { + $sql = "SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) AND status = %d"; + return db_result(db_query_range($sql, $type, $mask, 0, 0, 1)) && !db_result(db_query_range($sql, $type, $mask, 1, 0, 1)); + } else { + return FALSE; + } } /** @@ -900,6 +904,22 @@ } /** + * Generates an authenticated $user object. + * + * @return Object - the user object. + */ +function drupal_admin_user($session = '') { + $user = new stdClass(); + $user->uid = 1; + $user->hostname = ip_address(); + $user->roles = array(); + $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; + $user->session = $session; + $user->cache = 0; + return $user; +} + +/** * A string describing a phase of Drupal to load. Each phase adds to the * previous one, so invoking a later phase automatically runs the earlier * phases too. The most important usage is that if you want to access the @@ -1013,6 +1033,7 @@ break; case DRUPAL_BOOTSTRAP_FULL: + require_once './includes/app.inc'; require_once './includes/common.inc'; _drupal_bootstrap_full(); break; diff -ruP drupal-6.2/includes/cache.inc da/includes/cache.inc --- drupal-6.2/includes/cache.inc 2008-01-29 22:36:06.000000000 +1100 +++ da/includes/cache.inc 2008-06-03 15:58:58.328125000 +1000 @@ -136,7 +136,7 @@ if (!isset($cid) && !isset($table)) { // Clear the block cache first, so stale data will // not end up in the page cache. - cache_clear_all(NULL, 'cache_block'); + if (module_exists('block')) cache_clear_all(NULL, 'cache_block'); cache_clear_all(NULL, 'cache_page'); return; } diff -ruP drupal-6.2/includes/common.inc da/includes/common.inc --- drupal-6.2/includes/common.inc 2008-04-10 07:11:44.000000000 +1000 +++ da/includes/common.inc 2008-06-03 15:58:58.343750000 +1000 @@ -3520,8 +3520,9 @@ node_types_rebuild(); // Don't clear cache_form - in-progress form submissions may break. // Ordered so clearing the page cache will always be the last action. - $core = array('cache', 'cache_block', 'cache_filter', 'cache_page'); + $core = array('cache'); $cache_tables = array_merge(module_invoke_all('flush_caches'), $core); + $cache_tables[] = 'cache_page'; foreach ($cache_tables as $table) { cache_clear_all('*', $table, TRUE); } diff -ruP drupal-6.2/includes/module.inc da/includes/module.inc --- drupal-6.2/includes/module.inc 2007-12-27 23:31:05.000000000 +1100 +++ da/includes/module.inc 2008-06-03 15:58:58.343750000 +1000 @@ -325,7 +325,7 @@ foreach ($module_list as $module) { if (module_exists($module)) { // Check if node_access table needs rebuilding. - if (!node_access_needs_rebuild() && module_hook($module, 'node_grants')) { + if (module_exists('node') && !node_access_needs_rebuild() && module_hook($module, 'node_grants')) { node_access_needs_rebuild(TRUE); } @@ -345,7 +345,7 @@ // If there remains no more node_access module, rebuilding will be // straightforward, we can do it right now. - if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) { + if (module_exists('node') && node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) { node_access_rebuild(); } } @@ -488,5 +488,5 @@ * Array of modules required by core. */ function drupal_required_modules() { - return array('block', 'filter', 'node', 'system', 'user'); + return array('system'); // array('block', 'filter', 'node', 'system', 'user'); } diff -ruP drupal-6.2/includes/path.inc da/includes/path.inc --- drupal-6.2/includes/path.inc 2007-11-05 03:42:45.000000000 +1100 +++ da/includes/path.inc 2008-06-03 15:58:58.359375000 +1000 @@ -18,7 +18,7 @@ $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/')); } else { - $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node')); + $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'home')); } } @@ -218,7 +218,7 @@ function drupal_is_front_page() { // As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path, // we can check it against the 'site_frontpage' variable. - return $_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node')); + return $_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'home')); } /** @@ -236,7 +236,7 @@ static $regexps; if (!isset($regexps[$patterns])) { - $regexps[$patterns] = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($patterns, '/')) .')$/'; + $regexps[$patterns] = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'home'), '/') .'\2'), preg_quote($patterns, '/')) .')$/'; } return preg_match($regexps[$patterns], $path); } diff -ruP drupal-6.2/includes/session.inc da/includes/session.inc --- drupal-6.2/includes/session.inc 2008-02-07 22:58:40.000000000 +1100 +++ da/includes/session.inc 2008-06-03 17:04:23.562500000 +1000 @@ -28,6 +28,17 @@ return ''; } + // treat as anonymous if users module is not enabled + if (!db_table_exists('users')) { + $session = db_fetch_object(db_query("SELECT s.* FROM {sessions} s WHERE s.sid = '%s'", $key)); + if (strstr($session->session, 'admin_authenticated')) { // TODO: fix this hack!! + $user = drupal_admin_user($session->session); + } else { + $user = drupal_anonymous_user($session->session); + } + return $session->session; + } + // Otherwise, if the session is still active, we have a record of the client's session in the database. $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key)); diff -ruP drupal-6.2/includes/theme.inc da/includes/theme.inc --- drupal-6.2/includes/theme.inc 2008-03-25 22:55:08.000000000 +1100 +++ da/includes/theme.inc 2008-06-03 15:58:58.375000000 +1000 @@ -1711,7 +1711,7 @@ // Load all region content assigned via blocks. foreach (array_keys($regions) as $region) { // Prevent left and right regions from rendering blocks when 'show_blocks' == FALSE. - if (!(!$variables['show_blocks'] && ($region == 'left' || $region == 'right'))) { + if (module_exists('block') && !(!$variables['show_blocks'] && ($region == 'left' || $region == 'right'))) { $blocks = theme('blocks', $region); } else { diff -ruP drupal-6.2/install.php da/install.php --- drupal-6.2/install.php 2008-02-09 09:00:45.000000000 +1100 +++ da/install.php 2008-06-03 17:08:37.734375000 +1000 @@ -5,6 +5,9 @@ define('MAINTENANCE_MODE', 'install'); +define('USERNAME_MAX_LENGTH', 60); +define('EMAIL_MAX_LENGTH', 64); + /** * The Drupal installation happens in a series of steps. We begin by verifying * that the current environment meets our minimum requirements. We then go @@ -35,10 +38,8 @@ // Load module basics (needed for hook invokes). include_once './includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; - $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); - drupal_load('module', 'filter'); // Set up theme system for the maintenance page. drupal_maintenance_theme(); @@ -88,6 +89,13 @@ // Load the profile. require_once "./profiles/$profile/$profile.profile"; + if (in_array('filter', call_user_func($profile."_profile_core_modules"))) { + $module_list['filter']['filename'] = 'modules/filter/filter.module'; + drupal_load('module', 'filter'); + } else { + require_once './includes/app.inc'; + } + // Locale selection if (!empty($_GET['locale'])) { $install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']); @@ -523,27 +531,10 @@ } // One language, but not the default profile, assume // the user knows what he is doing. - return FALSE; + return _install_select_locale($locales, $profilename); } else { - // Allow profile to pre-select the language, skipping the selection. - $function = $profilename .'_profile_details'; - if (function_exists($function)) { - $details = $function(); - if (isset($details['language'])) { - foreach ($locales as $locale) { - if ($details['language'] == $locale->name) { - return $locale->name; - } - } - } - } - - foreach ($locales as $locale) { - if ($_POST['locale'] == $locale->name) { - return $locale->name; - } - } + _install_select_locale($locales, $profilename); install_task_list('locale-select'); @@ -553,6 +544,29 @@ } } +function _install_select_locale($locales, $profilename) { + // Allow profile to pre-select the language, skipping the selection. + $function = $profilename .'_profile_details'; + if (function_exists($function)) { + $details = $function(); + if (isset($details['language'])) { + foreach ($locales as $locale) { + if ($details['language'] == $locale->name) { + return $locale->name; + } + } + } + } + + foreach ($locales as $locale) { + if ($_POST['locale'] == $locale->name) { + return $locale->name; + } + } + + return FALSE; +} + /** * Form API array definition for language selection. */ @@ -707,7 +721,7 @@ } // Add JavaScript validation. - _user_password_dynamic_validation(); + if (module_exists('user')) _user_password_dynamic_validation(); drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module'); // We add these strings as settings because JavaScript translation does not // work on install time. @@ -1006,6 +1020,7 @@ '#required' => TRUE, '#weight' => -15, ); + $form['admin_account'] = array( '#type' => 'fieldset', '#title' => st('Administrator account'), @@ -1065,14 +1080,16 @@ '#weight' => 10, ); - $form['server_settings']['update_status_module'] = array( - '#type' => 'checkboxes', - '#title' => st('Update notifications'), - '#options' => array(1 => st('Check for updates automatically')), - '#default_value' => array(1), - '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is highly recommended. This requires your site to periodically send anonymous information on its installed components to drupal.org. For more information please see the update notification information.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), - '#weight' => 15, - ); + if (module_exists('update')) { + $form['server_settings']['update_status_module'] = array( + '#type' => 'checkboxes', + '#title' => st('Update notifications'), + '#options' => array(1 => st('Check for updates automatically')), + '#default_value' => array(1), + '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is highly recommended. This requires your site to periodically send anonymous information on its installed components to drupal.org. For more information please see the update notification information.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), + '#weight' => 15, + ); + } $form['submit'] = array( '#type' => 'submit', @@ -1096,18 +1113,50 @@ * Form API validate for the site configuration form. */ function install_configure_form_validate($form, &$form_state) { - if ($error = user_validate_name($form_state['values']['account']['name'])) { + if ($error = _install_configure_form_validate_name($form_state['values']['account']['name'])) { form_error($form['admin_account']['account']['name'], $error); } - if ($error = user_validate_mail($form_state['values']['account']['mail'])) { + if ($error = _install_configure_form_validate_name($form_state['values']['account']['mail'])) { form_error($form['admin_account']['account']['mail'], $error); } - if ($error = user_validate_mail($form_state['values']['site_mail'])) { + if ($error = _install_configure_form_validate_mail($form_state['values']['site_mail'])) { form_error($form['site_information']['site_mail'], $error); } } /** + * Verify the syntax of the given name. + */ +function _install_configure_form_validate_name($name) { + if (!strlen($name)) return t('You must enter a username.'); + if (substr($name, 0, 1) == ' ') return t('The username cannot begin with a space.'); + if (substr($name, -1) == ' ') return t('The username cannot end with a space.'); + if (strpos($name, ' ') !== FALSE) return t('The username cannot contain multiple spaces in a row.'); + if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.'); + if (preg_match('/[\x{80}-\x{A0}'. // Non-printable ISO-8859-1 + NBSP + '\x{AD}'. // Soft-hyphen + '\x{2000}-\x{200F}'. // Various space characters + '\x{2028}-\x{202F}'. // Bidirectional text overrides + '\x{205F}-\x{206F}'. // Various text hinting characters + '\x{FEFF}'. // Byte order mark + '\x{FF01}-\x{FF60}'. // Full-width latin + '\x{FFF9}-\x{FFFD}'. // Replacement characters + '\x{0}]/u', // NULL byte + $name)) { + return t('The username contains an illegal character.'); + } + if (strpos($name, '@') !== FALSE && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.'); + if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH)); +} + +function _install_configure_form_validate_mail($mail) { + if (!$mail) return t('You must enter an e-mail address.'); + if (!valid_email_address($mail)) { + return t('The e-mail address %mail is not valid.', array('%mail' => $mail)); + } +} + +/** * Form API submit for the site configuration form. */ function install_configure_form_submit($form, &$form_state) { @@ -1128,11 +1177,18 @@ $form_state['values'] = $form_state['values']['account']; // We precreated user 1 with placeholder values. Let's save the real values. - $account = user_load(1); - $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 1); - user_save($account, array_merge($form_state['values'], $merge_data)); - // Log in the first user. - user_authenticate($form_state['values']); + if (module_exists('user')) { + $account = user_load(1); + $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 1); + user_save($account, array_merge($form_state['values'], $merge_data)); + // Log in the first user. + user_authenticate($form_state['values']); + } else { + variable_set('admin_username', $form_state['values']['name']); + variable_set('admin_email', $form_state['values']['mail']); + variable_set('admin_password', md5($form_state['values']['pass'])); + } + $form_state['values'] = $form_state['old_values']; unset($form_state['old_values']); variable_set('user_email_verification', TRUE); diff -ruP drupal-6.2/modules/block/block.info da/modules/block/block.info --- drupal-6.2/modules/block/block.info 2008-04-10 07:20:08.000000000 +1000 +++ da/modules/block/block.info 2008-06-03 15:58:58.375000000 +1000 @@ -1,7 +1,7 @@ ; $Id: block.info,v 1.4 2007/06/08 05:50:53 dries Exp $ name = Block description = Controls the boxes that are displayed around the main content. -package = Core - required +package = Core - optional version = VERSION core = 6.x diff -ruP drupal-6.2/modules/block/block.install da/modules/block/block.install --- drupal-6.2/modules/block/block.install 2007-12-18 23:59:20.000000000 +1100 +++ da/modules/block/block.install 2008-06-03 15:58:58.390625000 +1000 @@ -2,6 +2,27 @@ // $Id: block.install,v 1.8 2007/12/18 12:59:20 dries Exp $ /** + * Implementation of hook_install(). + */ +function block_install() { + // Create tables. + drupal_install_schema('block'); + + // Add default blocks. + db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '0', 'garland', 1, 0, 'left', '', -1); + db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '1', 'garland', 1, 0, 'left', '', -1); + db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', '0', 'garland', 1, 10, 'footer', '', -1); +} + +/** + * Implementation of hook_uninstall(). + */ +function block_uninstall() { + // Remove tables. + drupal_uninstall_schema('block'); +} + +/** * Implementation of hook_schema(). */ function block_schema() { diff -ruP drupal-6.2/modules/block/block.module da/modules/block/block.module --- drupal-6.2/modules/block/block.module 2008-04-10 07:11:45.000000000 +1000 +++ da/modules/block/block.module 2008-06-03 15:58:58.390625000 +1000 @@ -500,6 +500,14 @@ } /** + * Implementation of hook_flush_caches(). + * + */ +function block_flush_caches() { + return array('cache_block'); +} + +/** * Assemble the cache_id to use for a given block. * * The cache_id string reflects the viewing context for the current block diff -ruP drupal-6.2/modules/comment/comment.info da/modules/comment/comment.info --- drupal-6.2/modules/comment/comment.info 2008-04-10 07:20:08.000000000 +1000 +++ da/modules/comment/comment.info 2008-06-03 15:58:58.406250000 +1000 @@ -1,6 +1,7 @@ ; $Id: comment.info,v 1.4 2007/06/08 05:50:54 dries Exp $ name = Comment description = Allows users to comment on and discuss published content. +dependencies[] = user package = Core - optional version = VERSION core = 6.x diff -ruP drupal-6.2/modules/comment/comment.install da/modules/comment/comment.install --- drupal-6.2/modules/comment/comment.install 2008-01-17 08:45:30.000000000 +1100 +++ da/modules/comment/comment.install 2008-06-03 15:58:58.406250000 +1000 @@ -2,6 +2,25 @@ // $Id: comment.install,v 1.19 2008/01/16 21:45:30 goba Exp $ /** + * Implementation of hook_install(). + */ +function comment_install() { + // Create tables. + drupal_install_schema('comment'); + + // Add default entries + db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 2, 'access comments, access content, post comments, post comments without approval', 0); +} + +/** + * Implementation of hook_uninstall(). + */ +function comment_uninstall() { + // Remove tables. + drupal_uninstall_schema('comment'); +} + +/** * Implementation of hook_enable(). */ function comment_enable() { diff -ruP drupal-6.2/modules/filter/filter.info da/modules/filter/filter.info --- drupal-6.2/modules/filter/filter.info 2008-04-10 07:20:08.000000000 +1000 +++ da/modules/filter/filter.info 2008-06-03 17:12:50.734375000 +1000 @@ -1,7 +1,7 @@ ; $Id: filter.info,v 1.4 2007/06/08 05:50:54 dries Exp $ name = Filter description = Handles the filtering of content in preparation for display. -package = Core - required +package = Core - optional version = VERSION core = 6.x diff -ruP drupal-6.2/modules/filter/filter.install da/modules/filter/filter.install --- drupal-6.2/modules/filter/filter.install 2007-12-18 23:59:21.000000000 +1100 +++ da/modules/filter/filter.install 2008-06-03 15:58:58.406250000 +1000 @@ -2,6 +2,50 @@ // $Id: filter.install,v 1.5 2007/12/18 12:59:21 dries Exp $ /** + * Implementation of hook_install(). + */ +function filter_install() { + // Create tables. + drupal_install_schema('filter'); + + // Add input formats. + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',1,2,', 1); + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1); + + // Enable filters for each input format. + + // Filtered HTML: + // URL filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 2, 0); + // HTML filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 0, 1); + // Line break filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 1, 2); + // HTML corrector filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 3, 10); + + // Full HTML: + // URL filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 2, 0); + // Line break filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 1, 1); + // HTML corrector filter. + db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 3, 10); + + db_query("INSERT INTO {variable} (name, value) VALUES ('%s','%s')", 'filter_html_1', 'i:1;'); +} + +/** + * Implementation of hook_uninstall(). + */ +function filter_uninstall() { + db_query("DELETE FROM {variable} WHERE name = 'filter_html_1'"); + + // Remove tables. + drupal_uninstall_schema('filter'); +} + +/** * Implementation of hook_schema(). */ function filter_schema() { diff -ruP drupal-6.2/modules/filter/filter.module da/modules/filter/filter.module --- drupal-6.2/modules/filter/filter.module 2008-04-10 07:11:47.000000000 +1000 +++ da/modules/filter/filter.module 2008-06-03 15:58:58.406250000 +1000 @@ -286,6 +286,14 @@ } /** + * Implementation of hook_flush_caches(). + * + */ +function filter_flush_caches() { + return array('cache_filter'); +} + +/** * Retrieve a list of input formats. */ function filter_formats($index = NULL) { diff -ruP drupal-6.2/modules/node/node.info da/modules/node/node.info --- drupal-6.2/modules/node/node.info 2008-04-10 07:20:08.000000000 +1000 +++ da/modules/node/node.info 2008-06-03 17:13:04.234375000 +1000 @@ -1,7 +1,7 @@ ; $Id: node.info,v 1.4 2007/06/08 05:50:55 dries Exp $ name = Node description = Allows content to be submitted to the site and displayed on pages. -package = Core - required +package = Core - optional version = VERSION core = 6.x diff -ruP drupal-6.2/modules/node/node.install da/modules/node/node.install --- drupal-6.2/modules/node/node.install 2007-12-18 23:59:21.000000000 +1100 +++ da/modules/node/node.install 2008-06-03 15:58:58.421875000 +1000 @@ -2,6 +2,28 @@ // $Id: node.install,v 1.4 2007/12/18 12:59:21 dries Exp $ /** + * Implementation of hook_install(). + */ +function node_install() { + // Create tables. + drupal_install_schema('node'); + + // Add default node data + db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0); + db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_options_forum', 'a:1:{i:0;s:6:"status";}'); +} + +/** + * Implementation of hook_uninstall(). + */ +function node_uninstall() { + db_query("DELETE FROM {variable} WHERE name = 'node_options_forum'"); + + // Remove tables. + drupal_uninstall_schema('node'); +} + +/** * Implementation of hook_schema(). */ function node_schema() { @@ -331,5 +353,4 @@ ); return $schema; -} - +} \ No newline at end of file diff -ruP drupal-6.2/modules/system/system.admin.inc da/modules/system/system.admin.inc --- drupal-6.2/modules/system/system.admin.inc 2008-03-25 22:58:16.000000000 +1100 +++ da/modules/system/system.admin.inc 2008-06-03 15:58:58.421875000 +1000 @@ -89,7 +89,11 @@ */ function system_admin_compact_page($mode = 'off') { global $user; - user_save($user, array('admin_compact_mode' => ($mode == 'on'))); + if (module_exists('user')) { + user_save($user, array('admin_compact_mode' => ($mode == 'on'))); + } else { + variable_set('admin_compact_mode', $mode == 'on' ? TRUE : FALSE); + } drupal_goto('admin'); } @@ -388,7 +392,7 @@ // Some features are not always available $disabled = array(); - if (!variable_get('user_pictures', 0)) { + if (!module_exists('node') || !variable_get('user_pictures', 0)) { $disabled['toggle_node_user_picture'] = TRUE; $disabled['toggle_comment_user_picture'] = TRUE; } @@ -420,7 +424,7 @@ ); // Toggle node display. - $node_types = node_get_types('names'); + if (module_exists('node')) $node_types = node_get_types('names'); if ($node_types) { $form['node_info'] = array( '#type' => 'fieldset', @@ -619,7 +623,7 @@ */ function system_modules($form_state = array()) { drupal_rebuild_theme_registry(); - node_types_rebuild(); + if (module_exists('node')) node_types_rebuild(); menu_rebuild(); cache_clear_all('schema', 'cache'); // Get current list of modules. @@ -1166,7 +1170,7 @@ $form['site_frontpage'] = array( '#type' => 'textfield', '#title' => t('Default front page'), - '#default_value' => variable_get('site_frontpage', 'node'), + '#default_value' => variable_get('site_frontpage', 'home'), '#size' => 40, '#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'), '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), @@ -1702,7 +1706,7 @@ } // MySQL import might have set the uid of the anonymous user to autoincrement // value. Let's try fixing it. See http://drupal.org/node/204411 - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0"); + if (db_table_exists('users')) db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0"); return theme('status_report', $requirements); } diff -ruP drupal-6.2/modules/system/system.install da/modules/system/system.install --- drupal-6.2/modules/system/system.install 2008-02-09 04:07:55.000000000 +1100 +++ da/modules/system/system.install 2008-06-03 15:58:58.437500000 +1000 @@ -300,6 +300,8 @@ * Implementation of hook_install(). */ function system_install() { + global $profile; + if ($GLOBALS['db_type'] == 'pgsql') { // Create unsigned types. db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)"); @@ -339,71 +341,16 @@ } // Create tables. - $modules = array('system', 'filter', 'block', 'user', 'node', 'comment', 'taxonomy'); - foreach ($modules as $module) { + $function = $profile .'_profile_core_modules'; + $core_modules = $function(); + foreach ($core_modules as $module) { drupal_install_schema($module); } // Load system theme data appropriately. system_theme_data(); - - // Inserting uid 0 here confuses MySQL -- the next user might be created as - // uid 2 which is not what we want. So we insert the first user here, the - // anonymous user. uid is 1 here for now, but very soon it will be changed - // to 0. - db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', ''); - // We need some placeholders here as name and mail are uniques and data is - // presumed to be a serialized array. Install will change uid 1 immediately - // anyways. So we insert the superuser here, the uid is 2 here for now, but - // very soon it will be changed to 1. - db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); - // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 - // otherwise MySQL might insert the next auto_increment value. - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); - // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. - db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); - - db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user'); - db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); - - db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 1, 'access content', 0); - db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 2, 'access comments, access content, post comments, post comments without approval', 0); - db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";'); db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland'); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '0', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '1', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', '0', 'garland', 1, 10, 'footer', '', -1); - - db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0); - - // Add input formats. - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',1,2,', 1); - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1); - - // Enable filters for each input format. - - // Filtered HTML: - // URL filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 2, 0); - // HTML filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 0, 1); - // Line break filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 1, 2); - // HTML corrector filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 3, 10); - - // Full HTML: - // URL filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 2, 0); - // Line break filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 1, 1); - // HTML corrector filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 3, 10); - - db_query("INSERT INTO {variable} (name, value) VALUES ('%s','%s')", 'filter_html_1', 'i:1;'); - - db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_options_forum', 'a:1:{i:0;s:6:"status";}'); } /** diff -ruP drupal-6.2/modules/system/system.module da/modules/system/system.module --- drupal-6.2/modules/system/system.module 2008-04-10 07:11:49.000000000 +1000 +++ da/modules/system/system.module 2008-06-03 15:58:58.437500000 +1000 @@ -422,14 +422,16 @@ 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); - $items['admin/content/rss-publishing'] = array( - 'title' => 'RSS publishing', - 'description' => 'Configure the number of items per feed and whether feeds should be titles/teasers/full-text.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('system_rss_feeds_settings'), - 'access arguments' => array('administer site configuration'), - 'file' => 'system.admin.inc', - ); + if (module_exists('node')) { + $items['admin/content/rss-publishing'] = array( + 'title' => 'RSS publishing', + 'description' => 'Configure the number of items per feed and whether feeds should be titles/teasers/full-text.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('system_rss_feeds_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'system.admin.inc', + ); + } $items['admin/settings/date-time'] = array( 'title' => 'Date and time', 'description' => "Settings for how Drupal displays date and time, as well as the system's default timezone.", @@ -1204,7 +1206,7 @@ $admin_tasks = array(); $admin_task_count = 0; // Check for permissions. - if (module_hook($module, 'perm') && $admin_access) { + if (module_exists('user') && module_hook($module, 'perm') && $admin_access) { $admin_tasks[-1] = l(t('Configure permissions'), 'admin/user/permissions', array('fragment' => 'module-'. $module)); } @@ -1244,7 +1246,7 @@ } db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); } - $core = array('cache', 'cache_block', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu'); + $core = array('cache', 'cache_page', 'cache_form', 'cache_menu'); $cache_tables = array_merge(module_invoke_all('flush_caches'), $core); foreach ($cache_tables as $table) { cache_clear_all(NULL, $table); diff -ruP drupal-6.2/modules/user/user.info da/modules/user/user.info --- drupal-6.2/modules/user/user.info 2008-04-10 07:20:08.000000000 +1000 +++ da/modules/user/user.info 2008-06-03 15:58:58.453125000 +1000 @@ -1,7 +1,7 @@ ; $Id: user.info,v 1.4 2007/06/08 05:50:57 dries Exp $ name = User description = Manages the user registration and login system. -package = Core - required +package = Core - optional version = VERSION core = 6.x diff -ruP drupal-6.2/modules/user/user.install da/modules/user/user.install --- drupal-6.2/modules/user/user.install 2008-01-08 18:46:41.000000000 +1100 +++ da/modules/user/user.install 2008-06-03 15:58:58.453125000 +1000 @@ -2,6 +2,45 @@ // $Id: user.install,v 1.5 2008/01/08 07:46:41 goba Exp $ /** + * Implementation of hook_install(). + */ +function user_install() { + // Create tables. + drupal_install_schema('user'); + + // Add default user values + + // Inserting uid 0 here confuses MySQL -- the next user might be created as + // uid 2 which is not what we want. So we insert the first user here, the + // anonymous user. uid is 1 here for now, but very soon it will be changed + // to 0. + db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', ''); + // We need some placeholders here as name and mail are uniques and data is + // presumed to be a serialized array. Install will change uid 1 immediately + // anyways. So we insert the superuser here, the uid is 2 here for now, but + // very soon it will be changed to 1. + db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); + // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 + // otherwise MySQL might insert the next auto_increment value. + db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); + // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. + db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); + + db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user'); + db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); + + db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 1, 'access content', 0); +} + +/** + * Implementation of hook_uninstall(). + */ +function user_uninstall() { + // Remove tables. + drupal_uninstall_schema('user'); +} + +/** * Implementation of hook_schema(). */ function user_schema() { diff -ruP drupal-6.2/modules/user/user.module da/modules/user/user.module --- drupal-6.2/modules/user/user.module 2008-04-10 07:11:51.000000000 +1000 +++ da/modules/user/user.module 2008-06-03 17:03:48.156250000 +1000 @@ -488,7 +488,7 @@ if (is_null($account)) { $account = $user; } - + // User #1 has all privileges: if ($account->uid == 1) { return TRUE; @@ -1354,7 +1354,7 @@ */ function user_authenticate_finalize(&$edit) { global $user; - watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); + if (module_exists('dblog')) watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); // Update the user table timestamp noting user has logged in. // This is also used to invalidate one-time login links. $user->login = time(); diff -ruP drupal-6.2/profiles/da/da.profile da/profiles/da/da.profile --- drupal-6.2/profiles/da/da.profile 1970-01-01 10:00:00.000000000 +1000 +++ da/profiles/da/da.profile 2008-06-03 17:05:22.093750000 +1000 @@ -0,0 +1,123 @@ + 'Drupal Framework', + 'description' => 'Select this profile to provide a framework for web app development (no node support).', + 'language' => 'en' + ); +} + +/** + * Return a list of tasks that this profile supports. + * + * @return + * A keyed array of tasks the profile will perform during + * the final stage. The keys of the array will be used internally, + * while the values will be displayed to the user in the installer + * task list. + */ +function da_profile_task_list() { +} + +/** + * Perform any final installation tasks for this profile. + * + * The installer goes through the profile-select -> locale-select + * -> requirements -> database -> profile-install-batch + * -> locale-initial-batch -> configure -> locale-remaining-batch + * -> finished -> done tasks, in this order, if you don't implement + * this function in your profile. + * + * If this function is implemented, you can have any number of + * custom tasks to perform after 'configure', implementing a state + * machine here to walk the user through those tasks. First time, + * this function gets called with $task set to 'profile', and you + * can advance to further tasks by setting $task to your tasks' + * identifiers, used as array keys in the hook_profile_task_list() + * above. You must avoid the reserved tasks listed in + * install_reserved_tasks(). If you implement your custom tasks, + * this function will get called in every HTTP request (for form + * processing, printing your information screens and so on) until + * you advance to the 'profile-finished' task, with which you + * hand control back to the installer. Each custom page you + * return needs to provide a way to continue, such as a form + * submission or a link. You should also set custom page titles. + * + * You should define the list of custom tasks you implement by + * returning an array of them in hook_profile_task_list(), as these + * show up in the list of tasks on the installer user interface. + * + * Remember that the user will be able to reload the pages multiple + * times, so you might want to use variable_set() and variable_get() + * to remember your data and control further processing, if $task + * is insufficient. Should a profile want to display a form here, + * it can; the form should set '#redirect' to FALSE, and rely on + * an action in the submit handler, such as variable_set(), to + * detect submission and proceed to further tasks. See the configuration + * form handling code in install_tasks() for an example. + * + * Important: Any temporary variables should be removed using + * variable_del() before advancing to the 'profile-finished' phase. + * + * @param $task + * The current $task of the install system. When hook_profile_tasks() + * is first called, this is 'profile'. + * @param $url + * Complete URL to be used for a link or form action on a custom page, + * if providing any, to allow the user to proceed with the installation. + * + * @return + * An optional HTML string to display to the user. Only used if you + * modify the $task, otherwise discarded. + */ +function da_profile_tasks(&$task, $url) { + +} + +/** + * Implementation of hook_form_alter(). + * + * Allows the profile to alter the site-configuration form. This is + * called through custom invocation, so $form_state is not populated. + */ +function da_form_alter(&$form, $form_state, $form_id) { + if ($form_id == 'install_configure') { + // Set default for site name field. + $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME']; + } +} diff -ruP drupal-6.2/sites/all/modules/app/app.info da/sites/all/modules/app/app.info --- drupal-6.2/sites/all/modules/app/app.info 1970-01-01 10:00:00.000000000 +1000 +++ da/sites/all/modules/app/app.info 2008-06-03 15:58:58.468750000 +1000 @@ -0,0 +1,12 @@ +; $Id: app.info,v 0.1 2008/05/20 11:15:53 sbounds Exp $ +name = App +description = Used to simplify the development on non-CMS applications using Drupal. +package = Application +version = VERSION +core = 6.x + +; Information added by drupal.org packaging script on 2008-04-09 +version = "6.2" +project = "guruj" +datestamp = "1211246370" + diff -ruP drupal-6.2/sites/all/modules/app/app.module da/sites/all/modules/app/app.module --- drupal-6.2/sites/all/modules/app/app.module 1970-01-01 10:00:00.000000000 +1000 +++ da/sites/all/modules/app/app.module 2008-06-03 15:58:58.468750000 +1000 @@ -0,0 +1,82 @@ +uid; + case 'update': + return user_access('edit app page', $account); + case 'delete': + return user_access('delete app page', $account); + } +} + +/** + * Implementation of hook_help(). + */ +function app_help($path, $arg) { + switch ($path) { + case 'admin/help#app': + $output = '

'. t('The app module provides a basic framework to allow the development of non-CMS applications, but benefiting from Drupal\'s sophisticated theming and forms support.') .'

'; + return $output; + } +} + +/** + * Implementation of hook_menu(). + */ +function app_menu() { + $items = app_user_login_form(); + + $items['home'] = array( + 'title' => 'Sample App', + 'page callback' => 'app_view', + 'access arguments' => array('view app page'), + 'type' => MENU_SUGGESTED_ITEM, + 'file' => 'app.pages.inc', + ); + $items['multiply'] = array( + 'title' => t('Multiplication Results'), + 'page callback' => 'app_multiply', + 'access arguments' => array('view app page'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'app.pages.inc'); + + return $items; +} + +/** + * Implementation of hook_block(). + */ +function app_block($op = 'list', $delta = 0) { + global $user; + + if ($op == 'list') { + $block[0]['info'] = t('App block sample'); + return $block; + } + else if ($op == 'view') { + if (user_access('access content')) { + $block['content'] = l('Multiply Numbers', 'multiply'); + $block['subject'] = t('Sample App Control Menu'); + return $block; + } + } +} \ No newline at end of file diff -ruP drupal-6.2/sites/all/modules/app/app.pages.inc da/sites/all/modules/app/app.pages.inc --- drupal-6.2/sites/all/modules/app/app.pages.inc 1970-01-01 10:00:00.000000000 +1000 +++ da/sites/all/modules/app/app.pages.inc 2008-06-03 15:58:58.468750000 +1000 @@ -0,0 +1,93 @@ +$anne says hello to $bob

"; + $output .= l('Multiply some numbers', 'home/form'); + } + } + return $output; +} + +function app_multiply($arg1, $arg2) { + $output = '

'; + $output .= $arg1. ' × ' . $arg2 . ' = ' . ($arg1 * $arg2); + $output .= '

'; + return $output; +} + +function sample_form($form_state) { + $form = array(); + + $form['value1'] = array( + '#type' => 'textfield', + '#title' => t('Value 1'), + '#size' => 4, + '#maxlength' => 4, + '#description' => t('The first value to multiply.') + ); + + $form['value2'] = array( + '#type' => 'textfield', + '#title' => t('Value 2'), + '#size' => 4, + '#maxlength' => 4, + '#description' => t('The second value to multiply.') + ); + + $form['submit'] = array('#type' => 'submit', '#value' => t('Multiply values')); + return $form; +} + +function sample_form_validate($form, &$form_state) { + if ( !isset($form_state['values']['value1']) ) { + form_set_error('value1', t('You must provide the first multiplication value.')); + } + else if ( !is_numeric($form_state['values']['value1']) ) { + form_set_error('value1', t('The first multiplication value must be a number.')); + } + + if ( !isset($form_state['values']['value2']) ) { + form_set_error('value2', t('You must provide the second multiplication value.')); + } + else if ( !is_numeric($form_state['values']['value2']) ) { + form_set_error('value2', t('The second multiplication value must be a number.')); + } +} + +function sample_form_submit($form, &$form_state) { + drupal_set_message(t('The multiplication was successful.')); + + // Submit routines do not directly produce any output + // They do something with the form values + // which is typically to store them in the database + // then return a path to determine what page is shown next + + // In this case the path construct includes the two values + $form_state['redirect'] = 'multiply/' . $form_state['values']['value1'] . '/' . $form_state['values']['value2']; +} \ No newline at end of file