Created
January 29, 2016 12:37
-
-
Save johnpuddephatt/45d42e30865a7061c9c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once(TOOLKIT . '/class.event.php'); | |
class eventcreate_child extends SectionEvent | |
{ | |
public $ROOTELEMENT = 'create-child'; | |
public $eParamFILTERS = array(); | |
public static function about() | |
{ | |
return array( | |
'name' => 'Create child', | |
'author' => array( | |
'name' => 'john puddephatt', | |
'website' => '###', | |
'email' => '###'), | |
'version' => 'Symphony 2.6.5', | |
'release-date' => '2016-01-29T10:18:14+00:00', | |
'trigger-condition' => 'action[create-child]' | |
); | |
} | |
public function priority(){ | |
return self::kHIGH; | |
} | |
public static function getSource() | |
{ | |
return '1'; | |
} | |
public static function allowEditorToParse() | |
{ | |
return false; | |
} | |
public static function documentation() | |
{ | |
return 'Chaining...' | |
} | |
public function load() | |
{ | |
$this->post = $_POST; | |
if (isset($_POST['action']['create-child'])) { | |
unset($_POST['fields']); | |
$_POST['fields'] = $this->post['create-child']['fields']; | |
$result = $this->__trigger(); | |
if($result->getAttribute('result') == "success") { | |
unset($_POST['action']['create-child']); | |
unset($_POST['fields']); | |
$_POST['fields'] = $this->post['create-parent']['fields']; | |
$child_id = $result->getAttribute('id'); | |
$_POST['fields']['children']['entries'] = [$child_id]; | |
$_POST['action']['create-parent'] = 'Submit'; | |
} | |
return $result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment