Exemplo n.º 1
0
 /**
  * @param CAccount $oAccount
  *
  * @return array|bool
  */
 public function getFetchers($oAccount)
 {
     $mResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->getFetchers($oAccount))) {
         $oRow = null;
         $mResult = array();
         while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
             $oFetcher = new CFetcher($oAccount);
             $oFetcher->InitByDbRow($oRow);
             $mResult[] = $oFetcher;
         }
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }
Exemplo n.º 2
0
 /**
  * @param CAccount $oAccount
  *
  * @return array
  */
 public function FoldersOrder($oAccount)
 {
     $aList = array();
     if ($this->oConnection->Execute($this->oCommandCreator->FoldersOrder($oAccount))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $sOrder = $oRow->folders_order;
             if (!empty($sOrder)) {
                 $aOrder = @json_decode($sOrder, 3);
                 if (is_array($aOrder) && 0 < count($aOrder)) {
                     $aList = $aOrder;
                 }
             }
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $aList;
 }
Exemplo n.º 3
0
 /**
  * @param array $aIds
  * @return array
  */
 public function ContactIdsLinkedToGroups($aIds)
 {
     $aResult = array();
     if ($this->oConnection->Execute($this->oCommandCreator->ContactIdsLinkedToGroups($aIds))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $aResult[] = (int) $oRow->id_addr;
         }
         $this->oConnection->FreeResult();
     }
     return $aResult;
 }
Exemplo n.º 4
0
 /**
  * Updates a list of senders wich are considered safe to show external images coming from.
  * 
  * @param string $iUserId User identifier.
  * @param string $sEmail Email of sender wich is considered safe.
  * 
  * @return bool
  */
 public function setSafetySender($iUserId, $sEmail)
 {
     $bResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->getSafetySenderQuery($iUserId, $sEmail))) {
         $oRow = $this->oConnection->GetNextRecord();
         if (!$oRow) {
             $bResult = $this->oConnection->Execute($this->oCommandCreator->insertSafetySenderQuery($iUserId, $sEmail));
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $bResult;
 }
Exemplo n.º 5
0
 /**
  * @param string $sSearchDesc Default value is empty string.
  * @param int $iTenantId Default value is **0**.
  *
  * @return int|false
  */
 public function getDomainCount($sSearchDesc = '', $iTenantId = 0)
 {
     $iResultCount = false;
     if ($this->oConnection->Execute($this->oCommandCreator->getDomainCount($sSearchDesc, $iTenantId))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $iResultCount = (int) $oRow->domains_count;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $iResultCount;
 }
Exemplo n.º 6
0
 /**
  * @param CSocial &$oSocial
  *
  * @return bool
  */
 public function isSocialExists(CSocial $oSocial)
 {
     $bResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->isSocialExists($oSocial->IdAccount, $oSocial->TypeStr))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $bResult = 0 < (int) $oRow->social_count;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $bResult;
 }
Exemplo n.º 7
0
 /**
  * @return array|bool
  */
 private function parseGetMinDbResult()
 {
     $mResult = false;
     $oRow = $this->oConnection->GetNextRecord();
     if ($oRow && !empty($oRow->data)) {
         $aData = @\json_decode($oRow->data, true);
         if (is_array($aData) && 0 < count($aData)) {
             $mResult = $aData;
         }
     }
     $this->oConnection->FreeResult();
     return $mResult;
 }
Exemplo n.º 8
0
 /**
  * @param string $sType
  * @param string $sIdSocial
  * @return string
  */
 public function SocialExists($sType, $sIdSocial)
 {
     $bResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->SocialExists($sType, $sIdSocial))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $bResult = 0 < (int) $oRow->social_count;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $bResult;
 }
