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


PHP PluginEvent类代码示例

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


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

示例1: actionCron

 public function actionCron($interval)
 {
     $pm = \Yii::app()->pluginManager;
     $event = new PluginEvent('cron');
     $event->set('interval', $interval);
     $pm->dispatchEvent($event);
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:7,代码来源:PluginCommand.php

示例2: actionPublicList

 public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage($lang);
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
     if ($oTemplate->cssFramework == 'bootstrap') {
         // We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
         // Then instead of using the composer dependency system for templates
         // We can use the package dependency system
         Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
         App()->bootstrap->registerAllScripts();
     }
     $aData = array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll());
     $htmlOut = $this->render('publicSurveyList', $aData, true);
     $event = new PluginEvent('beforeSurveysStartpageRender', $this);
     $event->set('aData', $aData);
     App()->getPluginManager()->dispatchEvent($event);
     if ($event->get('result')) {
         $htmlFromEvent = $event->get('result');
         $htmlOut = $htmlFromEvent['html'];
     }
     echo $htmlOut;
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:26,代码来源:SurveysController.php

示例3: dispatchPluginModelEvent

 /**
  * method for dispatching plugin events
  *
  * See {@link find()} for detailed explanation about $condition and $params.
  * @param string $sEventName event name to dispatch
  * @param array	$criteria array containing attributes, conditions and params for the filter query
  * @return PluginEvent the dispatched event
  */
 public function dispatchPluginModelEvent($sEventName, $criteria = null)
 {
     $oPluginEvent = new PluginEvent($sEventName, $this);
     $oPluginEvent->set('model', $this->owner);
     if (isset($criteria)) {
         $oPluginEvent->set('filterCriteria', $criteria);
     }
     return App()->getPluginManager()->dispatchEvent($oPluginEvent);
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:17,代码来源:PluginEventBehavior.php

示例4: exportSurvey

 /**
  * Root function for any export results action
  *
  * @param mixed $iSurveyId
  * @param mixed $sLanguageCode
  * @param csv|doc|pdf|xls $sExportPlugin Type of export
  * @param FormattingOptions $oOptions
  * @param string $sFilter 
  */
 function exportSurvey($iSurveyId, $sLanguageCode, $sExportPlugin, FormattingOptions $oOptions, $sFilter = '')
 {
     //Do some input validation.
     if (empty($iSurveyId)) {
         safeDie('A survey ID must be supplied.');
     }
     if (empty($sLanguageCode)) {
         safeDie('A language code must be supplied.');
     }
     if (empty($oOptions)) {
         safeDie('Formatting options must be supplied.');
     }
     if (empty($oOptions->selectedColumns)) {
         safeDie('At least one column must be selected for export.');
     }
     //echo $oOptions->toString().PHP_EOL;
     $writer = null;
     $iSurveyId = sanitize_int($iSurveyId);
     if ($oOptions->output == 'display') {
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Pragma: public");
     }
     $exports = $this->getExports();
     if (array_key_exists($sExportPlugin, $exports) && !empty($exports[$sExportPlugin])) {
         // This must be a plugin, now use plugin to load the right class
         $event = new PluginEvent('newExport');
         $event->set('type', $sExportPlugin);
         $oPluginManager = App()->getPluginManager();
         $oPluginManager->dispatchEvent($event, $exports[$sExportPlugin]);
         $writer = $event->get('writer');
     }
     if (!$writer instanceof IWriter) {
         throw new Exception(sprintf('Writer for %s should implement IWriter', $sExportPlugin));
     }
     $surveyDao = new SurveyDao();
     $survey = $surveyDao->loadSurveyById($iSurveyId, $sLanguageCode);
     $writer->init($survey, $sLanguageCode, $oOptions);
     $surveyDao->loadSurveyResults($survey, $oOptions->responseMinRecord, $oOptions->responseMaxRecord, $sFilter, $oOptions->responseCompletionState);
     $writer->write($survey, $sLanguageCode, $oOptions, true);
     $result = $writer->close();
     // Close resultset if needed
     if ($survey->responses instanceof CDbDataReader) {
         $survey->responses->close();
     }
     if ($oOptions->output == 'file') {
         return $writer->filename;
     } else {
         return $result;
     }
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:59,代码来源:exportresults_helper.php

示例5: authenticate

 public function authenticate()
 {
     // First initialize the result, we can later retieve it to get the exact error code/message
     $result = new LSAuthResult(self::ERROR_NONE);
     // Check if the ip is locked out
     if (FailedLoginAttempt::model()->isLockedOut()) {
         $message = sprintf(gT('You have exceeded the number of maximum login attempts. Please wait %d minutes before trying again.'), App()->getConfig('timeOutTime') / 60);
         $result->setError(self::ERROR_IP_LOCKED_OUT, $message);
     }
     // If still ok, continue
     if ($result->isValid()) {
         if (is_null($this->plugin)) {
             $result->setError(self::ERROR_UNKNOWN_HANDLER);
         } else {
             // Delegate actual authentication to plugin
             $authEvent = new PluginEvent('newUserSession', $this);
             $authEvent->set('identity', $this);
             App()->getPluginManager()->dispatchEvent($authEvent, array($this->plugin));
             $pluginResult = $authEvent->get('result');
             if ($pluginResult instanceof LSAuthResult) {
                 //print_r($pluginResult);
                 $result = $pluginResult;
             } else {
                 //echo 'out result';
                 $result->setError(self::ERROR_UNKNOWN_IDENTITY);
             }
         }
     }
     if ($result->isValid()) {
         // Perform postlogin
         //exit('you are in post login');
         $this->postLogin();
     } else {
         // Log a failed attempt
         //exit('you login failed');
         $userHostAddress = App()->request->getUserHostAddress();
         FailedLoginAttempt::model()->addAttempt($userHostAddress);
         App()->session->regenerateID();
         // Handled on login by Yii
     }
     $this->errorCode = $result->getCode();
     $this->errorMessage = $result->getMessage();
     return $result->isValid();
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:44,代码来源:LSUserIdentity.php

示例6: menuMain

 protected function menuMain()
 {
     $title = CHtml::tag('strong', array(), gT('Administration'));
     if (Yii::app()->session['loginID']) {
         $title .= ' -- ' . gT("Logged in as:");
         $text = ' ' . Yii::app()->session['user'] . ' ' . CHtml::image(Yii::app()->getConfig('adminimageurl') . 'profile_edit.png', gT("Edit your personal preferences"));
         $title .= CHtml::tag('strong', array(), CHtml::link($text, array('admin/user', 'sa' => 'personalsettings')));
     }
     $menu['title'] = CHtml::tag('div', array('class' => 'menubar-title-left'), $title);
     $menu['role'] = 'main';
     $menu['imageUrl'] = App()->getConfig('adminimageurl');
     $menu['items']['left'][] = array('href' => array('admin/survey'), 'alt' => gT('Default administration page'), 'image' => 'home.png');
     $menu['items']['left'][] = 'separator';
     if (Permission::model()->hasGlobalPermission('users', 'read')) {
         $menu['items']['left'][] = array('href' => array('admin/user'), 'alt' => gT('Manage survey administrators'), 'image' => 'security.png');
     }
     $menu['items']['left'][] = $this->userGroups();
     $menu['items']['left'][] = $this->globalSettings();
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = $this->checkIntegrity();
     $menu['items']['left'][] = $this->dumpDatabase();
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = $this->editLabels();
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = $this->editTemplates();
     $menu['items']['left'][] = 'separator';
     $menu['items']['left'][] = $this->participantDatabase();
     $menu['items']['left'][] = $this->pluginManager();
     $surveys = getSurveyList(true);
     $tmpList = array();
     $timeadjust = getGlobalSetting('timeadjust');
     foreach ($surveys as $survey) {
         if ($survey['active'] != 'Y') {
             $group = gT("Inactive");
             $list = 'inactive';
         } elseif ($survey['expires'] != '' && $survey['expires'] < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)) {
             $group = gT("Expired");
             $list = 'expired';
         } else {
             $group = gT("Active");
             $list = 'active';
         }
         $tmpList[$list][] = array('id' => $survey['sid'], 'title' => $survey['surveyls_title'], 'group' => $group);
     }
     $surveyList = array();
     if (array_key_exists('active', $tmpList)) {
         $surveyList = array_merge($surveyList, $tmpList['active']);
     }
     if (array_key_exists('expired', $tmpList)) {
         $surveyList = array_merge($surveyList, $tmpList['expired']);
     }
     if (array_key_exists('inactive', $tmpList)) {
         $surveyList = array_merge($surveyList, $tmpList['inactive']);
     }
     $menu['items']['right'][] = array('title' => gT('Surveys:'), 'type' => 'select', 'name' => 'surveyid', 'route' => 'admin/survey/sa/view', 'param' => 'surveyid', 'empty' => gT('No surveys available.'), 'values' => $surveyList, 'value' => $this->surveyId);
     $menu['items']['right'][] = array('href' => array('admin/survey', 'sa' => 'index'), 'alt' => gT('Detailed list of surveys'), 'image' => 'surveylist.png');
     $menu['items']['right'][] = $this->createSurvey();
     $menu['items']['right'][] = 'separator';
     $menu['items']['right'][] = array('href' => array('admin/authentication', 'sa' => 'logout'), 'alt' => gT('Logout'), 'image' => 'logout.png');
     $menu['items']['right'][] = array('href' => "http://docs.limesurvey.org", 'alt' => gT('LimeSurvey online manual'), 'image' => 'showhelp.png');
     $event = new PluginEvent('afterAdminMenuLoad', $this);
     $event->set('menu', $menu);
     $result = App()->getPluginManager()->dispatchEvent($event);
     $menu = $result->get('menu');
     return $menu;
 }
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:66,代码来源:MenuWidget.php

示例7: adduser

 function adduser()
 {
     if (!Permission::model()->hasGlobalPermission('users', 'create')) {
         Yii::app()->setFlashMessage(gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/user/sa/index"));
     }
     $new_user = flattenText(Yii::app()->request->getPost('new_user'), false, true);
     $aViewUrls = array();
     if (empty($new_user)) {
         $aViewUrls['message'] = array('title' => gT("Failed to add user"), 'message' => gT("A username was not supplied or the username is invalid."), 'class' => 'text-warning');
     } elseif (User::model()->find("users_name=:users_name", array(':users_name' => $new_user))) {
         $aViewUrls['message'] = array('title' => gT("Failed to add user"), 'message' => gT("The username already exists."), 'class' => 'text-warning');
     } else {
         $event = new PluginEvent('createNewUser');
         $event->set('errorCode', AuthPluginBase::ERROR_NOT_ADDED);
         $event->set('errorMessageTitle', gT("Failed to add user"));
         $event->set('errorMessageBody', gT("Plugin is not active"));
         App()->getPluginManager()->dispatchEvent($event);
         if ($event->get('errorCode') != AuthPluginBase::ERROR_NONE) {
             $aViewUrls['message'] = array('title' => $event->get('errorMessageTitle'), 'message' => $event->get('errorMessageBody'), 'class' => 'text-warning');
         } else {
             $iNewUID = $event->get('newUserID');
             $new_pass = $event->get('newPassword');
             $new_email = $event->get('newEmail');
             $new_full_name = $event->get('newFullName');
             // add default template to template rights for user
             Permission::model()->insertSomeRecords(array('uid' => $iNewUID, 'permission' => Yii::app()->getConfig("defaulttemplate"), 'entity' => 'template', 'read_p' => 1, 'entity_id' => 0));
             // add new user to userlist
             $sresult = User::model()->getAllRecords(array('uid' => $iNewUID));
             $srow = count($sresult);
             $userlist = getUserList();
             array_push($userlist, array("user" => $srow['users_name'], "uid" => $srow['uid'], "email" => $srow['email'], "password" => $srow["password"], "parent_id" => $srow['parent_id'], "create_survey" => $srow['create_survey'], "participant_panel" => $srow['participant_panel'], "configurator" => $srow['configurator'], "create_user" => $srow['create_user'], "delete_user" => $srow['delete_user'], "superadmin" => $srow['superadmin'], "manage_template" => $srow['manage_template'], "manage_label" => $srow['manage_label']));
             // send Mail
             $body = sprintf(gT("Hello %s,"), $new_full_name) . "<br /><br />\n";
             $body .= sprintf(gT("this is an automated email to notify that a user has been created for you on the site '%s'."), Yii::app()->getConfig("sitename")) . "<br /><br />\n";
             $body .= gT("You can use now the following credentials to log into the site:") . "<br />\n";
             $body .= gT("Username") . ": " . htmlspecialchars($new_user) . "<br />\n";
             // authent is not delegated to web server or LDAP server
             if (Yii::app()->getConfig("auth_webserver") === false && Permission::model()->hasGlobalPermission('auth_db', 'read', $iNewUID)) {
                 // send password (if authorized by config)
                 if (Yii::app()->getConfig("display_user_password_in_email") === true) {
                     $body .= gT("Password") . ": " . $new_pass . "<br />\n";
                 } else {
                     $body .= gT("Password") . ": " . gT("Please contact your LimeSurvey administrator for your password.") . "<br />\n";
                 }
             }
             $body .= "<a href='" . $this->getController()->createAbsoluteUrl("/admin") . "'>" . gT("Click here to log in.") . "</a><br /><br />\n";
             $body .= sprintf(gT('If you have any questions regarding this mail please do not hesitate to contact the site administrator at %s. Thank you!'), Yii::app()->getConfig("siteadminemail")) . "<br />\n";
             $subject = sprintf(gT("User registration at '%s'", "unescaped"), Yii::app()->getConfig("sitename"));
             $to = $new_user . " <{$new_email}>";
             $from = Yii::app()->getConfig("siteadminname") . " <" . Yii::app()->getConfig("siteadminemail") . ">";
             $extra = '';
             $classMsg = '';
             if (SendEmailMessage($body, $subject, $to, $from, Yii::app()->getConfig("sitename"), true, Yii::app()->getConfig("siteadminbounce"))) {
                 $extra .= "<br />" . gT("Username") . ": {$new_user}<br />" . gT("Email") . ": {$new_email}<br />";
                 $extra .= "<br />" . gT("An email with a generated password was sent to the user.");
                 $classMsg = 'text-success';
                 $sHeader = gT("Success");
             } else {
                 // has to be sent again or no other way
                 $tmp = str_replace("{NAME}", "<strong>" . $new_user . "</strong>", gT("Email to {NAME} ({EMAIL}) failed."));
                 $extra .= "<br />" . str_replace("{EMAIL}", $new_email, $tmp) . "<br />";
                 $classMsg = 'text-warning';
                 $sHeader = gT("Warning");
             }
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect(gT("Add user"), $sHeader, $classMsg, $extra, $this->getController()->createUrl("admin/user/sa/setuserpermissions"), gT("Set user permissions"), array('action' => 'setuserpermissions', 'user' => $new_user, 'uid' => $iNewUID));
         }
     }
     $this->_renderWrappedTemplate('user', $aViewUrls);
 }
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:70,代码来源:useraction.php

示例8: actionUnsecure

 /**
  * Launch the event newUnsecureRequest
  * @param $plugin : the target
  * @param $function : the function to call from the plugin
  */
 public function actionUnsecure($plugin, $function = null)
 {
     $oEvent = new PluginEvent('newUnsecureRequest');
     // The intended target of the call.
     $oEvent->set('target', $plugin);
     // The name of the function.
     $oEvent->set('function', $function);
     $oEvent->set('request', App()->request);
     App()->getPluginManager()->dispatchEvent($oEvent);
     $sOutput = '';
     foreach ($oEvent->getAllContent() as $content) {
         $sOutput .= $content->getContent();
     }
     if (!empty($sOutput)) {
         $this->renderText($sOutput);
     }
 }
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:22,代码来源:PluginsController.php

示例9: setPermissions

 /**
  * Sets permissions (global or survey-specific) for a survey administrator
  * Checks what permissions may be set and automatically filters invalid ones. 
  * A permission may be invalid if the permission does not exist or that particular user may not give that permission
  * 
  * @param mixed $iUserID
  * @param mixed $iEntityID
  * @param mixed $sEntityName
  * @param mixed $aPermissions
  * @param mixed $bBypassCheck
  */
 public static function setPermissions($iUserID, $iEntityID, $sEntityName, $aPermissions, $bBypassCheck = false)
 {
     $iUserID = sanitize_int($iUserID);
     // Filter global permissions on save
     if ($sEntityName == 'global') {
         $aBasePermissions = Permission::model()->getGlobalBasePermissions();
         if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && !$bBypassCheck) {
             // if not superadmin filter the available permissions as no admin may give more permissions than he owns
             // Make sure that he owns the user he wants to give global permissions for
             $oUser = User::model()->findByAttributes(array('uid' => $iUserID, 'parent_id' => Yii::app()->session['loginID']));
             if (!$oUser) {
                 die('You are not allowed to set permisisons for this user');
             }
             $aFilteredPermissions = array();
             foreach ($aBasePermissions as $PermissionName => $aPermission) {
                 foreach ($aPermission as $sPermissionKey => &$sPermissionValue) {
                     if ($sPermissionKey != 'title' && $sPermissionKey != 'img' && !Permission::model()->hasGlobalPermission($PermissionName, $sPermissionKey)) {
                         $sPermissionValue = false;
                     }
                 }
                 // Only have a row for that permission if there is at least one permission he may give to other users
                 if ($aPermission['create'] || $aPermission['read'] || $aPermission['update'] || $aPermission['delete'] || $aPermission['import'] || $aPermission['export']) {
                     $aFilteredPermissions[$PermissionName] = $aPermission;
                 }
             }
             $aBasePermissions = $aFilteredPermissions;
         } elseif (Permission::model()->hasGlobalPermission('superadmin', 'read') && Yii::app()->session['loginID'] != 1) {
             unset($aBasePermissions['superadmin']);
         }
     } elseif ($sEntityName == 'survey') {
         $aBasePermissions = Permission::model()->getSurveyBasePermissions();
     }
     $aFilteredPermissions = array();
     foreach ($aBasePermissions as $sPermissionname => $aPermission) {
         $aFilteredPermissions[$sPermissionname]['create'] = isset($aPermissions[$sPermissionname]['create']) && $aPermissions[$sPermissionname]['create'];
         $aFilteredPermissions[$sPermissionname]['read'] = isset($aPermissions[$sPermissionname]['read']) && $aPermissions[$sPermissionname]['read'];
         $aFilteredPermissions[$sPermissionname]['update'] = isset($aPermissions[$sPermissionname]['update']) && $aPermissions[$sPermissionname]['update'];
         $aFilteredPermissions[$sPermissionname]['delete'] = isset($aPermissions[$sPermissionname]['delete']) && $aPermissions[$sPermissionname]['delete'];
         $aFilteredPermissions[$sPermissionname]['import'] = isset($aPermissions[$sPermissionname]['import']) && $aPermissions[$sPermissionname]['import'];
         $aFilteredPermissions[$sPermissionname]['export'] = isset($aPermissions[$sPermissionname]['export']) && $aPermissions[$sPermissionname]['export'];
     }
     $condition = array('entity_id' => $iEntityID, 'uid' => $iUserID);
     $oEvent = new PluginEvent('beforePermissionSetSave');
     $oEvent->set('aNewPermissions', $aFilteredPermissions);
     $oEvent->set('iSurveyID', $iEntityID);
     $oEvent->set('iUserID', $iUserID);
     $result = App()->getPluginManager()->dispatchEvent($oEvent);
     // Only the original superadmin may change the superadmin permissions
     if (Yii::app()->session['loginID'] != 1) {
         Permission::model()->deleteAllByAttributes($condition, "permission <> 'superadmin'");
     } else {
         Permission::model()->deleteAllByAttributes($condition);
     }
     foreach ($aFilteredPermissions as $sPermissionname => $aPermission) {
         if ($aPermission['create'] || $aPermission['read'] || $aPermission['update'] || $aPermission['delete'] || $aPermission['import'] || $aPermission['export']) {
             $data = array('entity_id' => $iEntityID, 'entity' => $sEntityName, 'uid' => $iUserID, 'permission' => $sPermissionname, 'create_p' => (int) $aPermission['create'], 'read_p' => (int) $aPermission['read'], 'update_p' => (int) $aPermission['update'], 'delete_p' => (int) $aPermission['delete'], 'import_p' => (int) $aPermission['import'], 'export_p' => (int) $aPermission['export']);
             $permission = new self();
             foreach ($data as $k => $v) {
                 $permission->{$k} = $v;
             }
             $permission->save();
         }
     }
     return true;
 }
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:76,代码来源:Permission.php

示例10: email


//.........这里部分代码省略.........
                     /*
                      * Get attachments.
                      */
                     if ($sSubAction == 'email') {
                         $sTemplate = 'invitation';
                     } elseif ($sSubAction == 'remind') {
                         $sTemplate = 'reminder';
                     }
                     $aRelevantAttachments = array();
                     if (isset($aData['thissurvey'][$emrow['language']]['attachments'])) {
                         $aAttachments = unserialize($aData['thissurvey'][$emrow['language']]['attachments']);
                         if (!empty($aAttachments)) {
                             if (isset($aAttachments[$sTemplate])) {
                                 LimeExpressionManager::singleton()->loadTokenInformation($aData['thissurvey']['sid'], $emrow['token']);
                                 foreach ($aAttachments[$sTemplate] as $aAttachment) {
                                     if (LimeExpressionManager::singleton()->ProcessRelevance($aAttachment['relevance'])) {
                                         $aRelevantAttachments[] = $aAttachment['url'];
                                     }
                                 }
                             }
                         }
                     }
                     /**
                      * Event for email handling.
                      * Parameter    type    description:
                      * subject      rw      Body of the email
                      * to           rw      Recipient(s)
                      * from         rw      Sender(s)
                      * type         r       "invitation" or "reminder"
                      * send         w       If true limesurvey will send the email. Setting this to false will cause limesurvey to assume the mail has been sent by the plugin.
                      * error        w       If set and "send" is true, log the error as failed email attempt.
                      * token        r       Raw token data.
                      */
                     $event = new PluginEvent('beforeTokenEmail');
                     $event->set('type', $sTemplate);
                     $event->set('subject', $modsubject);
                     $event->set('to', $to);
                     $event->set('body', $modmessage);
                     $event->set('from', $from);
                     $event->set('bounce', getBounceEmail($iSurveyId));
                     $event->set('token', $emrow);
                     App()->getPluginManager()->dispatchEvent($event);
                     $modsubject = $event->get('subject');
                     $modmessage = $event->get('body');
                     $to = $event->get('to');
                     $from = $event->get('from');
                     if ($event->get('send', true) == false) {
                         // This is some ancient global used for error reporting instead of a return value from the actual mail function..
                         $maildebug = $event->get('error', $maildebug);
                         $success = $event->get('error') == null;
                     } else {
                         $success = SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyId), $aRelevantAttachments, $customheaders);
                     }
                     if ($success) {
                         // Put date into sent
                         $token = Token::model($iSurveyId)->findByPk($emrow['tid']);
                         if ($bEmail) {
                             $tokenoutput .= $clang->gT("Invitation sent to:");
                             $token->sent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
                         } else {
                             $tokenoutput .= $clang->gT("Reminder sent to:");
                             $token->remindersent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
                             $token->remindercount++;
                         }
                         $token->save();
                         //Update central participant survey_links
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:67,代码来源:tokens.php

示例11: listQuestionPlugins

 /**
  * @param PluginEvent $event
  */
 public function listQuestionPlugins(PluginEvent $event)
 {
     if (!empty($this->questionTypes)) {
         $event->set('questionplugins.' . get_class($this), $this->questionTypes);
     }
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:9,代码来源:QuestionPluginBase.php

示例12: hasPermission

 /**
  * Checks if a user has a certain permission
  *
  * @param $iEntityID integer The entity ID
  * @param $sEntityName string The entity name
  * @param $sPermission string Name of the permission
  * @param $sCRUD string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'
  * @param $iUserID integer User ID - if not given the one of the current user is used
  * @return bool True if user has the permission
  */
 function hasPermission($iEntityID, $sEntityName, $sPermission, $sCRUD = 'read', $iUserID = null)
 {
     static $aPermissionStatic;
     $oEvent = new PluginEvent('beforeHasPermission');
     $oEvent->set('iEntityID', $iEntityID);
     $oEvent->set('sEntityName', $sEntityName);
     $oEvent->set('sPermission', $sPermission);
     $oEvent->set('sCRUD', $sCRUD);
     $oEvent->set('iUserID', $iUserID);
     App()->getPluginManager()->dispatchEvent($oEvent);
     $pluginbPermission = $oEvent->get('bPermission');
     // isset — Determine if a variable is set and is not NULL. And isset seems little speedest.
     if (isset($pluginbPermission)) {
         return $pluginbPermission;
     }
     if (!in_array($sCRUD, array('create', 'read', 'update', 'delete', 'import', 'export'))) {
         return false;
     }
     $sCRUD = $sCRUD . '_p';
     $iUserID = self::getUserId($iUserID);
     if (!$iUserID) {
         return false;
     }
     // Check if superadmin and cache it
     if (!isset($aPermissionStatic[0]['global'][$iUserID]['superadmin']['read_p'])) {
         $aPermission = $this->findByAttributes(array("entity_id" => 0, 'entity' => 'global', "uid" => $iUserID, "permission" => 'superadmin'));
         $bPermission = is_null($aPermission) ? array() : $aPermission->attributes;
         if (!isset($bPermission['read_p']) || $bPermission['read_p'] == 0) {
             $bPermission = false;
         } else {
             $bPermission = true;
         }
         $aPermissionStatic[0]['global'][$iUserID]['superadmin']['read_p'] = $bPermission;
     }
     if ($aPermissionStatic[0]['global'][$iUserID]['superadmin']['read_p']) {
         return true;
     }
     if (!isset($aPermissionStatic[$iEntityID][$sEntityName][$iUserID][$sPermission][$sCRUD])) {
         $query = $this->findByAttributes(array("entity_id" => $iEntityID, "uid" => $iUserID, "entity" => $sEntityName, "permission" => $sPermission));
         $bPermission = is_null($query) ? array() : $query->attributes;
         if (!isset($bPermission[$sCRUD]) || $bPermission[$sCRUD] == 0) {
             $bPermission = false;
         } else {
             $bPermission = true;
         }
         $aPermissionStatic[$iEntityID][$sEntityName][$iUserID][$sPermission][$sCRUD] = $bPermission;
     }
     return $aPermissionStatic[$iEntityID][$sEntityName][$iUserID][$sPermission][$sCRUD];
 }
开发者ID:venurasasanka,项目名称:LimeSurvey,代码行数:59,代码来源:Permission.php

示例13: dispatchEvent

 /**
  * This function dispatches an event to all registered plugins.
  * @param PluginEvent $event Object holding all event properties
  * @param string|array $target Optional name of plugin to fire the event on
  * 
  * @return PluginEvent
  */
 public function dispatchEvent(PluginEvent $event, $target = array())
 {
     $eventName = $event->getEventName();
     if (is_string($target)) {
         $target = array($target);
     }
     if (isset($this->subscriptions[$eventName])) {
         foreach ($this->subscriptions[$eventName] as $subscription) {
             if (!$event->isStopped() && (empty($target) || in_array(get_class($subscription[0]), $target))) {
                 $subscription[0]->setEvent($event);
                 call_user_func($subscription);
             }
         }
     }
     return $event;
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:23,代码来源:PluginManager.php

示例14: index


//.........这里部分代码省略.........
         Yii::app()->loadHelper('database');
         foreach ($languagelist as $langname) {
             if ($langname) {
                 $url = Yii::app()->request->getPost('url_' . $langname);
                 if ($url == 'http://') {
                     $url = "";
                 }
                 $sURLDescription = html_entity_decode(Yii::app()->request->getPost('urldescrip_' . $langname), ENT_QUOTES, "UTF-8");
                 $sURL = html_entity_decode(Yii::app()->request->getPost('url_' . $langname), ENT_QUOTES, "UTF-8");
                 // Fix bug with FCKEditor saving strange BR types
                 $short_title = Yii::app()->request->getPost('short_title_' . $langname);
                 $description = Yii::app()->request->getPost('description_' . $langname);
                 $welcome = Yii::app()->request->getPost('welcome_' . $langname);
                 $endtext = Yii::app()->request->getPost('endtext_' . $langname);
                 $short_title = $oFixCKeditor->fixCKeditor($short_title);
                 $description = $oFixCKeditor->fixCKeditor($description);
                 $welcome = $oFixCKeditor->fixCKeditor($welcome);
                 $endtext = $oFixCKeditor->fixCKeditor($endtext);
                 $data = array('surveyls_title' => $short_title, 'surveyls_description' => $description, 'surveyls_welcometext' => $welcome, 'surveyls_endtext' => $endtext, 'surveyls_url' => $sURL, 'surveyls_urldescription' => $sURLDescription, 'surveyls_dateformat' => Yii::app()->request->getPost('dateformat_' . $langname), 'surveyls_numberformat' => Yii::app()->request->getPost('numberformat_' . $langname));
                 $SurveyLanguageSetting = SurveyLanguageSetting::model()->findByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $langname));
                 $SurveyLanguageSetting->attributes = $data;
                 $SurveyLanguageSetting->save();
                 // save the change to database
             }
         }
         //Yii::app()->session['flashmessage'] = gT("Survey text elements successfully saved.");
         ////////////////////////////////////////////////////////////////////////////////////
         // General settings (copy / paste from surveyadmin::update)
         // Preload survey
         $oSurvey = Survey::model()->findByPk($iSurveyID);
         // Save plugin settings.
         $pluginSettings = App()->request->getPost('plugin', array());
         foreach ($pluginSettings as $plugin => $settings) {
             $settingsEvent = new PluginEvent('newSurveySettings');
             $settingsEvent->set('settings', $settings);
             $settingsEvent->set('survey', $iSurveyID);
             App()->getPluginManager()->dispatchEvent($settingsEvent, $plugin);
         }
         /* Start to fix some param before save (TODO : use models directly ?) */
         /* Date management */
         Yii::app()->loadHelper('surveytranslator');
         $formatdata = getDateFormatData(Yii::app()->session['dateformat']);
         Yii::app()->loadLibrary('Date_Time_Converter');
         $startdate = App()->request->getPost('startdate');
         if (trim($startdate) == "") {
             $startdate = null;
         } else {
             Yii::app()->loadLibrary('Date_Time_Converter');
             $datetimeobj = new date_time_converter($startdate, $formatdata['phpdate'] . ' H:i');
             //new Date_Time_Converter($startdate,$formatdata['phpdate'].' H:i');
             $startdate = $datetimeobj->convert("Y-m-d H:i:s");
         }
         $expires = App()->request->getPost('expires');
         if (trim($expires) == "") {
             $expires = null;
         } else {
             $datetimeobj = new date_time_converter($expires, $formatdata['phpdate'] . ' H:i');
             //new Date_Time_Converter($expires, $formatdata['phpdate'].' H:i');
             $expires = $datetimeobj->convert("Y-m-d H:i:s");
         }
         // We have $oSurvey : update and save it
         $oSurvey->owner_id = Yii::app()->request->getPost('owner_id');
         $oSurvey->admin = Yii::app()->request->getPost('admin');
         $oSurvey->expires = $expires;
         $oSurvey->startdate = $startdate;
         $oSurvey->faxto = App()->request->getPost('faxto');
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:67,代码来源:database.php

示例15: checkCompletedQuota

/**
* checkCompletedQuota() returns matched quotas information for the current response
* @param integer $surveyid - Survey identification number
* @param bool $return - set to true to return information, false do the quota
* @return array|void - nested array, Quotas->Members->Fields, includes quota information matched in session.
*/
function checkCompletedQuota($surveyid, $return = false)
{
    /* Check if session is set */
    if (!isset(App()->session['survey_' . $surveyid]['srid'])) {
        return;
    }
    /* Check is Response is already submitted : only when "do" the quota: allow to send information about quota */
    $oResponse = Response::model($surveyid)->findByPk(App()->session['survey_' . $surveyid]['srid']);
    if (!$return && $oResponse && !is_null($oResponse->submitdate)) {
        return;
    }
    static $aMatchedQuotas;
    // EM call 2 times quotas with 3 lines of php code, then use static.
    if (!$aMatchedQuotas) {
        $aMatchedQuotas = array();
        $quota_info = $aQuotasInfo = getQuotaInformation($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
        // $aQuotasInfo have an 'active' key, we don't use it ?
        if (!$aQuotasInfo || empty($aQuotasInfo)) {
            return $aMatchedQuotas;
        }
        // OK, we have some quota, then find if this $_SESSION have some set
        $aPostedFields = explode("|", Yii::app()->request->getPost('fieldnames', ''));
        // Needed for quota allowing update
        foreach ($aQuotasInfo as $aQuotaInfo) {
            if (count($aQuotaInfo['members']) === 0) {
                continue;
            }
            $iMatchedAnswers = 0;
            $bPostedField = false;
            // Array of field with quota array value
            $aQuotaFields = array();
            // Array of fieldnames with relevance value : EM fill $_SESSION with default value even is unrelevant (em_manager_helper line 6548)
            $aQuotaRelevantFieldnames = array();
            // To count number of hidden questions
            $aQuotaQid = array();
            foreach ($aQuotaInfo['members'] as $aQuotaMember) {
                $aQuotaFields[$aQuotaMember['fieldname']][] = $aQuotaMember['value'];
                $aQuotaRelevantFieldnames[$aQuotaMember['fieldname']] = isset($_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']]) && $_SESSION['survey_' . $surveyid]['relevanceStatus'][$aQuotaMember['qid']];
                $aQuotaQid[] = $aQuotaMember['qid'];
            }
            $aQuotaQid = array_unique($aQuotaQid);
            // For each field : test if actual responses is in quota (and is relevant)
            foreach ($aQuotaFields as $sFieldName => $aValues) {
                $bInQuota = isset($_SESSION['survey_' . $surveyid][$sFieldName]) && in_array($_SESSION['survey_' . $surveyid][$sFieldName], $aValues);
                if ($bInQuota && $aQuotaRelevantFieldnames[$sFieldName]) {
                    $iMatchedAnswers++;
                }
                if (in_array($sFieldName, $aPostedFields)) {
                    // Need only one posted value
                    $bPostedField = true;
                }
            }
            // Condition to count quota : Answers are the same in quota + an answer is submitted at this time (bPostedField) OR all questions is hidden (bAllHidden)
            $bAllHidden = QuestionAttribute::model()->countByAttributes(array('qid' => $aQuotaQid), 'attribute=:attribute', array(':attribute' => 'hidden')) == count($aQuotaQid);
            if ($iMatchedAnswers == count($aQuotaFields) && ($bPostedField || $bAllHidden)) {
                if ($aQuotaInfo['qlimit'] == 0) {
                    // Always add the quota if qlimit==0
                    $aMatchedQuotas[] = $aQuotaInfo;
                } else {
                    $iCompleted = getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);
                    if (!is_null($iCompleted) && (int) $iCompleted >= (int) $aQuotaInfo['qlimit']) {
                        // This remove invalid quota and not completed
                        $aMatchedQuotas[] = $aQuotaInfo;
                    }
                }
            }
        }
    }
    if ($return) {
        return $aMatchedQuotas;
    }
    if (empty($aMatchedQuotas)) {
        return;
    }
    // Now we have all the information we need about the quotas and their status.
    // We need to construct the page and do all needed action
    $aSurveyInfo = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
    $oTemplate = Template::model()->getInstance('', $surveyid);
    $sTemplatePath = $oTemplate->path;
    $sTemplateViewPath = $oTemplate->viewPath;
    $sClientToken = isset($_SESSION['survey_' . $surveyid]['token']) ? $_SESSION['survey_' . $surveyid]['token'] : "";
    // $redata for templatereplace
    $aDataReplacement = array('thissurvey' => $aSurveyInfo, 'clienttoken' => $sClientToken, 'token' => $sClientToken);
    // We take only the first matched quota, no need for each
    $aMatchedQuota = $aMatchedQuotas[0];
    // If a token is used then mark the token as completed, do it before event : this allow plugin to update token information
    $event = new PluginEvent('afterSurveyQuota');
    $event->set('surveyId', $surveyid);
    $event->set('responseId', $_SESSION['survey_' . $surveyid]['srid']);
    // We allways have a responseId
    $event->set('aMatchedQuotas', $aMatchedQuotas);
    // Give all the matched quota : the first is the active
    App()->getPluginManager()->dispatchEvent($event);
    $blocks = array();
//.........这里部分代码省略.........
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:101,代码来源:frontend_helper.php


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