Example #1
0
 /**
  * check access rights
  *
  * @param string script name
  * @paral string target anchor, if any
  * @return boolean FALSE if access is denied, TRUE otherwise
  */
 function allow($script, $anchor = NULL)
 {
     global $context;
     // limit the scope of our check
     if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
         return TRUE;
     }
     // sanity check
     if (!$anchor) {
         die(i18n::s('No anchor has been found.'));
     }
     // stop here if the agreement has been gathered previously
     if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
         foreach ($agreements as $agreement) {
             if ($agreement == $anchor) {
                 return TRUE;
             }
         }
     }
     // which agreement?
     if (!$this->parameters) {
         die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
     }
     // do we have a related file to display?
     if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
         die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
     }
     // splash message
     $context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
     // load and display the file to be displayed
     $context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
     // target link to record agreement
     if ($context['with_friendly_urls'] == 'Y') {
         $agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
     } else {
         $agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
     }
     // display confirmation buttons at the end of the agreement
     $context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
     $context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
     $context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
     // render the skin based only on text provided by this behavior
     render_skin();
     exit;
 }
Example #2
0
File: select.php Project: rair/yacs
            }
            // only consider live categories
            $where = '(' . $where . ')' . ' AND ((categories.expiry_date is NULL)' . "\tOR (categories.expiry_date <= '" . NULL_DATE . "') OR (categories.expiry_date > '" . $context['now'] . "'))";
            // limit the query to top level only
            $query = "SELECT categories.id, categories.title " . " FROM " . SQL::table_name('categories') . " AS categories " . " WHERE (" . $where . ") AND (categories.anchor='category:" . $category_id . "')" . " ORDER BY categories.title";
            $result = SQL::query($query);
            $sub_categories = array();
            while ($result && ($option = SQL::fetch($result))) {
                $sub_categories['category:' . $option['id']] = $option['title'];
            }
            if (count($sub_categories)) {
                $suffix .= '<form method="post" action="' . $context['script_url'] . '"><div>' . i18n::s('More specific:') . ' <select name="anchor">';
                foreach ($sub_categories as $option_reference => $option_label) {
                    $suffix .= '<option value="' . $option_reference . '">' . $option_label . "</option>\n";
                }
                $suffix .= '</select>' . ' ' . Skin::build_submit_button(" >> ") . '<input type="hidden" name="member" value="' . $member . '">' . '<input type="hidden" name="father" value="category:' . $category_id . '">' . '</div></form>' . "\n";
            }
            // format the item
            $new_categories[$url] = array($prefix, $label, $suffix, $type, $icon);
        }
        // display attached categories with unlink buttons
        $context['text'] .= Skin::build_list($new_categories, 'decorated');
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
}
// render the skin
render_skin();
Example #3
0
File: view.php Project: rair/yacs
        $context['components']['channels'] = Skin::build_box(i18n::s('Monitor'), join(BR, $lines), 'channels', 'feed');
    }
    // categories attached to this item, if not at another follow-up page
    if (!$zoom_type || $zoom_type == 'categories') {
        // build a complete box
        $box = array();
        $box['bar'] = array();
        $box['text'] = '';
        // list categories by title
        $items =& Members::list_categories_by_title_for_member('user:'******'id'], 0, COMPACT_LIST_SIZE, 'sidebar');
        // the command to change categories assignments
        if (Categories::allow_assign($item)) {
            $items = array_merge($items, array(Categories::get_url('user:'******'id'], 'select') => i18n::s('Assign categories')));
        }
        // actually render the html for the section
        if (is_array($box['bar'])) {
            $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
        }
        if (is_array($items)) {
            $box['text'] .= Skin::build_list($items, 'compact');
        }
        if ($box['text']) {
            $context['components']['categories'] = Skin::build_box(i18n::s('See also'), $box['text'], 'categories', 'categories');
        }
    }
    // referrals, if any
    $context['components']['referrals'] =& Skin::build_referrals(Users::get_url($item['id']));
}
// render the skin -- do not provide Last-Modified header
render_skin(FALSE);