function email_collection_request($ref,$details) { # Request mode 0 # E-mails a collection request (posted) to the team global $applicationname,$email_from,$baseurl,$email_notify,$username,$useremail,$lang,$request_senduserupdates; $message=""; if (isset($username) && trim($username)!="") {$message.=$lang["username"] . ": " . $username . "\n\n";} # Create a copy of the collection which is the one sent to the team. This is so that the admin # user can e-mail back an external URL to the collection if necessary, to 'unlock' full (open) access. # The user cannot then gain access to further resources by adding them to their original collection as the # shared collection is a copy. # A complicated scenario that is best avoided using 'managed requests'. $copied=create_collection(-1,$lang["requestcollection"]); copy_collection($ref,$copied); $ref=$copied; 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 . ": " . $_POST[str_replace("_label","",$key)] . "\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"; } } $userconfirmmessage = $lang["requestsenttext"]; $message.=$lang["viewcollection"] . ":\n$baseurl/?c=$ref"; send_mail($email_notify,$applicationname . ": " . $lang["requestcollection"] . " - $ref",$message,$useremail); if ($request_senduserupdates){send_mail($useremail,$applicationname . ": " . $lang["requestsent"] . " - $ref",$userconfirmmessage,$email_from);} # Increment the request counter sql_query("update resource set request_count=request_count+1 where ref='$ref'"); return true; }
function email_collection_request($ref, $details) { # Request mode 0 # E-mails a collection request (posted) to the team global $applicationname, $email_from, $baseurl, $email_notify, $username, $useremail, $lang, $request_senduserupdates, $userref, $resource_type_request_emails; $message = ""; #if (isset($username) && trim($username)!="") {$message.=$lang["username"] . ": " . $username . "\n";} $templatevars['url'] = $baseurl . "/?c=" . $ref; $collectiondata = get_collection($ref); if (isset($collectiondata["name"])) { $templatevars["title"] = $collectiondata["name"]; } # Create a copy of the collection which is the one sent to the team. This is so that the admin # user can e-mail back an external URL to the collection if necessary, to 'unlock' full (open) access. # The user cannot then gain access to further resources by adding them to their original collection as the # shared collection is a copy. # A complicated scenario that is best avoided using 'managed requests'. $copied = create_collection(-1, $lang["requestcollection"]); copy_collection($ref, $copied); $ref = $copied; $templatevars["requesturl"] = $baseurl . "/?c=" . $ref; $templatevars['username'] = $username . " (" . $useremail . ")"; $userdata = get_user($userref); $templatevars["fullname"] = $userdata["fullname"]; 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 . ": " . $_POST[str_replace("_label", "", $key)] . "\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"; } } $templatevars["requestreason"] = $message; $userconfirmmessage = $lang["requestsenttext"] . "\n\n{$message}" . $lang["viewcollection"] . ":\n{$baseurl}/?c={$ref}"; $message = $lang["user_made_request"] . "\n\n" . $lang["username"] . ": " . $username . "\n{$message}"; $message .= $lang["viewcollection"] . ":\n{$baseurl}/?c={$ref}"; # 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_mail($admin_notify_email, $applicationname . ": " . $lang["requestcollection"] . " - {$ref}", $message, $useremail, $useremail, "emailcollectionrequest", $templatevars); if ($request_senduserupdates) { send_mail($useremail, $applicationname . ": " . $lang["requestsent"] . " - {$ref}", $userconfirmmessage, $email_from, $email_notify, "emailusercollectionrequest", $templatevars); } # Increment the request counter sql_query("update resource set request_count=request_count+1 where ref='{$ref}'"); return true; }
if (!collection_writeable($ref)) { exit($lang["no_access_to_collection"]); } # Fetch collection data $collection = get_collection($ref); if ($collection === false) { $error = $lang['error-collectionnotfound']; error_alert($error); exit; } $resources = do_search("!collection" . $ref); $colcount = count($resources); # Collection copy functionality $copy = getval("copy", ""); if ($copy != "") { copy_collection($copy, $ref, $copycollectionremoveall != ""); refresh_collection_frame(); } if (getval("submitted", "") != "") { # Save collection data save_collection($ref); if (getval("redirect", "") != "") { if (getval("addlevel", "") == "yes") { redirect($baseurl_short . "pages/collection_edit.php?ref=" . $ref . "&addlevel=yes"); } else { if (getval("theme", "") != "" || getval("newtheme", "") != "") { redirect($baseurl_short . "pages/themes.php?manage=true"); } else { redirect($baseurl_short . 'pages/collection_manage.php?offset=' . $offset . '&col_order_by=' . $col_order_by . '&sort=' . $sort . '&find=' . urlencode($find) . '&reload=true'); } }
collection_set_themes($collection_add, $themearr); } } if ($collection_add != "") { # Switch to the selected collection (existing or newly created) and refresh the frame. set_user_collection($userref, $collection_add); refresh_collection_frame($collection_add); } if ($send_collection_to_admin && $archive == -1 && getvalescaped('ajax', 'false') == true && getvalescaped('ajax_action', '') == 'send_collection_to_admin') { $collection_id = getvalescaped('collection', ''); if ($collection_id == '') { exit; } // Create a copy of the collection for admin: $admin_copy = create_collection(-1, $lang['send_collection_to_admin_emailedcollectionname']); copy_collection($collection_id, $admin_copy); $collection_id = $admin_copy; // Get the user (or username) of the contributor: $user = get_user($userref); if (isset($user) && trim($user['fullname']) != '') { $user = $user['fullname']; } else { $user = $user['username']; } // Get details about the collection: $collection = get_collection($collection_id); $collection_name = $collection['name']; $resources_in_collection = count(get_collection_resources($collection_id)); // Build mail and send it: $subject = $applicationname . ': ' . $lang['send_collection_to_admin_emailsubject'] . $user; $message = $user . $lang['send_collection_to_admin_usercontributedcollection'] . "\n\n";