Exemplo n.º 1
0
/**
 * 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);
            }
        }
    }
}