Check if site assigned with active license.

@author     Vova Feldman (@svovaf)
@since      1.0.6

@deprecated Please use has_active_valid_license() instead because license can be cancelled.
505890
function has_active_license() {
            return (
                is_object( $this->_license ) &&
                is_numeric( $this->_license->id ) &&
                ! $this->_license->is_expired()
            );
        }
128096
function is_free_plan() {
            if ( ! $this->is_registered() ) {
                return true;
            }

            if ( ! $this->has_paid_plan() ) {
                return true;
            }

            return (
                'free' === $this->get_plan_name() ||
                ! $this->has_features_enabled_license()
            );
        }
1323012
def is_active(self):
    
    if not self._multiplexer:
      return False

    scalars_plugin_instance = self._get_scalars_plugin()
    if not (scalars_plugin_instance and
            scalars_plugin_instance.is_active()):
      return False

    # This plugin is active if any run has a layout.
    return bool(self._multiplexer.PluginRunToTagToContent(metadata.PLUGIN_NAME))
489196
public function isActive()
    {
        if (($page = Director::get_current_page()) && $page instanceof Page) {
            
            $ids = $this->Pages()->column('ID');
            
            if (!$this->isInherited()) {
                return in_array($page->ID, $ids);
            }
            
            return !empty(array_intersect($ids, $page->getAncestors(true)->column('ID')));
            
        }
        
        return false;
    }
431948
private function handle_license_deactivation_result( $license, $hmm_text = false, $show_notice = true ) {
            if ( isset( $license->error ) ) {
                $this->_admin_notices->add(
                    $this->get_text_inline( 'It looks like the license deactivation failed.', 'license-deactivation-failed-message' ) . '<br> ' .
                    $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . var_export( $license->error, true ),
                    $hmm_text,
                    'error'
                );

                return;
            }

            // Update license cache.
            if ( is_array( $this->_licenses ) ) {
                for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
                    if ( $license->id == $this->_licenses[ $i ]->id ) {
                        $this->_licenses[ $i ] = new FS_Plugin_License( $license );
                    }
                }
            }

            // Update site plan to default.
            $this->_sync_plans();
            $this->_site->plan_id = $this->_plans[0]->id;
            // Unlink license from site.
            $this->_update_site_license( null );

            $this->_store_account();

            if ( $show_notice ) {
                $this->_admin_notices->add(
                    sprintf( $this->get_text_inline( 'Your license was successfully deactivated, you are back to the %s plan.', 'license-deactivation-message' ), $this->get_plan_title() ),
                    $this->get_text_inline( 'O.K', 'ok' )
                );
            }

            $this->_admin_notices->remove_sticky( array(
                'plan_upgraded',
                'license_activated',
            ) );
        }
982394
public function isAuthenticated()
    {
        if (parent::isAuthenticated()) {
            if (isset($this->token['access_token'])) {
                $expired = $this->isTokenExpired();
                //We err on the side of valid vs invalid, as the API will invalidate if we are wrong, which isn't harmful
                if ($expired === false || $expired === -1) {
                    return true;
                }
            }
        }
        return false;
    }
846843
public function check_activation() {
		$license_data = get_option( $this->product->get_key() . '_license_data', '' );
		if ( '' === $license_data ) {
			return false;
		}

		return isset( $license_data->error ) ? ( 'no_activations_left' == $license_data->error ) : false;

	}
652747
function has_premium_license( $licenses ) {
			if ( is_array( $licenses ) ) {
				/**
				 * @var FS_Plugin_License[] $licenses
				 */
				foreach ( $licenses as $license ) {
					if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
						return true;
					}
				}
			}

			return false;
		}
511528
private function is_license_network_active( $except_blog_id = 0 ) {
            $this->_logger->entrance();

            if ( ! is_object( $this->_license ) ) {
                return false;
            }

            $sites = self::get_sites();

            if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) {
                // There are more sites than the number of activations, so license cannot be network activated.
                return false;
            }

            foreach ( $sites as $site ) {
                $blog_id = self::get_site_blog_id( $site );

                if ( $except_blog_id == $blog_id ) {
                    // Skip excluded blog.
                    continue;
                }

                $install = $this->get_install_by_blog_id( $blog_id );

                if ( is_object( $install ) && $install->license_id != $this->_license->id ) {
                    return false;
                }
            }

            return true;
        }
