Example #1
0
function  HookMia_uploadEditEditbeforeheader(){
    global $baseurl;
    $resource_types=get_resource_types();
    $resource_extensions=array();
    $display_extensions = array();
    for($i=0; $i<count($resource_types); $i++){
        $display_extensions[get_resource_type_name($i+1)]=$resource_types[$i]['allowed_extensions'];
        //explode the allowed extensions into an array and remove any whitespaces?*
        $extension = preg_replace('/\s*/', '', $resource_types[$i]['allowed_extensions']);
        $before = explode("," , strtolower($extension));
        foreach($before as $after){
            $resource_extensions[] = $after;
        };
    };
    $resource_extensions = json_encode($resource_extensions);
    $getTMS=sql_query("select ref, tms_field from resource_type_field where tms_field != ''");
    $TMS = json_encode($getTMS);
    ?>

<script type="text/javascript">
        var identifier = 0;
        var filesinbatch = new Array();
        var allowedext = <?php echo($resource_extensions); ?>;
        var display_ext = <?php echo json_encode($display_extensions, true); ?>;
        var jpray = <?php echo($TMS); ?>;
</script>
<?php
}
 function send_research_request()
 {
     # Insert a search request into the requests table.
     # Resolve resource types
     $rt = "";
     $types = get_resource_types();
     for ($n = 0; $n < count($types); $n++) {
         if (getval("resource" . $types[$n]["ref"], "") != "") {
             if ($rt != "") {
                 $rt .= ", ";
             }
             $rt .= $types[$n]["ref"];
         }
     }
     global $userref;
     $as_user = getvalescaped("as_user", $userref, true);
     # If userref submitted, use that, else use this user
     # Insert the request
     sql_query("insert into research_request(created,user,name,description,deadline,contact,email,finaluse,resource_types,noresources,shape)\n\tvalues (now(),'{$as_user}','" . getvalescaped("name", "") . "','" . getvalescaped("description", "") . "'," . (getvalescaped("deadline", "") == "" ? "null" : "'" . getvalescaped("deadline", "") . "'") . ",'" . getvalescaped("contact", "") . "','" . getvalescaped("email", "") . "','" . getvalescaped("finaluse", "") . "','" . $rt . "'," . (getvalescaped("noresources", "") == "" ? "null" : "'" . getvalescaped("noresources", "") . "'") . ",'" . getvalescaped("shape", "") . "')");
     # E-mails a resource request (posted) to the team
     global $applicationname, $email_from, $baseurl, $email_notify, $username, $userfullname, $useremail, $lang;
     $templatevars['ref'] = sql_insert_id();
     $templatevars['teamresearchurl'] = $baseurl . "/pages/team/team_research.php";
     $templatevars['username'] = $username;
     $templatevars['userfullname'] = $userfullname;
     $templatevars['useremail'] = getvalescaped("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'];
     $message = "'{$username}' ({$userfullname} - {$useremail}) " . $lang["haspostedresearchrequest"] . ".\n\n";
     $message .= $templatevars['teamresearchurl'];
     hook("modifyresearchrequestemail");
     send_mail($email_notify, $applicationname . ": " . $lang["newresearchrequestwaiting"], $message, $useremail, "", "emailnewresearchrequestwaiting", $templatevars);
 }
Example #3
0
    exit("Permission denied.");
}
if (!isset($magictouch_account_id)) {
    $magictouch_account_id = "";
}
if (!isset($magictouch_secure)) {
    $magictouch_secure = "http";
}
if (getval("submit", "") != "") {
    $resourcetype = getvalescaped("resourcetype", "");
    $f = fopen("../config/config.php", "w");
    fwrite($f, "<?php \$embedvideo_resourcetype='{$resourcetype}'; ?>");
    fclose($f);
    redirect("pages/team/team_home.php");
}
$resource_types = get_resource_types();
include "../../../include/header.php";
?>
<div class="BasicsBox"> 
  <h2>&nbsp;</h2>
  <h1><?php 
echo $lang["embed_video_configuration"];
?>
</h1>

  <div class="VerticalNav">
 <form id="form1" name="form1" method="post" action="">

