Add allowAnonymousSubmissions(). objectManager checks the return value of this new function and

exists with an error during certain actions if the user is not logged in and the function returns
false
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-04-29 23:00:01 +00:00
committed by WineHQ
parent d09f78ca00
commit 11ecfa230b
13 changed files with 70 additions and 1 deletions

View File

@@ -994,6 +994,11 @@ class Application {
/* If no errors occured we return the number of moved children */
return $iCount;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
function get_vendor_from_keywords($sKeywords)

View File

@@ -314,6 +314,11 @@ class application_queue
{
$this->oApp->objectDisplayAddItemHelp();
}
function allowAnonymousSubmissions()
{
return application::allowAnonymousSubmissions();
}
}
?>

View File

@@ -615,6 +615,11 @@ class distribution {
{
return $this->iDistributionId;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -667,6 +667,11 @@ class maintainer
return TRUE;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -330,6 +330,19 @@ class ObjectManager
echo html_back_link(1, $sBackLink);
}
function handle_anonymous_submission()
{
$oObject = new $this->sClass();
if($oObject->allowAnonymousSubmissions() || $_SESSION['current']->isLoggedIn())
return;
util_show_error_page_and_exit("You need to be <a href=\"".BASE.
"account.php?sCmd=login\">logged in</a>. If you don&#8217;t have an ".
"account you can <a href=\"".BASE."account.php?sCmd=new\">register ".
"now</a>, it only takes a few seconds.");
}
/* View an entry */
function view($sBackLink)
{
@@ -401,6 +414,8 @@ class ObjectManager
$oObject->update();
} else
{
$this->handle_anonymous_submission();
$oObject->create();
}
break;

View File

@@ -639,6 +639,11 @@ class Screenshot {
/* STUB */
return TRUE;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -1005,6 +1005,11 @@ class testData{
return TRUE;
}
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -168,6 +168,11 @@ class testData_queue
{
return $this->oTest->objectMakeLink();
}
function allowAnonymousSubmissions()
{
return testData::allowAnonymousSubmissions();
}
}
?>

View File

@@ -308,6 +308,11 @@ class Vendor {
return $oRow->count;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -1416,6 +1416,11 @@ class Version {
/* Return the number of updated objects if everything was successful */
return $iCount;
}
function allowAnonymousSubmissions()
{
return FALSE;
}
}
?>

View File

@@ -222,6 +222,11 @@ class version_queue
{
return $this->oVersion->objectMoveChildren($iNewId);
}
function allowAnonymousSubmissions()
{
return version::allowAnonymousSubmissions();
}
}
?>

View File

@@ -62,6 +62,9 @@ $sErrors = $oObject->processForm($aClean);
if($oObject->iId && $aClean['sAction'] == "delete")
$oObject->delete_entry();
if($aClean['sAction'] == "add")
$oObject->handle_anonymous_submission();
/* Provided the necessary values are present, an object's children may be moved
without any confirmation */
if($oObject->iId && $aClean['sAction'] == "moveChildren" && $aClean['iNewId'])

View File

@@ -122,7 +122,8 @@ function test_object_methods()
{
test_start(__FUNCTION__);
$aTestMethods = array("canEdit",
$aTestMethods = array("allowAnonymousSubmissions",
"canEdit",
"display",
"getOutputEditorValues",
"objectGetEntries",