public static function IsRelationRegistered($entityTypeID, $entityID, $typeID, $userID)
 {
     if (!CCrmOwnerType::IsDefined($entityTypeID)) {
         return false;
     }
     $userID = intval($userID);
     $entityID = intval($entityID);
     if ($userID <= 0 || $entityID <= 0) {
         return false;
     }
     $filter = array('SL_ENTITY_TYPE' => CCrmLiveFeedEntity::GetByEntityTypeID($entityTypeID), 'ENTITY_ID' => $entityID, 'USER_ID' => $userID);
     $typeID = intval($typeID);
     if (CCrmSonetSubscriptionType::IsDefined($typeID)) {
         $filter['TYPE_ID'] = $typeID;
     }
     $dbResult = CCrmSonetSubscription::GetList(array(), $filter, array(), false, array('TYPE_ID'));
     return is_int($dbResult) ? $dbResult > 0 : false;
 }
 public function UnRegisterByType($entityTypeID, $entityID, $typeID)
 {
     if (!CCrmOwnerType::IsDefined($entityTypeID)) {
         return false;
     }
     $entityID = intval($entityID);
     if ($entityID <= 0) {
         return false;
     }
     $typeID = intval($typeID);
     if (!CCrmSonetSubscriptionType::IsDefined($typeID)) {
         $typeID = CCrmSonetSubscriptionType::Observation;
     }
     global $DB;
     $tableName = self::TABLE_NAME;
     $slEntityType = $DB->ForSql(CCrmLiveFeedEntity::GetByEntityTypeID($entityTypeID));
     $deleteSql = "DELETE FROM {$tableName} WHERE SL_ENTITY_TYPE = '{$slEntityType}' AND ENTITY_ID = {$entityID} AND TYPE_ID = {$typeID}";
     $dbResult = $DB->Query($deleteSql, false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__);
     return is_object($dbResult) && $dbResult->AffectedRowsCount() > 0;
 }