コード例 #1
0
<?php

/**
 * Provide a list of pigenoholes
 *
 * @package pigeonholes
 * @subpackage functions
 * @version $Header$
 *
 * Copyright ( c ) 2005 bitweaver.org
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 */
/**
 * Required Files
 */
$gContent = new Pigeonholes(!empty($_REQUEST['structure_id']) ? $_REQUEST['structure_id'] : NULL, !empty($_REQUEST['content_id']) ? $_REQUEST['content_id'] : NULL);
$gContent->load(TRUE);
$gBitSmarty->assign_by_ref('gContent', $gContent);
コード例 #2
0
ファイル: Pigeonholes.php プロジェクト: bitweaver/pigeonholes
/**
 * pigeonholes_content_display 
 * 
 * @param array $pObject 
 * @access public
 * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
 */
function pigeonholes_content_display(&$pObject)
{
    global $gBitSystem, $gBitSmarty, $gBitUser, $gBitThemes;
    $pigeonholes = new Pigeonholes();
    // first we need to check permissions
    if ($gBitSystem->isFeatureActive('pigeonhole_permissions') || $gBitSystem->isFeatureActive('pigeonholes_groups')) {
        if ($pigeons = $pigeonholes->getPigeonholesFromContentId($pObject->mContentId)) {
            foreach ($pigeons as $pigeon) {
                // we will loop through here until we get one pigeonhole that allows access
                if (empty($access_granted)) {
                    if ($pigeonholes->checkPathPermissions($pigeonholes->getPigeonholePath($pigeon['structure_id']))) {
                        $access_granted = TRUE;
                    } else {
                        $access_granted = FALSE;
                    }
                }
            }
        }
        // we need to check all pigeonholes in the path, load the prefs and work out if the user is allowed to view the page
        if (isset($access_granted) && $access_granted === FALSE) {
            $msg = tra("This content is part of a category to which you have no access to. Please log in or request the appropriate permission from the site administrator.");
            $gBitSystem->fatalPermission(NULL, $msg);
        }
    }
    if ($gBitSystem->isFeatureActive('pigeonholes_display_members') || $gBitSystem->isFeatureActive('pigeonholes_display_path')) {
        if ($gBitUser->hasPermission('p_pigeonholes_view')) {
            if ($pigeons = $pigeonholes->getPigeonholesFromContentId($pObject->mContentId)) {
                foreach ($pigeons as $key => $pigeon) {
                    $pigeonholes->mContentId = $pigeon['content_id'];
                    $pigeonholes->load(TRUE, FALSE);
                    $pigeonData[] = $pigeonholes->mInfo;
                    // set the theme chosen for this page - virtually random if page is part of multiple themes
                    if ($gBitSystem->isFeatureActive('pigeonholes_themes')) {
                        // loadPreferences is called by getPreference if needed
                        $gBitThemes->setStyle($pigeonholes->getPreference('style'));
                    }
                }
                $gBitSmarty->assign('pigeonData', !empty($pigeonData) ? $pigeonData : FALSE);
            }
        }
    }
}
コード例 #3
0
    foreach ($rootTree as $node) {
        $pigeonStructure[$node['structure_id']] = str_repeat('-', $node['level']) . ' ' . $node['title'];
    }
    $gBitSmarty->assign('pigeonStructure', $pigeonStructure);
}
global $gStructure;
// store the form if we need to
if (!empty($_REQUEST['pigeonhole_store'])) {
    if (empty($_REQUEST['pigeonhole']['title'])) {
        $gBitSystem->fatalError(tra("You must specify a title."));
    }
    // we need to get the root structure id
    $_REQUEST['pigeonhole']['root_structure_id'] = !empty($rootStructure->mStructureId) ? $rootStructure->mStructureId : NULL;
    // store the pigeonhole
    $pigeonStore = new Pigeonholes(NULL, !empty($_REQUEST['pigeonhole_content_id']) ? $_REQUEST['pigeonhole_content_id'] : NULL);
    $pigeonStore->load();
    if ($pigeonStore->store($_REQUEST['pigeonhole'])) {
        header("Location: " . $_SERVER['SCRIPT_NAME'] . '?structure_id=' . $pigeonStore->mStructureId . (!empty($_REQUEST['action']) ? '&action=' . $_REQUEST['action'] : '') . "&success=" . urlencode(tra("The category was successfully stored")));
    } else {
        $feedback['error'] = $gContent->mErrors;
    }
}
if (!empty($_REQUEST['action']) || isset($_REQUEST["confirm"])) {
    // if we need to edit, show the information
    if ($_REQUEST['action'] == 'edit') {
        $pigeonInfo = $gContent->mInfo;
        $gContent->loadPreferences();
    }
    if ($_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'create') {
        $gBitSmarty->assign('pigeonInfo', !empty($pigeonInfo) ? $pigeonInfo : NULL);
    }