YaWK  24.1
Yet another WebKit
YAWK\settings Class Reference

Settings class: get and set YaWK system settings. More...

Static Public Member Functions

static getAllSettingsArray ($db, $property)
 Returns an array with all setings where property is like $property. More...
 
static getAllSettingsIntoArray ($db)
 Returns an array with all settings data. More...
 
static getCurrentLanguageFormElements ($lang)
 override the current language More...
 
static getEditorSettings ($db, $typeID=0)
 Returns an associative array containing the editor settings. More...
 
static getFormElements ($db, $settings, $type, $lang)
 Return corresponding form elements for given settings. More...
 
static getLongSetting ($db, $property)
 Get and return longValue for property from settings database. More...
 
static getSetting ($db, $property)
 Get and return value for property from settings database. More...
 
static getSettingDescription ($db, $property)
 Get setting description from requested property. More...
 
static getSettingsByType ($db, $typeID)
 get all settings by typeID More...
 
static getValueSettingsArray ($db, $property)
 Returns an array containing property as key and values corresponding to this property where p like $property%. More...
 
static getWidgetSetting ($db, $property)
 Get widget setting value from widgets_settings. More...
 
static setLongSetting ($db, $property, $value)
 Set (update) long setting value for property. More...
 
static setSetting ($db, $property, $value, $lang)
 Set value for property into settings database. More...
 
static setTemplateSetting ($db, $property, $value)
 Set (update) template setting value for property. More...
 
static setWidgetSetting ($db, $property, $value, $widgetID)
 Set widget setting value into widgets_settings. More...
 
static toggleOffline ($db, $property, $new_status, $lang)
 Toggle setting offline where requested property. More...
 

Detailed Description

Settings class: get and set YaWK system settings.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 8 of file settings.php.

Member Function Documentation

◆ getAllSettingsArray()

static YAWK\settings::getAllSettingsArray (   $db,
  $property 
)
static

Returns an array with all setings where property is like $property.

Parameters
object$dbDatabase Object
string$property
Returns
mixed

Definition at line 16 of file settings.php.

17  {
18  /* @param $db \YAWK\db */
19  if ($res= $db->query("SELECT * FROM {settings} WHERE property LIKE '".$property."%'")) {
20  $settingsArray = array();
21  while ($row = $res->fetch_assoc())
22  { // fill array
23  $settingsArray[$row['property']] = $row;
24  }
25  }
26  else
27  { // q failed, throw error
28  \YAWK\sys::setSyslog($db, 35, 1, "failed to get settings from database ", 0, 0, 0, 0);
29  \YAWK\alert::draw("warning", "Warning!", "Fetch database error: getSettingsArray failed.","","4800");
30  return false;
31  }
32  return $settingsArray;
33  }
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30

References $db, $res, and YAWK\alert\draw().

◆ getAllSettingsIntoArray()

static YAWK\settings::getAllSettingsIntoArray (   $db)
static

Returns an array with all settings data.

Parameters
object$dbDatabase Object
Returns
array|bool

Definition at line 441 of file settings.php.

442  {
443  /* @param $db \YAWK\db */
444  if ($res= $db->query("SELECT * FROM {settings} ORDER by sortation"))
445  {
446  $settingsArray = array();
447  while ($row = $res->fetch_assoc())
448  { // fill array
449  $settingsArray[] = $row;
450  }
451  }
452  else
453  { // q failed, throw error
454  \YAWK\sys::setSyslog($db, 35, 1, "failed to get settings from database ", 0, 0, 0, 0);
455  // \YAWK\alert::draw("warning", "Warning!", "Fetch database error: getSettingsArray failed.","","4800");
456  return false;
457  }
458  return $settingsArray;
459  }

References $db, and $res.

Referenced by YAWK\settings\getFormElements().

◆ getCurrentLanguageFormElements()

static YAWK\settings::getCurrentLanguageFormElements (   $lang)
static

override the current language

Parameters
array$langlanguage array

Definition at line 334 of file settings.php.

