public static function requestAccountConnection($session, $profile) { if (self::isValid($session) === false) { return false; } $uid = trim($session->authUid); $source = str_replace("-sp", "", trim($session->authSource)); $ispending = self::isPending($session); if ($ispending === true) { return true; } //Save pending account entry $pending = new Default_Model_PendingAccount(); $pending->researcherid = $profile->id; $pending->accountid = $uid; $pending->accountType = $source; $pending->accountName = trim($session->userFirstName . " " . $session->userLastName); $pending->save(); //make sure you get the pending account item data from race conditions $try_count = 0; while ($try_count < 10) { $paccounts = new Default_Model_PendingAccounts(); $paccounts->filter->id->equals($pending->id); if (count($paccounts->items) > 0) { $pending = $paccounts->items[0]; break; } $try_count += 1; sleep(1); } self::updateSessionAsPending($session, $pending); self::sendConfirmationEmail($session, $pending); return true; }
public function save(Default_Model_PendingAccount $value) { global $application; $data = array(); if (!isnull($value->getId())) { $data['id'] = $value->getId(); } if (!isnull($value->getCode())) { $data['code'] = $value->getCode(); } if (!isnull($value->getResearcherID())) { $data['researcherid'] = $value->getResearcherID(); } if (!isnull($value->getAccountID())) { $data['accountid'] = $value->getAccountID(); } if (!isnull($value->getAccountType())) { $data['account_type'] = $value->getAccountType(); } if (!isnull($value->getAccountName())) { $data['account_name'] = $value->getAccountName(); } if (!isnull($value->getResolved())) { $data['resolved'] = $this->pgBool($value->getResolved()); } if (!isnull($value->getResolvedon())) { $data['resolvedon'] = $value->getResolvedon(); } if (!isnull($value->getAddedon())) { $data['addedon'] = $value->getAddedon(); } $q1 = 'id = ?'; $q2 = $value->id; if (null === ($id = $value->id)) { unset($data['id']); $value->id = $this->getDbTable()->insert($data); } else { $s = $this->getDbTable()->getAdapter()->quoteInto($q1, $q2); $this->getDbTable()->update($data, $s); } }