Beispiel #1
0
 /**
  * @param string $sSql
  * @param int $iUserId = null
  * @param int $iSharedTenantId = null
  * @return CContact
  */
 protected function getContactBySql($sSql, $iUserId = null, $iSharedTenantId = null)
 {
     $oContact = false;
     if ($this->oConnection->Execute($sSql)) {
         $oContact = null;
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $oContact = new CContact();
             $oContact->InitByDbRow($oRow);
             if ($oContact->ReadOnly && null !== $iUserId && (EContactType::Global_ === $oContact->Type || EContactType::GlobalAccounts === $oContact->Type)) {
                 $oGContact = $this->GetMyGlobalContact($iUserId);
                 if ($oGContact && (string) $oContact->IdTypeLink === (string) $oGContact->IdContact) {
                     $oContact->ReadOnly = false;
                     $oContact->ItsMe = true;
                 }
             }
             $this->oConnection->FreeResult();
             $this->updateContactGroupIds($oContact);
         } else {
             $this->oConnection->FreeResult();
         }
     }
     $this->throwDbExceptionIfExist();
     return $oContact;
 }