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


PHP Plugin::model方法代码示例

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


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

示例1: compilePluginsConfig

 public function compilePluginsConfig()
 {
     Yii::import('ygin.models.Plugin');
     $plugins = Plugin::model()->enabled()->findAll();
     $config = array('pluginsCompile' => true);
     foreach ($plugins as $plugin) {
         $applPlugin = $this->getPluginConfig($plugin->code);
         $defaultConfig = isset($applPlugin['defaultConfig']) ? $applPlugin['defaultConfig'] : array();
         $pluginConfig = $plugin->config !== null ? $plugin->getConfig() : array();
         $config = CMap::mergeArray($config, $defaultConfig, $pluginConfig);
     }
     $path = $this->getRuntimePath() . '/plugin-compile.dat';
     file_put_contents($path, serialize($config));
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:14,代码来源:BaseApplication.php

示例2: index

 /**
  * Show login screen and parse login data
  */
 public function index()
 {
     $this->_redirectIfLoggedIn();
     // Make sure after first run / update the authdb plugin is registered and active
     // it can not be deactivated
     if (!class_exists('Authdb', false)) {
         $plugin = Plugin::model()->findByAttributes(array('name' => 'Authdb'));
         if (!$plugin) {
             $plugin = new Plugin();
             $plugin->name = 'Authdb';
             $plugin->active = 1;
             $plugin->save();
             App()->getPluginManager()->loadPlugin('Authdb', $plugin->id);
         } else {
             $plugin->active = 1;
             $plugin->save();
         }
     }
     $beforeLogin = new PluginEvent('beforeLogin');
     $beforeLogin->set('identity', new LSUserIdentity('', ''));
     App()->getPluginManager()->dispatchEvent($beforeLogin);
     /* @var $identity LSUserIdentity */
     $identity = $beforeLogin->get('identity');
     if (!$beforeLogin->isStopped() && is_null(App()->getRequest()->getPost('login_submit'))) {
         if (!is_null($beforeLogin->get('default'))) {
             $aData['defaultAuth'] = $beforeLogin->get('default');
         } else {
             if (App()->getPluginManager()->isPluginActive(Yii::app()->getConfig('default_displayed_auth_method'))) {
                 $aData['defaultAuth'] = Yii::app()->getConfig('default_displayed_auth_method');
             } else {
                 $aData['defaultAuth'] = 'Authdb';
             }
         }
         $newLoginForm = new PluginEvent('newLoginForm');
         App()->getPluginManager()->dispatchEvent($newLoginForm);
         $aData['summary'] = $this->_getSummary('logout');
         $aData['pluginContent'] = $newLoginForm->getAllContent();
         $this->_renderWrappedTemplate('authentication', 'login', $aData);
     } else {
         // Handle getting the post and populating the identity there
         $authMethod = App()->getRequest()->getPost('authMethod', $identity->plugin);
         $identity->plugin = $authMethod;
         $event = new PluginEvent('afterLoginFormSubmit');
         $event->set('identity', $identity);
         App()->getPluginManager()->dispatchEvent($event, array($authMethod));
         $identity = $event->get('identity');
         // Now authenticate
         if ($identity->authenticate()) {
             FailedLoginAttempt::model()->deleteAttempts();
             App()->user->setState('plugin', $authMethod);
             $this->getController()->_GetSessionUserRights(Yii::app()->session['loginID']);
             Yii::app()->session['just_logged_in'] = true;
             Yii::app()->session['loginsummary'] = $this->_getSummary();
             $event = new PluginEvent('afterSuccessfulLogin');
             App()->getPluginManager()->dispatchEvent($event);
             $this->_doRedirect();
         } else {
             // Failed
             $event = new PluginEvent('afterFailedLoginAttempt');
             $event->set('identity', $identity);
             App()->getPluginManager()->dispatchEvent($event);
             $message = $identity->errorMessage;
             if (empty($message)) {
                 // If no message, return a default message
                 $message = gT('Incorrect username and/or password!');
             }
             App()->user->setFlash('error', $message);
             $this->getController()->redirect(array('/admin/authentication/sa/login'));
         }
     }
 }
开发者ID:jgianpiere,项目名称:lime-survey,代码行数:74,代码来源:authentication.php

示例3: loadPlugins

 /**
  * Handles loading all active plugins
  *
  * Possible improvement would be to load them for a specific context.
  * For instance 'survey' for runtime or 'admin' for backend. This needs
  * some thinking before implementing.
  */
 public function loadPlugins()
 {
     try {
         $pluginModel = Plugin::model();
         $records = $pluginModel->findAllByAttributes(array('active' => 1));
         foreach ($records as $record) {
             $this->loadPlugin($record->name, $record->id);
         }
     } catch (Exception $exc) {
         // Something went wrong, maybe no database was present so we load no plugins
     }
     $this->dispatchEvent(new PluginEvent('afterPluginLoad', $this));
     // Alow plugins to do stuff after all plugins are loaded
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:21,代码来源:PluginManager.php

示例4: db_upgrade_all


//.........这里部分代码省略.........
            $oDB->createCommand()->addColumn('{{groups}}', 'grelevance', "text");
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 154), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 155) {
            addColumn('{{surveys}}', 'googleanalyticsstyle', "string(1)");
            addColumn('{{surveys}}', 'googleanalyticsapikey', "string(25)");
            try {
                setTransactionBookmark();
                $oDB->createCommand()->renameColumn('{{surveys}}', 'showXquestions', 'showxquestions');
            } catch (Exception $e) {
                rollBackToTransactionBookmark();
            }
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 155), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 156) {
            try {
                $oDB->createCommand()->dropTable('{{survey_url_parameters}}');
            } catch (Exception $e) {
                // do nothing
            }
            $oDB->createCommand()->createTable('{{survey_url_parameters}}', array('id' => 'pk', 'sid' => 'integer NOT NULL', 'parameter' => 'string(50) NOT NULL', 'targetqid' => 'integer', 'targetsqid' => 'integer'));
            $oDB->createCommand()->dropTable('{{sessions}}');
            if (Yii::app()->db->driverName == 'mysql') {
                $oDB->createCommand()->createTable('{{sessions}}', array('id' => 'string(32) NOT NULL', 'expire' => 'integer', 'data' => 'longtext'));
            } else {
                $oDB->createCommand()->createTable('{{sessions}}', array('id' => 'string(32) NOT NULL', 'expire' => 'integer', 'data' => 'text'));
            }
            addPrimaryKey('sessions', array('id'));
            addColumn('{{surveys_languagesettings}}', 'surveyls_attributecaptions', "TEXT");
            addColumn('{{surveys}}', 'sendconfirmation', "string(1) default 'Y'");
            upgradeSurveys156();
            // If a survey has an deleted owner, re-own the survey to the superadmin
            $oDB->schema->refresh();
            Survey::model()->refreshMetaData();
            $surveys = Survey::model();
            $surveys = $surveys->with(array('owner'))->findAll();
            foreach ($surveys as $row) {
                if (!isset($row->owner->attributes)) {
                    Survey::model()->updateByPk($row->sid, array('owner_id' => 1));
                }
            }
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 156), "stg_name='DBVersion'");
            $oTransaction->commit();
            $oTransaction = $oDB->beginTransaction();
        }
        if ($iOldDBVersion < 157) {
            // MySQL DB corrections
            try {
                setTransactionBookmark();
                $oDB->createCommand()->dropIndex('questions_idx4', '{{questions}}');
            } catch (Exception $e) {
                rollBackToTransactionBookmark();
            }
            alterColumn('{{answers}}', 'assessment_value', 'integer', false, '0');
            dropPrimaryKey('answers');
            alterColumn('{{answers}}', 'scale_id', 'integer', false, '0');
            addPrimaryKey('answers', array('qid', 'code', 'language', 'scale_id'));
            alterColumn('{{conditions}}', 'method', "string(5)", false, '');
            alterColumn('{{participants}}', 'owner_uid', 'integer', false);
            alterColumn('{{participant_attribute_names}}', 'visible', 'string(5)', false);
            alterColumn('{{questions}}', 'type', "string(1)", false, 'T');
            alterColumn('{{questions}}', 'other', "string(1)", false, 'N');
            alterColumn('{{questions}}', 'mandatory', "string(1)");
            alterColumn('{{questions}}', 'scale_id', 'integer', false, '0');
            alterColumn('{{questions}}', 'parent_qid', 'integer', false, '0');
            alterColumn('{{questions}}', 'same_default', 'integer', false, '0');
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:67,代码来源:updatedb_helper.php

示例5: actionIndex

 /**
  * Show list of plugins
  *
  * @return void
  */
 public function actionIndex()
 {
     if (!Permission::model()->hasGlobalPermission('settings', 'read')) {
         Yii::app()->session['flashmessage'] = gT('Access denied!');
         $this->redirect($this->createUrl("/admin"));
     }
     $oPluginManager = App()->getPluginManager();
     // Scan the plugins folder.
     $aDiscoveredPlugins = $oPluginManager->scanPlugins();
     $aInstalledPlugins = $oPluginManager->getInstalledPlugins();
     $aInstalledNames = array_map(function ($installedPlugin) {
         return $installedPlugin->name;
     }, $aInstalledPlugins);
     // Install newly discovered plugins.
     foreach ($aDiscoveredPlugins as $discoveredPlugin) {
         if (!in_array($discoveredPlugin['pluginClass'], $aInstalledNames)) {
             $oPlugin = new Plugin();
             $oPlugin->name = $discoveredPlugin['pluginClass'];
             $oPlugin->active = 0;
             $oPlugin->save();
         }
     }
     $aoPlugins = Plugin::model()->findAll();
     $data = array();
     foreach ($aoPlugins as $oPlugin) {
         /* @var $plugin Plugin */
         if (array_key_exists($oPlugin->name, $aDiscoveredPlugins)) {
             $aPluginSettings = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id)->getPluginSettings(false);
             $data[] = array('id' => $oPlugin->id, 'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'], 'description' => $aDiscoveredPlugins[$oPlugin->name]['description'], 'active' => $oPlugin->active, 'settings' => $aPluginSettings, 'new' => !in_array($oPlugin->name, $aInstalledNames));
         } else {
             // This plugin is missing, maybe the files were deleted but the record was not removed from the database
             // Now delete this record. Depending on the plugin the settings will be preserved
             App()->user->setFlash('pluginDelete' . $oPlugin->id, sprintf(gT("Plugin '%s' was missing and is removed from the database."), $oPlugin->name));
             $oPlugin->delete();
         }
     }
     echo $this->render('/plugins/index', compact('data'));
 }
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:43,代码来源:PluginsController.php

