static function checkMediaInUse($params) { $warning = $params['subject']; $sql = rex_sql::factory(); $sql->setQuery('SELECT `table_name`, `type_name`, `name` FROM `' . rex_yform_manager_field::table() . '` WHERE `type_id`="value" AND `type_name` IN("be_medialist","be_mediapool","mediafile")'); $rows = $sql->getRows(); if ($rows == 0) { return $warning; } $where = array(); $filename = addslashes($params['filename']); while ($sql->hasNext()) { $table = $sql->getValue('table_name'); switch ($sql->getValue('type_name')) { case 'be_mediapool': case 'mediafile': $where[$table][] = $sql->getValue('name') . '="' . $filename . '"'; break; case 'be_medialist': $where[$table][] = 'FIND_IN_SET("' . $filename . '", ' . $sql->getValue('name') . ')'; break; default: trigger_error('Unexpected fieldtype "' . $sql->getValue('type_name') . '"!', E_USER_ERROR); } $sql->next(); } $tupel = ''; foreach ($where as $table => $cond) { $sql->setQuery('SELECT id FROM ' . $table . ' WHERE ' . implode(' OR ', $cond)); while ($sql->hasNext()) { $sql_tupel = rex_sql::factory(); $sql_tupel->setQuery('SELECT name FROM `' . rex_yform_manager_table::table() . '` WHERE `table_name`="' . $table . '"'); $tupel .= '<li><a href="javascript:openPage(\'index.php?page=yform/manager/data_edit&table_name=' . $table . '&data_id=' . $sql->getValue('id') . '&func=edit\')">' . $sql_tupel->getValue('name') . ' [id=' . $sql->getValue('id') . ']</a></li>'; $sql->next(); } } if ($tupel != '') { $warning[] = 'Tabelle<br /><ul>' . $tupel . '</ul>'; } return $warning; }
}, '', rex_i18n::msg('yform_manager_table_exists'))); $yform->setActionField('wrapper_value', array('table_name', '###value###')); // Tablename $yform->setActionField('db', array(rex_yform_manager_table::table())); } $yform->setValueField('text', array('name', rex_i18n::msg('yform_manager_name'))); $yform->setValidateField('empty', array('name', rex_i18n::msg('yform_manager_table_enter_name'))); $yform->setValueField('textarea', array('description', rex_i18n::msg('yform_manager_table_description'), 'css_class' => "short1")); $yform->setValueField('checkbox', array('status', rex_i18n::msg('yform_tbl_active'))); // $yform->setValueField("fieldset",array("fs-list","Liste")); $yform->setValueField('text', array('list_amount', rex_i18n::msg('yform_manager_entries_per_page'), '50')); $yform->setValidateField('type', array('list_amount', 'int', rex_i18n::msg('yform_manager_enter_number'))); $sortFields = array('id'); if ($func === 'edit') { $sortFieldsSql = rex_sql::factory(); $sortFieldsSql->setQuery('SELECT f.name FROM `' . rex_yform_manager_field::table() . '` f LEFT JOIN `' . rex_yform_manager_table::table() . '` t ON f.table_name = t.table_name WHERE t.id = ' . (int) $table_id . ' ORDER BY f.prio'); while ($sortFieldsSql->hasNext()) { $sortFields[] = $sortFieldsSql->getValue('name'); $sortFieldsSql->next(); } } $yform->setValueField('select', array('list_sortfield', rex_i18n::msg('yform_manager_sortfield'), implode(',', $sortFields))); $yform->setValueField('select', array('list_sortorder', rex_i18n::msg('yform_manager_sortorder'), array('ASC' => rex_i18n::msg('yform_manager_sortorder_asc'), 'DESC' => rex_i18n::msg('yform_manager_sortorder_desc')))); $yform->setValueField('checkbox', array('search', rex_i18n::msg('yform_manager_search_active'))); $yform->setValueField('checkbox', array('hidden', rex_i18n::msg('yform_manager_table_hide'))); $yform->setValueField('checkbox', array('export', rex_i18n::msg('yform_manager_table_allow_export'))); $yform->setValueField('checkbox', array('import', rex_i18n::msg('yform_manager_table_allow_import'))); $form = $yform->getForm(); if ($yform->objparams['form_show']) { if ($func == 'edit') { $title = rex_i18n::msg('yform_manager_edit_table');
public function getMaximumPrio() { $sql = 'select max(prio) as prio from ' . rex_yform_manager_field::table() . ' where table_name="' . $this->getTableName() . '"'; $gf = rex_sql::factory(); if (self::$debug) { $gf->setDebug(); } $gf->setQuery($sql); return $gf->getValue('prio'); }
static function createMissingFieldColumns($field) { $columns = array(); foreach (rex_sql::showColumns(rex_yform_manager_field::table()) as $column) { $columns[$column['name']] = true; } $alterTable = array(); foreach ($field as $column => $value) { if (!isset($columns[$column])) { $alterTable[] = 'ADD `' . mysql_real_escape_string($column) . '` TEXT NOT NULL'; } $columns[$column] = true; } if (count($alterTable)) { $alter = rex_sql::factory(); $alter->debugsql = self::$debug; $alter->setQuery('ALTER TABLE `' . rex_yform_manager_field::table() . '` ' . implode(',', $alterTable)); } }