From: <var...@us...> - 2009-06-01 10:04:41
|
Revision: 6835 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6835&view=rev Author: vargenau Date: 2009-06-01 10:04:38 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Implement external pages (ENABLE_EXTERNAL_PAGES) Modified Paths: -------------- trunk/lib/PagePerm.php trunk/lib/editpage.php trunk/lib/loadsave.php trunk/lib/ziplib.php trunk/themes/gforge/templates/editpage.tmpl trunk/themes/gforge/themeinfo.php Modified: trunk/lib/PagePerm.php =================================================================== --- trunk/lib/PagePerm.php 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/lib/PagePerm.php 2009-06-01 10:04:38 UTC (rev 6835) @@ -234,6 +234,12 @@ global $request; $page = $request->getPage($pagename); + if (defined('GFORGE') and GFORGE) { + if ($pagename != '.' && isset($request->_user->_is_external) && $request->_user->_is_external && ! $page->get('external')) { + $permcache[$pagename][$access] = 0; + return 0; + } + } // Page not found; check against default permissions if (! $page->exists() ) { $perm = new PagePermission(); Modified: trunk/lib/editpage.php =================================================================== --- trunk/lib/editpage.php 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/lib/editpage.php 2009-06-01 10:04:38 UTC (rev 6835) @@ -235,7 +235,7 @@ function updateLock() { $changed = false; - if (!ENABLE_PAGE_PUBLIC) { + if (!ENABLE_PAGE_PUBLIC && !ENABLE_EXTERNAL_PAGES) { if ((bool)$this->page->get('locked') == (bool)$this->locked) return false; // Not changed. } @@ -260,6 +260,17 @@ : _("Page now not-public.")); $changed = true; } + + if (ENABLE_EXTERNAL_PAGES) { + if ((bool)$this->page->get('external') != (bool)$this->external) { + $this->page->set('external', (bool)$this->external); + $this->tokens['LOCK_CHANGED_MSG'] + = ($this->external + ? _("Page now external.") + : _("Page now not-external.")) . " "; + $changed = true; + } + } return $changed; // lock changed. } @@ -676,6 +687,14 @@ 'disabled' => (bool) !$this->user->isAdmin(), 'checked' => (bool) $this->page->get('public'))); } + if (ENABLE_EXTERNAL_PAGES) { + $el['EXTERNAL_CB'] + = HTML::input(array('type' => 'checkbox', + 'name' => 'edit[external]', + 'id' => 'edit-external', + 'disabled' => (bool) !$this->user->isAdmin(), + 'checked' => (bool) $this->page->get('external'))); + } if (ENABLE_WYSIWYG) { if (($this->version == 0) and ($request->getArg('mode') != 'wysiwyg')) { $el['WYSIWYG_B'] = Button(array("action" => "edit", "mode" => "wysiwyg"), "Wysiwyg Editor"); @@ -770,6 +789,8 @@ $this->locked = !empty($posted['locked']); if (ENABLE_PAGE_PUBLIC) $this->public = !empty($posted['public']); + if (ENABLE_EXTERNAL_PAGES) + $this->external = !empty($posted['external']); foreach (array('preview','save','edit_convert', 'keep_old','overwrite','diff','upload') as $o) Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/lib/loadsave.php 2009-06-01 10:04:38 UTC (rev 6835) @@ -1182,6 +1182,8 @@ if (!defined('FLAG_PAGE_LOCKED')) define('FLAG_PAGE_LOCKED', 1); + if (!defined('FLAG_PAGE_EXTERNAL')) + define('FLAG_PAGE_EXTERNAL', 1); $pageinfo = array('pagedata' => array(), 'versiondata' => array()); @@ -1208,6 +1210,8 @@ case 'flags': if (($value & FLAG_PAGE_LOCKED) != 0) $pagedata['locked'] = 'yes'; + if (($value & FLAG_PAGE_EXTERNAL) != 0) + $pagedata['external'] = 'yes'; break; case 'owner': case 'created': Modified: trunk/lib/ziplib.php =================================================================== --- trunk/lib/ziplib.php 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/lib/ziplib.php 2009-06-01 10:04:38 UTC (rev 6835) @@ -603,6 +603,8 @@ $params['created'] = $page->get('mtime'); if ($page->get('locked')) $params['flags'] = 'PAGE_LOCKED'; + if (ENABLE_EXTERNAL_PAGES && $page->get('external')) + $params['flags'] = ($params['flags'] ? $params['flags'] . ',EXTERNAL_PAGE' : 'EXTERNAL_PAGE'); if ($revision->get('author_id')) $params['author_id'] = $revision->get('author_id'); if ($revision->get('markup')) // what is the default? we must use 1 @@ -830,6 +832,8 @@ case 'flags': if (preg_match('/PAGE_LOCKED/', $value)) $pagedata['locked'] = 'yes'; + if (ENABLE_EXTERNAL_PAGES && preg_match('/EXTERNAL_PAGE/', $value)) + $pagedata['external'] = 'yes'; break; case 'owner': case 'created': Modified: trunk/themes/gforge/templates/editpage.tmpl =================================================================== --- trunk/themes/gforge/templates/editpage.tmpl 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/themes/gforge/templates/editpage.tmpl 2009-06-01 10:04:38 UTC (rev 6835) @@ -66,6 +66,9 @@ <?= $LOCKED_CB ?> <label for="edit-locked" title="<?=_("Make the page read-only?")?>"><?=_("Locked")?></label> <?php if (ENABLE_PAGE_PUBLIC) { ?> <?= $PUBLIC_CB ?> <label for="edit-public" title="<?=_("Make the page public?")?>"><?=_("Public")?></label> + <?php } ?> + <?php if (ENABLE_EXTERNAL_PAGES) { ?> + <?= $EXTERNAL_CB ?> <label for="edit-external" title="<?=_("Make the page external?")?>"><?=_("External")?></label> <?php }} ?> </td> </tr> Modified: trunk/themes/gforge/themeinfo.php =================================================================== --- trunk/themes/gforge/themeinfo.php 2009-06-01 10:01:51 UTC (rev 6834) +++ trunk/themes/gforge/themeinfo.php 2009-06-01 10:04:38 UTC (rev 6835) @@ -6,7 +6,7 @@ class WikiTheme_gforge extends WikiTheme { function header() { - global $HTML, $group_id, $group_public_name, $request, $project; + global $HTML, $group_id, $group_public_name, $request, $project, $Language; $pagename = $request->getArg('pagename'); @@ -28,6 +28,24 @@ 'pagename'=> $pagename, 'group' => $group_id, 'toptab' => 'wiki', 'css' => 'gforge.css" />'."\n".' <base href="'.PHPWIKI_BASE_URL, 'submenu' => $submenu->asXML())); + + // Display a warning banner for internal users when the wiki is opened + // to external users. + if ($project->getIsExternal()) { + $external_user = false; + if (session_loggedin()) { + $user = session_get_user(); + $external_user = $user->getIsExternal(); + } + if (!$external_user) { + $page = $request->getPage(); + if ($page->get('external')) { + $external_msg = 'This page is external.'; + } + echo $HTML->warning_msg($Language->getText('project_admin','external_project') . + (isset($external_msg) ? ' ' . $external_msg : '')); + } + } } function footer() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |