/** * Wyszukiwanie użytkownika po kodzie systemu oraz loginie * @param string $login - login użytkownika * @param string $system - kod systemu zewnętrznego * @return integer - klucz główny z tabelki external_user */ public function findExternalUserByLogin($system, $login) { if (!$login or !$system) { throw new Exception('Brak identyikatora loginu uzytkownika lub identyfikatora systemu zewnetrznego'); } $login = strtoupper($login); $dictionary = new Dictionarybs(); $dictbs = new DictionarybsEntry(); $extUsr = new ExternalUser(); $select = $dictbs->select()->where('code = ?', $system); $dictEntryRowset = $dictionary->fetchRow("code = 'SYST'")->findDependentRowset('DictionarybsEntry', null, $select); $systemCount = $dictEntryRowset->count(); if ($systemCount === 0) { throw new SoapFault('088', 'Nieprawidłowy identyfikator aplikacji dostępowej.'); } else { $systemId = $dictEntryRowset->current()->id; try { $userId = $extUsr->createRow(array('system_id' => $systemId, 'login' => $login))->save(); } catch (Exception $e) { $result = $this->_findExternalUser($system, null, $login); return $result['id']; } } return $userId; }