<p><?php 
echo $lang["specify_resourcetype"];
?>
function get_search_title($searchstring)
{
    // for naming smart collections, takes a full searchstring with the form 'search=restypes=archive=starsearch=' (all parameters optional)
    // and uses search_title_processing to autocreate a more informative title
    $order_by = "";
    $sort = "";
    $offset = "";
    $k = getvalescaped("k", "");
    $search_titles = true;
    $search_titles_searchcrumbs = true;
    $use_refine_searchstring = true;
    $search_titles_shortnames = false;
    global $lang, $userref, $baseurl, $collectiondata, $result, $display, $pagename, $collection, $userrequestmode, $preview_all;
    parse_str($searchstring, $searchvars);
    if (isset($searchvars["archive"])) {
        $archive = $searchvars["archive"];
    } else {
        $archive = 0;
    }
    if (isset($searchvars["search"])) {
        $search = $searchvars["search"];
    } else {
        $search = "";
    }
    if (isset($searchvars["starsearch"])) {
        $starsearch = $searchvars["starsearch"];
    } else {
        $starsearch = "";
    }
    if (isset($searchvars["restypes"])) {
        $restypes = $searchvars["restypes"];
    } else {
        $restypes = "";
    }
    $collection_dropdown_user_access_mode = false;
    include dirname(__FILE__) . "/search_title_processing.php";
    if ($starsearch != 0) {
        $search_title .= "(" . $starsearch;
        $search_title .= $starsearch > 1 ? " " . $lang['stars'] : " " . $lang['star'];
        $search_title .= ")";
    }
    if ($restypes != "") {
        $resource_types = get_resource_types($restypes);
        foreach ($resource_types as $type) {
            $typenames[] = $type['name'];
        }
        $search_title .= " [" . implode(', ', $typenames) . "]";
    }
    $title = str_replace(">", "", strip_tags($search_title));
    return $title;
}
Example #5
0
<div class="Question" id="contacttelephone">
<label><?php echo $lang["contacttelephone"]?></label>
<input name="contact" class="stdwidth" value="<?php echo htmlspecialchars(getval("contact","")) ?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="finaluse">
<label><?php echo $lang["finaluse"]?><br/><span class="OxColourPale"><?php echo $lang["finaluseeg"]?></span></label>
<input name="finaluse" class="stdwidth" value="<?php echo htmlspecialchars(getval("finaluse","")) ?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="resourcetype">
<label><?php echo $lang["resourcetype"]?></label>
<div class="tickset lineup">
<?php $types=get_resource_types();for ($n=0;$n<count($types);$n++) {?><div class="Inline"><input id="TickBox" type=checkbox name="resource<?php echo $types[$n]["ref"]?>" value="yes" checked>&nbsp;<?php echo htmlspecialchars($types[$n]["name"])?></div><?php } ?>
</div>
<div class="clearerleft"> </div>
</div>

