-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
activity duplication bug fix See merge request !9
- Loading branch information
Showing
31 changed files
with
830 additions
and
48 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
<?php | ||
|
||
class Iati_Aidstream_Element_Activity_Budget extends Iati_Core_BaseElement | ||
{ | ||
{ | ||
protected $isMultiple = true; | ||
protected $className = 'Budget'; | ||
protected $displayName = 'Budget'; | ||
protected $tableName = 'iati_budget'; | ||
protected $attribs = array('id','@type'); | ||
protected $iatiAttribs = array('@type'); | ||
protected $childElements = array('PeriodStart' , 'PeriodEnd','Value'); | ||
|
||
public function save($data , $parentId = null, $duplicate = false) | ||
{ | ||
if(!$duplicate) | ||
{ | ||
return parent::save($data, $parentId); | ||
} | ||
else | ||
{ | ||
if ($parentId) | ||
{ | ||
$parentColumnName = $this->getParentCoulmn(); | ||
} | ||
if ($this->isMultiple) | ||
{ | ||
foreach ($data as $elementData) | ||
{ | ||
if ($this->hasData($elementData)) | ||
{ | ||
$elementsData = $this->getElementsData($elementData); | ||
if ($parentId) | ||
{ | ||
$elementsData[$parentColumnName] = $parentId; | ||
} | ||
$elementsData['id'] = ''; | ||
$eleId = $this->db->insert($elementsData); | ||
} | ||
|
||
// If children are present create children elements and call their save function. | ||
if (!empty($this->childElements)) | ||
{ | ||
foreach ($this->childElements as $childElementClass) | ||
{ | ||
$childElementName = get_class($this) . "_$childElementClass"; | ||
$childElement = new $childElementName(); | ||
$childElement->save($elementData[$childElement->getClassName()] , $eleId, true); | ||
|
||
} | ||
} | ||
} | ||
} | ||
return $eleId; | ||
} | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
<?php | ||
|
||
class Iati_Aidstream_Element_Activity_Conditions extends Iati_Core_BaseElement | ||
{ | ||
{ | ||
protected $isMultiple = true; | ||
protected $className = 'Conditions'; | ||
protected $displayName = 'Conditions'; | ||
protected $tableName = 'iati_conditions'; | ||
protected $attribs = array('id','@attached'); | ||
protected $iatiAttribs = array('@attached'); | ||
protected $childElements = array('Condition'); | ||
|
||
public function save($data , $parentId = null, $duplicate = false) | ||
{ | ||
if(!$duplicate) | ||
{ | ||
return parent::save($data, $parentId); | ||
} | ||
else | ||
{ | ||
if ($parentId) | ||
{ | ||
$parentColumnName = $this->getParentCoulmn(); | ||
} | ||
if ($this->isMultiple) | ||
{ | ||
foreach ($data as $elementData) | ||
{ | ||
if ($this->hasData($elementData)) | ||
{ | ||
$elementsData = $this->getElementsData($elementData); | ||
if ($parentId) | ||
{ | ||
$elementsData[$parentColumnName] = $parentId; | ||
} | ||
$elementsData['id'] = ''; | ||
$eleId = $this->db->insert($elementsData); | ||
} | ||
|
||
// If children are present create children elements and call their save function. | ||
if (!empty($this->childElements)) | ||
{ | ||
foreach ($this->childElements as $childElementClass) | ||
{ | ||
$childElementName = get_class($this) . "_$childElementClass"; | ||
$childElement = new $childElementName(); | ||
$childElement->save($elementData[$childElement->getClassName()] , $eleId, true); | ||
|
||
} | ||
} | ||
} | ||
} | ||
return $eleId; | ||
} | ||
} | ||
} |
28 changes: 26 additions & 2 deletions
28
library/Iati/Aidstream/Element/Activity/Conditions/Condition.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
<?php | ||
|
||
class Iati_Aidstream_Element_Activity_Conditions_Condition extends Iati_Core_BaseElement | ||
{ | ||
protected $isMultiple = true; | ||
{ | ||
protected $isMultiple = true; | ||
protected $className = 'Condition'; | ||
protected $displayName = 'Condition'; | ||
protected $tableName = 'iati_conditions/condition'; | ||
protected $attribs = array('id','text','@type'); | ||
protected $iatiAttribs = array('text','@type'); | ||
|
||
public function save($data , $parentId = null, $duplicate = false) | ||
{ | ||
if(!$duplicate) | ||
{ | ||
return parent::save($data, $parentId); | ||
} | ||
else | ||
{ | ||
foreach ($data as $d) | ||
{ | ||
if ($this->hasData($d)) | ||
{ | ||
if($duplicate == true) | ||
{ | ||
$d['id'] = ''; | ||
$d['conditions_id'] = $parentId; | ||
$eleId = $this->db->insert($d); | ||
} | ||
} | ||
} | ||
return $eleId; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
<?php | ||
|
||
class Iati_Aidstream_Element_Activity_ContactInfo extends Iati_Core_BaseElement | ||
{ | ||
{ | ||
protected $isMultiple = true; | ||
protected $className = 'ContactInfo'; | ||
protected $displayName = 'Contact Info'; | ||
protected $tableName = 'iati_contact_info'; | ||
protected $attribs = array('id' , '@type' , '@xml_lang'); | ||
protected $iatiAttribs = array('@type' , '@xml_lang'); | ||
protected $childElements = array('Organisation','PersonName' , 'JobTitle' , 'Telephone','Email','MailingAddress' , 'Website'); | ||
|
||
public function save($data , $parentId = null, $duplicate = false) | ||
{ | ||
if(!$duplicate) | ||
{ | ||
return parent::save($data, $parentId); | ||
} | ||
else | ||
{ | ||
if ($parentId) | ||
{ | ||
$parentColumnName = $this->getParentCoulmn(); | ||
} | ||
if ($this->isMultiple) | ||
{ | ||
foreach ($data as $elementData) | ||
{ | ||
if ($this->hasData($elementData)) | ||
{ | ||
$elementsData = $this->getElementsData($elementData); | ||
if ($parentId) | ||
{ | ||
$elementsData[$parentColumnName] = $parentId; | ||
} | ||
$elementsData['id'] = ''; | ||
$eleId = $this->db->insert($elementsData); | ||
} | ||
|
||
// If children are present create children elements and call their save function. | ||
if (!empty($this->childElements)) | ||
{ | ||
foreach ($this->childElements as $childElementClass) | ||
{ | ||
$childElementName = get_class($this) . "_$childElementClass"; | ||
$childElement = new $childElementName(); | ||
$childElement->save($elementData[$childElement->getClassName()] , $eleId, true); | ||
} | ||
} | ||
} | ||
} | ||
return $eleId; | ||
} | ||
} | ||
} | ||
|
28 changes: 26 additions & 2 deletions
28
library/Iati/Aidstream/Element/Activity/ContactInfo/Email.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
<?php | ||
|
||
class Iati_Aidstream_Element_Activity_ContactInfo_Email extends Iati_Core_BaseElement | ||
{ | ||
{ | ||
protected $isMultiple = true; | ||
protected $className = 'Email'; | ||
protected $displayName = 'Email'; | ||
protected $tableName = 'iati_contact_info/email'; | ||
protected $attribs = array('id','text'); | ||
protected $iatiAttribs = array('text'); | ||
protected $iatiAttribs = array('text'); | ||
|
||
public function save($data , $parentId = null, $duplicate = false) | ||
{ | ||
if(!$duplicate) | ||
{ | ||
return parent::save($data, $parentId); | ||
} | ||
else | ||
{ | ||
foreach($data as $d) | ||
{ | ||
if($this->hasData($d)) | ||
{ | ||
if($duplicate == true) | ||
{ | ||
$d['id'] = ''; | ||
$d['contact_info_id'] = $parentId; | ||
$eleId = $this->db->insert($d); | ||
} | ||
} | ||
} | ||
return $eleId; | ||
} | ||
} | ||
} |
Oops, something went wrong.