335  {
336  echo "<h2>Language <small>override the selected language</small></h2>";
337  $i = 0;
338  foreach ($lang as $property=>$tag)
339  {
340  $i++;
341  echo "<label for=\"$property\">$property</label>
342  <input type=\"text\" id=\"$property\" class=\"form-control\" name=\"$property\" value=\"$tag\"><br>";
343  }
344  echo "Total: ".$i." language tags found.";
345  }
print $lang['SAVE_SETTINGS']
Definition: settings.php:292
$i

References $i, and $lang.

◆ getEditorSettings()

static YAWK\settings::getEditorSettings (   $db,
  $typeID = 0 
)
static

Returns an associative array containing the editor settings.

Parameters
object$dbDatabase object
int$typeIDThe ID of settings type to get.
Returns
array|bool

Definition at line 377 of file settings.php.

378  { /* @param $db \YAWK\db */
379  // check if type is set, if not, try to fetch it
380  if (!isset($typeID) || ($typeID == 0))
381  { // if type is not set, try to query db to get the ID of editor settings
382  if ($res = $db->query("SELECT id FROM {settings_types} WHERE value = 'editor'"))
383  { // fetch data
384  if ($row = mysqli_fetch_row($res))
385  {
386  $typeID = $row[0];
387  }
388  }
389  else
390  { // no type was set, try to fetch editor type failed.
391  \YAWK\sys::setSyslog($db, 35, 1, "failed to get editor settings from database ", 0, 0, 0, 0);
392  \YAWK\alert::draw("danger", "Could not fetch editor settings.", "Settings type not set. Tried to fetch, but it seems that there is no setting type called editor.", "", 6500);
393  }
394  }
395  // ok, now we got the type, lets go: fetch editor settings
396  if ($res = $db->query("SELECT * FROM {settings} WHERE type = $typeID"))
397  { // build an array
398  $editorSettingsArray = array();
399  while ($row = $res->fetch_assoc())
400  { // fill it with settings
401  if ($row['property'] === "editorLineNumbers") {
402  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
403  }
404  if ($row['property'] === "editorSmartIndent") {
405  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
406  }
407  if ($row['property'] === "editorActiveLine") {
408  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
409  }
410  if ($row['property'] === "editorCloseBrackets") {
411  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
412  }
413  if ($row['property'] === "editorCloseTags") {
414  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
415  }
416  if ($row['property'] === "editorMatchBrackets") {
417  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
418  }
419  if ($row['property'] === "editorMatchTags") {
420  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
421  }
422  if ($row['property'] === "editorAutoCodeview") {
423  if ($row['value'] == "1") { $row['value'] = "true"; } else { $row['value'] = "false"; }
424  }
425  $editorSettingsArray[$row['property']] = $row['value'];
426  }
427  }
428  else
429  { // query failed...
430  return false;
431  }
432  return $editorSettingsArray;
433  }

References $db, $res, and YAWK\alert\draw().

Referenced by YAWK\editor\getEditor().

◆ getFormElements()

static YAWK\settings::getFormElements (   $db,
  $settings,
  $type,
  $lang 
)
static

Return corresponding form elements for given settings.

Parameters
object$dbDatabase Object
array$settingsSettings: property|value|type|sortation|activated|label|icon|heading|subtext|fieldClass|fieldType|placeholder|description|options
int$type

Definition at line 66 of file settings.php.

67  { // loop trough array
68  $i_settings = 0;
69  if(!isset($settings) || (empty($settings)) || (!is_array($settings)))
70  { // if settings are not set, try to get them...
72  }
73  if(!isset($type) && (empty($type)))
74  { // if param 'type' is missing, show all settings
75  $type = 1;
76  }
77  // loop trough settings array
78  foreach ($settings as $setting)
79  { // field type not set or empty
80  if (!isset($setting['fieldType']) && (empty($fieldType)))
81  { // set input field as common default
82  $setting['fieldType'] = "input";
83  }
84  else
85  { // settings type must be equal to param $type
86  // equals settings category
87  if ($setting['type'] === "$type" && ($setting['activated'] === "1"))
88  {
89  // check if ICON is set
90  // if an icon is set, it will be drawn before the heading, to the left.
91  if (isset($setting['icon']) && (!empty($setting['icon'])))
92  { // fill it w icon
93  $setting['icon'] = "<i class=\"$setting[icon]\"></i>";
94  }
95  else
96  { // leave empty - no icon available
97  $setting['icon'] = '';
98  }
99 
100  // check if LABEL is set
101  // The label sits directly above, relative to the setting form element
102  if (isset($setting['label']) && (!empty($setting['label'])))
103  { // if its set, put it into $lang array for L11n
104  $setting['label'] = $lang[$setting['label']];
105  }
106  else
107  { // otherwise throw error
108  $setting['label'] = 'sorry, there is not label set. meh!';
109  }
110 
111  // check if HEADING is set
112  // if set, a <H3>Heading</H3> will be shown above the setting
113  if (isset($setting['heading']) && (!empty($setting['heading'])))
114  { // L11n
115  $setting['heading'] = $lang[$setting['heading']];
116  }
117  else
118  { // leave empty - no heading for that setting
119  $setting['heading'] = '';
120  }
121 
122  // check if SUBTEXT is set
123  // this is shown in <small>tags</small> beneath the heading
124  if (isset($setting['subtext']) && (!empty($setting['subtext'])))
125  { // L11n
126  $setting['subtext'] = $lang[$setting['subtext']];
127  }
128  else
129  { // leave empty - no subtext beneath the heading
130  $setting['subtext'] = '';
131  }
132 
133  // check if description is set
134 
135  // check if description is set
136  // the description will be shown right beside the label
137  if (isset($setting['description']) && (!empty($setting['description'])))
138  { // L11n
139  $setting['description'] = $lang[$setting['description']];
140  $setting['description'] = "&nbsp;<small><i class=\"fa fa-question-circle-o text-info\" data-placement=\"auto right\" data-toggle=\"tooltip\" title=\"$setting[description]\"></i></small>";
141  }
142  else
143  { // leave empty - no description available
144  $setting['description'] = '';
145  }
146 
147  // check if readonly option is set
148  if ($setting['options'] === "readonly")
149  {
150  $readonly = " readonly";
151  $disabled = " disabled";
152  }
153  else
154  {
155  $readonly = '';
156  $disabled = '';
157  }
158 
159  // check if placeholder is set and not empty
160  if (isset($setting['placeholder']) && (!empty($setting['placeholder'])))
161  {
162  $ph = $setting['placeholder'];
163  $placeholder = $lang[$ph];
164  }
165  else
166  {
167  $placeholder = '';
168  }
169 
170  // CHECKBOX
171  if ($setting['fieldType'] === "checkbox")
172  { // build a checkbox
173  if ($setting['value'] === "1")
174  { // set checkbox to checked
175  $checked = "checked";
176  }
177  else
178  { // checkbox not checked
179  $checked = "";
180  }
181  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
182  {
183  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
184  }
185  echo "<input type=\"hidden\" name=\"$setting[property]\" value=\"0\">
186  <input type=\"checkbox\" id=\"$setting[property]\" name=\"$setting[property]\" value=\"1\" $checked>
187  <label style=\"margin-bottom:10px;\" for=\"$setting[property]\">&nbsp; $setting[label] $setting[description]</label><br>";
188  }
189 
190  /* RADIO BUTTTONS */
191  if ($setting['fieldType'] === "radio")
192  {
193  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
194  <input style=\"margin-bottom:10px;\" type=\"radio\" id=\"$setting[property]\" name=\"$setting[property]\">";
195  echo "<input type=\"radio\" value=\"$setting[value]\">$lang[SETTING_CURRENT] $setting[value]</option>";
196  // explode option string into array
197  $optionValues = explode(":", $setting['options']);
198  foreach ($optionValues as $value)
199  {
200  // extract value from option setting string
201  $optionValue = preg_replace("/,[a-zA-Z0-9]*/", "", $value);
202  // extract description from option setting
203  $optionDesc = preg_replace('/.*,(.*)/','$1',$value);
204 
205  echo "<option value=\"$optionValue\">$optionDesc</option>";
206  }
207  echo "</select>";
208  echo "<p>$setting[description]</p>";
209  }
210 
211  /* SELECT FIELD */
212  else if ($setting['fieldType'] === "select")
213  { // display icon, heading and subtext, if its set
214  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
215  {
216  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
217  }
218  // TEMPLATE SELECTOR
219  if ($setting['property'] === "selectedTemplate")
220  { // if property is selected template...
221  echo "<b>".$setting['label']." ".$setting['description']."</b>";
222  \YAWK\backend::drawTemplateSelectField($db, $setting['description']);
223  }
224  // GLOBALMENU ID SELECTOR
225  else if ($setting['property'] === "globalmenuid")
226  {
227  $currentMenu = \YAWK\menu::getMenuNameByID($db, $setting['value'], $lang);
228  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
229  <select style=\"margin-bottom:10px;\" name=\"$setting[property]\" class=\"form-control\" id=\"$setting[property]\">";
230  echo "<option value=\"$setting[value]\">$currentMenu</option>";
231  foreach (\YAWK\backend::getMenuNamesArray($db) as $property=>$row)
232  {
233  if ($row['id'] !== $setting['value']){
234  echo "<option value=\"$row[id]\">$row[name]</option>";
235  }
236 
237  }
238  echo "<option value=\"0\">$lang[NO_ENTRY]</option>";
239  echo "</select>";
240  }
241  else
242  { // begin draw select
243  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
244  <select style=\"margin-bottom:10px;\" class=\"form-control\" id=\"$setting[property]\" name=\"$setting[property]\">";
245  echo "<option value=\"$setting[value]\">$lang[SETTING_CURRENT] $setting[value]</option>";
246  // explode option string into array
247  $optionValues = explode(":", $setting['options']);
248  foreach ($optionValues as $value)
249  {
250  // extract value from option setting string
251  // $optionValue = preg_replace("/,[a-zA-Z0-9]*/", "", $value);
252  // extract description from option setting
253  $optionDesc = preg_replace('/.*,(.*)/','$1', $value);
254  $optionValue = preg_split("/,[a-zA-Z0-9]*/", $value);
255 
256  echo "<option value=\"$optionValue[0]\">$optionDesc</option>";
257  // echo "<option value=\"$optionValue[0]\">$optionDesc</option>";
258  // echo "<option value=\"$value\">$value</option>";
259  }
260  echo "</select>";
261  }
262  }
263 
264  /* TEXTAREA */
265  else if ($setting['fieldType'] === "textarea")
266  { // if a long value is set
267  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
268  {
269  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
270  }
271  $placeholder = $setting['placeholder']; // store placeholder from array in var to use it at language array
272  if (isset($setting['longValue']) && (!empty($setting['longValue'])))
273  { // build a longValue tagged textarea and fill with longValue
274  $setting['longValue'] = nl2br($setting['longValue']);
275  echo "<label for=\"$setting[property]-long\">$setting[label] $setting[description]</label>
276  <textarea style=\"margin-bottom:10px;\" cols=\"64\" rows=\"4\" placeholder=\"$placeholder\" class=\"$setting[fieldClass]\" id=\"$setting[property]-long\" name=\"$setting[property]-long\"$disabled>$setting[longValue]</textarea>";
277  }
278  else
279  { // draw default textarea
280  $placeholder = $setting['placeholder']; // store placeholder from array in var to use it at language array
281  $setting['value'] = nl2br($setting['value']);
282  echo "<label for=\"$setting[property]-long\">$setting[label] $setting[description]</label>
283  <textarea style=\"margin-bottom:10px;\" cols=\"64\" rows=\"4\" placeholder=\"$placeholder\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"$disabled>$setting[value]</textarea>";
284  }
285  }
286 
287  /* INPUT PASSWORD FIELD */
288  else if ($setting['fieldType'] === "password")
289  { // draw an input field
290  $placeholder = $setting['placeholder']; // store placeholder from array in var to use it at language array
291  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
292  {
293  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
294  }
295  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
296  <input style=\"margin-bottom:10px;\" type=\"password\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
297  value=\"$setting[value]\" placeholder=\"$placeholder\"$readonly$disabled>";
298  }
299 
300  /* INPUT TEXT FIELD */
301  else if ($setting['fieldType'] === "input")
302  { // draw an input field
303 
304  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
305  {
306  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
307  }
308  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
309  <input style=\"margin-bottom:10px;\" type=\"text\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
310  value=\"$setting[value]\" placeholder=\"$placeholder\"$readonly$disabled>";
311  }
312 
313  /* INPUT TEXT FIELD */
314  else if ($setting['fieldType'] === "color")
315  { // draw an input field
316  $placeholder = $setting['placeholder']; // store placeholder from array in var to use it at language array
317  if (!empty($setting['icon']) || (!empty($setting['heading']) || (!empty($setting['subtext']))))
318  {
319  echo "<h3>$setting[icon]&nbsp;$setting[heading]&nbsp;<small>$setting[subtext]</small></h3>";
320  }
321  echo "<label for=\"$setting[property]\">$setting[label] $setting[description]</label>
322  <input style=\"margin-bottom:10px;\" type=\"text\" class=\"$setting[fieldClass]\" id=\"$setting[property]\" name=\"$setting[property]\"
323  value=\"$setting[value]\">";
324  }
325  }
326  }
327  }
328  }
$i_settings
Definition: settings.php:415
$settings
Definition: settings.php:416
static drawTemplateSelectField($db, $description)
Draw a SELECT field with all templates, current active template is selected.
Definition: backend.php:213
static getMenuNamesArray($db)
return all menu ids and names as array
Definition: backend.php:465
static getMenuNameByID($db, $id)
get menu name for given id
Definition: menu.php:1047
static getAllSettingsIntoArray($db)
Returns an array with all settings data.
Definition: settings.php:441
$type
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
$value

