Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Namecheap/Users/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ public function login($password) {
* @todo When you call this API, a link to reset password will be emailed to the end user's profile email id.The end user needs to click on the link to reset password.
* @note : UserName should be omitted for this API call.All other Global parameters must be included.
*
* @param str|FindBy|req : Possible values:EMAILADDRESS, DOMAINNAME,USERNAME
* @param str|FindByValue|req : The username/email address/domain of the user
* @param str|FindBy|req : Possible values:EMAILADDRESS, DOMAINNAME,USERNAME
* @param str|EmailFromName|opt : Enter a different value to overwrite the default value - Default Value: namecheap.com
* @param str|EmailFrom|opt : Enter a different value to overwrite the default value - Default Value: support@namecheap.com
* @param str|URLPattern|opt : Enter a different URL to overwrite namecheap.com. Refer Example Request#2 - Default Value: http://namecheap.com [RESETCODE]
*/
public function resetPassword($findBy='EMAILADDRESS', $findByValue, $emailFromName=null, $emailFrom=null, $uRLPattern=null) {
public function resetPassword($findByValue, $findBy='EMAILADDRESS', $emailFromName=null, $emailFrom=null, $uRLPattern=null) {
$this->userName = null; // UserName should be omitted for this API call.All other Global parameters must be included.

$data = [
Expand Down
45 changes: 29 additions & 16 deletions src/Namecheap/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private static function &convert($node)
break;
case XML_ELEMENT_NODE:
// for each child node, call the covert function recursively
$textNodes = [];
for ($i = 0, $m = $node->childNodes->length; $i < $m; $i++) {
$child = $node->childNodes->item($i);
$v = self::convert($child);
Expand All @@ -84,31 +85,23 @@ private static function &convert($node)
} else {
//check if it is not an empty text node
if ($v !== '') {
$output = $v;
$textNodes[] = $v;
}
}
}
if (is_array($output)) {
// if only one node of its kind, assign it directly instead if array($value);
foreach ($output as $t => $v) {
if (is_array($v) && count($v) == 1) {
$output[$t] = $v[0];
}
}
if (empty($output)) {
//for empty nodes
$output = '';
}

if (!empty($textNodes)) {
$output['__text'] = implode(PHP_EOL, $textNodes);
}

// loop through the attributes and collect them
if ($node->attributes->length) {
$a = [];
foreach ($node->attributes as $attrName => $attrNode) {
$a[$attrName] = (string) $attrNode->value;
}
// if its an leaf node, store the value in @value instead of directly storing it.
if (!is_array($output) && !empty($output)) {
$output = ['__text' => $output];
if (!empty($output)) {
if (count($a)) {
foreach ($a as $kk => $vv) {
$output['_'.$kk] = $vv;
Expand All @@ -118,12 +111,32 @@ private static function &convert($node)
if (is_string($output) && empty($output)) {
$output = [];
}

foreach ($a as $k => $v) {
$output['_'.$k] = $v;
$output['_'.$k] = $v;
}
}
}

if (is_array($output)) {
if (empty($output)) {
//for empty nodes
$output = '';
break;
}

// if only one node of its kind, assign it directly instead if array($value);
foreach ($output as $t => $v) {
if (is_array($v) && count($v) == 1) {
$output[$t] = $v[0];
}
}

if (count($output) == 1 && array_key_exists('__text', $output)) {
$output = $output['__text'];
}
}

break;
}
return $output;
Expand Down