Handler for plugin actions (AJAX)
484512
function acl_actions()
    {
        $action = trim(rcube_utils::get_input_value('_act', rcube_utils::INPUT_GPC));

        // Connect to IMAP
        $this->rc->storage_init();

        // Load localization and configuration
        $this->add_texts('localization/');
        $this->load_config();

        if ($action == 'save') {
            $this->action_save();
        }
        else if ($action == 'delete') {
            $this->action_delete();
        }
        else if ($action == 'list') {
            $this->action_list();
        }

        // Only AJAX actions
        $this->rc->output->send();
    }
435371
function(event) {
			var elem = (event.data && event.data.elem) || event.target;
			var inst = plugin._getInst(elem);
			var handled = false;
			if (inst.inline || inst.div) {
				if (event.keyCode === 9) { // Tab - close
					plugin.hide(elem);
				}
				else if (event.keyCode === 13) { // Enter - select
					plugin.selectDate(elem,
						$('a.' + inst.options.renderer.highlightedClass, inst.div)[0]);
					handled = true;
				}
				else { // Command keystrokes
					var commands = inst.options.commands;
					for (var name in commands) {
						var command = commands[name];
						if (command.keystroke.keyCode === event.keyCode &&
								!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
								!!command.keystroke.altKey === event.altKey &&
								!!command.keystroke.shiftKey === event.shiftKey) {
							plugin.performAction(elem, name);
							handled = true;
							break;
						}
					}
				}
			}
			else { // Show on 'current' keystroke
				var command = inst.options.commands.current;
				if (command.keystroke.keyCode === event.keyCode &&
						!!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) &&
						!!command.keystroke.altKey === event.altKey &&
						!!command.keystroke.shiftKey === event.shiftKey) {
					plugin.show(elem);
					handled = true;
				}
			}
			inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey);
			if (handled) {
				event.preventDefault();
				event.stopPropagation();
			}
			return !handled;
		}
327221
private function reloadActivatedPlugins()
    {
        $pluginsToPostPendingEventsTo = array();
        foreach ($this->pluginsToLoad as $pluginName) {
            $pluginsToPostPendingEventsTo = $this->reloadActivatedPlugin($pluginName, $pluginsToPostPendingEventsTo);
        }

        // post pending events after all plugins are successfully loaded
        foreach ($pluginsToPostPendingEventsTo as $plugin) {
            EventDispatcher::getInstance()->postPendingEventsTo($plugin);
        }
    }
1314638
def on_click(self, handler):
        
        self.on_change('active', lambda attr, old, new: handler(new))