References $db, $i_settings, $lang, $settings, $type, $value, YAWK\backend\drawTemplateSelectField(), YAWK\settings\getAllSettingsIntoArray(), YAWK\menu\getMenuNameByID(), and YAWK\backend\getMenuNamesArray().

◆ getLongSetting()

static YAWK\settings::getLongSetting (   $db,
  $property 
)
static

Get and return longValue for property from settings database.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyProperty to get longValue from database.
Returns
mixed

Definition at line 527 of file settings.php.

528  { /* @param $db \YAWK\db */
529  if ($res = $db->query("SELECT longValue FROM {settings} WHERE property = '".$property."'")) {
530  $row = mysqli_fetch_row($res);
531  $res->close();
532  return $row[0];
533  }
534  else
535  { // q failed, throw error
536  \YAWK\sys::setSyslog($db, 35, 1, "failed to get settings longValue from property <b>$property</b> ", 0, 0, 0, 0);
537  \YAWK\alert::draw("warning", "Warning!", "Fetch database error: getLongSetting failed.","","4800");
538  return false;
539  }
540  }

References $db, $res, and YAWK\alert\draw().

Referenced by YAWK\PLUGINS\SIGNUP\buildForm\getLegend(), and YAWK\sys\getRobotsText().

◆ getSetting()

static YAWK\settings::getSetting (   $db,
  $property 
)
static

Get and return value for property from settings database.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
object$langlanguage array
string$propertyProperty to select from database
Returns
bool

Definition at line 470 of file settings.php.

471  { /* @param $db \YAWK\db */
472  $sql = $db->query("SELECT value FROM {settings} WHERE property = '".$property."'");
473 
474  // fetch data from db
475  if ($row = mysqli_fetch_row($sql))
476  { // return settings of property
477  if (isset($row[0]) && (!empty($row[0])))
478  {
479  return $row[0];
480  }
481  else
482  {
483  return false;
484  }
485  }
486  else
487  { // q failed, throw error
488  return false;
489  }
490  }
$sql
Definition: message-new.php:32

References $db, and $sql.

Referenced by YAWK\BACKEND\AdminLTE\__construct(), YAWK\PLUGINS\MESSAGES\messages\__construct(), YAWK\menu\display(), YAWK\template\drawAssetsSelectFields(), YAWK\template\drawAssetsTitles(), YAWK\BACKEND\AdminLTE\drawHtmlEnd(), YAWK\BACKEND\AdminLTE\drawHtmlFooter(), YAWK\BACKEND\AdminLTE\drawHtmlLogo(), YAWK\backend\drawLoginBox(), YAWK\PLUGINS\USERPAGE\profile\drawProfile(), YAWK\WIDGETS\BOOKING\FORM\bookingWidget\drawThankYouMessage(), YAWK\update\fetchFiles(), YAWK\PLUGINS\SIGNUP\buildForm\getAdditionalFields(), YAWK\page\getContent(), YAWK\language\getCurrentLanguage(), YAWK\language\getCurrentLanguageStatic(), YAWK\sys\getDirPrefix(), YAWK\backend\getFX(), YAWK\sys\getHost(), YAWK\PLUGINS\SIGNUP\buildForm\getLayout(), YAWK\page\getMetaTagsArray(), YAWK\PLUGINS\USERPAGE\userpage\getRootPage(), YAWK\PLUGINS\SIGNUP\buildForm\getSubmitButton(), YAWK\template\getTemplateSettingsArray(), YAWK\PLUGINS\SIGNUP\buildForm\getTerms(), YAWK\PLUGINS\SIGNUP\buildForm\getTitle(), YAWK\template\getValidTemplateID(), YAWK\template\includeHeader(), YAWK\WIDGETS\BOOKING\FORM\bookingWidget\init(), YAWK\language\init(), YAWK\user\isTemplateEqual(), YAWK\template\loadProperties(), YAWK\user\sendResetEmail(), YAWK\stats\setStats(), and YAWK\PLUGINS\SIGNUP\signup\signUp().

◆ getSettingDescription()

static YAWK\settings::getSettingDescription (   $db,
  $property 
)
static

Get setting description from requested property.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyProperty to get description from.
Returns
bool

Definition at line 612 of file settings.php.

613  { /* @param $db \YAWK\db */
614  if ($res = $db->query("SELECT description FROM {settings} WHERE property = '".$property."'")) {
615  $row = mysqli_fetch_row($res);
616  return $row[0];
617  }
618  else
619  { // q failed, throw error
620  \YAWK\sys::setSyslog($db, 35, 1, "failed to set settings description of <b>$property</b> ", 0, 0, 0, 0);
621  \YAWK\alert::draw("warning", "Warning!", "Error loading setting description of property $property", "","4800");
622  return false;
623  }
624  }

References $db, $res, and YAWK\alert\draw().

◆ getSettingsByType()

static YAWK\settings::getSettingsByType (   $db,
  $typeID 
)
static

get all settings by typeID

Parameters
object$dbdatabase
int$typeIDsettings type to get settings for
Returns
array|bool returns an array with requested settings or false

Definition at line 353 of file settings.php.

354  { /* @param $db \YAWK\db */
355  if ($res = $db->query("SELECT * FROM {settings} WHERE type = $typeID"))
356  {
357  $settingsArray = array();
358  while ($row = $res->fetch_assoc())
359  { // fill array with settings by type
360  $settingsArray[] = $row;
361  }
362  }
363  else
364  { // query failed...
365  \YAWK\sys::setSyslog($db, 35, 1, "could not get settings for typeID $typeID ", 0, 0, 0, 0);
366  return false;
367  }
368  return $settingsArray;
369  }

References $db, and $res.

◆ getValueSettingsArray()

static YAWK\settings::getValueSettingsArray (   $db,
  $property 
)
static

Returns an array containing property as key and values corresponding to this property where p like $property%.

Parameters
object$dbDatabase Object
string$property
Returns
mixed

