diff --git a/include/application.php b/include/application.php
index 5ae587c..f342345 100644
--- a/include/application.php
+++ b/include/application.php
@@ -1341,6 +1341,11 @@ class Application {
return $sMsg;
}
+ public function objectAllowCreatingParents()
+ {
+ return true;
+ }
+
public function objectSetParent($iNewId, $sClass = '')
{
$this->iVendorId = $iNewId;
diff --git a/include/objectManager.php b/include/objectManager.php
index 2b23921..a695cda 100644
--- a/include/objectManager.php
+++ b/include/objectManager.php
@@ -917,6 +917,8 @@ class ObjectManager
$sClassDisplayName = $oParentOM->GetOptionalSetting('objectGetClassDisplayName', 'parent entry');
+ echo '
Create and move to a new $sClassDisplayName
\n";
+
/* Display some help text */
echo "Move ".$oObject->objectMakeLink()." to the $sClassDisplayName ";
echo "selected below:
\n";
@@ -1127,6 +1129,61 @@ class ObjectManager
echo "\n";
}
+ public function move_to_new_parent($aClean, $sErrors = '')
+ {
+ $oObject = new $this->sClass($this->iId);
+ $oOldParent = $oObject->objectGetParent();
+ $sParentClass = get_class($oOldParent);
+ $oParent = new $sParentClass();
+ $oParentOM = new objectManager($sParentClass);
+
+ echo "\n";
+
+ echo '
Move '.$oObject->objectMakeLink().' to a new entry:
';
+
+ /* Display errors, if any, and fetch form data */
+ if($this->displayErrors($sErrors))
+ {
+ global $aClean;
+ $oParent->getOutputEditorValues($aClean);
+
+ if($sErrors === PREVIEW_ENTRY)
+ $this->show_preview($oParent, $aClean);
+ }
+
+ /* Display help if it exists */
+ if(method_exists($oParent, "objectDisplayAddItemHelp"))
+ {
+ $aVars = $this->get_custom_vars($aClean, "addHelp");
+
+ if($aVars)
+ $oParent->objectDisplayAddItemHelp($aClean);
+ else
+ $oParent->objectDisplayAddItemHelp();
+ }
+
+ echo "
\n";
+ echo html_back_link(1);
+
+ echo "
\n";
+ }
+
private function handle_preview_button()
{
$oObject = $this->getObject();
@@ -1290,6 +1347,14 @@ class ObjectManager
$this->iId = $this->getIdFromInput($aClean);
$oObject = new $this->sClass($this->iId);
+
+ if($aClean['sSubmit'] == 'Move to new parent')
+ {
+ $oOldParent = $oObject->objectGetParent();
+ $sParentClass = get_class($oOldParent);
+ $oObject = new $sParentClass();
+ }
+
$oOriginalObject = new $this->sClass($this->iId); /* Prevent possible security hole if users change key
variables, making the permission checks run on
the wrong criteria */
@@ -1314,7 +1379,7 @@ class ObjectManager
/* Check input, if necessary */
if($aClean['sSubmit'] != "Delete" &&
- method_exists(new $this->sClass, "checkOutputEditorInput"))
+ method_exists($oObject, "checkOutputEditorInput"))
{
$sErrors = $oObject->checkOutputEditorInput($aClean);
}
@@ -1329,6 +1394,27 @@ class ObjectManager
case "Preview":
return PREVIEW_ENTRY;
+ case 'Move to new parent':
+ if(!$this->iId)
+ return FALSE;
+
+ if($sErrors)
+ return $sErrors;
+
+ if(!$oOriginalObject->canEdit())
+ return FALSE;
+
+ if(!$this->getOptionalSetting('objectAllowCreatingParents', false))
+ return FALSE;
+
+ $oObject->create();
+ if($oObject->objectGetState() != 'accepted')
+ $oObject->unQueue();
+
+ $oOriginalObject->objectSetParent($oObject->objectGetId());
+ $oOriginalObject->update();
+ break;
+
case "Submit":
// if we have errors, return them
if($sErrors)
diff --git a/include/vendor.php b/include/vendor.php
index 1aad746..e85966a 100644
--- a/include/vendor.php
+++ b/include/vendor.php
@@ -105,9 +105,6 @@ class Vendor {
*/
function unQueue()
{
- if(!$this->canEdit())
- return FALSE;
-
$hResult = query_parameters("UPDATE vendor SET state = '?' WHERE vendorId = '?'",
'accepted', $this->iVendorId);
diff --git a/objectManager.php b/objectManager.php
index 012c845..7283027 100644
--- a/objectManager.php
+++ b/objectManager.php
@@ -128,6 +128,10 @@ if($oObject->getId() && $sAction != "add")
$oObject->display_entry_for_editing($aClean, $sErrors);
break;
+ case 'moveToNewParent':
+ $oObject->move_to_new_parent($aClean, $sErrors);
+ break;
+
case 'showChangeParent':
$oObject->display_change_parent();
break;