Check if add-on was connected to install

@author Vova Feldman (@svovaf)
@since  1.1.7

@param  string|number $id_or_slug

@return bool
2331
function is_addon_connected( $id_or_slug ) {
            $this->_logger->entrance();

            $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );

            $addon_id = self::get_module_id( $id_or_slug );
            $addon    = $this->get_addon( $addon_id );
            $slug     = $addon->slug;
            if ( ! isset( $sites[ $slug ] ) ) {
                return false;
            }

            $site = $sites[ $slug ];

            $plugin = FS_Plugin_Manager::instance( $addon_id )->get();

            if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
                // The given slug do NOT belong to any of the plugin's add-ons.
                return false;
            }

            return ( is_object( $site ) &&
                     is_numeric( $site->id ) &&
                     is_numeric( $site->user_id ) &&
                     FS_Plugin_Plan::is_valid_id( $site->plan_id )
            );
        }
84951
public function remove($id_or_external_id) {
    if (count($this) === 0) {
      return true;
    }
    $this->_set_items(array_filter($this->_get_items(), function($item) use ($id_or_external_id) {
      return !($item->id == $id_or_external_id || $item->external_id == $id_or_external_id);
    }));
  }
844256
public function load($id = null)
    {
        if (!is_null($id)) {
            $this->setId($id);
        }

        $this->isLoaded = false;
        $data = $this->getDbGateway()->load($this->getId());
        if ($data) {
            $this->setData($data);
            $this->isLoaded = true;
        }

        return $this->isLoaded();
    }
651319
public function has($id)
    {
        // second argument
        $withAutowiring = func_num_args() > 1 ? (bool) func_get_arg(1) :
            $this->autowiring;

        // return FALSE if $id not a string
        return is_string($id) && (
            // found in definitions ?
            isset($this->services[$id])  ||

            // Or in definition providers ?
            $this->hasInProvider($id) ||

            // Or with id autowired ?
            $this->autoWiringId($id, $withAutowiring)
        ) ? true : false;
    }
522907
public function has($id) {
		if (! $this->connectionCheckStatus) {
			$this->addServer();
		}
		
		return $this->getClient()->get($this->prepareId($id)) !== false;
	}
990021
public function actionView($id = null, $slug = null)
    {
        $model = User::find()->where(['and',
                ['id' => $id],
                ['!=', 'status', User::STATUS_REGISTERED],
                ['or',
                    ['slug' => $slug],
                    ['slug' => ''],
                    ['slug' => null],
                ]
            ])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
            return $this->redirect(['members/index']);
        }
        return $this->render('view', ['model' => $model]);
    }
168044
public function isBlocking($id): bool
    {
        if (is_array($id)) {
            return count($id) === $this->blockingUsers()->whereIn('blocked_by_id', $id)->count();
        }

        return $this->blockingUsers()->where('blocked_by_id', $id)->exists();
    }
712612
public function recordExists($id)
    {
        if (is_object($id)) {
            return true;
        }
        if (is_numeric($id) or $this->shouldBeNumber($id)) {
            return $this->findById($id, true);
        }
        if (is_string($id)) {
            return $this->findByIdentifier($id, true);
        }
    }
447862
public function actionCategory($id = null, $slug = null)
    {
        if (!is_numeric($id) || $id < 1 || empty($slug)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the category you are looking for.'));
            return $this->redirect(['forum/index']);
        }
        $conditions = ['id' => $id, 'slug' => $slug];
        if ($this->module->user->isGuest) {
            $conditions['visible'] = 1;
        }
        $model = Category::find()->where($conditions)->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the category you are looking for.'));
            return $this->redirect(['forum/index']);
        }
        $this->setMetaTags($model->keywords, $model->description);
        return $this->render('category', ['model' => $model]);
    }
