Skip to content

Commit

Permalink
More constructs for PHP 5.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 19, 2023
1 parent 278c12e commit 1919889
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
15 changes: 9 additions & 6 deletions editor/upload.php
Expand Up @@ -259,20 +259,23 @@ function update_oai($data){
$user_type = '';
//get access status
$sql = "select access_to_whom from {$xerte_toolkits_site->database_table_prefix}templatedetails where template_id=?";
$status = db_query_one($sql, array($_POST['template_id']))["access_to_whom"];
$rec = db_query_one($sql, array($_POST['template_id']));
$status = $rec["access_to_whom"];

if ($oaiPmhAgree !== "") {
$sql = "select status from {$xerte_toolkits_site->database_table_prefix}oai_publish where template_id=? ORDER BY audith_id DESC LIMIT 1";
$params = array($_POST['template_id']);
$last_oaiTable_status = db_query_one($sql, $params)["status"];
$rec = db_query_one($sql, $params);
$last_oaiTable_status = $rec["status"];

//find user type
if (is_user_admin()){
$user_type = "admin";
} else {
$sql = "select role from {$xerte_toolkits_site->database_table_prefix}templaterights where template_id=? AND user_id=?";
$params = array($_POST['template_id'], $_SESSION['toolkits_logon_id']);
$user_type = db_query_one($sql, $params)["role"];
$rec = db_query_one($sql, $params);
$user_type = $rec["role"];
}

$query = "insert into {$xerte_toolkits_site->database_table_prefix}oai_publish set template_id=?, login_id=?, user_type=?, status=?";
Expand All @@ -281,17 +284,17 @@ function update_oai($data){
if ($oaiPmhAgree == 'true' and $category !== "" and $level !== "" and $status === "Public") {
//add new row to oai_published to indicate current oai-pmh status
if (is_null($last_oaiTable_status) || $last_oaiTable_status != "published") {
db_query_one($query, array_merge($params, ["published"]));
db_query_one($query, array_merge($params, array("published")));
}
} elseif ($oaiPmhAgree == 'true' and ($category == "" or $level == "") and $status === "Public") {
//if the project has never been oai published we don't add it here
if ($last_oaiTable_status != "incomplete" AND !is_null($last_oaiTable_status)){
db_query_one($query, array_merge($params, ["incomplete"]));
db_query_one($query, array_merge($params, array("incomplete")));
}
} else {
//if the project has never been oai published we don't add it here
if ($last_oaiTable_status != "deleted" AND !is_null($last_oaiTable_status)){
db_query_one($query, array_merge($params, ["deleted"]));
db_query_one($query, array_merge($params, array("deleted")));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions modules/site/edithtml.php
Expand Up @@ -33,7 +33,7 @@ function get_children ($parent_id, $lookup, $column, $type) {
return $children;
}
foreach ($lookup[$parent_id]['children'] as $node) {
$children[] = [name => $node[$column], value => $node[$column], children => get_children($node[$type], $lookup, $column, $type)];
$children[] = array(name => $node[$column], value => $node[$column], children => get_children($node[$type], $lookup, $column, $type));
}
return $children;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$lookup = array();
foreach ($categories as $node){
$node['children'] = array();
$lookup = $lookup + [$node['category_id'] => $node];
$lookup = $lookup + array($node['category_id'] => $node);
}
foreach ($lookup as $node){
if ($node['parent_id'] != null){
Expand All @@ -191,7 +191,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
//find all tree origins
if ($value['parent_id'] == null) {
//add node and all its children recursively
$node = ['name' => $value['category_name'], 'value' => $value['category_name'], 'children' => get_children($value['category_id'], $lookup, 'category_name', 'category_id')];
$node = array('name' => $value['category_name'], 'value' => $value['category_name'], 'children' => get_children($value['category_id'], $lookup, 'category_name', 'category_id'));
$parsed_categories[] = $node;
}
}
Expand All @@ -205,7 +205,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$lookup = array();
foreach ($educationlevels as $node){
$node['children'] = array();
$lookup = $lookup + [$node['educationlevel_id'] => $node];
$lookup = $lookup + array($node['educationlevel_id'] => $node);
}
foreach ($lookup as $node){
if ($node['parent_id'] != null){
Expand All @@ -218,7 +218,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
//find all tree origins
if ($value['parent_id'] == null) {
//add node and all its children recursively
$node = ['name' => $value['educationlevel_name'], 'value' => $value['educationlevel_name'], 'children' => get_children($value['educationlevel_id'], $lookup, 'educationlevel_name', 'educationlevel_id')];
$node = array('name' => $value['educationlevel_name'], 'value' => $value['educationlevel_name'], 'children' => get_children($value['educationlevel_id'], $lookup, 'educationlevel_name', 'educationlevel_id'));
$parsed_educationlevels[] = $node;
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/xerte/edithtml.php
Expand Up @@ -34,7 +34,7 @@ function get_children ($parent_id, $lookup, $column, $type) {
return $children;
}
foreach ($lookup[$parent_id]['children'] as $node) {
$children[] = [name => $node[$column], value => $node[$column], children => get_children($node[$type], $lookup, $column, $type)];
$children[] = array(name => $node[$column], value => $node[$column], children => get_children($node[$type], $lookup, $column, $type));
}
return $children;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$lookup = array();
foreach ($categories as $node){
$node['children'] = array();
$lookup = $lookup + [$node['category_id'] => $node];
$lookup = $lookup + array($node['category_id'] => $node);
}
foreach ($lookup as $node){
if ($node['parent_id'] != null){
Expand All @@ -214,7 +214,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
//find all tree origins
if ($value['parent_id'] == null) {
//add node and all its children recursively
$node = ['name' => $value['category_name'], 'value' => $value['category_name'], 'children' => get_children($value['category_id'], $lookup, 'category_name', 'category_id')];
$node = array('name' => $value['category_name'], 'value' => $value['category_name'], 'children' => get_children($value['category_id'], $lookup, 'category_name', 'category_id'));
$parsed_categories[] = $node;
}
}
Expand Down

0 comments on commit 1919889

Please sign in to comment.