1205093
private function _handle_account_edits() {
            if ( ! $this->is_user_admin() ) {
                return;
            }

            $action = fs_get_action();

            if ( empty( $action ) ) {
                return;
            }

            $plugin_id  = fs_request_get( 'plugin_id', $this->get_id() );
            $install_id = fs_request_get( 'install_id', '' );

            // Alias.
            $oops_text = $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...';

            $is_network_action = $this->is_network_level_action();
            $blog_id           = $this->is_network_level_site_specific_action();

            if ( is_numeric( $blog_id ) ) {
                $this->switch_to_blog( $blog_id );
            } else {
                $blog_id = '';
            }

            switch ( $action ) {
                case 'opt_in':
                    check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );

                    if ( $plugin_id == $this->get_id() ) {
                        if ( $is_network_action && ! empty( $blog_id ) ) {
                            if ( ! $this->is_registered() ) {
                                $this->install_with_user(
                                    $this->get_network_user(),
                                    false,
                                    false,
                                    false,
                                    false
                                );

                                $this->_admin_notices->add(
                                    $this->get_text_inline( 'Site successfully opted in.', 'successful-opt-in' ),
                                    $this->get_text_inline( 'Awesome', 'awesome' )
                                );
                            }
                        }
                    }
                    break;

                case 'toggle_tracking':
                    check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );

                    if ( $plugin_id == $this->get_id() ) {
                        if ( $is_network_action && ! empty( $blog_id ) ) {
                            if ( $this->is_registered() ) {
                                if ( $this->is_tracking_prohibited() ) {
                                    if ( $this->allow_site_tracking() ) {
                                        $this->_admin_notices->add(
                                            sprintf( $this->get_text_inline( 'We appreciate your help in making the %s better by letting us track some usage data.', 'opt-out-message-appreciation' ), $this->_module_type ),
                                            $this->get_text_inline( 'Thank you!', 'thank-you' )
                                        );
                                    }
                                } else {
                                    if ( $this->stop_site_tracking() ) {
                                        $this->_admin_notices->add(
                                            sprintf(
                                                $this->get_text_inline( 'We will no longer be sending any usage data of %s on %s to %s.', 'opted-out-successfully' ),
                                                $this->get_plugin_title(),
                                                fs_strip_url_protocol( get_site_url( $blog_id ) ),
                                                sprintf(
                                                    '<a href="%s" target="_blank">%s</a>',
                                                    'https://freemius.com',
                                                    'freemius.com'
                                                )
                                            )
                                        );
                                    }
                                }
                            }
                        }
                    }

                    break;

                case 'delete_account':
                    check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );

                    if ( $plugin_id == $this->get_id() ) {
                        if ( $is_network_action && empty( $blog_id ) ) {
                            $this->delete_network_account_event();
                        } else {
                            $this->delete_account_event();
                        }

                        // Clear user and site.
                        $this->_site = null;
                        $this->_user = null;

                        $this->maybe_set_slug_and_network_menu_exists_flag();

                        fs_redirect( $this->get_activation_url() );
                    } else {
                        if ( $this->is_addon_activated( $plugin_id ) ) {
                            $fs_addon = self::get_instance_by_id( $plugin_id );
                            $fs_addon->delete_account_event();

                            fs_redirect( $this->_get_admin_page_url( 'account' ) );
                        }
                    }

                    return;

                case 'downgrade_account':
                    if ( is_numeric( $blog_id ) ) {
                        check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );
                    } else {
                        check_admin_referer( $action );
                    }

                    $switch_to_network_install_blog_after_cancellation = (
                        is_numeric( $blog_id ) &&
                        $plugin_id == $this->get_id() &&
                        ! $this->is_trial()
                    );

                    $result = $this->cancel_subscription_or_trial( $plugin_id );
                    if ( $this->is_api_error( $result ) ) {
                        $this->_admin_notices->add(
                            $result->error->message,
                            $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
                            'error'
                        );
                    }

                    if ( $switch_to_network_install_blog_after_cancellation ) {
                        $this->switch_to_blog( $this->_storage->network_install_blog_id );
                    }

                    return;

                case 'activate_license':
                    check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );

                    $fs = $this;
                    if ( $plugin_id != $this->get_id() ) {
                        $fs = $this->is_addon_activated( $plugin_id ) ?
                            self::get_instance_by_id( $plugin_id ) :
                            null;
                    }

                    if ( is_object( $fs ) ) {
                        $fs->_activate_license();
                    }

                    return;

                case 'deactivate_license':
                    check_admin_referer( trim( "{$action}:{$blog_id}:{$install_id}", ':' ) );

                    if ( $plugin_id == $this->get_id() ) {
                        $this->_deactivate_license();

                        if ( $this->is_only_premium() ) {
                            // Clear user and site.
                            $this->_site = null;
                            $this->_user = null;

                            if ( ! $is_network_action ) {
                                fs_redirect( $this->get_activation_url() );
                            } else if ( is_numeric( $blog_id ) ) {
                                $this->switch_to_blog( $this->_storage->network_install_blog_id );
                            }
                        }
                    } else {
                        if ( $this->is_addon_activated( $plugin_id ) ) {
                            $fs_addon = self::get_instance_by_id( $plugin_id );
                            $fs_addon->_deactivate_license();
                        }
                    }

                    return;

                case 'check_updates':
                    check_admin_referer( $action );
                    $this->check_updates();

                    return;

                case 'change_owner':
                    $state = fs_request_get( 'state', 'init' );
                    switch ( $state ) {
                        case 'init':
                            $candidate_email = fs_request_get( 'candidate_email', '' );

                            if ( $this->init_change_owner( $candidate_email ) ) {
                                $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.', 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
                            }
                            break;
                        case 'owner_confirmed':
                            $candidate_email = fs_request_get( 'candidate_email', '' );

                            $this->_admin_notices->add( sprintf( $this->get_text_inline( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
                            break;
                        case 'candidate_confirmed':
                            if ( $this->complete_change_owner() ) {
                                $this->_admin_notices->add_sticky(
                                    sprintf( $this->get_text_inline( '%s is the new owner of the account.', 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
                                    'ownership_changed',
                                    $this->get_text_x_inline( 'Congrats', 'as congratulations', 'congrats' ) . '!'
                                );
                            } else {
                                // @todo Handle failed ownership change message.
                            }
                            break;
                    }

                    return;

                case 'update_email':
                    check_admin_referer( 'update_email' );

                    $new_email = fs_request_get( 'fs_email_' . $this->get_unique_affix(), '' );
                    $result    = $this->update_email( $new_email );

                    if ( isset( $result->error ) ) {
                        switch ( $result->error->code ) {
                            case 'user_exist':
                                $this->_admin_notices->add(
                                    $this->get_text_inline( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'user-exist-message' ) . ' ' .
                                    sprintf( $this->get_text_inline( 'If you would like to give up the ownership of the %s\'s account to %s click the Change Ownership button.', 'user-exist-message_ownership' ), $this->_module_type, '<b>' . $new_email . '</b>' ) .
                                    sprintf(
                                        '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
                                        $this->get_account_url( 'change_owner', array(
                                            'state'           => 'init',
                                            'candidate_email' => $new_email
                                        ) ),
                                        $this->get_text_inline( 'Change Ownership', 'change-ownership' )
                                    ),
                                    $oops_text,
                                    'error'
                                );
                                break;
                        }
                    } else {
                        $this->_admin_notices->add( $this->get_text_inline( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.', 'email-updated-message' ) );
                    }

                    return;

                case 'update_user_name':
                    check_admin_referer( 'update_user_name' );

                    $result = $this->update_user_name();

                    if ( isset( $result->error ) ) {
                        $this->_admin_notices->add(
                            $this->get_text_inline( 'Please provide your full name.', 'name-update-failed-message' ),
                            $oops_text,
                            'error'
                        );
                    } else {
                        $this->_admin_notices->add( $this->get_text_inline( 'Your name was successfully updated.', 'name-updated-message' ) );
                    }

                    return;

                #region Actions that might be called from external links (e.g. email)

                case 'cancel_trial':
                    $result = $this->cancel_subscription_or_trial( $plugin_id );
                    if ( $this->is_api_error( $result ) ) {
                        $this->_admin_notices->add(
                            $result->error->message,
                            $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
                            'error'
                        );
                    }

                    return;

                case 'verify_email':
                    $this->verify_email();

                    return;

                case 'sync_user':
                    $this->_handle_account_user_sync();

                    return;

                case $this->get_unique_affix() . '_sync_license':
                    $this->_sync_license();

                    return;

                case 'download_latest':
                    $this->download_latest_directly( $plugin_id );

                    return;

                #endregion
            }

            if ( WP_FS__IS_POST_REQUEST ) {
                $properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
                foreach ( $properties as $p ) {
                    if ( 'update_' . $p === $action ) {
                        check_admin_referer( $action );

                        $this->_logger->log( $action );

                        $site_property                      = substr( $p, strlen( 'site_' ) );
                        $site_property_value                = fs_request_get( 'fs_' . $p . '_' . $this->get_unique_affix(), '' );
                        $this->get_site()->{$site_property} = $site_property_value;

                        // Store account after modification.
                        $this->_store_site();

                        $this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );

                        $this->_admin_notices->add( sprintf(
                        /* translators: %s: User's account property (e.g. email address, name) */
                            $this->get_text_inline( 'You have successfully updated your %s.', 'x-updated' ),
                            '<b>' . str_replace( '_', ' ', $p ) . '</b>'
                        ) );

                        return;
                    }
                }
            }
        }
190317
def run_hook(self, hook, *args, **kwargs):
        
        for plugin in self.raw_plugins:
            if hasattr(plugin, hook):
                self.logger.debug('Calling hook {0} in plugin {1}'.format(hook, plugin.__name__))
                getattr(plugin, hook)(*args, **kwargs)
1211376
function (plugin) {
    var that = this;
    var ajaxCallback = function (event) {
        return function () {
            that.plugin.log(that.plugin.LOG_INFO, 'Invoking AjaxBootstrapSelectRequest.' + event + ' callback:', arguments);
            that[event].apply(that, arguments);
            if (that.callbacks[event]) {
                that.plugin.log(that.plugin.LOG_INFO, 'Invoking ajax.' + event + ' callback:', arguments);
                that.callbacks[event].apply(that, arguments);
            }
        };
    };
    var events = ['beforeSend', 'success', 'error', 'complete'];
    var i, l = events.length;

    // Reference the existing plugin.
    this.plugin = plugin;

    // Clone the default ajax options.
    this.options = $.extend(true, {}, plugin.options.ajax);

    // Save any existing callbacks provided in the options and replace it with
    // the relevant method callback. The provided callback will be invoked
    // after this plugin has executed.
    this.callbacks = {};
    for (i = 0; i < l; i++) {
        var event = events[i];
        if (this.options[event] && $.isFunction(this.options[event])) {
            this.callbacks[event] = this.options[event];
        }
        this.options[event] = ajaxCallback(event);
    }

    // Allow the data option to be dynamically generated.
    if (this.options.data && $.isFunction(this.options.data)) {
        this.options.data = this.options.data.apply(this) || {
            q: '{{{q}}}'
        };
    }

    // Replace all data values that contain "{{{q}}}" with the value of the
    // current search query.
    this.plugin.replaceValue(this.options.data, '{{{q}}}', this.plugin.query);

    // Allow the url to be dynamically generated if passed as function.
    if (this.options.url && $.isFunction(this.options.url)) {
        this.options.url = this.options.url.apply(this);
    }

    // Invoke the AJAX request.
    this.jqXHR = $.ajax(this.options);
}
893622
function eventHandler(e) {
      if (e.page.path === loader.getPage(pathname).path) {
        emitter.off(`onPostLoadPageResources`, eventHandler)
        clearTimeout(timeoutId)
        window.___history.push(pathname)
      }
    }
882461
function Plugin(option) {
			return this.each(function () {
				var $this = $(this);
				var data = $this.data("bs.dropdown");

				if (!data) $this.data("bs.dropdown", (data = new Dropdown(this)));
				if (typeof option == "string") data[option].call($this);
			});
		}
526766
function( type, event, ui ) {
            ui = ui || this._uiHash();
            $.ui.plugin.call( this, type, [ event, ui, this ], true );

            // Absolute position and offset (see #6884 ) have to be recalculated after plugins
            if ( /^(drag|start|stop)/.test( type ) ) {
                this.positionAbs = this._convertPositionTo( "absolute" );
                ui.offset = this.positionAbs;
            }
            return $.Widget.prototype._trigger.call( this, type, event, ui );
        }
510499
public function onBulkAction()
    {
        if (($bulkAction = post('action')) &&
            ($checkedIds = post('checked')) &&
            is_array($checkedIds) &&
            count($checkedIds)
        ) {
            $manager = PluginManager::instance();

            foreach ($checkedIds as $pluginId) {
                if (!$plugin = PluginVersion::find($pluginId)) {
                    continue;
                }

                $savePlugin = true;
                switch ($bulkAction) {
                    // Enables plugin's updates.
                    case 'freeze':
                        $plugin->is_frozen = 1;
                        break;

                    // Disables plugin's updates.
                    case 'unfreeze':
                        $plugin->is_frozen = 0;
                        break;

                    // Disables plugin on the system.
                    case 'disable':
                        $plugin->is_disabled = 1;
                        $manager->disablePlugin($plugin->code, true);
                        break;

                    // Enables plugin on the system.
                    case 'enable':
                        $plugin->is_disabled = 0;
                        $manager->enablePlugin($plugin->code, true);
                        break;

                    // Rebuilds plugin database migrations.
                    case 'refresh':
                        $savePlugin = false;
                        $manager->refreshPlugin($plugin->code);
                        break;

                    // Rollback and remove plugins from the system.
                    case 'remove':
                        $savePlugin = false;
                        $manager->deletePlugin($plugin->code);
                        break;
                }

                if ($savePlugin) {
                    $plugin->save();
                }
            }
        }

        Flash::success(Lang::get("system::lang.plugins.{$bulkAction}_success"));
        return $this->listRefresh('manage');
    }
1036034
function(type, event, ui) {
		ui = ui || this._uiHash();
		$.ui.plugin.call(this, type, [event, ui]);
		if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
		return $.Widget.prototype._trigger.call(this, type, event, ui);
	}
1215059
function handler ( err, data ){
      if ( callback != null ){
        callback.apply( b9, arguments );
      }
      // only emit events when there is no error
      if ( err == null ){
        b9.emit.call( b9, method, data );
      }
    }
578497
async def handler(event):
    """"""
    await asyncio.wait([
        event.delete(),
        event.respond(
            LEARN_PYTHON, reply_to=event.reply_to_msg_id, link_preview=False)
    ])
983567
@Override
    public void onPluginEvent(PluginEvent event) {
        ElementPlugin plugin = event.getPlugin();
        
        switch (event.getAction()) {
            case SUBSCRIBE:
                init();
                plugins.add(plugin);
                plugin.setDisabled(isDisabled());
                break;
            
            case UNSUBSCRIBE:
                plugins.remove(plugin);
                plugin.setDisabled(false);
                break;
        }
    }
295675
function(widget, target_name, view, template_arguments, callback_arguments) {

		return widget.handleEvent(
			callback_arguments.event_name,
			callback_arguments.event_object,
			target_name,
			view,
			template_arguments
		);

	}
1327550
function handler() {
		// Get the current orientation.
		var orientation = get_orientation();

		if ( orientation !== last_orientation ) {
			// The orientation has changed, so trigger the orientationchange event.
			last_orientation = orientation;
			win.trigger( event_name );
		}
	}