Skip to content

Commit df2f16d

Browse files
Merge pull request #234 from KennyDs/beta
Added extra API user variable + XML attribute possibility
2 parents a7a740d + 922ef7a commit df2f16d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

application/libraries/Format.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,24 @@ public function to_xml($data = null, $structure = null, $basenode = 'xml')
127127
// replace anything not alpha numeric
128128
$key = preg_replace('/[^a-z_\-0-9]/i', '', $key);
129129

130+
if ($key === '_attributes' && (is_array($value) || is_object($value)))
131+
{
132+
$attributes = $value;
133+
if (is_object($attributes)) $attributes = get_object_vars($attributes);
134+
135+
foreach ($attributes as $attributeName => $attributeValue)
136+
{
137+
$structure->addAttribute($attributeName, $attributeValue);
138+
}
139+
}
130140
// if there is another array found recursively call this function
131-
if (is_array($value) || is_object($value))
141+
else if (is_array($value) || is_object($value))
132142
{
133143
$node = $structure->addChild($key);
134144

135145
// recursive call.
136146
$this->to_xml($value, $node, $key);
137147
}
138-
139148
else
140149
{
141150
// add single node.

application/libraries/REST_Controller.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ abstract class REST_Controller extends CI_Controller
172172
'html' => 'text/html',
173173
'csv' => 'application/csv'
174174
);
175+
176+
/**
177+
* Information about the current API user
178+
*
179+
* @var object
180+
*/
181+
protected $_apiuser;
175182

176183
/**
177184
* Developers can extend this class and add a check in here.
@@ -692,6 +699,8 @@ protected function _detect_api_key()
692699
isset($row->level) AND $this->rest->level = $row->level;
693700
isset($row->ignore_limits) AND $this->rest->ignore_limits = $row->ignore_limits;
694701

702+
$this->_apiuser = $row;
703+
695704
/*
696705
* If "is private key" is enabled, compare the ip address with the list
697706
* of valid ip addresses stored in the database.

0 commit comments

Comments
 (0)