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


PHP Token::createTable方法代码示例

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


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

示例1: activate_tokens

 /**
  * RPC routine to to initialise the survey's collection of tokens where new participant tokens may be later added.
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param integer $iSurveyID ID of the survey where a token table will be created for
  * @param array $aAttributeFields  An array of integer describing any additional attribute fields
  * @return array Status=>OK when successfull, otherwise the error description
  */
 public function activate_tokens($sSessionKey, $iSurveyID, $aAttributeFields = array())
 {
     if (!$this->_checkSessionKey($sSessionKey)) {
         return array('status' => 'Invalid session key');
     }
     if (Permission::model()->hasGlobalPermission('surveys', 'create')) {
         $oSurvey = Survey::model()->findByPk($iSurveyID);
         if (is_null($oSurvey)) {
             return array('status' => 'Error: Invalid survey ID');
         }
         if (is_array($aAttributeFields) && count($aAttributeFields) > 0) {
             foreach ($aAttributeFields as &$sField) {
                 $sField = intval($sField);
                 $sField = 'attribute_' . $sField;
             }
             $aAttributeFields = array_unique($aAttributeFields);
         }
         Yii::app()->loadHelper('admin/token');
         if (Token::createTable($iSurveyID, $aAttributeFields)) {
             return array('status' => 'OK');
         } else {
             return array('status' => 'Token table could not be created');
         }
     } else {
         return array('status' => 'No permission');
     }
 }
开发者ID:kasutori,项目名称:LimeSurvey,代码行数:36,代码来源:remotecontrol_handle.php

