Program check if is valid and active.

@param int $programId
@param int $websiteId

@return bool
@throws \Exception
438851
private function checkCampignEnrolmentActive($programId, $websiteId)
    {
        //program is not set
        if (!$programId) {
            return false;
        }
        $client = $this->helper->getWebsiteApiClient($websiteId);
        $program = $client->getProgramById($programId);
        //program status
        if (isset($program->status)) {
            $this->programStatus = $program->status;
        }
        if (isset($program->status) && $program->status == 'Active') {
            return true;
        }

        return false;
    }
868393
public function lookup($nodeId, $siteId)
    {
        if (!$this->isLoaded) {
            $this->load();
            $this->isLoaded = true;
        }

        // Build the array we will store at the end of the query if we have
        // anything changed during the request
        if ($this->queriedCount < self::MAX_CACHE_SIZE) {
            $this->queried[$nodeId][$siteId] = true;
        }
        $this->queriedCount++;

        if (!isset($this->loaded[$nodeId][$siteId])) {
            // We already have cached this path in the past, or it was not in
            // original cache source array, or it is non existing anymore or
            // outdated, our cache is broken, we need to lookup and update
            return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId;
        }

        // Best case scenario, it exists!
        return $this->loaded[$nodeId][$siteId];
    }
249046
public static function setCurrentProvider($providerId)
    {
        $provider = self::getProviderById($providerId);
        if (empty($provider)) {
            throw new Exception(
                "Invalid provider ID '$providerId'. The provider either does not exist or is not available");
        }

        $provider->activate();

        Option::set(self::CURRENT_PROVIDER_OPTION_NAME, $providerId);
        Cache::clearCacheGeneral();
        return $provider;
    }
41839
public function checkWebsiteBeforeSave($websiteId, $type, $ruleId = false)
    {
        return $this->getCollection()
            ->hasCollectionAnyItemsByWebsiteAndType($websiteId, $type, $ruleId);
    }
876733
public function getPushIntegrationCode($websiteID)
    {
        if (empty($websiteID)) {
            return $this->handleError('Empty website id');
        }

        $requestResult = $this->sendRequest('/push/websites/' . $websiteID . '/code');

        return $this->handleResult($requestResult);
    }
14640
public function isGuestSyncEnabled($websiteId = 0)
    {
        return $this->scopeConfig->isSetFlag(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $websiteId
        );
    }
981535
public function isOrderSyncEnabled($websiteId = 0)
    {
        return $this->scopeConfig->isSetFlag(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $websiteId
        );
    }
1215289
public function deleteEvent($eventId)
    {
        if (is_null($eventId) || $eventId == '') {
            throw new Exception('The eventId is required to delete an event.');
        }

        $params = array(
            'method' => 'sp.event.delete',
            'event_id' => $eventId
        );

        return $this->_makeApiRequest($params);
    }
838475
public function reset($userId = null, $code = null)
    {
        try {
            if (post('postback')) {
                return $this->reset_onSubmit();
            }

            if (!$userId || !$code) {
                throw new ApplicationException(trans('backend::lang.account.reset_error'));
            }
        }
        catch (Exception $ex) {
            Flash::error($ex->getMessage());
        }

        $this->vars['code'] = $code;
        $this->vars['id'] = $userId;
    }
663785
public function isValid($siteId, $pageName, $pageType = PageTypes::NORMAL)
    {
        $isValidQueryBuilder = $this->_em->createQueryBuilder();
        $isValidQueryBuilder->select('page.pageId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->where('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->andWhere('page.site = :siteId')
            ->setParameter('pageName', $pageName)
            ->setParameter('pageType', $pageType)
            ->setParameter('siteId', $siteId);

        $result = $isValidQueryBuilder->getQuery()->getScalarResult();

        if (!empty($result)) {
            return true;
        }

        return false;
    }
1318293
public function setDefault($websiteId)
    {
        /** @var ConfigInterface $config */
        $config = $this->configFactory->create();

        $foundDifference = false;

        foreach ($this->defaultConfig as $key => $value) {
            if ($config->setConfigValue($key, $value, $websiteId)) {
                $foundDifference = true;
            }
        }

        if ($foundDifference) {
            $config->cleanScope();
        }

        return $this->statusResponseFactory->create()
            ->setStatus('ok');
    }
819294
public function verifyCode($sessionId, $code) {
    	try{
			if (empty($sessionId))
				throw new Exception('Paramer "sessionId" is required');

			if (empty($code))
				throw new Exception('Paramer "code" is required');


    		$params = array (
    		'sessionId' => $sessionId,
    		'code' => $code
    		);

    		$ret = $this->SendRequest->curl('/verifyCode.json',$params,'urlencoded','sms','POST');
    		if(empty($ret))
    			throw new Exception('bad request');
    		return $ret;

    	}catch (Exception $e) {
    		print_r($e->getMessage());
    	}
   }
665382
public function getActiveRuleByWebsiteAndType($type, $websiteId)
    {
        $collection = $this->addFieldToFilter('type', ['eq' => $type])
            ->addFieldToFilter('status', ['eq' => 1])
            ->addFieldToFilter('website_ids', ['finset' => $websiteId])
            ->setPageSize(1);

        if ($collection->getSize()) {
            return $collection->getFirstItem();
        }

        return [];
    }
99985
public function isSiteEmpty($siteId)
    {
        $sql = sprintf('SELECT idsite FROM %s WHERE idsite = ? limit 1', Common::prefixTable('log_visit'));

        $result = \Piwik\Db::fetchOne($sql, array($siteId));

        return $result == null;
    }
1160711
public function getDriveBySite($siteId)
    {
        $siteLocator  = "/sites/$siteId";
        $driveLocator = '/drive';
        $endpoint     = "$siteLocator$driveLocator";

        $response = $this
            ->graph
            ->createRequest('GET', $endpoint)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200) {
            throw new \Exception();
        }

        $drive = $response->getResponseAsObject(Model\Drive::class);

        return new DriveProxy($this->graph, $drive);
    }
676719
public function setActiveSite($siteID) {
		if($this->owner->config()->use_active_site_session) {
			Multisites::inst()->setActiveSite($siteID);
		} else {
			$this->owner->getRequest()->getSession()->set($this->getActiveSiteSessionKey(), $siteID);
		}
	}
683701
public function getRateLimitData($applicationId, $userId)
	{
		$sql = "SELECT * FROM `#__developer_rate_limit` 
				WHERE `application_id` = " . $this->db->quote($applicationId) . "
				AND `uidNumber` = " . $this->db->quote($userId) . "
				ORDER BY `created` LIMIT 1";
		$this->db->setQuery($sql);
		return $this->db->loadObject();
	}