|
|
@@ -208,7 +208,14 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
|
|
|
}
|
|
|
return parent::serviceGetParticipatingProfiles($iProfileId);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ public function serviceGetSafeServices()
|
|
|
+ {
|
|
|
+ return array_merge(parent::serviceGetSafeServices(), [
|
|
|
+ 'GetQuestionnaire' => '',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Check if this module entry can be used as profile
|
|
|
*/
|
|
|
@@ -1146,80 +1153,31 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
|
|
|
{
|
|
|
$CNF = &$this->_oConfig->CNF;
|
|
|
|
|
|
- $aContentProfileInfo = BxDolProfileQuery::getInstance()->getInfoById($iContentProfileId);
|
|
|
- if(empty($aContentProfileInfo) || !is_array($aContentProfileInfo))
|
|
|
- return ['code' => 1];
|
|
|
-
|
|
|
- $aForm = [
|
|
|
- 'form_attrs' => [
|
|
|
- 'id' => $this->getName() . '_questionnaire',
|
|
|
- 'action' => BX_DOL_URL_ROOT . bx_append_url_params($this->_oConfig->getBaseUri() . 'get_questionnaire', [
|
|
|
- 's' => $sSource,
|
|
|
- 'o' => $sObject,
|
|
|
- 'a' => $sAction,
|
|
|
- 'cpi' => $iContentProfileId
|
|
|
- ])
|
|
|
- ],
|
|
|
- 'params' => [
|
|
|
- 'db' => [
|
|
|
- 'table' => $CNF['TABLE_ANSWERS'],
|
|
|
- 'key' => '',
|
|
|
- 'uri' => '',
|
|
|
- 'uri_title' => '',
|
|
|
- 'submit_name' => 'do_submit'
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'inputs' => []
|
|
|
- ];
|
|
|
-
|
|
|
- $aQuestions = $this->_oDb->getQuestions(['sample' => 'content_id', 'content_id' => $aContentProfileInfo['content_id']]);
|
|
|
- if(empty($aQuestions) || !is_array($aQuestions))
|
|
|
+ $aContentInfo = $this->_oDb->getContentInfoByProfileId($iContentProfileId);
|
|
|
+ if(empty($aContentInfo) || !is_array($aContentInfo))
|
|
|
return ['code' => 1];
|
|
|
+
|
|
|
+ $oForm = null;
|
|
|
+ if(($oConnection = BxDolConnection::getObjectInstance($sObject)) !== false) {
|
|
|
+ $oForm = $oConnection->getQuestionnaireForm($sAction, $iContentProfileId, ['request' => [
|
|
|
+ 's' => $sSource,
|
|
|
+ ]]);
|
|
|
|
|
|
- foreach($aQuestions as $aQuestion) {
|
|
|
- $aForm['inputs'][] = [
|
|
|
- 'type' => 'text',
|
|
|
- 'name' => 'question_' . $aQuestion['id'],
|
|
|
- 'caption' => $aQuestion['question'],
|
|
|
- 'value' => '',
|
|
|
- 'required' => '1',
|
|
|
- 'checker' => [
|
|
|
- 'func' => 'Avail',
|
|
|
- 'params' => [],
|
|
|
- 'error' => _t($CNF['T']['form_qnr_field_qn_err']),
|
|
|
- ],
|
|
|
- 'db' => [
|
|
|
- 'pass' => 'Xss',
|
|
|
- ],
|
|
|
- ];
|
|
|
+ if($oForm === false)
|
|
|
+ return ['code' => 3];
|
|
|
}
|
|
|
-
|
|
|
- $aForm['inputs']['controls'] = [
|
|
|
- 'name' => 'controls',
|
|
|
- 'type' => 'input_set', [
|
|
|
- 'type' => 'submit',
|
|
|
- 'name' => 'do_submit',
|
|
|
- 'value' => _t('_Submit'),
|
|
|
- ], [
|
|
|
- 'type' => 'reset',
|
|
|
- 'name' => 'close',
|
|
|
- 'value' => _t('_Cancel'),
|
|
|
- 'attrs' => [
|
|
|
- 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
|
|
|
- 'class' => 'bx-def-margin-sec-left',
|
|
|
- ],
|
|
|
- ]
|
|
|
- ];
|
|
|
-
|
|
|
- $oForm = new BxTemplFormView($aForm);
|
|
|
+ else
|
|
|
+ return ['code' => 2];
|
|
|
+
|
|
|
$oForm->initChecker();
|
|
|
if($oForm->isSubmittedAndValid()) {
|
|
|
$iProfileId = bx_get_logged_profile_id();
|
|
|
|
|
|
+ $aQuestions = $this->_oDb->getQuestions(['sample' => 'content_pid', 'content_pid' => $iContentProfileId]);
|
|
|
foreach($aQuestions as $aQuestion)
|
|
|
$this->_oDb->insertAnswer((int)$aQuestion['id'], $iProfileId, $oForm->getCleanValue('question_' . $aQuestion['id']));
|
|
|
|
|
|
- return ['code' => 0, 'o' => $sObject, 'a' => $sAction, 'cpi' => $iContentProfileId, 'ci' => $aContentProfileInfo['content_id'], 'eval' => $this->_oConfig->getJsObject($sSource) . '.connActionPerformed(oData)'];
|
|
|
+ return ['code' => 0, 'o' => $sObject, 'a' => $sAction, 'cpi' => $iContentProfileId, 'ci' => $aContentInfo[$CNF['FIELD_ID']], 'eval' => $this->_oConfig->getJsObject($sSource) . '.connActionPerformed(oData)'];
|
|
|
}
|
|
|
|
|
|
bx_import('BxTemplFunctions');
|