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

More
3 years 6 days ago #120525 by mcalvoca
mcalvoca created the topic: launch a mysql query from __contructor() of a new plugin
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.')'
);
}
}

Please Log in or Create an account to join the conversation.

More
3 years 6 days ago #120530 by mcalvoca
mcalvoca replied the topic: launch a mysql query from __contructor() of a new plugin
ok find the solution overwriting getPluginSettings($getValues) method, thanks

thanks

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!