Check if it's an AJAX call targeted for current request.

@author Vova Feldman (@svovaf)
@since  1.2.0

@param array|string $actions Collection of AJAX actions.
@param number|null  $module_id

@return bool
975429
static function is_ajax_action_static( $actions, $module_id = null ) {
            // Verify it's an ajax call.
            if ( ! self::is_ajax() ) {
                return false;
            }


            if ( ! empty( $module_id ) ) {
                // Verify the call is relevant for the plugin.
                if ( $module_id != fs_request_get( 'module_id' ) ) {
                    return false;
                }
            }

            // Verify it's one of the specified actions.
            if ( is_string( $actions ) ) {
                $actions = explode( ',', $actions );
            }

            if ( is_array( $actions ) && 0 < count( $actions ) ) {
                $ajax_action = fs_request_get( 'action' );

                foreach ( $actions as $action ) {
                    if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) {
                        return true;
                    }
                }
            }

            return false;
        }
173805
protected static function isActive($dbId)
    {
        if (!isset(static::$_modulesData[$dbId])) {
            $result = static::findOne($dbId);
            static::$_modulesData[$dbId] = $result;
        }
        if (empty(static::$_modulesData[$dbId])) {
            return false;
        } else {
            $isActive = static::$_modulesData[$dbId]->is_active;
            return $isActive;
        }
    }
1154400
public function hasMethod($action) {
		return array_key_exists($action, $this->actions())
        || method_exists($this, $action.config('app.action'));
	}
903909
public static function systemModuleExists(string $module_code) : bool {
		$result = \Object\Controller::getSystemModuleByModuleCode($module_code);
		return !empty($result);
	}
78406
public function getModule($id)
    {
        $returnValue = null;

    	$className = $this->getId().'_actions_'.$id;
		if(class_exists($className)) {
			$returnValue = new $className;
		} else {
			common_Logger::e('could not load '.$className);
		}

        return $returnValue;
    }
948638
public static function hasName( $name, $module_id = null ): bool
	{
		if( !self::isValidName($name) )
		{
			return false;
		}

		$builder = \DB::table("events")->where("name", $name);
		if( is_numeric($module_id) )
		{
			$builder->where("module_id", (int) $module_id );
		}

		return $builder->count(["id"]) > 0;
	}
1115006
protected function actionListModule()
    {
        $this->controlToken('action');

        $action = $this->getQuery('action');
        $module_id = $this->getQuery('module_id');

        if (!empty($action) && !empty($module_id)) {
            $this->setModule($module_id);
            $result = $this->startActionModule($action);
            $this->finishActionModule($result);
        }
    }
189005
public function checkModuleId($module_id)
    {
        if (!$this->module->isValidId($module_id)) {
            throw new UnexpectedValueException($this->translation->text('Invalid module ID'));
        }

        return true;
    }
1237609
protected function hasModule()
    {
        global $post;

        $postId = null;
        $modules = array();
        $archiveSlug = \Modularity\Helper\Wp::getArchiveSlug();

        if ($archiveSlug) {
            $postId = $archiveSlug;
        } elseif (isset($post->ID)) {
            $postId = $post->ID;
        } else {
            return apply_filters('Modularity/hasModule', false, null);
        }

        $modules = \Modularity\Editor::getPostModules($postId);
        $modules = array_merge($modules, $this->getShortcodeModules($postId));
        $modules = array_merge($modules, $this->getOnePageModules($postId));

        $modules = json_encode($modules);

        $moduleSlug = $this->moduleSlug;
        if (empty($moduleSlug)) {
            $moduleSlug = isset($this->data['post_type']) ? $this->data['post_type'] : null;
        }

        return apply_filters('Modularity/hasModule', strpos($modules, '"post_type":"' . $moduleSlug . '"') == true, $archiveSlug);
    }
468284
function isAllowed( $moduleName, $functionName, $connectType )
    {
        $eventArray = $this->fetchEvents();

        foreach ( array_keys( $eventArray ) as $key )
        {
            $eventType = $eventArray[$key]->attribute( 'workflow_type' );
            if ( !is_object( $eventType ) or !$eventType->isAllowed( $moduleName, $functionName, $connectType ) )
            {
                return false;
            }
        }

        return true;
    }
718220
public function disable($module_id)
    {
        try {
            $result = $this->canDisable($module_id);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

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

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

        if ($this->module->isInstalled($module_id)) {
            $this->module->update($module_id, array('status' => false));
        } else {
            $this->module->add(array('status' => false, 'module_id' => $module_id));
        }

        $this->setOverrideConfig();

        $this->hook->attach("module.disable.after|$module_id", $result, $this);
        return $result;
    }
561740
public function canCached($action, $method_code = null) : bool {
		$method_code = $method_code ?? $this->method_code;
		if (!isset($this->cached_can_requests[$method_code][$action])) {
			$this->cached_can_requests[$method_code][$action] = $this->can($action, $method_code);
		}
		return $this->cached_can_requests[$method_code][$action];
	}
198845
private function api_request( $_action = '', $_data = '' ) {
		$update_data = $this->get_version_data();
		if ( empty( $update_data ) ) {
			return false;
		}
		if ( $update_data && isset( $update_data->sections ) ) {
			$update_data->sections = maybe_unserialize( $update_data->sections );
		}

		return $update_data;
	}
905932
public function actionExists($id)
    {
        $inlineActionMethodName = 'action' . Inflector::camelize($id);
        if (method_exists($this->controller, $inlineActionMethodName)) {
            return true;
        }
        if (array_key_exists($id, $this->controller->actions())) {
            return true;
        }
        return false;
    }
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;
    }
1171512
static function isCurrentAction( $action ) {

		if ( isset( $_REQUEST['action'] ) && -1 !== (int) $_REQUEST['action'] ) {
			$compare = $_REQUEST['action'];
		} elseif ( isset( $_REQUEST['action2'] ) && -1 !== (int) $_REQUEST['action2'] ) {
			$compare = $_REQUEST['action2'];
		} else {
			return false;
		}

		return ( $action === $compare );
	}
632511
public function isModulesLoaded( $modules )
    {
        if ( $modules instanceof Traversable )
        {
            $modules = ArrayUtils::iteratorToArray( $modules );
        }

        if ( ! is_array( $modules ) )
        {
            $modules = preg_split( '/\|{1,2}/', (string) $modules );
        }

        foreach ( $modules as $module )
        {
            if ( ! is_array( $module ) )
            {
                $module = preg_split( '/&{1,2}/', (string) $module );
            }

            if ( $this->isAllModulesLoaded( $module ) )
            {
                return true;
            }
        }

        return false;
    }