示例6: configure

 /**
  * Configure for plugin
  */
 public function configure($id)
 {
     if (!Permission::model()->hasGlobalPermission('settings', 'read')) {
         Yii::app()->setFlashMessage(gT("No permission"), 'error');
         $this->getController()->redirect(array('/admin/pluginmanager/sa/index'));
     }
     $arPlugin = Plugin::model()->findByPk($id)->attributes;
     $oPluginObject = App()->getPluginManager()->loadPlugin($arPlugin['name'], $arPlugin['id']);
     if ($arPlugin === null) {
         Yii::app()->user->setFlash('error', gT('The plugin was not found.'));
         $this->getController()->redirect(array('admin/pluginmanager/sa/index'));
     }
     // If post handle data, yt0 seems to be the submit button
     if (App()->request->isPostRequest) {
         if (!Permission::model()->hasGlobalPermission('settings', 'update')) {
             Yii::app()->setFlashMessage(gT("No permission"), 'error');
             $this->getController()->redirect(array('/admin/pluginmanager/sa/index'));
         }
         $aSettings = $oPluginObject->getPluginSettings(false);
         $aSave = array();
         foreach ($aSettings as $name => $setting) {
             $aSave[$name] = App()->request->getPost($name, null);
         }
         $oPluginObject->saveSettings($aSave);
         Yii::app()->user->setFlash('success', gT('The plugin settings were saved.'));
         if (App()->request->getPost('redirect')) {
             $this->getController()->redirect(App()->request->getPost('redirect'), true);
         }
     }
     // Prepare settings to be send to the view.
     $aSettings = $oPluginObject->getPluginSettings();
     if (empty($aSettings)) {
         // And show a message
         Yii::app()->user->setFlash('notice', gt('This plugin has no settings.'));
         $this->getController()->redirect('admin/pluginmanager/sa/index', true);
     }
     // Send to view plugin porperties: name and description
     $aPluginProp = App()->getPluginManager()->getPluginInfo($arPlugin['name']);
     $this->_renderWrappedTemplate('pluginmanager', 'configure', array('settings' => $aSettings, 'plugin' => $arPlugin, 'properties' => $aPluginProp));
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:43,代码来源:pluginmanager.php

示例7: loadByCode

 public static function loadByCode($code)
 {
     return Plugin::model()->notDeleted()->find('code=:code', array(':code' => $code));
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:4,代码来源:Plugin.php

示例8: actionTurnOn

 public function actionTurnOn($code)
 {
     $plugin = Plugin::loadByCode($code);
     if ($plugin == null) {
         echo CJSON::encode(array('error' => 'Запрашиваемый плагин не доступен.'));
         return;
     }
     if ($plugin->status == Plugin::STATUS_ENABLE) {
         echo CJSON::encode(array('error' => 'Плагин уже установлен и работает.'));
         return;
     }
     // проверяем зависимости
     $depends = $plugin->getDepends();
     $cr = new CDbCriteria();
     $cr->addInCondition('code', $depends);
     $allPlugin = Plugin::model()->enabled()->findAll($cr);
     $not = array();
     foreach ($depends as $d) {
         foreach ($allPlugin as $current) {
             if ($current->code == $d) {
                 continue 2;
             }
         }
         $not[] = $d;
     }
     if (count($not) > 0) {
         echo CJSON::encode(array('error' => 'Нет возможности включить данный плагин, т.к. не подключены другие: ' . implode(', ', $not) . '.'));
         return;
     }
     if ($plugin->status == Plugin::STATUS_NEW) {
         // запускаем процедуру установки
         try {
             $plugin->install($plugin);
         } catch (Exception $e) {
             echo CJSON::encode(array('error' => $e->getMessage()));
             return;
         }
         $plugin->status = Plugin::STATUS_DISABLE;
         $model = new PluginParameters();
         $model->setParameters($plugin->getSettingsOfParameters());
         $plugin->setConfig($plugin->getConfigByParamsValue($model->getParamsValue(), $plugin->getData()));
     }
     if ($plugin->status == Plugin::STATUS_DISABLE) {
         // запускаем процедуру активации
         try {
             $plugin->activate($plugin);
         } catch (Exception $e) {
             echo CJSON::encode(array('error' => $e->getMessage()));
             return;
         }
         $plugin->status = Plugin::STATUS_ENABLE;
         $model = new PluginParameters();
         $model->setParameters($plugin->getSettingsOfParameters());
         $plugin->setConfig($plugin->getConfigByParamsValue($model->getParamsValue(), $plugin->getData()));
         $plugin->save();
         Yii::app()->compilePluginsConfig();
     }
     $html = $this->renderPartial('/_buttons', array('plugin' => $plugin), true);
     $result = array('html' => $html);
     if ($plugin->isMenuChange()) {
         $result['updateMenu'] = true;
     }
     echo CJSON::encode($result);
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:64,代码来源:PluginController.php

示例9: actionConfigure

 public function actionConfigure($id)
 {
     $arPlugin = Plugin::model()->findByPk($id)->attributes;
     $oPluginObject = App()->getPluginManager()->loadPlugin($arPlugin['name'], $arPlugin['id']);
     if ($arPlugin === null) {
         Yii::app()->user->setFlash('pluginmanager', 'Plugin not found');
         $this->redirect(array('plugins/'));
     }
     // If post handle data.
     if (App()->request->isPostRequest) {
         $aSettings = $oPluginObject->getPluginSettings(false);
         $aSave = array();
         foreach ($aSettings as $name => $setting) {
             $aSave[$name] = App()->request->getPost($name, null);
         }
         $oPluginObject->saveSettings($aSave);
         Yii::app()->user->setFlash('pluginmanager', 'Settings saved');
     }
     $aSettings = $oPluginObject->getPluginSettings();
     if (empty($aSettings)) {
         // And show a message
         Yii::app()->user->setFlash('pluginmanager', 'This plugin has no settings');
         $this->forward('plugins/index', true);
     }
     $this->render('/plugins/configure', array('settings' => $aSettings, 'plugin' => $arPlugin));
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:26,代码来源:PluginsController.php

示例10: pluginIsActive

 /**
  * Returns true if plugin with name $name is active; otherwise false
  *
  * @param string $name Name of plugin
  * @return boolean
  * @throws InvalidArgumentException if $name is not a string
  * @throws Exception if no plugin with name $name is found
  */
 public function pluginIsActive($name)
 {
     if (!is_string($name)) {
         throw new InvalidArgumentException('$name must be a string');
     }
     $plugin = \Plugin::model()->findByAttributes(array('name' => $name));
     if ($plugin) {
         return $plugin->active == 1;
     } else {
         throw new Exception("Can't find a plugin with name " . $name);
     }
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:20,代码来源:LimesurveyApi.php


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