@@ 2396-2430 (lines=35) @@ | ||
2393 | ||
2394 | $row = get_entity_as_row($guid); |
|
2395 | ||
2396 | if ($row) { |
|
2397 | // Exists and you have access to it |
|
2398 | $query = "SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}"; |
|
2399 | if ($exists = get_data_row($query)) { |
|
2400 | $query = "UPDATE {$CONFIG->dbprefix}sites_entity |
|
2401 | set name='$name', description='$description', url='$url' where guid=$guid"; |
|
2402 | $result = update_data($query); |
|
2403 | ||
2404 | if ($result != false) { |
|
2405 | // Update succeeded, continue |
|
2406 | $entity = get_entity($guid); |
|
2407 | if (elgg_trigger_event('update', $entity->type, $entity)) { |
|
2408 | return $guid; |
|
2409 | } else { |
|
2410 | $entity->delete(); |
|
2411 | //delete_entity($guid); |
|
2412 | } |
|
2413 | } |
|
2414 | } else { |
|
2415 | // Update failed, attempt an insert. |
|
2416 | $query = "INSERT into {$CONFIG->dbprefix}sites_entity |
|
2417 | (guid, name, description, url) values ($guid, '$name', '$description', '$url')"; |
|
2418 | $result = insert_data($query); |
|
2419 | ||
2420 | if ($result !== false) { |
|
2421 | $entity = get_entity($guid); |
|
2422 | if (elgg_trigger_event('create', $entity->type, $entity)) { |
|
2423 | return $guid; |
|
2424 | } else { |
|
2425 | $entity->delete(); |
|
2426 | //delete_entity($guid); |
|
2427 | } |
|
2428 | } |
|
2429 | } |
|
2430 | } |
|
2431 | ||
2432 | return false; |
|
2433 | } |
|
@@ 2526-2557 (lines=32) @@ | ||
2523 | if ($row) { |
|
2524 | // Exists and you have access to it |
|
2525 | $query = "SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}"; |
|
2526 | if ($exists = get_data_row($query)) { |
|
2527 | $query = "UPDATE {$CONFIG->dbprefix}users_entity |
|
2528 | SET name='$name', username='$username', password='$password', salt='$salt', |
|
2529 | email='$email', language='$language' |
|
2530 | WHERE guid = $guid"; |
|
2531 | ||
2532 | $result = update_data($query); |
|
2533 | if ($result != false) { |
|
2534 | // Update succeeded, continue |
|
2535 | $entity = get_entity($guid); |
|
2536 | if (elgg_trigger_event('update', $entity->type, $entity)) { |
|
2537 | return $guid; |
|
2538 | } else { |
|
2539 | $entity->delete(); |
|
2540 | } |
|
2541 | } |
|
2542 | } else { |
|
2543 | // Exists query failed, attempt an insert. |
|
2544 | $query = "INSERT into {$CONFIG->dbprefix}users_entity |
|
2545 | (guid, name, username, password, salt, email, language) |
|
2546 | values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')"; |
|
2547 | ||
2548 | $result = insert_data($query); |
|
2549 | if ($result !== false) { |
|
2550 | $entity = get_entity($guid); |
|
2551 | if (elgg_trigger_event('create', $entity->type, $entity)) { |
|
2552 | return $guid; |
|
2553 | } else { |
|
2554 | $entity->delete(); |
|
2555 | } |
|
2556 | } |
|
2557 | } |
|
2558 | } |
|
2559 | ||
2560 | return false; |