'Single User Blog', 'description' => 'Select this profile to set up a basic blog.' ); } /** * Perform any final installation tasks for this profile. * * @return * An optional HTML string to display to the user on the final installation * screen. */ function single_user_blog_profile_tasks() { /* * Pages are used for about me kinds of things, * and Blog posts are used as entries to the blog */ $types = array( array( 'type' => 'page', 'name' => st('Page'), 'module' => 'node', 'description' => st('If you want to add a static page, like a contact page or an about page, use a page.'), 'custom' => TRUE, 'modified' => TRUE, 'locked' => FALSE, ), array( 'type' => 'blog', 'name' => st('Blog post'), 'module' => 'node', 'description' => st('A blog is a regularly updated journal or diary made up of individual posts shown in reversed chronological order.'), 'custom' => TRUE, 'modified' => TRUE, 'locked' => FALSE, ), ); /* * Save the node types */ foreach ($types as $type) { $type = (object) _node_type_set_defaults($type); node_type_save($type); } // Default page to not be promoted and have comments disabled. variable_set('node_options_page', array('status')); variable_set('comment_page', COMMENT_NODE_DISABLED); // However, comments are accepted on blog posts, and they are promoted to the front page variable_set('node_options_blog', array('status', 'promoted')); variable_set('comment_blog', COMMENT_NODE_READ_WRITE); // Theme settings $theme_settings = variable_get('theme_settings', array()); $theme_settings['toggle_node_info_page'] = FALSE; $theme_settings['toggle_node_info_blog'] = TRUE; $theme_settings['default_logo'] = 0; $theme_settings['toggle_name'] = 1; $theme_settings['toggle_slogan'] = 1; variable_set('theme_settings', $theme_settings); // Don't let users register variable_set('user_register', '0'); //Make a vocabulary for blog entries $vocabulary = array( 'name' => 'Categories', 'description' => '', 'help' => '', 'nodes' => array('blog'), 'hierarchy' => 0, 'relations' => 0, 'tags' => 1, 'multiple' => 1, 'required' => 1, 'weight' => 0, 'module' => 'taxonomy' ); taxonomy_save_vocabulary($vocabulary); return st('An account with full administrative privileges has been created for you, named "Administrator"; it has the same password you do. Do not lose this information, you may need it for some operations! However, for most operations, you will not.'); } function single_user_blog_form_alter(&$form, $form_id) { if($form_id == 'install_configure') { $form['intro']['#value'] = st('Please enter the following information, and then your installaion will be complete, and your site will be ready to go.'); $form['site_information']['site_slogan'] = array( '#type' => 'textfield', '#title' => st('Slogan'), '#default_value' => variable_get('site_slogan', ''), '#description' => st('The name of this website.'), '#required' => TRUE, '#weight' => -17, ); $form['site_mail']['#description'] = st('This is the e-mail address used for lost password requests, and all e-mails to the system, such as from the contact form, go to this e-mail address, so it must be a valid.'); // Tweak the account settings to make more sense unset($form['admin_account']['markup']); $form['admin_account']['#title'] = 'Your account'; $form['admin_account']['name']['#title'] = st('Your username'); $form['admin_account']['name']['#description'] = st('Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores. This name will show up on all of your blog posts, as well as your comments.'); $form['admin_account']['pass']['#description'] = st('Provide a password for your account in both fields.'); // Add our own submit and validate functions $form['#submit'] = array('single_user_blog_install_finalize_submit'); $form['#validate'] = array('single_user_blog_install_finalize_validate'); } } function single_user_blog_install_finalize_submit($form_values, $form, &$form_state) { global $user; /* * Set site settings */ variable_set('site_name', $form_values['site_name']); variable_set('site_slogan', $form_values['site_slogan']); variable_set('site_mail', $form_values['site_mail']); variable_set('date_default_timezone', $form_values['date_default_timezone']); /* * Set the role to authenticated user, not blocked, and set init to mail */ $form_values['account']['roles'] = array(3 => 3); $form_values['account']['status'] = 1; $form_values['account']['init'] = $form_values['account']['mail']; /* * The admin user has the site e-mail address, * the username 'Administrator', and the users's * password. This is because many functions of * user #1 may be confusing to the user */ $admin = $form_values['account']; $admin['name'] = st('Administrator'); $admin['mail'] = $form_values['site_mail']; /* * The blog user, however follows everything the user entered */ $blog_user = $form_values['account']; user_save('', $admin); $account = user_save('', $blog_user); // Log user #2 in user_authenticate($account->name, trim($blog_user['pass'])); // Dissallow user registrations variable_set('user_register', 0); // Disable clean URLs if (isset($form_values['clean_url'])) { variable_set('clean_url', $form_values['clean_url']); } $form_state['redirect'] = 'finished'; $form_state['user'] = $user; } function single_user_blog_install_finalize_validate($form_values, $form, &$form_state) { if ($form_values['account']['mail'] == $form_values['site_mail']) { form_error($form_values['account']['mail'], 'Both e-mail addresses may not be the same'); form_error($form_values['site_mail']); } if ($form_values['account']['name'] == st('Administrator')) { form_error($form_values['account']['name'], 'The username may not be Administrator'); } }