Commit ce88de35 authored by Romain Loth's avatar Romain Loth

fix print_scholar_directory when scholar has no keywords

parent 245218c3
......@@ -4,6 +4,16 @@
* Common utility functions
*/
// canonical person name label
function name_string($title, $first_name, $mid_name, $last_name) {
$mid_initial = (strlen($mid_name) ? substr($mid_name,0,1)."." : "");
return implode(' ', array_filter(
array($title, $first_name, $mid_initial, $last_name)
));
}
function clean_exp($string) {
// enlève les comma trainantes
if (strcmp(substr(trim($string),-1),',')==0){
......
......@@ -355,11 +355,14 @@ $insts_ids = array_unique($insts_ids);
// all institutions with infos to retrieve
$institutions = array();
$ids_str = implode(',', $insts_ids);
$sql = "SELECT * FROM orgs WHERE orgid IN (" . $ids_str. ") ORDER BY label";
foreach ($base->query($sql) as $row) {
if (count($insts_ids)) {
$ids_str = implode(',', $insts_ids);
$sql = "SELECT * FROM orgs WHERE orgid IN (" . $ids_str. ") ORDER BY label";
foreach ($base->query($sql) as $row) {
if ($row['name'] == "_NULL") continue ;
$info = array();
......@@ -384,8 +387,10 @@ foreach ($base->query($sql) as $row) {
}
$institutions[$row['orgid']] = $info;
}
}
// debug
// $content .= var_dump($institutions) ;
......
......@@ -9,12 +9,14 @@
// to autoselect current whoswho filters
// NB: uses global value $data
$auto_popfilters_snippet = '<script type="text/javascript">' ;
foreach ($data as $filter => $array_vals) {
if (isset($data) && $data) {
foreach ($data as $filter => $array_vals) {
foreach ($array_vals as $val) {
$auto_popfilters_snippet .= '
whoswho.popfilter("'.$filter.'", {"prefill":"'.$val.'"});
';
}
}
}
$auto_popfilters_snippet .= '</script>';
......
......@@ -14,6 +14,10 @@ $meta = $html_head_inner;
$userid = $_GET['query'];
// get param for current user (allows customize user menus w/o looking at cookie)
$logged = $_GET['u'];
// $base = new PDO("sqlite:" . $dbname);
$base = new PDO($dsn, $user, $pass, $opt);
......@@ -70,7 +74,6 @@ if ($userid) {
FROM (
SELECT
scholars_and_labs.*,
-- GROUP_CONCAT(insts.orgid SEPARATOR ',') AS insts_ids,
GROUP_CONCAT(insts.label SEPARATOR '%%%') AS insts_list
FROM (
......@@ -99,7 +102,6 @@ if ($userid) {
GROUP BY luid
) AS scholars_and_orgs
-- expansion (+kw info)
LEFT JOIN sch_kw AS second_level
ON second_level.uid = scholars_and_orgs.luid
JOIN sch_kw ON sch_kw.kwid = second_level.kwid
......@@ -113,6 +115,10 @@ if ($userid) {
HERE_QUERY;
// print_r('=== print_scholar_directory query ===<br>');
// print_r($sql);
foreach ($base->query($sql) as $row) {
$info = array();
$info['unique_id'] = $row['luid'];
......@@ -197,16 +203,29 @@ HERE_QUERY;
}
}
// we keep the query-ed user's details
$target_name_elements = array(
// if no keywords matched, the previous select is empty
if (count($scholars)==0){
$sqlsingle = "SELECT hon_title, first_name, middle_name, last_name FROM scholars WHERE luid =".$userid ;
$target_name = "";
foreach ($base->query($sqlsingle) as $row) {
$target_name = name_string(
$row['hon_title'],
$row['first_name'],
$row['middle_name'],
$row['last_name']
);
}
}
// otherwise we keep the query-ed user's details
else {
$target_name = name_string(
$scholars[$userid]['title'],
$scholars[$userid]['first_name'],
$scholars[$userid]['mid_initial'],
$scholars[$userid]['last_name']
);
$target_name = implode(' ', array_filter($target_name_elements) );
);
}
// both our stats have been filled
// var_dump($lab_counts) ;
......@@ -275,7 +294,7 @@ Contributions and ideas are welcome to improve this directory.
if (count($scholars)==0){
// TODO message in modal panel
echo '<h2>Sorry, '.$target_name.' did not mention any keywords ... we cannot process its network.</h2><br/>
echo '<h2>Sorry, '.$target_name.' did not mention any keywords ... we cannot process the network.</h2><br/>
If you are '.$target_name.', you can <a href="/services/user/profile" target="_BLANK">modify your profile</a> and see your
network in few minutes.';
}else{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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