Commit 5f9c2b85 by pupi1985

Add default value for permit field in userfields initialization

parent 5f5f36a6
...@@ -716,18 +716,42 @@ function qa_db_create_table_sql($rawname, $definition) ...@@ -716,18 +716,42 @@ function qa_db_create_table_sql($rawname, $definition)
*/ */
function qa_db_default_userfields_sql() function qa_db_default_userfields_sql()
{ {
$oldprofileflags = array( require_once QA_INCLUDE_DIR . 'app/options.php';
'name' => 0,
'location' => 0, $profileFields = array(
'website' => QA_FIELD_FLAGS_LINK_URL, array(
'about' => QA_FIELD_FLAGS_MULTI_LINE, 'title' => 'name',
'position' => 0,
'flags' => 0,
'permit' => QA_PERMIT_ALL,
),
array(
'title' => 'location',
'position' => 1,
'flags' => 0,
'permit' => QA_PERMIT_ALL,
),
array(
'title' => 'website',
'position' => 2,
'flags' => QA_FIELD_FLAGS_LINK_URL,
'permit' => QA_PERMIT_ALL,
),
array(
'title' => 'about',
'position' => 3,
'flags' => QA_FIELD_FLAGS_MULTI_LINE,
'permit' => QA_PERMIT_ALL,
),
); );
$sql = 'INSERT INTO ^userfields (title, position, flags) VALUES '; // content column will be NULL, meaning use default from lang files $sql = 'INSERT INTO ^userfields (title, position, flags, permit) VALUES'; // content column will be NULL, meaning use default from lang files
foreach ($profileFields as $field) {
$sql .= sprintf('("%s", %d, %d, %d), ', qa_db_escape_string($field['title']), $field['position'], $field['flags'], $field['permit']);
}
$index = 0; $sql = substr($sql, 0, -2);
foreach ($oldprofileflags as $title => $flags)
$sql .= ($index ? ', ' : '') . "('" . qa_db_escape_string($title) . "', " . (++$index) . ", " . (int)@$oldprofileflags[$title] . ")";
return $sql; return $sql;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment