Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

launch a mysql query from __contructor() of a new plugin

  • mcalvoca
  • mcalvoca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #120525 by mcalvoca
Hello i am trying to set the settings array, i need to set one setting per language, it returns a 500 error.

any idea to launch mysql querys in contructor or something similar?

thanks


public function __construct(PluginManager $manager, $id)
{
parent::__construct($manager, $id);

# Here you should handle subscribing to the events your plugin will handle
$this->subscribe('newDirectRequest');
$this->subscribe('afterSurveyComplete');
$this->setSettings();
}

/**
* PRIVATE :: Obtener idiomas a partir de las preguntas
* USED BY :: setSettings()
*
* @return array
*/
private function getLangs() {
$sql = 'select distinct language from {{questions}}';
$result = \dbExecuteAssoc($sql);
return $result->readAll();
}

/**
* PRIVATE :: Generar los campos de configuración
* USED BY :: __construct()
*
* @return array
*/
private function setSettings() {
$languages = $this->getLangs();
foreach ($languages as $key => $value) {
$this->settings[$value."_titulo_1"] = array(
'type' => 'string'
, 'label' => 'Titulo 1 ('.$value.')'
);
$this->settings[$value."_titulo_2"] = array(
'type' => 'string'
, 'label' => 'Titulo 2 ('.$value.')'
);
$this->settings[$value."_texto"] = array(
'type' => 'string'
, 'label' => 'Texto ('.$value.')'
);
}
}
The topic has been locked.
  • mcalvoca
  • mcalvoca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #120530 by mcalvoca
ok find the solution overwriting getPluginSettings($getValues) method, thanks

thanks
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose