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:
committed by
WineHQ
parent
d09f78ca00
commit
11ecfa230b
@@ -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)
|
||||
|
||||
@@ -314,6 +314,11 @@ class application_queue
|
||||
{
|
||||
$this->oApp->objectDisplayAddItemHelp();
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return application::allowAnonymousSubmissions();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -615,6 +615,11 @@ class distribution {
|
||||
{
|
||||
return $this->iDistributionId;
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -667,6 +667,11 @@ class maintainer
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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’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;
|
||||
|
||||
@@ -639,6 +639,11 @@ class Screenshot {
|
||||
/* STUB */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1005,6 +1005,11 @@ class testData{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -168,6 +168,11 @@ class testData_queue
|
||||
{
|
||||
return $this->oTest->objectMakeLink();
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return testData::allowAnonymousSubmissions();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -308,6 +308,11 @@ class Vendor {
|
||||
|
||||
return $oRow->count;
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1416,6 +1416,11 @@ class Version {
|
||||
/* Return the number of updated objects if everything was successful */
|
||||
return $iCount;
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -222,6 +222,11 @@ class version_queue
|
||||
{
|
||||
return $this->oVersion->objectMoveChildren($iNewId);
|
||||
}
|
||||
|
||||
function allowAnonymousSubmissions()
|
||||
{
|
||||
return version::allowAnonymousSubmissions();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -122,7 +122,8 @@ function test_object_methods()
|
||||
{
|
||||
test_start(__FUNCTION__);
|
||||
|
||||
$aTestMethods = array("canEdit",
|
||||
$aTestMethods = array("allowAnonymousSubmissions",
|
||||
"canEdit",
|
||||
"display",
|
||||
"getOutputEditorValues",
|
||||
"objectGetEntries",
|
||||
|
||||
Reference in New Issue
Block a user