738013
private function _sync_addon_license( $addon_id, $background ) {
            $this->_logger->entrance();

            if ( $this->is_addon_activated( $addon_id ) ) {
                // If already installed, use add-on sync.
                $fs_addon = self::get_instance_by_id( $addon_id );
                $fs_addon->_sync_license( $background );

                return;
            }

            // Validate add-on exists.
            $addon = $this->get_addon( $addon_id );

            if ( ! is_object( $addon ) ) {
                return;
            }

            // Add add-on into account add-ons.
            $account_addons = $this->get_account_addons();
            if ( ! is_array( $account_addons ) ) {
                $account_addons = array();
            }
            $account_addons[] = $addon->id;
            $account_addons   = array_unique( $account_addons );
            $this->_store_account_addons( $account_addons );

            // Load add-on licenses.
            $licenses = $this->_fetch_licenses( $addon->id );

            // Sync add-on licenses.
            if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
                $this->_update_licenses( $licenses, $addon->id );

                if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) {
                    $plans_result = $this->get_api_site_or_plugin_scope()->get( $this->add_show_pending( "/addons/{$addon_id}/plans.json" ) );

                    if ( ! isset( $plans_result->error ) ) {
                        $plans = array();
                        foreach ( $plans_result->plans as $plan ) {
                            $plans[] = new FS_Plugin_Plan( $plan );
                        }

                        $this->_admin_notices->add_sticky(
                            sprintf(
                                ( FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
                                    $this->get_text_inline( 'Your %s Add-on plan was successfully upgraded.', 'addon-successfully-upgraded-message' ) :
                                    /* translators: %s:product name, e.g. Facebook add-on was successfully... */
                                    $this->get_text_inline( '%s Add-on was successfully purchased.', 'addon-successfully-purchased-message' ) ),
                                $addon->title
                            ) . ' ' . $this->get_latest_download_link(
                                $this->get_text_inline( 'Download the latest version', 'download-latest-version' ),
                                $addon_id
                            ),
                            'addon_plan_upgraded_' . $addon->slug,
                            $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
                        );
                    }
                }
            }
        }
1305970
protected function hasInProvider(/*# string */ $id)/*# : bool */
    {
        $extName = ProviderExtension::EXTENSION_CLASS;

        // provider extension loaded
        if ($this->hasExtension($extName)) {
            /* @var $ext ProviderExtension */
            $ext = $this->getExtension($extName);
            return $ext->providerHas($id);
        }

        // extension not loaded yet
        return false;
    }
1330883
public function isLoaded($id)
    {
        $id = strtolower($id);

        return $this->hasInstanceOf($id)
            || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')
        ;
    }
1184868
public function enable($module_id)
    {
        try {
            $result = $this->canEnable($module_id);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach("module.enable.before|$module_id", $result, $this);

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

        $this->module->update($module_id, array('status' => 1));
        $this->setOverrideConfig();

        $this->hook->attach("module.enable.after|$module_id", $result, $this);
        return $result;
    }
995326
public static function verify($categoryId = null, $id = null, $slug = null, $guest = true)
    {
        if (!is_numeric($categoryId) || $categoryId < 1 || !is_numeric($id) || $id < 1 || empty($slug)) {
            return null;
        }
        return static::find()->joinWith(['category' => function ($query) use ($guest) {
                if ($guest) {
                    $query->andWhere([Category::tableName() . '.visible' => 1]);
                }
            }])->where([
                static::tableName() . '.id' => $id,
                static::tableName() . '.slug' => $slug,
                static::tableName() . '.category_id' => $categoryId,
            ])->limit(1)->one();
    }
545538
public function is_plugin_installed( $slug )
	{
		$element = $this->search_plugin( $slug );
		if ( count( $element ) ) {
			return true;
		} else {
			return false;
		}
	}
1200766
public function makeUnique($id, $slug) {
        $repo = $this->getRepository();
        $scope = $this->getConfig('scope');

        /** @type \Titon\Db\Query $query */
        foreach ([
            $repo->select()->where($this->getConfig('slug'), $slug),
            $repo->select()->where($this->getConfig('slug'), 'like', $slug . '%')
        ] as $i => $query) {
            if ($scope) {
                $query->bindCallback($scope);
            }

            if ($id) {
                $query->where($repo->getPrimaryKey(), '!=', $id);
            }

            $count = $query->count();

            if ($count <= 0) {
                break;

            } else if ($i) {
                return $slug . '-' . $count;
            }
        }

        return $slug;
    }
520685
public function has(string $id_option = null, bool $force = false): bool
  {
    if ( !$force && $this->user->is_dev() ){
      return true;
    }
    return (bool)$this->retrieve_ids($id_option);
  }