Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_research_requests()

Description

@var string JSON representation of custom research request fields after removing the generated HTML properties we
needed during form processing
@see gen_custom_fields_html_props()

$rr_cfields_json = json_encode(array_map(function($v) { unset($v["html_properties"]); return $v; }, $rr_cfields), JSON_UNESCAPED_UNICODE);
if(json_last_error() !== JSON_ERROR_NONE)
{
trigger_error(json_last_error_msg());
}
$rr_cfields_json_sql = ($rr_cfields_json == "" ? "" : $rr_cfields_json);
$parameters=array_merge($parameters,array("s",$rr_cfields_json_sql));

ps_query("insert into research_request(created,user,name,description,deadline,contact,email,finaluse,resource_types,noresources,shape, custom_fields_json)
values (now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $parameters);

# Send request
$templatevars['ref']=sql_insert_id();
$templatevars['teamresearchurl']=$baseurl."/pages/team/team_research_edit.php?ref=" . $templatevars['ref'];
$templatevars['username']=$username;
$templatevars['userfullname']=$userfullname;
$templatevars['useremail']=getval("email",$useremail); # Use provided e-mail (for anonymous access) or drop back to user email.
$templatevars['url']=$baseurl."/pages/team/team_research_edit.php?ref=".$templatevars['ref'];

$research_notify_users=get_notification_users("RESEARCH_ADMIN");
$userconfirmmessage = new ResourceSpaceUserNotification();
$userconfirmmessage->set_subject("lang_newresearchrequestwaiting");
$userconfirmmessage->set_text("'$username' ($userfullname - $useremail) ");
$userconfirmmessage->append_text("lang_haspostedresearchrequest");
$userconfirmmessage->append_text(".\n\n");
$userconfirmmessage->preference = "user_pref_resource_access_notifications";
$userconfirmmessage->template = "emailnewresearchrequestwaiting";
$userconfirmmessage->templatevars = $templatevars;
$userconfirmmessage->url = $templatevars["teamresearchurl"];

// Hook needs to update the ResourceSpaceUserNotification object
hook("modifyresearchrequestemail", "", array($userconfirmmessage));
send_user_notification($research_notify_users,$userconfirmmessage);
}

Parameters

ColumnTypeDefaultDescription
$find ""
$order_by "name"
$sort "ASC"

Location

include/research_functions.php lines 89 to 111

Definition

 
function get_research_requests($find="",$order_by="name",$sort="ASC")
    {
    
$searchsql="";
    
$use_order_by "";
    
$use_sort "";
    
$parameters=array();
    if (
$find!="") {
        
$searchsql="WHERE name like ? or description like ? or contact like ? or ref=?"
        
$parameters=array("s","%{$find}%""s","%{$find}%""s","%{$find}%""i",(int)$find);
    }
    if (
in_array($order_by, array("ref","name","created","status","assigned_to","collection")))
        {
        
$use_order_by $order_by;        
        }
    if (
in_array($sort, array("ASC","DESC")))
        {
        
$use_sort $sort;        
        }
    return 
ps_query("select " columns_in("research_request","r") . ",(select username from user u where u.ref=r.user) username, 
        (select username from user u where u.ref=r.assigned_to) assigned_username from research_request r 
        
$searchsql 
        order by 
$use_order_by $use_sort"$parameters);
    }

This article was last updated 5th October 2022 04:05 Europe/London time based on the source file dated 1st July 2022 09:30 Europe/London time.