$id = NULL; if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Sections::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // editors have associate-like capabilities if (isset($item['id']) && Sections::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) { Surfer::empower(); } // load the skin, maybe with a variant load_skin('sections', $anchor, isset($item['options']) ? $item['options'] : ''); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); die(i18n::s('You are not allowed to perform this operation.')); } // page title if (isset($item['title'])) { $context['page_title'] = $item['title']; } // not found if (!$item['id']) {
/** * check if new links can be added * * This function returns TRUE if links can be added to some place, * and FALSE otherwise. * * @param object an instance of the Anchor interface, if any * @param array a set of item attributes, if any * @param string the type of item, e.g., 'section' * @return boolean TRUE or FALSE */ public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL) { global $context; // backward compatibility, reverse parameters : // $anchor is always a object and $item a array if (is_object($item) || is_array($anchor)) { $permute = $anchor; $anchor = $item; $item = $permute; } // guess the variant if (!$variant) { // most frequent case if (isset($item['id'])) { $variant = 'article'; } elseif (is_object($anchor)) { $variant = $anchor->get_type(); } else { return FALSE; } } // only in articles if ($variant == 'article') { // 'no_links' option if (Articles::has_option('no_links', $anchor, $item)) { return FALSE; } // other containers } else { // links have to be activated if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bwith_links\\b/i', $item['options'])) { } elseif (!isset($item['id']) && is_object($anchor) && $anchor->has_option('with_links', FALSE)) { } else { return FALSE; } } // surfer is an associate if (Surfer::is_associate()) { return TRUE; } // submissions have been disallowed if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') { return FALSE; } // only in articles if ($variant == 'article') { // surfer owns this item, or the anchor if (Articles::is_owned($item, $anchor)) { return TRUE; } // surfer is an editor, and the page is not private if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) { return TRUE; } // only in sections } elseif ($variant == 'section') { // surfer owns this item, or the anchor if (Sections::is_owned($item, $anchor, TRUE)) { return TRUE; } // surfer is an editor, and the section is not private if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) { return TRUE; } } // surfer is an editor, and container is not private if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) { return TRUE; } if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) { return TRUE; } // item has been locked if (isset($item['locked']) && $item['locked'] == 'Y') { return FALSE; } // anchor has been locked --only used when there is no item provided if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) { return FALSE; } // surfer is an editor (and item has not been locked) if ($variant == 'article' && isset($item['id']) && Articles::is_assigned($item['id'])) { return TRUE; } if ($variant == 'section' && isset($item['id']) && Sections::is_assigned($item['id'])) { return TRUE; } if (is_object($anchor) && $anchor->is_assigned()) { return TRUE; } // container is hidden if (isset($item['active']) && $item['active'] == 'N') { return FALSE; } if (is_object($anchor) && $anchor->is_hidden()) { return FALSE; } // authenticated members and subscribers are allowed to add links if (Surfer::is_logged()) { return TRUE; } // container is restricted if (isset($item['active']) && $item['active'] == 'R') { return FALSE; } if (is_object($anchor) && !$anchor->is_public()) { return FALSE; } // anonymous contributions are allowed for articles if ($variant == 'article') { if (isset($item['options']) && preg_match('/\\banonymous_edit\\b/i', $item['options'])) { return TRUE; } if (is_object($anchor) && $anchor->has_option('anonymous_edit')) { return TRUE; } } // the default is to not allow for new links return FALSE; }
// invite participants, for owners if (Sections::is_owned($item, $anchor, TRUE) && isset($context['with_email']) && $context['with_email'] == 'Y') { Skin::define_img('SECTIONS_INVITE_IMG', 'sections/invite.gif'); $box['bar'] += array(Sections::get_url($item['id'], 'invite') => SECTIONS_INVITE_IMG . i18n::s('Invite participants')); } // notify participants if ($count > 1 && Sections::allow_message($item, $anchor) && isset($context['with_email']) && $context['with_email'] == 'Y') { Skin::define_img('SECTIONS_EMAIL_IMG', 'sections/email.gif'); $box['bar'] += array(Sections::get_url($item['id'], 'mail') => SECTIONS_EMAIL_IMG . i18n::s('Notify participants')); } // manage editors, for owners if (Sections::is_owned($item, $anchor, TRUE) || Surfer::is_associate()) { Skin::define_img('SECTIONS_ASSIGN_IMG', 'sections/assign.gif'); $box['bar'] += array(Users::get_url('section:' . $item['id'], 'select') => SECTIONS_ASSIGN_IMG . i18n::s('Manage participants')); // leave this section, for editors } elseif (Sections::is_assigned($item['id'])) { Skin::define_img('SECTIONS_ASSIGN_IMG', 'sections/assign.gif'); $box['bar'] += array(Users::get_url('section:' . $item['id'], 'leave') => SECTIONS_ASSIGN_IMG . i18n::s('Leave this section')); } // headers $headers = array(i18n::s('Person'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner')); // layout columns if ($rows) { $box['text'] .= Skin::table($headers, $rows, 'grid'); } // actually render the html $users .= Skin::build_content(NULL, NULL, $box['text'], $box['bar']); } // display in a separate panel if ($users) { $label = i18n::s('Persons');
/** * check if a surfer can send a message to group participants * * @param array a set of item attributes, aka, the target section * @param object an instance of the Anchor interface * @return TRUE or FALSE */ public static function allow_message($item, $anchor = NULL) { global $context; // subscribers can never sned a message if (!Surfer::is_member()) { return FALSE; } // sanity check if (!isset($item['id'])) { return FALSE; } // surfer is an associate if (Surfer::is_associate()) { return TRUE; } // surfer owns the container or the section if (Sections::is_owned($item, $anchor, TRUE)) { return TRUE; } // section editors can proceed if (isset($item['id']) && Sections::is_assigned($item['id'])) { return TRUE; } // container editors can proceed if (is_object($anchor) && $anchor->is_assigned()) { return TRUE; } // default case return FALSE; }
/** * check if new files can be added * * This function returns TRUE if files can be added to some place, * and FALSE otherwise. * * @param array a set of item attributes, if any * @param object an instance of the Anchor interface, if any * @param string the type of item, e.g., 'article' or 'section' * @return boolean TRUE or FALSE */ public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL) { global $context; // guess the variant if (!$variant) { // most frequent case if (isset($item['id'])) { $variant = 'article'; } elseif (is_object($anchor)) { $variant = $anchor->get_type(); } else { return FALSE; } } // attach a file to an article if ($variant == 'article') { // 'no initial upload' option if (!isset($item['id']) && Articles::has_option('no_initial_upload', $anchor, $item)) { return FALSE; } // 'no files' option if (Articles::has_option('no_files', $anchor, $item)) { return FALSE; } // attach a file to a user profile } elseif ($variant == 'user') { // associates can always proceed if (Surfer::is_associate()) { } elseif (!is_object($anchor) || !Surfer::get_id()) { return FALSE; } elseif ($anchor->get_reference() != 'user:'******'options']) && is_string($item['options']) && preg_match('/\\bwith_files\\b/i', $item['options'])) { } elseif (!isset($item['id']) && is_object($anchor) && $anchor->has_option('with_files', FALSE)) { } else { return FALSE; } } // surfer is not allowed to upload a file if (!Surfer::may_upload()) { return FALSE; } // surfer is an associate if (Surfer::is_associate()) { return TRUE; } // submissions have been disallowed if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') { return FALSE; } // only in articles if ($variant == 'article') { // surfer owns this item, or the anchor if (Articles::is_owned($item, $anchor)) { return TRUE; } // surfer is an editor, and the page is not private if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) { return TRUE; } // only in sections } elseif ($variant == 'section') { // surfer owns this item, or the anchor if (Sections::is_owned($item, $anchor, TRUE)) { return TRUE; } // surfer is an editor, and the section is not private if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) { return TRUE; } } // surfer is an editor, and container is not private if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) { return TRUE; } if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) { return TRUE; } // item has been locked if (isset($item['locked']) && $item['locked'] == 'Y') { return FALSE; } // anchor has been locked --only used when there is no item provided if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) { return FALSE; } // surfer is an editor (and item has not been locked) if ($variant == 'article' && isset($item['id']) && Articles::is_assigned($item['id'])) { return TRUE; } if ($variant == 'section' && isset($item['id']) && Sections::is_assigned($item['id'])) { return TRUE; } if (is_object($anchor) && $anchor->is_assigned()) { return TRUE; } // container is hidden if (isset($item['active']) && $item['active'] == 'N') { return FALSE; } if (is_object($anchor) && $anchor->is_hidden()) { return FALSE; } // authenticated members and subscribers are allowed to add files if (Surfer::is_logged()) { return TRUE; } // container is restricted if (isset($item['active']) && $item['active'] == 'R') { return FALSE; } if (is_object($anchor) && !$anchor->is_public()) { return FALSE; } // anonymous contributions are allowed for articles and for sections if ($variant == 'article' || $variant == 'section') { if (isset($item['options']) && preg_match('/\\banonymous_edit\\b/i', $item['options'])) { return TRUE; } if (is_object($anchor) && $anchor->has_option('anonymous_edit')) { return TRUE; } } // the default is to not allow for new files return FALSE; }
/** * check if new articles can be added * * This function returns TRUE if articles can be added to some place, * and FALSE otherwise. * * @param array a set of item attributes, if any --always a section * @param object an instance of the Anchor interface, if any * @return boolean TRUE or FALSE */ public static function allow_creation($item, $anchor = NULL) { global $context; // articles are prevented in item, through layout if (isset($item['articles_layout']) && $item['articles_layout'] == 'none') { return FALSE; } // surfer is an associate if (Surfer::is_associate()) { return TRUE; } // submissions have been disallowed if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') { return FALSE; } // surfer owns this item, or the anchor if (Sections::is_owned($item, $anchor, TRUE)) { return TRUE; } // not for subscribers if (Surfer::is_member()) { // surfer is an editor, and the section is not private if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) { return TRUE; } if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) { return TRUE; } if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) { return TRUE; } } // container has been locked if (isset($item['locked']) && $item['locked'] == 'Y') { return FALSE; } // anchor has been locked if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) { return FALSE; } // anonymous contributions are allowed for articles if (isset($item['options']) && preg_match('/\\banonymous_edit\\b/i', $item['options'])) { return TRUE; } if (is_object($anchor) && $anchor->has_option('anonymous_edit')) { return TRUE; } // subscribers can contribute too if (Surfer::is_logged() && isset($item['options']) && preg_match('/\\bmembers_edit\\b/i', $item['options'])) { return TRUE; } if (Surfer::is_logged() && is_object($anchor) && $anchor->has_option('members_edit')) { return TRUE; } // not for subscribers if (Surfer::is_member()) { // surfer is an editor (and item has not been locked) if (isset($item['id']) && Sections::is_assigned($item['id'])) { return TRUE; } if (is_object($anchor) && $anchor->is_assigned()) { return TRUE; } } // container is hidden if (isset($item['active']) && $item['active'] == 'N') { return FALSE; } if (is_object($anchor) && $anchor->is_hidden()) { return FALSE; } // surfer is a member if (Surfer::is_member()) { return TRUE; } // the default is to not allow for new articles return FALSE; }
$id = NULL; if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Sections::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // editors have associate-like capabilities if (Surfer::is_empowered('M') && (isset($item['id']) && isset($user['id']) && Sections::is_assigned($item['id'], $user['id'])) || is_object($anchor) && $anchor->is_assigned()) { Surfer::empower('A'); } // load a skin, maybe with a variant load_skin('sections', $anchor, isset($item['options']) ? $item['options'] : ''); // path to this page $context['path_bar'] = array('sections/' => i18n::s('Site map')); // page title $context['page_title'] = i18n::s('RSS feed'); // not found if (!isset($item['id']) || !$item['id']) { include '../error.php'; // access denied } elseif (!Sections::allow_access($item, $anchor)) { // give anonymous surfers a chance for HTTP authentication if (!Surfer::is_logged()) {