<div class="Question" id="noresourcesrequired">
<label><?php echo $lang["noresourcesrequired"]?></label>
<input name="noresources" class="shrtwidth" value="<?php echo htmlspecialchars(getval("noresources",""))?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="shaperequired">
<label><?php echo $lang["shaperequired"]?></label>
<select name="shape" class="stdwidth">
<option><?php echo $lang["portrait"]?></option><option><?php echo $lang["landscape"]?></option><option selected><?php echo $lang["either"]?></option>
</select>
function updateResourcesFromContacts($resourcestoupdate,$rs_fields,$resref, $oldvals,$oldvalmatch){
    $resourceupdates = array(); $resources=array(); $rf=array(); $rv=array(); $toindex=array();//empty array vars

    //filter for only resources where this name matches the resource_field_type
    $filteredray = array();
    for ($ru=0; $ru<count($resourcestoupdate); $ru++){
        if($resourcestoupdate[$ru]['resource_type_field']==$resref){
            $filteredray[] = $resourcestoupdate[$ru];
        };
    };
    //loop through the filtered resources
    for($r=0; $r<count($filteredray); $r++){
        //for all of the resources and foreach mapped resource field
        foreach($rs_fields as $k => $v){
            if($v !=""){
                // Check to see if resource data exists for that field and resource
                $exists = sql_query("SELECT * FROM resource_data WHERE resource ='".$filteredray[$r]['resource']."' AND resource_type_field='".$k."'");
                //if it doesn't exist and the value has changed
                if(empty($exists) && !in_array($v,$oldvals[0])){
                    //push the data that needs to be INSERTED
                    $resourceupdates[]="(".$filteredray[$r]['resource'].",".$k.",'".$v."')";
                    $oldkey = matcholdkey($k,$oldvalmatch);
                    $toindex[]=$k.",'".$v."',".$filteredray[$r]['resource'].",'".$oldvals[0][$oldkey]."'";
                    // else if the value does exist and the value has changed
                }else if(!in_array($v,$oldvals[0])){
                    //push the data that needs to be UPDATED
                    $resources[]=$filteredray[$r]['resource'];
                    $rf[]=$k;
                    $rv[]=$v;
                    $oldkey=matcholdkey($k,$oldvalmatch);
                    $toindex[]=$k.",'".$v."',".$filteredray[$r]['resource'].",'".$oldvals[0][$oldkey]."'";
                };
            };
        };
    };//end filtered loop

    $updateq = "";
    //if there is data to INSERT build the statement
    if(!empty($resourceupdates)){
        sql_query("INSERT INTO resource_data (resource, resource_type_field, value) VALUES ". join(",",$resourceupdates));
    }
    //if there is data to UPDATE build the statement
    if(!empty($resources)){
        $updateq = "UPDATE resource_data SET value = CASE resource_type_field";
        foreach($rs_fields as $k => $v){
            if($v !=""){
                $updateq .= " WHEN $k THEN '$v' \n";
            }
        };
        $updateq .= "ELSE value END ";
        $updateq .= "WHERE resource IN (" . join(",",$resources).")";
        sql_query($updateq);//update
    }
    //add remove and index keywords
    for($ti = 0; $ti<count($toindex);$ti++){
        $toind = explode(",", $toindex[$ti]);
        remove_keyword_mappings($toind[2],$toind[3],$toind[0]);
        add_keyword_mappings($toind[2],$toind[1],$toind[0]);
    }
    $results=array();
    for($fr=0; $fr<count($filteredray); $fr++){
        $ref=$filteredray[$fr]['resource'];
        $results[]=get_resource_data($ref);
    }
    //elastic search
    $results=mia_results($results);
    $resource_types=get_resource_types();
    $results=mia_elastic_encode($resource_types,$results,false);
    for($e=0; $e<count($results); $e++){
        $resourcetype=get_resource_type_name($results[$e]['resource_type']);
        $ref=$results[$e]['ref'];
        push_RStoElastic($resourcetype,$ref,json_encode($results[$e]));
    }
};//end function
<?php } ?>

<div class="Question"><label><?php echo $lang["date"]?></label><div class="Fixed"><?php echo nicedate($research["created"],false,true)?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["deadline"]?></label><div class="Fixed"><?php echo nicedate($research["deadline"],false,true)?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["contacttelephone"]?></label><div class="Fixed"><?php echo htmlspecialchars($research["contact"])?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["finaluse"]?></label><div class="Fixed"><?php echo $research["finaluse"]?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["resourcetypes"]?></label><div class="Fixed">
<?php $first=true;$set=explode(", ",$research["resource_types"]);$types=get_resource_types();for ($n=0;$n<count($types);$n++) {if (in_array($types[$n]["ref"],$set)) {if (!$first) {echo ", ";}echo $types[$n]["name"];$first=false;}} ?>
</div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["noresourcesrequired"]?></label><div class="Fixed"><?php echo $research["noresources"]?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["shaperequired"]?></label><div class="Fixed"><?php echo $research["shape"]?></div>
<div class="clearerleft"> </div></div>

