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


PHP Plugins::findById方法代码示例

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


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

示例1: enable_disable_system_modules

 function enable_disable_system_modules()
 {
     ajx_current("empty");
     if (!can_manage_configuration(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $module_list = json_decode(array_var($_REQUEST, 'modules'), true);
     try {
         DB::beginWork();
         foreach ($module_list as $module_id => $enabled) {
             $tab_panel = TabPanels::instance()->findById($module_id);
             if ($tab_panel instanceof TabPanel) {
                 $tab_panel->setEnabled($enabled > 0);
                 $tab_panel->save();
                 if ($enabled > 0) {
                     DB::execute("INSERT INTO " . TABLE_PREFIX . "tab_panel_permissions (permission_group_id, tab_panel_id) VALUES (" . logged_user()->getPermissionGroupId() . ",'" . $tab_panel->getId() . "') ON DUPLICATE KEY UPDATE tab_panel_id=tab_panel_id;");
                 }
                 if ($tab_panel->getPluginId() > 0) {
                     $plugin = Plugins::findById($tab_panel->getPluginId());
                     if ($plugin instanceof Plugin) {
                         if ($enabled) {
                             $plugin->activate();
                         } else {
                             $plugin->deactivate();
                         }
                     }
                 }
             }
         }
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         Logger::log("Error occurred when trying to enable/disable modules\n" . $e->getMessage() . "\n" . print_r($module_list, 1));
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:37,代码来源:MoreController.class.php

示例2: update_plugins

 function update_plugins()
 {
     trace(__FILE__, 'update_plugins()');
     $plugins = array_var($_POST, 'plugins');
     //$plugins = array('invoices' => '1');
     if (is_null($plugins)) {
         $this->redirectTo('administration', 'plugins');
     }
     $reference = Plugins::getAllPlugins();
     trace(__FILE__, 'update_plugins() - getAllPlugins done');
     $errors = array();
     foreach ($plugins as $name => $yes_no) {
         //If it is not a plugin continue
         $plugin_file_path = APPLICATION_PATH . '/plugins/' . $name . '/init.php';
         trace(__FILE__, "update_plugins() - plugin_file_path=[{$plugin_file_path}]");
         if (!file_exists($plugin_file_path)) {
             continue;
         }
         trace(__FILE__, "update_plugins() - plugin_file_path=[{$plugin_file_path}] exists");
         // get existing id
         $id = $reference[$name];
         $nicename = ucwords(str_replace('_', ' ', $name));
         trace(__FILE__, "update_plugins() - id={$id} name={$name} nicename={$nicename}");
         if ($yes_no && '-' == $id) {
             trace(__FILE__, "update_plugins() - activating [{$name}]");
             try {
                 // Check if plugin exists in database
                 $plugin = Plugins::findOne(array('conditions' => array('`name` = ?', $name)));
                 trace(__FILE__, "update_plugins() - findOne");
                 if ($plugin == NULL) {
                     $plugin = new Plugin();
                 }
                 trace(__FILE__, "update_plugins() - setName");
                 $plugin->setName($name);
                 trace(__FILE__, "update_plugins() - setInstalled");
                 $plugin->setInstalled(true);
                 DB::beginWork();
                 trace(__FILE__, "update_plugins() - including [{$plugin_file_path}]");
                 // get the file loaded here
                 include $plugin_file_path;
                 // get activation routine ready
                 trace(__FILE__, "update_plugins() - activate: {$name}");
                 $activate = $name . '_activate';
                 if (function_exists($activate)) {
                     trace(__FILE__, "update_plugins() - calling: {$activate}");
                     $activate();
                 }
                 // save to db now
                 $plugin->save();
                 DB::commit();
             } catch (Exception $e) {
                 trace(__FILE__, 'update_plugins() - ' . $e->getMessage());
                 DB::rollback();
                 $errors[] = $nicename . ' (' . $e->getMessage() . ')';
             }
         } elseif (!$yes_no && '-' != $id) {
             try {
                 trace(__FILE__, "update_plugins() - deactivating [{$name}]");
                 $plugin = Plugins::findById($id);
                 DB::beginWork();
                 $deactivate = $name . '_deactivate';
                 if (function_exists($deactivate)) {
                     trace(__FILE__, "update_plugins() - calling {$deactivate}");
                     //Check if user choose to purge data
                     if ($plugins[$name . "_data"] == "0") {
                         trace(__FILE__, "update_plugins() - calling {$deactivate}(true)");
                         $deactivate(true);
                     } else {
                         $deactivate();
                     }
                 }
                 $plugin->setInstalled(false);
                 $plugin->save();
                 DB::commit();
             } catch (Exception $e) {
                 DB::rollback();
                 $errors[] = $nicename . ' (' . $e->getMessage() . ')';
             }
         }
     }
     if (count($errors)) {
         flash_error(lang('plugin activation failed', implode(", ", $errors)));
     } else {
         flash_success(lang('plugins updated'));
     }
     $this->redirectTo('administration', 'plugins');
 }
开发者ID:469306621,项目名称:Languages,代码行数:87,代码来源:AdministrationController.class.php


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