Definition at line 41 of file settings.php.

42  {
43  /* @param $db \YAWK\db */
44  if ($res= $db->query("SELECT property, value FROM {settings} WHERE property LIKE '".$property."%'")) {
45  $settingsArray = array();
46  while ($row = $res->fetch_assoc())
47  { // fill array
48  $settingsArray[$row['property']] = $row['value'];
49  }
50  }
51  else
52  { // q failed, throw error
53  \YAWK\sys::setSyslog($db, 35, 1, "failed to get settings from database ", 0, 0, 0, 0);
54  \YAWK\alert::draw("warning", "Warning!", "Fetch database error: getSettingsArray failed.","","4800");
55  return false;
56  }
57  return $settingsArray;
58  }

References $db, $res, and YAWK\alert\draw().

Referenced by YAWK\BACKEND\AdminLTE\drawHtmlNavbarWebmailMenu().

◆ getWidgetSetting()

static YAWK\settings::getWidgetSetting (   $db,
  $property 
)
static

Get widget setting value from widgets_settings.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyProperty to get value from.
Returns
bool

Definition at line 634 of file settings.php.

635  {
636  /* @param $db \YAWK\db */
637  if ($res = $db->query("SELECT value FROM {widget_settings}
638  WHERE property = '".$property."' AND widgetID = '".$widgetID."'")) {
639  $row = mysqli_fetch_row($res);
640  $res->close();
641  return $row[0];
642  }
643  else
644  { // q failed, throw error
645  \YAWK\sys::setSyslog($db, 35, 1, "failed to get widget setting of <b>$property</b> ", 0, 0, 0, 0);
646  \YAWK\alert::draw("warning", "Warning!", "Error loading Widget Setting $property","","4800");
647  return false;
648  }
649  }

References $db, $res, and YAWK\alert\draw().

◆ setLongSetting()

static YAWK\settings::setLongSetting (   $db,
  $property,
  $value 
)
static

Set (update) long setting value for property.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyProperty to set
string$valueLong value to set
Returns
bool

Definition at line 578 of file settings.php.

579  {
580  /* solution for redirect after db update
581  if (!empty($_SERVER['HTTP_REFERER'])){
582  $referer = $_SERVER['HTTP_REFERER'];
583  } else {
584  $referer = "index.php";
585  }
586  */
587  /* @param $db \YAWK\db */
588  $property = $db->quote($property);
589  $value = $db->quote($value);
590  if ($res = $db->query("UPDATE {settings} SET longValue = '".$value."' WHERE property = '".$property."'"))
591  { // success
592  // \YAWK\alert::draw("success", "Success!","Setting $property saved.","","120");
593  return true;
594  }
595  else
596  { // q failed, throw error
597  \YAWK\sys::setSyslog($db, 35, 1, "failed to set settings longValue <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
598  \YAWK\alert::draw("danger", "Error!", "Sorry, update database error: could not set LongValue: ".$value." - setLongSetting failed.", "","4800");
599  return false;
600  // echo \YAWK\backend::setTimeout($referer,"4800");
601  }
602  }

References $db, $res, $value, and YAWK\alert\draw().

◆ setSetting()

static YAWK\settings::setSetting (   $db,
  $property,
  $value,
  $lang 
)
static

Set value for property into settings database.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
object$dblanguage
string$propertyProperty to set into database
string$valueValue to set into database
Returns
bool

Definition at line 502 of file settings.php.

503  { /* @param $db \YAWK\db */
504  $property = $db->quote($property);
505  $value = $db->quote($value);
506  if ($res = $db->query("UPDATE {settings} SET value = '".$value."' WHERE property = '".$property."'")) {
507  // success
508  // \YAWK\alert::draw("success", "$lang[SUCCESS]","$lang[SETTING] $property $lang[SAVED]","","120");
509  return true;
510  }
511  else
512  { // q failed
513  \YAWK\sys::setSyslog($db, 35, 1, "failed to set <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
514  \YAWK\alert::draw("warning", "$lang[WARNING]", "$lang[SETTING] $property $lang[NOT_SAVED]", "","4800");
515  return false;
516  }
517  }

References $db, $res, $value, and YAWK\alert\draw().

Referenced by YAWK\update\fetchFiles(), YAWK\installer\step3(), YAWK\installer\step4(), and YAWK\installer\step5().

◆ setTemplateSetting()

static YAWK\settings::setTemplateSetting (   $db,
  $property,
  $value 
)
static

Set (update) template setting value for property.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyTemplate property to set
string$valueTemplate value to set
Returns
bool

Definition at line 551 of file settings.php.

552  {
553  /* @param $db \YAWK\db */
554  $property = $db->quote($property);
555  $value = $db->quote($value);
556  if ($res = $db->query("UPDATE {template_settings} SET value = '".$value."' WHERE property = '".$property."'"))
557  { // success
558  \YAWK\alert::draw("success", "Success!","Template setting $property saved.","","120");
559  return true;
560  }
561  else
562  { // q failed, throw error
563  \YAWK\sys::setSyslog($db, 35, 1, "failed to set templateSetting <b>$value</b> to <b>$property</b> ", 0, 0, 0, 0);
564  \YAWK\alert::draw("danger", "Error!", "Sorry, could not save template setting $property.","","4800");
565  return false;
566  }
567  }

References $db, $res, $value, and YAWK\alert\draw().

◆ setWidgetSetting()

static YAWK\settings::setWidgetSetting (   $db,
  $property,
  $value,
  $widgetID 
)
static

Set widget setting value into widgets_settings.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
string$propertyProperty to get value from.
string$valueValue of requested property
int$widgetIDWidgetID to get value from.
Returns
bool

Definition at line 661 of file settings.php.

662  {
663  /* @param $db \YAWK\db */
664  $property = $db->quote($property);
665  $value = $db->quote($value);
666  $value = nl2br($value);
667  $value = preg_replace('/<br (\s*)?\/?>/i', "", $value); // to make sure html code gets stored properly
668  if ($res = $db->query("UPDATE {widget_settings} SET value = '".$value."'
669  WHERE property = '".$property."' AND widgetID = '".$widgetID."'"))
670  { // q successful
671  // uncomment following line, if you wish detailed save messages
672  // \YAWK\alert::draw("success", "Success!", "Widget Setting $property saved.", "","1200");
673  return true;
674  }
675  else
676  {
677  // q failed
678  \YAWK\sys::setSyslog($db, 35, 1, "failed to set widget value <b>$value</b> of <b>$property</b> ", 0, 0, 0, 0);
679  \YAWK\alert::draw("danger", "Error!", "Sorry, update database error: could not set Widget Setting $value of property $property.", "","4800");
680  return false;
681  // echo \YAWK\backend::setTimeout($referer,"4800");
682  }
683  }

References $db, $res, $value, and YAWK\alert\draw().

◆ toggleOffline()

static YAWK\settings::toggleOffline (   $db,
  $property,
  $new_status,
  $lang 
)
static

Toggle setting offline where requested property.

Version
1.0.0
Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Parameters
object$dbDatabase object
object$langlanguage
string$propertyProperty to get value from.
string$new_status
Returns
bool

Definition at line 695 of file settings.php.

696  {
697  /* @param $db \YAWK\db */
698  $property = $db->quote($property);
699  $new_status = $db->quote($new_status);
700  if ($res = $db->query("UPDATE {settings} SET activated = '" . $new_status . "'
701  WHERE property = '" . $property . "'"))
702  { // success
703  return true;
704  }
705  else
706  { // q failed, throw error
707  \YAWK\sys::setSyslog($db, 35, 1, "failed to toggle <b>$new_status</b> of <b>$property</b> ", 0, 0, 0, 0);
708  \YAWK\alert::draw("danger", "Error!", "$lang[TOGGLE_FAILED] $property $lang[TO] $new_status", "","4800");
709  return false;
710  }
711  }

References $db, $res, and YAWK\alert\draw().


The documentation for this class was generated from the following file: