当前位置: 首页>>代码示例>>PHP>>正文


PHP Plugins::activate_plugin方法代码示例

本文整理汇总了PHP中Plugins::activate_plugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::activate_plugin方法的具体用法?PHP Plugins::activate_plugin怎么用?PHP Plugins::activate_plugin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugins的用法示例。


在下文中一共展示了Plugins::activate_plugin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: activate_plugins

 public function activate_plugins()
 {
     // extract checked plugin IDs from $_POST
     $plugin_ids = array();
     foreach ($this->handler_vars as $id => $activate) {
         if (preg_match('/plugin_([a-f0-9]{8})/u', $id, $matches) && $activate) {
             $plugin_ids[] = $matches[1];
         } elseif (preg_match('/plugin_(.+)/u', $id, $matches) && $activate) {
             $plugin_ids[] = $matches[1];
         }
     }
     if (count($plugin_ids) == 0) {
         return;
     }
     // set the user_id in the session in case plugin activation methods need it
     if (!($u = User::get_by_name($this->handler_vars['admin_username']))) {
         // @todo die gracefully
         die(_t('No admin user found'));
     }
     $u->remember();
     // loop through all plugins to find matching plugin files
     $plugin_files = Plugins::list_all();
     foreach ($plugin_files as $file) {
         if (in_array(basename($file), $plugin_ids)) {
             Plugins::activate_plugin($file);
             continue;
         }
         $id = Plugins::id_from_file($file);
         if (in_array($id, $plugin_ids)) {
             Plugins::activate_plugin($file);
         }
     }
     // unset the user_id session variable
     Session::clear_userid($_SESSION['user_id']);
     unset($_SESSION['user_id']);
 }
开发者ID:habari,项目名称:system,代码行数:36,代码来源:installhandler.php

示例2: get_plugin_toggle

 /**
  * Handles plugin activation or deactivation.
  */
 public function get_plugin_toggle()
 {
     $extract = $this->handler_vars->filter_keys('plugin_id', 'action');
     foreach ($extract as $key => $value) {
         ${$key} = $value;
     }
     $plugins = Plugins::list_all();
     foreach ($plugins as $file) {
         if (Plugins::id_from_file($file) == $plugin_id) {
             switch (strtolower($action)) {
                 case 'activate':
                     if (Plugins::activate_plugin($file)) {
                         $plugins = Plugins::get_active();
                         Session::notice(_t("Activated plugin '%s'", array($plugins[Plugins::id_from_file($file)]->info->name)), $plugins[Plugins::id_from_file($file)]->plugin_id);
                     }
                     break;
                 case 'deactivate':
                     if (Plugins::deactivate_plugin($file)) {
                         $plugins = Plugins::get_active();
                         Session::notice(_t("Deactivated plugin '%s'", array($plugins[Plugins::id_from_file($file)]->info->name)), $plugins[Plugins::id_from_file($file)]->plugin_id);
                     }
                     break;
                 default:
                     Plugins::act('adminhandler_get_plugin_toggle_action', $action, $file, $plugin_id, $plugins);
                     break;
             }
         }
     }
     Utils::redirect(URL::get('admin', 'page=plugins'));
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:33,代码来源:adminhandler.php

示例3: activate_plugins

	public function activate_plugins()
	{
		// extract checked plugin IDs from $_POST
		$plugin_ids = array();
		foreach ( $_POST as $id => $activate ) {
			if ( preg_match( '/plugin_\w+/u', $id ) && $activate ) {
				$id = substr( $id, 7 );
				$plugin_ids[] = $id;
			}
		}

		// set the user_id in the session in case plugin activation methods need it
		if ( ! $u = User::get_by_name( $this->handler_vars['admin_username'] ) ) {
			// @todo die gracefully
			die( _t( 'No admin user found' ) );
		}
		$u->remember();

		// loop through all plugins to find matching plugin files
		$plugin_files = Plugins::list_all();
		foreach ( $plugin_files as $file ) {
			$id = Plugins::id_from_file( $file );
			if ( in_array( $id, $plugin_ids ) ) {
				Plugins::activate_plugin( $file );
			}
		}

		// unset the user_id session variable
		Session::clear_userid( $_SESSION['user_id'] );
		unset( $_SESSION['user_id'] );
	}
开发者ID:rynodivino,项目名称:system,代码行数:31,代码来源:installhandler.php


注:本文中的Plugins::activate_plugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。