327253
private function sync_site_license() {
            $api = $this->get_api_user_scope();

            $result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true );

            if ( ! $this->is_api_result_entity( $result ) ) {
                return $result;
            }

            $license = $this->_update_site_license( new FS_Plugin_License( $result ) );
            $this->_store_licenses();

            return $license;
        }
1295111
function check_expiration() {
		$license_data = get_option( $this->product->get_key() . '_license_data', '' );
		if ( '' === $license_data ) {
			return false;
		}
		if ( ! isset( $license_data->expires ) ) {
			return false;
		}
		if ( strtotime( $license_data->expires ) - time() > 30 * 24 * 3600 ) {
			return false;
		}

		return true;
	}
13932
public function isActive()
    {
        // wee need a namespace first
        if(!isset($this->namespace)) {
            return false;
        }

        // Plugin is not active is it's not installed
        if(!self::isInstalled($this->namespace)) {
            return false;
        }

        if(!$this->isActive) {
            return false;
        }
        return true;
    }
614766
def is_valid_sites(self):
        
        if 'site_model' in self.inputs and 'sites' in self.inputs:
            return False
        elif 'site_model' in self.inputs and self.sites:
            return False
        elif 'sites' in self.inputs and self.sites:
            return False
        elif self.sites and self.region and self.region_grid_spacing:
            return False
        else:
            return True
1112945
public function isAllowed()
    {
        /** @var \Magento\Framework\App\Request\Http $req */
        $req = $this->context->getRequest();

        if ($this->legacyContext->getAppState()->getAreaCode() !== FrontNameResolver::AREA_CODE
            && !$req->isAjax()
            && $this->sgConfig->isValid()
        ) {
            return true;
        }

        return false;
    }
146867
public function is_active() : bool {
        $active = [
            api::DATAREQUEST_STATUS_APPROVED => true,
        ];

        return isset($active[$this->get('status')]);
    }
189548
public function license_view() {
		$status = $this->get_license_status();
		$value  = $this->license_key;

		$activate_string   = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
		$deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
		$valid_string      = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
		$invalid_string    = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
		$license_message   = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );

		echo '<p ><input ' . ( ( 'valid' === $status ) ? ( 'style="border:1px solid #7ad03a; "' ) : '' ) . ' type="text" id="' . $this->product->get_key() . '_license" name="' . $this->product->get_key() . '_license" value="' . $value . '" /><a ' . ( ( 'valid' === $status ) ? ( 'style="color:#fff;background:  #7ad03a; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px;  -webkit-border-radius: 3px;border-radius: 3px; ">' . $valid_string ) : ( 'style="color:#fff;background:  #dd3d36; display: inline-block;text-decoration: none;font-size: 13px;line-height: 26px;height: 26px; margin-left:5px; padding: 0 10px 1px;  -webkit-border-radius: 3px;border-radius: 3px; ">' . $invalid_string ) ) . ' </a>&nbsp;&nbsp;&nbsp;<button name="' . $this->product->get_key() . '_btn_trigger" ' . ( ( 'valid' === $status ) ? ( ' class="button button-primary">' . $deactivate_string ) : ( ' class="button button-primary" value="yes" type="submit" >' . $activate_string ) ) . ' </button></p><p class="description">' . sprintf( $license_message, '<a  href="' . $this->get_api_url() . '">' . $this->get_distributor_name() . '</a> ', $this->product->get_type() ) . '</p>';

	}
526343
public function is_valid($mark_as_used=true) {
	if (!empty($this->data['used'])) {
		return false;
	}
	if (time() > $this->data['expire_at']) {
		return false;
	}
	
	if ($mark_as_used) {
		$this->mark_as_used();
	}
	
	return true;
}