示例2: _newtokentable

 /**
  * Show dialogs and create a new tokens table
  */
 public function _newtokentable($iSurveyId)
 {
     $aSurveyInfo = getSurveyInfo($iSurveyId);
     if (!Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create')) {
         Yii::app()->session['flashmessage'] = gT("Survey participants have not been initialised for this survey.");
         $this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
     }
     $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
     //The token table already exist ?
     if ($bTokenExists) {
         Yii::app()->session['flashmessage'] = gT("Tokens already exist for this survey.");
         $this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
     }
     // The user have rigth to create token, then don't test right after
     Yii::import('application.helpers.admin.token_helper', true);
     // Update table, must be CRSF controlled
     if (Yii::app()->request->getPost('createtable') == "Y") {
         Token::createTable($iSurveyId);
         $aData['sidemenu']['state'] = false;
         LimeExpressionManager::SetDirtyFlag();
         // LimeExpressionManager needs to know about the new token table
         $this->_renderWrappedTemplate('token', array('message' => array('title' => gT("Survey participants"), 'message' => gT("A participant table has been created for this survey.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}\")<br /><br />\n" . "<input type='submit' class='btn btn-default' value='" . gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n")));
     } elseif (returnGlobal('restoretable') == "Y" && Yii::app()->request->getPost('oldtable')) {
         //Rebuild attributedescription value for the surveys table
         $table = Yii::app()->db->schema->getTable(Yii::app()->request->getPost('oldtable'));
         $fields = array_filter(array_keys($table->columns), 'filterForAttributes');
         $fieldcontents = $aSurveyInfo['attributedescriptions'];
         if (!is_array($fieldcontents)) {
             $fieldcontents = array();
         }
         foreach ($fields as $fieldname) {
             $name = $fieldname;
             if ($fieldname[10] == 'c') {
                 //This belongs to a cpdb attribute
                 $cpdbattid = substr($fieldname, 15);
                 $data = ParticipantAttributeName::model()->getAttributeName($cpdbattid, Yii::app()->session['adminlang']);
                 $name = $data['attribute_name'];
             }
             if (!isset($fieldcontents[$fieldname])) {
                 $fieldcontents[$fieldname] = array('description' => $name, 'mandatory' => 'N', 'show_register' => 'N');
             }
         }
         Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => json_encode($fieldcontents)));
         Yii::app()->db->createCommand()->renameTable(Yii::app()->request->getPost('oldtable'), Yii::app()->db->tablePrefix . "tokens_" . intval($iSurveyId));
         Yii::app()->db->schema->getTable(Yii::app()->db->tablePrefix . "tokens_" . intval($iSurveyId), true);
         // Refresh schema cache just in case the table existed in the past
         //Add any survey_links from the renamed table
         SurveyLink::model()->rebuildLinksFromTokenTable($iSurveyId);
         $aData = array();
         $aData['sidemenu']['state'] = false;
         $this->_renderWrappedTemplate('token', array('message' => array('title' => gT("Import old tokens"), 'message' => gT("A token table has been created for this survey and the old tokens were imported.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}" . "\")<br /><br />\n" . "<input type='submit' class='btn btn-default' value='" . gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n")));
         LimeExpressionManager::SetDirtyFlag();
         // so that knows that token tables have changed
     } else {
         $this->getController()->loadHelper('database');
         $result = Yii::app()->db->createCommand(dbSelectTablesLike("{{old_tokens_" . intval($iSurveyId) . "_%}}"))->queryAll();
         $tcount = count($result);
         if ($tcount > 0) {
             foreach ($result as $rows) {
                 $oldlist[] = reset($rows);
             }
             $aData['oldlist'] = $oldlist;
         }
         $thissurvey = getSurveyInfo($iSurveyId);
         $aData['thissurvey'] = $thissurvey;
         $aData['surveyid'] = $iSurveyId;
         $aData['tcount'] = $tcount;
         $aData['databasetype'] = Yii::app()->db->getDriverName();
         /////////////////////////////
         $surveyinfo = Survey::model()->findByPk($iSurveyId)->surveyinfo;
         $aData['sidemenu']['state'] = false;
         $aData["surveyinfo"] = $surveyinfo;
         $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyId . ")";
         $aData['sidemenu']["token_menu"] = TRUE;
         $this->_renderWrappedTemplate('token', 'tokenwarning', $aData);
     }
     Yii::app()->end();
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:81,代码来源:tokens.php

示例3: importSurveyFile

function importSurveyFile($sFullFilePath, $bTranslateLinksFields, $sNewSurveyName = NULL, $DestSurveyID = NULL)
{
    $aPathInfo = pathinfo($sFullFilePath);
    if (isset($aPathInfo['extension'])) {
        $sExtension = strtolower($aPathInfo['extension']);
    } else {
        $sExtension = "";
    }
    if ($sExtension == 'lss') {
        return XMLImportSurvey($sFullFilePath, null, $sNewSurveyName, $DestSurveyID, $bTranslateLinksFields);
    } elseif ($sExtension == 'txt') {
        return TSVImportSurvey($sFullFilePath);
    } elseif ($sExtension == 'lsa') {
        Yii::import("application.libraries.admin.pclzip.pclzip", true);
        $pclzip = new PclZip(array('p_zipname' => $sFullFilePath));
        $aFiles = $pclzip->listContent();
        if ($pclzip->extract(PCLZIP_OPT_PATH, Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR, PCLZIP_OPT_BY_EREG, '/(lss|lsr|lsi|lst)$/') == 0) {
            unset($pclzip);
        }
        // Step 1 - import the LSS file and activate the survey
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lss') {
                //Import the LSS file
                $aImportResults = XMLImportSurvey(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], null, null, null, true, false);
                // Activate the survey
                Yii::app()->loadHelper("admin/activate");
                $activateoutput = activateSurvey($aImportResults['newsid']);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 2 - import the responses file
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lsr') {
                //Import the LSS file
                $aResponseImportResults = XMLImportResponses(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid'], $aImportResults['FieldReMap']);
                $aImportResults = array_merge($aResponseImportResults, $aImportResults);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 3 - import the tokens file - if exists
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lst') {
                Yii::app()->loadHelper("admin/token");
                if (Token::createTable($aImportResults['newsid'])) {
                    $aTokenCreateResults = array('tokentablecreated' => true);
                    $aImportResults = array_merge($aTokenCreateResults, $aImportResults);
                    $aTokenImportResults = XMLImportTokens(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid']);
                } else {
                    $aTokenCreateResults = array('tokentablecreated' => false);
                    $aTokenImportResults['warnings'][] = gT("Unable to create token table");
                }
                $aImportResults = array_merge_recursive($aTokenImportResults, $aImportResults);
                $aImportResults['importwarnings'] = array_merge($aImportResults['importwarnings'], $aImportResults['warnings']);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        // Step 4 - import the timings file - if exists
        Yii::app()->db->schema->refresh();
        foreach ($aFiles as $aFile) {
            if (pathinfo($aFile['filename'], PATHINFO_EXTENSION) == 'lsi' && tableExists("survey_{$aImportResults['newsid']}_timings")) {
                $aTimingsImportResults = XMLImportTimings(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename'], $aImportResults['newsid'], $aImportResults['FieldReMap']);
                $aImportResults = array_merge($aTimingsImportResults, $aImportResults);
                unlink(Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $aFile['filename']);
                break;
            }
        }
        return $aImportResults;
    } else {
        return null;
    }
}
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:74,代码来源:import_helper.php

示例4: newSurveySettings

    public function newSurveySettings() {
        $oEvent = $this->getEvent();
        $iSurveyId = $oEvent->get('survey');
        $aSettings = $oEvent->get('settings');
        
        //check tokens table when YES
        if ($aSettings['bUse'] == 1 && !tableExists("tokens_{$iSurveyId}")) {
            Token::createTable($iSurveyId);
        }

        $this->set('bUse', array_shift($aSettings), 'Survey', $oEvent->get('survey'));
        $this->set('surveyIdpAttributes', json_encode($aSettings), 'Survey', $oEvent->get('survey'));
    }
开发者ID:hotcyv,项目名称:limesurvey-saml,代码行数:13,代码来源:AuthSAML.php


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