- Posts: 14219
- Thank you received: 2573
Ask the community, share ideas, and connect with other LimeSurvey users!
Plugin or API ?Is there a way to connect to the database in the plugin-code without entering the database user and password?
Want to use something like:
$sql = 'SELECT token FROM lime_tokens_[surveyId]';
Please Log in to join the conversation.
$this->subscribe('beforeToolsMenuRender'); $this->subscribe('pTsIndex'); $this->subscribe('pTsCreate');
public function pTsIndex($surveyId) { if (!Permission::model()->hasSurveyPermission($surveyId, 'tokens', 'read')) { throw new CHttpException(403, gT("You do not have permission to access this page.")); } $surveyId = (int) $surveyId; $survey = Survey::model()->findByPk($surveyId); $tkcount = Token::model($surveyId)->count(); if (!$survey->hasTokensTable) { // If no tokens table exists $this->newtokentable($iSurveyId); } Yii::app()->loadHelper("surveytranslator"); if ($survey->hasTokensTable) { $content = "There are a lot of Tokens in the database for this survey<br/> <label for='ssid' class='control-label'>Umfrage-ID</label> <input type='text' class='form-control' id='ssid' name='ssid' placeholder='$surveyId' readonly> <label for='stitle' class='control-label'>Titel</label> <input type='text' class='form-control' id='stitle' name='stitle' readonly> <label for='count_tokens' class='control-label'>Anzahl TANs</label> <input type='text' class='form-control' id='scount_tokens' name='scount_tokens' placeholder='$tkcount' readonly> <label for='count_tokens' class='control-label'>Anfang</label> <input type='text' class='form-control' id='sstartdate' name='sstartdate' readonly> <label for='count_tokens' class='control-label'>Ende</label> <input type='text' class='form-control' id='sexpires' name='sexpires' readonly> <form id='tokenForm' action='pluginhelper?sa=printAction&surveyId=$surveyId'> <input type='text' class='form-control' id='stokencount' name='stokencount' placeholder='Anzahl'> <input type='submit' id='stokenButton' class='btn btn-primary'>Create Tokens</button> </form>"; } if( isset($_POST['button']) ) { $content = "ELSE TEST"; } return $content; }
public function pTsCreate($surveyId) { if (!Permission::model()->hasSurveyPermission($surveyId, 'tokens', 'read')) { throw new CHttpException(403, gT("You do not have permission to access this page.")); } $surveyId = (int) $surveyId; $stokencount = $_GET["stokencount"]; for ($i = 0; $i < $stokencount; $i++) { $oToken = Token::create($surveyId); $oToken->setAttributes(Yii::app()->getRequest()->getParam('tokenattribute')); //$resultToken = $oToken->save(); $oToken->generateToken(); $oToken->save(); } return "It works: $surveyId $stokencount $oToken->token"; }
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
No : it's not an issueThat looks pretty good - I got it work to create individual qr codes with token and save it temporary on the server and put 5 codes per page (with a "for"-function). Unfortunately "NewDirectRequest" does not work - I open a bug report...
400: Falsche Anfrage Der CSRF-Token konnte nicht verifiziert werden.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
$dateFrom = Yii::app()->getController()->widget('ext.DateTimePickerWidget.DateTimePicker', [ 'name' => 'validfrom', 'value' => $validfrom ?? '', 'pluginOptions' => [ 'format' => "DD.MM.YYYY HH:mm", 'allowInputToggle' => true, 'showClear' => true, 'locale' => 'de' ] ]);
Please Log in to join the conversation.
Please Log in to join the conversation.