<div class="Question"><label><?php echo $lang["assignedtoteammember"]?></label>
<select class="shrtwidth" name="assigned_to"><option value="0"><?php echo $lang["requeststatus0"]?></option>
<?php $users=get_users_with_permission("r");
for ($n=0;$n<count($users);$n++)
	{
	?>
Example #8
0
			}
		$suggest=suggest_refinement($refs,$search);
		if (count($suggest)>0)
			{
			?><p><?php echo $lang["torefineyourresults"]?>: <?php
			for ($n=0;$n<count($suggest);$n++)
				{
				if ($n>0) {echo ", ";}
				?><a  href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo  urlencode(strip_tags($suggest[$n])) ?>" onClick="return CentralSpaceLoad(this);"><?php echo stripslashes($suggest[$n])?></a><?php
				}
			?></p><?php
			}
		}
		
	$rtypes=array();
	if (!isset($types)){$types=get_resource_types();}
	for ($n=0;$n<count($types);$n++) {$rtypes[$types[$n]["ref"]]=$types[$n]["name"];}
    if (is_array($result) && count($result)>0)
        {
        $showkeypreview = false;
        $showkeycollect = false;
        $showkeycollectout = false;
        $showkeyemail = false;
        $showkeystar = false;
        $showkeycomment = false;

        # loop and display the results
        for ($n=$offset;(($n<count($result)) && ($n<($offset+$per_page)));$n++)
            {
			
			if ($order_by=="resourcetype" && $display!="list")
Example #9
0
/**
 * Generate an html multi-select check boxes block for selecting multiple the RS resource types. The
 * selected field type is posted as an array of the values of the "ref" column of the selected
 * resource types.
 *
 * @param string $name the name of the select block. Usually the name of the config variable being set.
 * @param string $label the user text displayed to label the select block. Usually a $lang string.
 * @param integer array $current the current value of the config variable being set
 * @param integer $width the width of the input field in pixels. Default: 300.
 */
function config_multi_rtype_select($name, $label, $current, $width=300)
    {
    global $lang;
    $rtypes=get_resource_types();
?>
  <div class="Question">
    <label for="<?php echo $name?>" title="<?php echo str_replace('%cvn', $name, $lang['plugins-configvar'])?>"><?php echo $label?></label>
    <fieldset id="<?php echo $name?>" style="width:<?php echo $width ?>px">
<?php
    foreach($rtypes as $rtype)
        {
        echo '    <input type="checkbox" value="'. $rtype['ref'] . '" name="' . $name . '[]"' . (in_array($rtype['ref'],$current)?' checked="checked"':'') . '>' . lang_or_i18n_get_translated($rtype['name'],'resourcetype-') . '</option><br />';
        }
?>
    </fieldset>
  </div>
  <div class="clearerleft"></div>
<?php
    }
     }
     // add a tooltip to Smart Collection titles (which provides a more detailed view of the searchstring.
     $alt_text = '';
     if ($pagename == "search" && isset($collectiondata['savedsearch']) && $collectiondata['savedsearch'] != '') {
         $smartsearch = sql_query("select * from collection_savedsearch where ref=" . $collectiondata['savedsearch']);
         if (isset($smartsearch[0])) {
             $alt_text = "title='search=" . $smartsearch[0]['search'] . "&restypes=" . $smartsearch[0]['restypes'] . "&archive=" . $smartsearch[0]['archive'] . "&starsearch=" . $smartsearch[0]['starsearch'] . "'";
         }
     }
     hook("collectionsearchtitlemod");
     $search_title .= '<div align="left"><h1><div class="searchcrumbs">' . ($is_theme ? $theme_link . " > " : "") . '<span id="coltitle' . $collection . '"><a ' . $alt_text . ' href="' . $baseurl_short . 'pages/search.php?search=!collection' . $collection . $parameters_string . '" onClick="return CentralSpaceLoad(this,true);">' . i18n_get_collection_name($collectiondata) . ($display_user_and_access ? " <span class='CollectionUser'>(" . $colusername . $colaccessmode . ")" : "") . '</span></a></span>' . $searchcrumbs . '</div></h1> ';
 } elseif ($search == "" && $archive == 0) {
     # Which resource types (if any) are selected?
     $searched_types_refs_array = explode(",", $restypes);
     # Searched resource types and collection types
     $resource_types_array = get_resource_types("", false);
     # Get all resource types, untranslated
     $searched_resource_types_names_array = array();
     for ($n = 0; $n < count($resource_types_array); $n++) {
         if (in_array($resource_types_array[$n]["ref"], $searched_types_refs_array)) {
             $searched_resource_types_names_array[] = htmlspecialchars(lang_or_i18n_get_translated($resource_types_array[$n]["name"], "resourcetype-", "-2"));
         }
     }
     if (count($searched_resource_types_names_array) == count($resource_types_array)) {
         # All resource types are selected, don't list all of them
         unset($searched_resource_types_names_array);
         $searched_resource_types_names_array[0] = $lang["all-resourcetypes"];
     }
     # Which collection types (if any) are selected?
     $searched_collection_types_names_array = array();
     if (in_array("mycol", $searched_types_refs_array)) {
function managed_collection_request($ref, $details, $ref_is_resource = false)
{
    # Request mode 1
    # Managed via the administrative interface
    # An e-mail is still sent.
    global $applicationname, $email_from, $baseurl, $email_notify, $username, $useremail, $userref, $lang, $request_senduserupdates, $watermark, $filename_field, $view_title_field, $access, $resource_type_request_emails, $manage_request_admin;
    # Has a resource reference (instead of a collection reference) been passed?
    # Manage requests only work with collections. Create a collection containing only this resource.
    if ($ref_is_resource) {
        $admin_mail_template = "emailresourcerequest";
        $user_mail_template = "emailuserresourcerequest";
        $resourcedata = get_resource_data($ref);
        $templatevars['thumbnail'] = get_resource_path($ref, true, "thm", false, "jpg", $scramble = -1, $page = 1, $watermark ? $access == 1 ? true : false : false);
        # Allow alternative configuration settings for this resource type
        resource_type_config_override($resourcedata['resource_type']);
        if (!file_exists($templatevars['thumbnail'])) {
            $templatevars['thumbnail'] = "../gfx/" . get_nopreview_icon($resourcedata["resource_type"], $resourcedata["file_extension"], false);
        }
        $templatevars['url'] = $baseurl . "/?r=" . $ref;
        if (isset($filename_field)) {
            $templatevars["filename"] = $lang["fieldtitle-original_filename"] . ": " . get_data_by_field($ref, $filename_field);
        }
        if (isset($resourcedata["field" . $view_title_field])) {
            $templatevars["title"] = $resourcedata["field" . $view_title_field];
        }
        $c = create_collection($userref, $lang["request"] . " " . date("ymdHis"));
        add_resource_to_collection($ref, $c);
        $ref = $c;
        # Proceed as normal
    } else {
        $admin_mail_template = "emailcollectionrequest";
        $user_mail_template = "emailusercollectionrequest";
        $collectiondata = get_collection($ref);
        $templatevars['url'] = $baseurl . "/?c=" . $ref;
        if (isset($collectiondata["name"])) {
            $templatevars["title"] = $collectiondata["name"];
        }
    }
    # Fomulate e-mail text
    $templatevars['username'] = $username;
    $templatevars["useremail"] = $useremail;
    $userdata = get_user($userref);
    $templatevars["fullname"] = $userdata["fullname"];
    $message = "";
    reset($_POST);
    foreach ($_POST as $key => $value) {
        if (strpos($key, "_label") !== false) {
            # Add custom field
            $setting = trim($_POST[str_replace("_label", "", $key)]);
            if ($setting != "") {
                $message .= $value . ": " . $setting . "\n\n";
            }
        }
    }
    if (trim($details) != "") {
        $message .= $lang["requestreason"] . ": " . newlines($details) . "\n\n";
    } else {
        return false;
    }
    # Add custom fields
    $c = "";
    global $custom_request_fields, $custom_request_required;
    if (isset($custom_request_fields)) {
        $custom = explode(",", $custom_request_fields);
        # Required fields?
        if (isset($custom_request_required)) {
            $required = explode(",", $custom_request_required);
        }
        for ($n = 0; $n < count($custom); $n++) {
            if (isset($required) && in_array($custom[$n], $required) && getval("custom" . $n, "") == "") {
                return false;
                # Required field was not set.
            }
            $message .= i18n_get_translated($custom[$n]) . ": " . getval("custom" . $n, "") . "\n\n";
        }
    }
    # Create the request
    global $request_query;
    $request_query = "insert into request(user,collection,created,request_mode,status,comments) values ('{$userref}','{$ref}',now(),1,0,'" . escape_check($message) . "')";
    global $notify_manage_request_admin, $assigned_to_user;
    $notify_manage_request_admin = false;
    // Manage individual requests of resources:
    hook('autoassign_individual_requests', '', array($userref, $ref, $message, isset($collectiondata)));
    if (isset($manage_request_admin) && !isset($collectiondata)) {
        $query = sprintf("\n                    SELECT DISTINCT r.resource_type AS value\n                      FROM collection_resource AS cr\n                INNER JOIN resource r ON cr.resource = r.ref\n                     WHERE cr.collection = '%s';\n            ", $ref);
        $request_resource_type = sql_value($query, 0);
        if ($request_resource_type != 0 && array_key_exists($request_resource_type, $manage_request_admin)) {
            $request_query = sprintf("\n                    INSERT INTO request(\n                                            user,\n                                            collection,\n                                            created,\n                                            request_mode,\n                                            `status`,\n                                            comments,\n                                            assigned_to\n                                       )\n                         VALUES (\n                                     '%s',\n                                     '%s',\n                                     NOW(),\n                                     1,\n                                     0,\n                                     '%s',\n                                     '%s'\n                                );\n                ", $userref, $ref, escape_check($message), $manage_request_admin[$request_resource_type]);
            $assigned_to_user = get_user($manage_request_admin[$request_resource_type]);
            $notify_manage_request_admin = true;
        }
    }
    // Manage collection requests:
    hook('autoassign_collection_requests', '', array($userref, isset($collectiondata) ? $collectiondata : array(), $message, isset($collectiondata)));
    if (isset($manage_request_admin) && isset($collectiondata)) {
        $all_r_types = get_resource_types();
        foreach ($all_r_types as $r_type) {
            $all_resource_types[] = $r_type['ref'];
        }
        $resources = get_collection_resources($collectiondata['ref']);
        // Get distinct resource types found in this collection:
        $resource_types = array();
        $collection_resources_by_type = array();
        foreach ($resources as $resource_id) {
            $resource_data = get_resource_data($resource_id);
            $resource_types[$resource_id] = $resource_data['resource_type'];
            // Create a list of resource IDs based on type to separate them into different collections:
            $collection_resources_by_type[$resource_data['resource_type']][] = $resource_id;
        }
        // Split into collections based on resource type:
        foreach ($collection_resources_by_type as $collection_type => $collection_resources) {
            // Store all resources of unmanaged type in one collection which will be sent to the system administrator:
            if (!isset($manage_request_admin[$collection_type])) {
                $collections['not_managed'] = create_collection($userref, $collectiondata['name'] . ' for unmanaged types');
                foreach ($collection_resources as $collection_resource_id) {
                    add_resource_to_collection($collection_resource_id, $collections['not_managed']);
                }
                continue;
            }
            $collections[$collection_type] = create_collection($userref, $collectiondata['name'] . ' for type ' . $collection_type);
            foreach ($collection_resources as $collection_resource_id) {
                add_resource_to_collection($collection_resource_id, $collections[$collection_type]);
            }
        }
        if (isset($collections) && count($collections) > 1) {
            foreach ($collections as $request_resource_type => $collection_id) {
                $assigned_to = '';
                $assigned_to_user['email'] = $email_notify;
                if (array_key_exists($request_resource_type, $manage_request_admin)) {
                    $assigned_to = $manage_request_admin[$request_resource_type];
                    $assigned_to_user = get_user($manage_request_admin[$request_resource_type]);
                }
                $request_query = sprintf("\n                        INSERT INTO request(\n                                                user,\n                                                collection,\n                                                created,\n                                                request_mode,\n                                                `status`,\n                                                comments,\n                                                assigned_to\n                                           )\n                             VALUES (\n                                         '%s',\n                                         '%s',\n                                         NOW(),\n                                         1,\n                                         0,\n                                         '%s',\n                                         '%s'\n                                    );\n                    ", $userref, $collection_id, escape_check($message), $assigned_to);
                if (trim($assigned_to) == '') {
                    $request_query = sprintf("\n                        INSERT INTO request(\n                                                user,\n                                                collection,\n                                                created,\n                                                request_mode,\n                                                `status`,\n                                                comments\n                                           )\n                             VALUES (\n                                         '%s',\n                                         '%s',\n                                         NOW(),\n                                         1,\n                                         0,\n                                         '%s'\n                                    );\n                    ", $userref, $collection_id, escape_check($message));
                }
                sql_query($request_query);
                $request = sql_insert_id();
                // Send the mail:
                $email_message = $lang['requestassignedtoyoumail'] . "\n\n" . $baseurl . "/?q=" . $request . "\n";
                send_mail($assigned_to_user['email'], $applicationname . ': ' . $lang['requestassignedtoyou'], $email_message);
                unset($email_message);
            }
            $notify_manage_request_admin = false;
        } else {
            $ref = implode('', $collections);
        }
    }
    if (hook('bypass_end_managed_collection_request', '', array(!isset($collectiondata), $ref, $request_query, $message, $templatevars, $assigned_to_user, $admin_mail_template, $user_mail_template))) {
        return true;
    }
    sql_query($request_query);
    $request = sql_insert_id();
    $templatevars["request_id"] = $request;
    $templatevars["requesturl"] = $baseurl . "/?q=" . $request;
    $templatevars["requestreason"] = $message;
    hook("afterrequestcreate", "", array($request));
    # Automatically notify the admin who was assigned the request:
    if (isset($manage_request_admin) && $notify_manage_request_admin) {
        $message = $lang['requestassignedtoyoumail'] . "\n\n" . $baseurl . "/?q=" . $request . "\n";
        send_mail($assigned_to_user['email'], $applicationname . ': ' . $lang['requestassignedtoyou'], $message);
    }
    # Check if alternative request email notification address is set, only valid if collection contains resources of the same type
    $admin_notify_email = $email_notify;
    if (isset($resource_type_request_emails)) {
        $requestrestypes = array_unique(sql_array("select r.resource_type as value from collection_resource cr left join resource r on cr.resource=r.ref where cr.collection='{$ref}'"));
        if (count($requestrestypes) == 1 && isset($resource_type_request_emails[$requestrestypes[0]])) {
            $admin_notify_email = $resource_type_request_emails[$requestrestypes[0]];
        }
    }
    # Send the e-mail
    $userconfirmmessage = $lang["requestsenttext"] . "<br /><br />{$message}<br /><br />" . $lang["clicktoviewresource"] . "<br />{$baseurl}/?c={$ref}";
    $message = $lang["user_made_request"] . "<br /><br />" . $lang["username"] . ": " . $username . "<br />{$message}<br /><br />";
    $message .= $lang["clicktoviewresource"] . "<br />{$baseurl}/?q={$request}";
    send_mail($admin_notify_email, $applicationname . ": " . $lang["requestcollection"] . " - {$ref}", $message, $useremail, $useremail, $admin_mail_template, $templatevars);
    if ($request_senduserupdates) {
        send_mail($useremail, $applicationname . ": " . $lang["requestsent"] . " - {$ref}", $userconfirmmessage, $email_from, $email_notify, $user_mail_template, $templatevars);
    }
    # Increment the request counter
    sql_query("update resource set request_count=request_count+1 where ref='{$ref}'");
    return true;
}
Example #12
0
function HookResourceConnectSearchRepleacesearchresults()
{
    global $lang, $language, $resourceconnect_affiliates, $baseurl, $resourceconnect_selected, $search, $resourceconnect_this, $resourceconnect_treat_local_system_as_affiliate;
    if (!checkperm("resourceconnect")) {
        return false;
    }
    # Do not replace results for special searches
    if (substr($search, 0, 1) == "!") {
        return false;
    }
    # Do not replace results for searches of this system.
    if (!$resourceconnect_treat_local_system_as_affiliate && $resourceconnect_selected == $resourceconnect_this) {
        return false;
    }
    $affiliate = $resourceconnect_affiliates[$resourceconnect_selected];
    $counter = $resourceconnect_selected;
    $page_size = 15;
    $restypes = "";
    $resource_types = get_resource_types();
    reset($_GET);
    foreach ($_GET as $key => $value) {
        if (substr($key, 0, 8) == "resource") {
            $restype = substr($key, 8);
            if (is_numeric($restype)) {
                if ($restypes != "") {
                    $restypes .= ",";
                }
                foreach ($resource_types as $resource_type) {
                    if ($resource_type["ref"] == $restype) {
                        $restypes .= $resource_type["name"];
                    }
                }
            }
        }
    }
    ?>
	
		
	<div id="resourceconnect_container_<?php 
    echo $counter;
    ?>
"><p><?php 
    echo $lang["resourceconnect-pleasewait"];
    ?>
</p></div>
	<div class="clearerleft"></div>

	<script>
	// Repage / pager function
	var offset_<?php 
    echo $counter;
    ?>
=0;
	function ResourceConnect_Repage(distance)
		{
		offset_<?php 
    echo $counter;
    ?>
+=distance;
		if (offset_<?php 
    echo $counter;
    ?>
<0) {offset_<?php 
    echo $counter;
    ?>
=0;}
	
		jQuery('#resourceconnect_container_<?php 
    echo $counter;
    ?>
').load('<?php 
    echo $baseurl;
    ?>
/plugins/resourceconnect/pages/ajax_request.php?search=<?php 
    echo urlencode($search);
    ?>
&pagesize=<?php 
    echo $page_size;
    ?>
&affiliate=<?php 
    echo $resourceconnect_selected;
    ?>
&affiliatename=<?php 
    echo urlencode($affiliate["name"]);
    ?>
&restypes=<?php 
    echo urlencode($restypes);
    ?>
&offset=' + offset_<?php 
    echo $counter;
    ?>
);

		
		}

	ResourceConnect_Repage(0);
	</script>


	<?php 
    return true;
}