Exemplo n.º 9
0
 /**
  * @param int $iTenantId
  *
  * @return array
  */
 public function GetTenantDomains($iTenantId)
 {
     $mResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->GetTenantDomains($iTenantId))) {
         $oRow = null;
         $mResult = array();
         while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
             $mResult[$oRow->id_domain] = $oRow->name;
         }
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }
Exemplo n.º 10
0
 /**
  * @param int $iIdTenant
  * @param string $sSocialName
  *
  * @return array | false
  */
 public function GetSocialByName($iIdTenant, $sSocialName)
 {
     $oSocial = null;
     if ($this->oConnection->Execute($this->oCommandCreator->GetSocialByName($iIdTenant, $sSocialName))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $oSocial = new CTenantSocials();
             $oSocial->InitByDbRow($oRow);
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $oSocial;
 }
Exemplo n.º 11
0
 /**
  * @param int $iSubscriptionID
  *
  * @return array|bool
  */
 public function getSubscriptionById($iSubscriptionID)
 {
     $mResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->getSubscriptionById($iSubscriptionID))) {
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow && isset($oRow->id_tenant) && 0 < (int) $oRow->id_tenant) {
             $oSubscription = new CSubscription((int) $oRow->id_tenant);
             $oSubscription->InitByDbRow($oRow);
             $mResult = $oSubscription;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }
Exemplo n.º 12
0
 /**
  * @param int $iThreadID
  *
  * @return array|bool
  */
 public function GetOnline(CHelpdeskUser $oHelpdeskUser, $iThreadID)
 {
     $mResult = false;
     if ($this->oConnection->Execute($this->oCommandCreator->GetOnline($oHelpdeskUser, $iThreadID, 5))) {
         $oRow = null;
         $mResult = array();
         while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
             if ($oRow && isset($oRow->id_helpdesk_user) && isset($oRow->name) && isset($oRow->email)) {
                 if ((string) $oRow->id_helpdesk_user !== (string) $oHelpdeskUser->IdHelpdeskUser) {
                     $mResult[$oRow->id_helpdesk_user] = array((string) $oRow->name, (string) $oRow->email);
                 }
             }
         }
         $mResult = array_values($mResult);
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }
Exemplo n.º 13
0
 /**
  * 
  * @param type $sType
  * @param type $aViewAttrs
  * @param type $iOffset
  * @param type $iLimit
  * @param type $aSearchAttrs
  * @param type $sOrderBy
  * @param type $iSortOrder
  * @param type $aIdsOrUUIDs
  * @return \AEntity
  */
 public function getEntities($sType, $aViewAttrs = array(), $iOffset = 0, $iLimit = 20, $aSearchAttrs = array(), $sOrderBy = '', $iSortOrder = \ESortOrder::ASC, $aIdsOrUUIDs = array())
 {
     $mResult = false;
     if ($aViewAttrs === null) {
         $aViewAttrs = array();
     } else {
         if (count($aViewAttrs) === 0) {
             $this->oConnection->Execute($this->oCommandCreator->getAttributesNamesByEntityType($sType));
             while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
                 $aViewAttrs[] = $oRow->name;
             }
             $this->oConnection->FreeResult();
         }
     }
     if ($this->oConnection->Execute($this->oCommandCreator->getEntities($sType, $aViewAttrs, $iOffset, $iLimit, $aSearchAttrs, $sOrderBy, $iSortOrder, $aIdsOrUUIDs))) {
         $oRow = null;
         $mResult = array();
         while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
             if (class_exists($sType)) {
                 $oEntity = call_user_func($sType . '::createInstance');
             } else {
                 $oEntity = new \AEntity($sType);
             }
             $oEntity->iId = (int) $oRow->entity_id;
             $oEntity->sUUID = $oRow->entity_uuid;
             $oEntity->sModuleName = $oRow->entity_module;
             foreach (get_object_vars($oRow) as $sKey => $mValue) {
                 if (strrpos($sKey, 'attr_', -5) !== false) {
                     $sAttrKey = substr($sKey, 5);
                     $oEntity->{$sAttrKey} = \CAttribute::createInstance($sAttrKey, $mValue, null, $oEntity->isEncryptedAttribute($sAttrKey), $oEntity->iId);
                 }
             }
             $mResult[] = $oEntity;
         }
         $this->oConnection->FreeResult();
     }
     $this->throwDbExceptionIfExist();
     return $mResult;
 }