Skip to content
This repository
Browse code

fields can be set to custom xml now

  • Loading branch information...
commit d1fed995bca8ba17085728ffd0692ab90502ef4a 1 parent f39db22
Kyle Robinson Young authored
21  README.md
Source Rendered
@@ -148,21 +148,22 @@ FreshCake is offered under an [MIT license](http://www.opensource.org/licenses/m
148 148
 ## Roadmap and Known Issues
149 149
 
150 150
 * MORE TESTING! MORE TESTS!
151  
-* Fix issue with some text fields showing up as Array
152  
-* Format lines/xml on invoice, estimate and recurring afterFind (so they dont break scaffold)
153  
-* Implement estimate.sendByEmail
154  
-* Implement invoice.sendByEmail, invoice.sendBySnailMail
155  
-* Implement recurring.auto_bill
156  
-* Implement staff.current
157  
-* Implement OAuth support
158  
-* Add support for staff (needs custom afterFind)
159  
-* Test support for linking models together (hopefully already does automatically)
160  
-* i18n
  151
+* Fix issue with some text fields showing up as Array - v0.2
  152
+* Format lines/xml on invoice, estimate and recurring afterFind (so they dont break scaffold) - v0.2
  153
+* Implement estimate.sendByEmail - v0.2
  154
+* Implement invoice.sendByEmail, invoice.sendBySnailMail - v0.2
  155
+* Implement recurring.auto_bill - v0.2
  156
+* Implement staff.current - v0.2
  157
+* Add support for staff (needs custom afterFind) - v0.2
  158
+* Test support for linking models together (hopefully already does automatically) - v0.2
  159
+* Implement OAuth support - v0.3
  160
+* i18n - v0.3
161 161
 
162 162
 ## Changelog
163 163
 
164 164
 ### 0.2
165 165
 
  166
+* Fields can be set to custom XML now (needed for fixing tasks in project)
166 167
 * Added test cases for callback.verify, callback.resendToken
167 168
 * Added support for callback.verify, callback.resendToken
168 169
 * Added methods to return last request and response xml
23  models/datasources/freshbooks_source.php
@@ -230,16 +230,21 @@ public function create(&$model, $fields=null, $values=null) {
230 230
 			$submethod = 'create';
231 231
 		}
232 232
 		$xml =& new Xml(array('Request' => array('method' => $method.'.'.$submethod)));
233  
-		if (!isset($data['xml'])) {
234  
-			foreach ($data as $key => $val) {
235  
-				if (is_array($val)) {
236  
-					$singular = Inflector::singularize($key);
237  
-					$data[$key] = array($singular => $val);
238  
-				}
  233
+		$node =& new Xml(array($method => array()));
  234
+		foreach ($data as $key => $val) {
  235
+			if (is_array($val)) {
  236
+				$singular = Inflector::singularize($key);
  237
+				$val = array($key => array($singular => $val));
  238
+				$node->first()->append($val, array('format' => 'tags'));
  239
+				unset($data[$key]);
  240
+			} elseif (substr($val, 0, 1) == '<') {
  241
+				$my_node =& new Xml($val);
  242
+				$node->first()->append($my_node->children);
  243
+				unset($data[$key]);
  244
+			} else {
  245
+				$my = array($key => array(array($val)));
  246
+				$node->first()->append($my);
239 247
 			}
240  
-			$node =& new Xml(array($method => $data), array('format' => 'tags'));
241  
-		} else {
242  
-			$node =& new Xml($data['xml']);
243 248
 		}
244 249
 		$xml->first()->append($node->children);
245 250
 		$this->__requestXml = $xml->toString(array('header' => true));
18  models/project.php
@@ -44,10 +44,6 @@ class Project extends FreshbooksAppModel {
44 44
 			'type' => 'text',
45 45
 			'null' => true,
46 46
 		),
47  
-		'xml' => array(
48  
-			'type' => 'text',
49  
-			'null' => true,
50  
-		),
51 47
 	);
52 48
 	public $validate = array(
53 49
 		'name' => 'notEmpty',
@@ -56,8 +52,8 @@ class Project extends FreshbooksAppModel {
56 52
 
57 53
 /**
58 54
  * beforeSave
59  
- * Custom format because datasource 
60  
- * can't handle 'tasks'.
  55
+ * Set tasks to xml as the datasource 
  56
+ * cant handle it automatically
61 57
  * 
62 58
  * @return boolean
63 59
  */
@@ -68,15 +64,7 @@ public function beforeSave() {
68 64
 				array('tasks' => $this->data[$this->name]['tasks']),
69 65
 				array('format' => 'tags')
70 66
 			);
71  
-			unset($this->data[$this->name]['tasks']);
72  
-			$data =& new Xml($this->data, array('format' => 'tags'));
73  
-			$data->first()->append($tasks->children);
74  
-			$xml = $data->toString();
75  
-			$this->data = array(
76  
-				$this->name => array(
77  
-					'xml' => $xml,
78  
-				),
79  
-			);
  67
+			$this->data[$this->name]['tasks'] = $tasks->toString();
80 68
 		}
81 69
 		return true;
82 70
 	}

0 notes on commit d1fed99

Please sign in to comment.
Something went wrong with that request. Please try again.