} // not found -- help web crawlers if (!isset($item['id'])) { include $context['path_to_root'] . 'error.php'; // permission denied } elseif (!$permitted) { // make it clear to crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); } elseif (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Sections::get_permalink($item))); } elseif (isset($_REQUEST['requested']) && ($requested = Users::get($_REQUEST['requested'])) && $requested['email']) { // prepare the mail message $to = Mailer::encode_recipient($requested['email'], $requested['full_name']); $subject = sprintf(i18n::c('%s: %s'), i18n::c('Request'), strip_tags($item['title'])); $message = Sections::build_notification('apply', $item, $overlay); $headers = Mailer::set_thread('section:' . $item['id']); // allow for skinnable template $message = Skin::build_mail_message($message); // build multiple parts, for HTML rendering $message = Mailer::build_multipart($message); // send the message to requested user if (Mailer::post(Surfer::from(), $to, $subject, $message, NULL, $headers)) { $text = sprintf(i18n::s('Your request has been transmitted to %s. Check your mailbox for feed-back.'), Skin::build_link(Users::get_permalink($requested), Codes::beautify_title($requested['full_name']), 'user')); $context['text'] .= Skin::build_block($text, 'note'); } // follow-up navigation $context['text'] .= '<div>' . i18n::s('Where do you want to go now?') . '</div>'; $menu = array(); $menu[] = Skin::build_link($context['url_to_root'], i18n::s('Front page'), 'button'); $menu[] = Skin::build_link(Surfer::get_permalink(), i18n::s('My profile'), 'span');
} // create a new section } elseif (!($_REQUEST['id'] = Sections::post($_REQUEST))) { $item = $_REQUEST; $with_form = TRUE; // successful post } else { // post an overlay, with the new section id --don't stop on error if (is_object($overlay)) { $overlay->remember('insert', $_REQUEST, 'section:' . $_REQUEST['id']); } // notification to send by e-mail $mail = array(); $anchor_title = is_object($anchor) ? strip_tags($anchor->get_title()) : i18n::s('Root'); $mail['subject'] = sprintf(i18n::c('%s: %s'), $anchor_title, strip_tags($_REQUEST['title'])); $mail['notification'] = Sections::build_notification('create', $_REQUEST); $mail['headers'] = Mailer::set_thread('section:' . $_REQUEST['id']); // touch the related anchor if (is_object($anchor)) { // send to watchers of this anchor if (isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y') { $anchor->alert_watchers($mail, 'section:create', $_REQUEST['active'] == 'N'); } // update anchors $anchor->touch('section:create', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y'); } // send to followers of this user if (isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y' && Surfer::get_id() && $_REQUEST['active'] != 'N') { $mail['message'] = Mailer::build_notification($mail['notification'], 2); Users::alert_watchers('user:' . Surfer::get_id(), $mail); }