st('Single User Blog'), 'description' => st('Select this profile to set up a basic blog for a single user.'), ); } /** * 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 single_user_blog_profile_task_list() { $tasklist = array('single-user-blog-setup' => st('Single User Blog Setup')); return $tasklist; } /** * 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(&$task) { /* * 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, 'help' => '', 'min_word_count' => '', ), array( 'type' => 'blogpost', '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, 'help' => '', 'min_word_count' => '', ), ); /* * Save the node types */ $perms = 'access comment, access content, post comment, post comment without approval'; foreach ($types as $type) { $type = (object) _node_type_set_defaults($type); node_type_save($type); $name = $type->type; $perms .= ', create '. $name .' content'; $perms .= ', delete own '. $name .' content'; $perms .= ', delete '. $name .' content'; $perms .= ', edit own '. $name .' content'; $perms .= ', edit '. $name .' content'; } // Grant permissions to authenticated user db_query("UPDATE {permission} SET perm = '%s' WHERE rid = 2", $perms); // 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' => st('Tags'), 'description' => '', 'help' => '', 'nodes' => array('blog'), 'hierarchy' => 0, 'relations' => 0, 'tags' => 1, 'multiple' => 1, 'required' => 1, 'weight' => 0, 'module' => 'taxonomy' ); taxonomy_save_vocabulary($vocabulary); drupal_set_message(st('An account named "Administrator", with full administrative privileges, has been created for you. The password is the same as your user account. Write this information down and put it in a safe place. You will need this information for advanced administrative tasks like upgrading.')); return; } function single_user_blog_form_alter(&$form, $form_id) { if ($form_id == 'install_configure') { $form['intro']['#value'] = st('Please provide the information, to complete the configuration of your site.'); $form['site_information']['site_slogan'] = array( '#type' => 'textfield', '#title' => st('Slogan'), '#default_value' => variable_get('site_slogan', ''), '#description' => st('A short slogan for your site.'), '#required' => TRUE, '#weight' => -17, ); $form['site_information']['site_mission'] = array( '#type' => 'textfield', '#title' => st('Mission'), '#default_value' => variable_get('site_mission', ''), '#description' => st('Your site\'s mission statement or focus.'), '#weight' => -17, ); $form['site_information']['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'] = st('Account'); $form['admin_account']['#description'] = st('Two accounts will be created for you: an adminstrator account with complete permissions, and a normal user account for posting content to your blog.'); $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, &$form_state) { global $user; $form_values = $form_state['values']; // 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('site_mission', $form_values['site_mission']); 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(2 => 2); $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 normal blog user, uses exactly the information they provided. $blog_user = $form_values['account']; user_save(user_load(1), $admin); $account = user_save('', $blog_user); // Log in as the normal user. user_authenticate($account->name, trim($blog_user['pass'])); // Dissallow user registrations. variable_set('user_register', 0); // Store the clean URLs setting. 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, &$form_state) { $form_values = $form_state['values']; // The email addresses are used to create user accounts and must be unique. 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. A separate account with that name will be created for you.'); } }