function morsle_get_files($morsle, $wdir, &$collectionid) { global $USER, $COURSE; global $userstr, $deptstr; $collections = explode('/', $wdir); if ($wdir === '') { // root of morsle files, user and department are prepended in display_dir $files = get_doc_feed($morsle, $collectionid); // go get folder contents from Google } elseif (strpos($wdir, $deptstr) === false && strpos($wdir, $userstr) === false) { // course collection $basecollectionid = sizeof($collections) > 2 ? get_collection($morsle, $collections[sizeof($collections) - 2]) : null; // $basecollectionid = second to last collection in path that is passed $collectionid = get_collection($morsle, $collections[sizeof($collections) - 1], $basecollectionid); // $collectionid = last collection in path that is passed // TODO: send a path to be used to get the doc feed from a nested collection $files = get_doc_feed($morsle, $collectionid); // go get folder contents from Google } else { // departmental or user account collection $basecollectionid = sizeof($collections) > 3 ? get_collection($morsle, $collections[sizeof($collections) - 2]) : null; // $basecollectionid = second to last collection in path that is passed $collectionid = sizeof($collections) > 2 ? get_collection($morsle, $collections[sizeof($collections) - 1], $basecollectionid) : null; // $collectionid = last collection in path that is passed // go get folder contents from Google if ($collectionid == null || $collectionid === '') { $collectionid = 'root'; } // TODO: send a path to be used to get the doc feed from a nested collection $files = get_doc_feed($morsle, $collectionid); // go get folder contents from Google } return $files; }
function get_table($table) { $db = get_collection(); $t = $db->{$table}; switch ($table) { case 'answer': $t->ensureIndex(array('vote' => -1, 'q_id' => -1)); break; case 'question': $t->ensureIndex(array('id' => 1)); break; case 'user': $t->ensureIndex(array('name' => -1)); break; default: # code... break; } return $t; }
<?php include "../include/db.php"; include "../include/general.php"; # External access support (authenticate only if no key provided, or if invalid access key provided) $k=getvalescaped("k","");if (($k=="") || (!check_access_key(getvalescaped("ref","",true),$k))) {include "../include/authenticate.php";} include "../include/collections_functions.php"; include "../include/resource_functions.php"; include "../include/search_functions.php"; $ref=getvalescaped("ref","",true); $collection=getvalescaped("collection","",true); # Fetch collection data $cinfo=get_collection($collection);if ($cinfo===false) {exit("Collection not found.");} $commentdata=get_collection_resource_comment($ref,$collection); $comment=$commentdata["comment"]; $rating=$commentdata["rating"]; # Check access if (!$cinfo["request_feedback"] && ($userref!=$cinfo["user"]) && ($cinfo["allow_changes"]!=1) && (!checkperm("h"))) {exit("Access denied.");} if (getval("save","")!="") { # Save comment $comment=trim(getvalescaped("comment","")); $rating=trim(getvalescaped("rating","")); save_collection_resource_comment($ref,$collection,$comment,$rating); if ($k=="") { redirect ($baseurl_short."pages/search.php?refreshcollectionframe=true&search=!collection" . $collection); }
$per_page=getvalescaped("per_page_list_log",15);setcookie("per_page_list_log",$per_page, 0, '', '', false, true); include "../include/header.php"; $log=get_collection_log($ref, $offset+$per_page); $results=count($log); $totalpages=ceil($results/$per_page); $curpage=floor($offset/$per_page)+1; $url=$baseurl . "/pages/collection_log.php?ref=" . $ref; $jumpcount=1; ?> <?php # Fetch and translate collection name $colinfo = get_collection($ref); $colname = i18n_get_collection_name($colinfo); if (!checkperm("b")) { # Add selection link to collection name. $colname = "<a href=\"" . $baseurl_short . "pages/collections.php?collection=" . $ref . "\" onClick=\"return CollectionDivLoad(this);\">" . $colname . "</a>"; } ?> <div class="BasicsBox"> <?php if ($back_to_collections_link != "") { ?><div style="float:right;"><a href="<?php echo $baseurl_short?>pages/collection_manage.php" onClick="return CentralSpaceLoad(this,true);"><strong><?php echo $back_to_collections_link ?></strong> </a></div> <?php } ?> <h1><?php echo str_replace("%collection", $colname, $lang["collectionlogheader"]);?></h1> <div class="TopInpageNav"> <div class="InpageNavLeftBlock"><?php echo $lang["resultsdisplay"]?>: <?php for($n=0;$n<count($list_display_array);$n++){?>
} $bottomy = $pdf->GetY(); # Add spacing cell if ($sheetstyle == "list") { $pdf->Cell($cellsize[0], 0.5, '', 0, 0); } else { if ($sheetstyle == "thumbnails") { $pdf->Setx($topx); $pdf->Cell($cellsize[0], $bottomy - $topy + $imagesize + 0.2, '', 0, 0); } } } $deltay = 1; do_contactsheet_sizing_calculations(); #Get data $collectiondata = get_collection($collection); if (is_numeric($order_by)) { $order_by = "field" . $order_by; } //debug("Contact Sheet Sort is $order_by $sort"); $result = do_search("!collection" . $collection, "", $order_by, 0, -1, $sort); if ($sheetstyle == "thumbnails") { $getfields = $config_sheetthumb_fields; } else { if ($sheetstyle == "list") { $getfields = $config_sheetlist_fields; } else { if ($sheetstyle == "single") { $getfields = $config_sheetsingle_fields; } }
daily_stat("New collection",$userref); } elseif(!isset($usercollection) || $collection!=$usercollection) { $validcollection=sql_value("select ref value from collection where ref='$collection'",0); # Switch the existing collection if ($k=="") {set_user_collection($userref,$collection);} $usercollection=$collection; } hook("postchangecollection"); } # Load collection info. $cinfo=get_collection($usercollection); # Check to see if the user can edit this collection. $allow_reorder=false; if (($k=="") && (($userref==$cinfo["user"]) || ($cinfo["allow_changes"]==1) || (checkperm("h")))) { $allow_reorder=true; } # Reordering capability if ($allow_reorder) { # Also check for the parameter and reorder as necessary. $reorder=getvalescaped("reorder",false); if ($reorder) {
$collections = $getthemes; $collection = $getthemes[$m]["ref"]; $colresult = do_search("!collection" . $collection); $cinfo = get_collection($collection); $feedback = $cinfo["request_feedback"]; $k = ""; } else { if ($pagename == "collections") { $collection = $usercollection; $colresult = $result; } } } if ($pagename == "search" && isset($resources) && is_array($resources)) { $colresult = $resources; $cinfo = get_collection($collections[$n]['ref']); $feedback = $cinfo["request_feedback"]; $collection_results = true; $collection = $collections[$n]['ref']; } $count_result = count($colresult); // check editability $col_editable = false; if (count($colresult) > 0 && checkperm("e" . $colresult[0]["archive"]) && allow_multi_edit($colresult)) { $col_editable = true; } if ($pagename != "collection_manage" && $pagename != "collection_public" && $pagename != "themes") { ?> <form method="get" name="colactions" id="colactions" action="collections_compact_style.php"> <?php }
<?php include "../include/db.php"; include "../include/authenticate.php"; include "../include/general.php"; include "../include/search_functions.php"; include "../include/resource_functions.php"; include "../include/collections_functions.php"; # Fetch vars $ref = getvalescaped("ref", "", true); # if bypass sharing page option is on, redirect to e-mail if ($bypass_share_screen) { header('Location:collection_email.php?ref=' . $ref); } $collection = get_collection($ref); # Process deletion of access keys if (getval("deleteaccess", "") != "") { delete_collection_access_key($ref, getvalescaped("deleteaccess", "")); } # Get min access to this collection $minaccess = collection_min_access($ref); if ($minaccess >= 1 && !$restricted_share) { $show_error = true; $error = $lang["restrictedsharecollection"]; } if (!$collection_allow_empty_share && count(get_collection_resources($ref)) == 0) { $show_error = true; $error = $lang["cannotshareemptycollection"]; } include "../include/header.php"; ?>
echo $message; } ?> <?php if (isset($collection_results)) { ?> <div class="collectionresults"> <a href="?action=collectionsearch">Search again</a> <h1>Results</h1> <ul> <?php foreach ($collection_results as $collection_result) { ?> <?php //var_dump($collection_result); $collection = get_collection($collection_result['collection_id']); $collection_owner = get_owner($collection_result['collection_id']); ?> <li><a href="<?php echo '.?action=collection&collectionid=' . $collection['collection_id']; ?> "><?php echo $collection['collection_name'] . ' by ' . $collection_owner['user_name']; ?> </a></li> <?php } ?> </ul> </div>
dbg_error_log("PROPFIND", "Getting item: Path: %s", $item_path); $sql = "SELECT caldav_data.dav_name, caldav_data, caldav_data.dav_etag "; $sql .= "FROM caldav_data WHERE dav_name = ?"; $qry = new PgQuery($sql, PgQuery::Plain(iCalendar::HttpDateFormat()), PgQuery::Plain(iCalendar::HttpDateFormat()), $item_path); if ($qry->Exec("PROPFIND", __LINE__, __FILE__) && $qry->rows > 0) { while ($item = $qry->Fetch()) { $responses[] = item_to_xml($item); } } return $responses; } $request->UnsupportedRequest($unsupported); // Won't return if there was unsupported stuff. /** * Something that we can handle, at least roughly correctly. */ $url = $c->protocol_server_port_script . $request->path; $url = preg_replace('#/$#', '', $url); if ($request->IsCollection()) { $responses = get_collection($request->depth, $request->user_no, $request->path); } elseif ($request->AllowedTo('read')) { $responses = get_item($request->path); } else { $request->DoResponse(403, translate("You do not have appropriate rights to view that resource.")); } $multistatus = new XMLElement("multistatus", $responses, array('xmlns' => 'DAV:')); // dbg_log_array( "PROPFIND", "XML", $multistatus, true ); $xmldoc = $multistatus->Render(0, '<?xml version="1.0" encoding="utf-8" ?>'); $etag = md5($xmldoc); header("ETag: \"{$etag}\""); $request->DoResponse(207, $xmldoc, 'text/xml; charset="utf-8"');
$cinfo=get_collection($collection); $feedback=$cinfo["request_feedback"]; } elseif ($pagename=="themes"){ $n=$m; $collections=$getthemes; $collection=$getthemes[$m]["ref"]; $colresult=do_search("!collection" . $collection); $cinfo=get_collection($collection); $feedback=$cinfo["request_feedback"]; $k=""; } else if ($pagename=="collections"||$pagename=="collections_frameless_loader"){ $collection=$usercollection;$colresult=$result; } if ($pagename=="search" && isset($resources) && is_array($resources)){$colresult=$resources;$cinfo=get_collection($collections[$n]['ref']);$feedback=$cinfo["request_feedback"];$collection_results=true;$collection=$collections[$n]['ref'];} } $count_result=count($colresult); // check editability $col_editable=false; if (count($colresult)>0 && checkperm("e" . $colresult[0]["archive"]) && allow_multi_edit($colresult)){ $col_editable=true; } ?> <select <?php if ($pagename=="collections"){if ($collection_dropdown_user_access_mode){?>class="SearchWidthExp" style="margin:0;"<?php } else { ?> class="SearchWidth" style="margin:0;"<?php } } $tag=$pagename."-coltools-".$collection;if ($pagename=="collections"){$tag.="_usercol";}
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; # 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); 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 sql_query("insert into request(user,collection,created,request_mode,status,comments) values ('{$userref}','{$ref}',now(),1,0,'" . escape_check($message) . "')"); $request = sql_insert_id(); $templatevars["request_id"] = $request; $templatevars["requesturl"] = $baseurl . "/?q=" . $request; $templatevars["requestreason"] = $message; hook("afterrequestcreate", "", array($request)); # 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; }
<?php get_image_main('220x', true, true, '660x', 'divImgLeft'); ?> <?php get_description(); ?> <div class="clear"></div> </div> <div class="clear"></div> <!-- Overview --> <div class="divContentOverview"> <?php get_collection(); ?> <div class="clear"></div> </div> <!-- Content Sidebar --> <div class="divContentSidebar"> <!-- Contact --> <?php get_contacts(); ?> <!-- Sidebar Blocks --> <?php get_sidebar_blocks(); ?>
if ($api_resource['signed']) { // test signature? get query string minus leading ? and skey parameter $test_query = ""; parse_str($_SERVER["QUERY_STRING"], $parsed); foreach ($parsed as $parsed_parameter => $value) { if ($parsed_parameter != "skey") { $test_query .= $parsed_parameter . '=' . $value . "&"; } } $test_query = rtrim($test_query, "&"); // get hashkey that should have been used to create a signature. $hashkey = md5($api_scramble_key . getval("key", "")); // generate the signature required to match against given skey to continue $keytotest = md5($hashkey . $test_query); if ($keytotest != getval('skey', '')) { header("HTTP/1.0 403 Forbidden."); echo "HTTP/1.0 403 Forbidden. Invalid Signature"; exit; } } if ($collection == 'all') { // get all collections $all_collections = sql_query("select c.*, c.theme2, c.theme3, c.keywords, u.fullname, u.username, c.home_page_publish, c.home_page_text, c.home_page_image,c.session_id from collection c left outer join user u on u.ref = c.user where 1"); print json_encode($all_collections); } elseif ($collection != '') { // get specific collection print json_encode(get_collection($collection)); } else { // die('invalid request'); }
} else { ?> <div class="login" id="loginDiv"> <form method="post" action="."> <input type="hidden" name="action" value="login"> <input type="email" name="email" placeholder="Email" required> <input type="password" name="password" placeholder="Password" required> <input type="submit" value="Login"> </form> <a href=".?action=signupform">Signup</a> </div> <?php } ?> <h3>Top 10 Collections</h3> <ul class="top10list"> <?php $collections_10 = get_top_collections(); //var_dump($collections_10); foreach ($collections_10 as $collection_data) { $collection_data = get_collection($collection_data['collection_id']); $collection_owner = get_owner($collection_data['collection_id']); echo '<li><a href=".?action=collection&collectionid=' . $collection_data['collection_id'] . '">' . $collection_data['collection_name'] . ' by ' . $collection_owner['user_name'] . '</a></li> '; } ?> </ul> <a href="?action=collectionsearch">Search Collections</a> </div>
selected<?php $found = true; } ?> ><?php echo i18n_get_collection_name($list[$n]); if ($collection_dropdown_user_access_mode) { echo " " . htmlspecialchars("(" . $colusername . "/" . $accessmode . ")"); } ?> </option> <?php } if ($found == false) { # Add this one at the end, it can't be found $notfound = get_collection($ref); if ($notfound !== false) { ?> <option value="<?php echo urlencode($ref); ?> " selected><?php echo $notfound["name"]; ?> </option> <?php } } ?> </select> <?php }
/** * Add url instance. * @param object $data * @param object $mform * @return int new url instance id */ function morsle_add_instance($data, $mform) { global $CFG, $DB, $COURSE, $USER; require_once $CFG->dirroot . '/mod/morsle/locallib.php'; require_once $CFG->dirroot . '/google/lib.php'; require_once $CFG->dirroot . '/blocks/morsle/morsle.php'; require_once $CFG->dirroot . '/repository/morsle/lib.php'; require_once $CFG->dirroot . '/repository/morsle/morsle_class.php'; $username = '******'; $morsle = new morsle_google_auth($username, 'drive'); $morsle->domain = '@luther.edu'; $morsle->useremail = strtolower($COURSE->shortname) . $morsle->domain; $parameters = array(); for ($i = 0; $i < 100; $i++) { $parameter = "parameter_{$i}"; $variable = "variable_{$i}"; if (empty($data->{$parameter}) or empty($data->{$variable})) { continue; } $parameters[$data->{$parameter}] = $data->{$variable}; } $data->parameters = serialize($parameters); $displayoptions = array(); if ($data->display == RESOURCELIB_DISPLAY_POPUP) { $displayoptions['popupwidth'] = $data->popupwidth; $displayoptions['popupheight'] = $data->popupheight; } if (in_array($data->display, array(RESOURCELIB_DISPLAY_AUTO, RESOURCELIB_DISPLAY_EMBED, RESOURCELIB_DISPLAY_FRAME))) { $displayoptions['printheading'] = (int) (!empty($data->printheading)); $displayoptions['printintro'] = (int) (!empty($data->printintro)); } $data->displayoptions = serialize($displayoptions); $data->externalurl = morsle_fix_submitted_url($data->externalurl); // get the docid $docid = get_doc_id($data->externalurl); // get the read-only folder id // $morsle = new repository_morsle(); $title = strtolower($COURSE->shortname) . '-read'; $owner = strtolower($COURSE->shortname) . '@' . $morsle->domain; $collectionid = get_collection($morsle, $title); // share resource with course user // $base_feed = $morsle->docs_feed . $docid . '/acl'; assign_permissions($morsle, $docid, 'writer', $USER->email, $base_feed); // link resource to the read-only folder add_file_tocollection($morsle, $docid, $collectionid); $data->timemodified = time(); $data->id = $DB->insert_record('morsle', $data); return $data->id; }
$userstr = get_string('useraccountstring', 'block_morsle') . $USER->email; $deptstr = get_string('departmentaccountstring', 'block_morsle'); $owner = $COURSE->shortname; // determine the folder id needed for all queries if (aminroot($wdir)) { $collectionid = 'root'; $basecollectionid = null; $files = get_doc_feed($morsle, $collectionid); $collection = $wdir; } else { $collections = explode('/', $wdir); $basecollectionid = null; foreach ($collections as $collection) { // cycle through the path so our ultimate collection is a subcollection of its parent if ($collection !== '') { $collectionid = get_collection($morsle, $collection, $basecollectionid); $basecollectionid = $collectionid; // just for cycling through the collections, not used again } } $files = get_doc_feed($morsle, $collectionid); } $PAGE->navbar->ignore_active(); if ($wdir === '') { $PAGE->navbar->add($morslefilestr, $returnurl); } else { // $PAGE->navbar->add($wdir, $returnurl); $PAGE->navbar->add($collection, $returnurl); } echo $OUTPUT->header(); // get read-only folderid because we'll use this a lot and its easier than trying to keep getting it from Google
$title = getvalescaped("title", ""); if ($tile_type == "srch") { $srch = getvalescaped("link", ""); $order_by = getvalescaped("order_by", ""); $sort = getvalescaped("sort", ""); $archive = getvalescaped("archive", ""); $daylimit = getvalescaped("daylimit", ""); $restypes = getvalescaped("restypes", ""); $title = getvalescaped("title", ""); $promoted_resource = getvalescaped("promoted_resource", FALSE); $resource_count = getvalescaped("resource_count", 0, TRUE); $link = $srch . "&order_by=" . urlencode($order_by) . "&sort=" . urlencode($sort) . "&archive=" . urlencode($archive) . "&daylimit=" . urlencode($daylimit) . "&k=" . urlencode($k) . "&restypes=" . urlencode($restypes); $title = preg_replace("/^.*search=/", "", $srch); if (substr($title, 0, 11) == "!collection") { include_once "../include/collections_functions.php"; $col = get_collection(preg_replace("/^!collection/", "", $title)); $promoted_resource = true; $title = $col["name"]; } else { if (substr($title, 0, 7) == "!recent") { $title = $lang["recent"]; } else { if (substr($title, 0, 5) == "!last") { $last = preg_replace("/^!last/", "", $title); $title = $last != "" ? $lang["last"] . " " . $last : $lang["recent"]; } } } } $pagetitle = $lang["createnewdashtile"]; $formextra = '<input type="hidden" name="submitdashtile" value="true" />';
<?php include "../../../include/db.php"; include "../../../include/authenticate.php"; include "../../../include/general.php"; include "../../../include/resource_functions.php"; include "../../../include/collections_functions.php"; include "../../../include/search_functions.php"; include "../include/general.php"; $ref = getvalescaped("ref", ""); $col = getvalescaped("col", ""); if ($col != "") { $is_collection = true; $collection = get_collection($col); $resources = do_search("!collection" . $col); set_user_collection($userref, $col); refresh_collection_frame(); $ref = "C" . $col; $realref = $col; // C allows us to distinguish a collection from a resource in the JS without adding extra params. } else { $is_collection = false; $resources = do_search("!list" . $ref); $realref = $ref; } // prune unnannotated resources if necessary $annotate = true; if ($annotate_pdf_output_only_annotated) { $resources_modified = array(); $x = 0; for ($n = 0; $n < count($resources); $n++) {
&k=<?php echo urlencode($k); ?> ">> <?php echo $lang["vertical"]; ?> </a> </tr> <?php if (!$collections_compact_style) { echo $search_title; } else { echo $search_title; if (substr($search, 0, 11) == "!collection" && $k == "") { $cinfo = get_collection(substr($search, 11)); $feedback = $cinfo["request_feedback"]; $count_result = count($result); if (!$search_titles) { ?> <br/><?php } draw_compact_style_selector($cinfo['ref']); if ($vertical == "v") { ?> <br/><br/><?php } ?> <?php } /*end if a collection search and compact_style - action selector*/
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; }
function send_collection_feedback($collection, $comment) { # Sends the feedback to the owner of the collection. global $applicationname, $lang, $userfullname, $userref, $k, $feedback_resource_select, $feedback_email_required, $regex_email; $cinfo = get_collection($collection); if ($cinfo === false) { exit("Collection not found"); } $user = get_user($cinfo["user"]); $body = $lang["collectionfeedbackemail"] . "\n\n"; if (isset($userfullname)) { $body .= $lang["user"] . ": " . $userfullname . "\n"; } else { # External user. if ($feedback_email_required && !preg_match("/{$regex_email}/", getvalescaped("email", ""))) { $errors[] = $lang["youremailaddress"] . ": " . $lang["requiredfield"]; return $errors; } $body .= $lang["fullname"] . ": " . getval("name", "") . "\n"; $body .= $lang["email"] . ": " . getval("email", "") . "\n"; } $body .= $lang["message"] . ": " . stripslashes(str_replace("\\r\\n", "\n", trim($comment))); $f = get_collection_comments($collection); for ($n = 0; $n < count($f); $n++) { $body .= "\n\n" . $lang["resourceid"] . ": " . $f[$n]["resource"]; $body .= "\n" . $lang["comment"] . ": " . trim($f[$n]["comment"]); if (is_numeric($f[$n]["rating"])) { $body .= "\n" . $lang["rating"] . ": " . substr("**********", 0, $f[$n]["rating"]); } } if ($feedback_resource_select) { $body .= "\n\n" . $lang["selectedresources"] . ": "; $file_list = ""; $result = do_search("!collection" . $collection); for ($n = 0; $n < count($result); $n++) { $ref = $result[$n]["ref"]; if (getval("select_" . $ref, "") != "") { global $filename_field; $filename = get_data_by_field($ref, $filename_field); $body .= "\n" . $ref . " : " . $filename; # Append to a file list that is compatible with Adobe Lightroom if ($file_list != "") { $file_list .= ", "; } $s = explode(".", $filename); $file_list .= $s[0]; } } # Append Lightroom compatible summary. $body .= "\n\n" . $lang["selectedresourceslightroom"] . "\n" . $file_list; } $cc = getval("email", ""); if (filter_var($cc, FILTER_VALIDATE_EMAIL)) { send_mail($user["email"], $applicationname . ": " . $lang["collectionfeedback"] . " - " . $cinfo["name"], $body, "", "", "", NULL, "", $cc); } else { send_mail($user["email"], $applicationname . ": " . $lang["collectionfeedback"] . " - " . $cinfo["name"], $body); } # Cancel the feedback request for this resource. /* - Commented out - as it may be useful to leave the feedback request in case the user wishes to leave additional feedback or make changes. if (isset($userref)) { sql_query("update user_collection set request_feedback=0 where collection='$collection' and user='******'"); } else { sql_query("update external_access_keys set request_feedback=0 where access_key='$k'"); } */ }
<h5 id="wip">#search-and-load-tweets-into-mongo</h5> <form name="loadform" method="get" action="load-tweets.php"> <input id="q" class="searchterm" name="q" type="text" title="Find tweets matching search criteria and load into MongoDB"/> <div id="delete"><span id="x">x</span></div> <input id="submit" class="loadtweets" name="submit" type="submit" value="Load tweets" title="Search and load tweets into MongoDB"/> </form> </div> <br> <?php include 'common.php'; // Get tweets collection in MongoDB. $collection = get_collection(TWEETS_COLLECTION); $cursor = $collection->find(); $resarray = iterator_to_array($cursor); ?> <div id="contentdiv"> <div class="floaterdiv"> <table id="twtable" class="sortable" cellspacing="0" summary="Saved tweets"> <?php echo "<caption>MongoDB: A timeline of saved tweets [" . count($resarray) . "]<br />an <a href=\"https://openshift.redhat.com/app/\" target=\"_new\">OpenShift</a> demo application with MongoDB -- follow us <a href=\"https://twitter.com/#!/openshift\" target=\"_new\">@openshift</a></caption>\n"; ?> <tr> <th scope="col" abbr="tweets" class="nobackground">timeline</th> <th scope="col" abbr="@when">@when</th> <th scope="col" abbr="tag">Tag</th>
<?php include "../include/db.php"; include "../include/authenticate.php"; if (!(checkperm("c") || checkperm("d"))) { exit("Permission denied."); } include "../include/general.php"; include "../include/image_processing.php"; include "../include/resource_functions.php"; include "../include/collections_functions.php"; $status = ""; $resource_type = getvalescaped("resource_type", ""); $collection_add = getvalescaped("collection_add", ""); $collectiondata = get_collection($collection_add); $collectionname = $collectiondata['name']; $allowed_extensions = ""; if ($resource_type != "") { $allowed_extensions = get_allowed_extensions_by_type($resource_type); } $replace_resource = getvalescaped("replace_resource", ""); # Option to replace existing resource file # generate AllowedFileExtensions parameter $allowed = ""; if ($allowed_extensions != "") { $extensions = explode(",", $allowed_extensions); foreach ($extensions as $allowed_extension) { $allowed .= $allowed_extension . "/"; } } ?>
echo $message; } } } else { $message = 'Please login to manage collections'; echo 'Please login to manage collections'; } break; case 'updatecollectionitem': if (isset($_SESSION['user_name'])) { $collection_id = filter_input(INPUT_POST, 'collectionid', FILTER_VALIDATE_INT); if ($collection_id == NULL || $collection_id == FALSE) { $message = 'That Collection doesnt exist'; include 'home.php'; } else { $collection = get_collection($collection_id); $ownerinfo = get_owner($collection_id); $edit = false; $owner = true; $collection_items = get_collection_items($collection_id); $collection_item_ids = array(); $amounts = array(); $collection_item_ids = filter_input(INPUT_POST, 'collection_item_id', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY); $amounts = filter_input(INPUT_POST, 'amount', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY); for ($i = 0; $i < count($collection_item_ids); $i++) { $collection_item_id = $collection_item_ids[$i]; $amount = $amounts[$i]; if ($collection_item_id == NULL || $collection_item_id == false) { $message = 'ID field cannot be Empty'; die; } else {
><?php echo htmlspecialchars(i18n_get_collection_name($list[$n])); ?> <?php if ($collection_dropdown_user_access_mode) { echo htmlspecialchars("(" . $colusername . "/" . $accessmode . ")"); } ?> </option> <?php } } } if (!$currentfound && !$upload_force_mycollection) { # The user's current collection has not been found in their list of collections (perhaps they have selected a theme to edit). Display this as a separate item. $cc = get_collection($usercollection); if ($cc !== false) { $currentfound = true; ?> <option value="<?php echo htmlspecialchars($usercollection); ?> " <?php if ($usercollection == $collection_add) { ?> selected <?php } ?> ><?php echo htmlspecialchars(i18n_get_collection_name($cc)); ?>
// set the new row position by case if (max($page_end_1, $page_end_2) == $page_start) { $ynew = max($y_end_1, $y_end_2); } elseif ($page_end_1 == $page_end_2) { $ynew = max($y_end_1, $y_end_2); } elseif ($page_end_1 > $page_end_2) { $ynew = $y_end_1; } else { $ynew = $y_end_2; } $this->setPage(max($page_end_1, $page_end_2)); $this->SetXY($this->GetX(), $ynew); } } if ($is_collection) { $collectiondata = get_collection($ref); $resources = do_search("!collection{$ref}"); } else { $resourcedata = get_resource_data($ref); $resources = do_search("!list{$ref}"); } // prune unnannotated resources if necessary if ($annotate_pdf_output_only_annotated) { $resources_modified = array(); $x = 0; for ($n = 0; $n < count($resources); $n++) { unset($notes); if ($annotate_pdf_output_only_annotated && $resources[$n]['annotation_count'] != 0) { $resources_modified[$x] = $resources[$n]; $x++; }
include "../include/db.php"; include "../include/general.php"; include "../include/collections_functions.php"; # External access support (authenticate only if no key provided, or if invalid access key provided) $k = getvalescaped("k", ""); if ($k == "" || !check_access_key_collection(getvalescaped("collection", "", true), $k)) { include "../include/authenticate.php"; } include "../include/resource_functions.php"; include "../include/search_functions.php"; $collection = getvalescaped("collection", "", true); $errors = ""; $done = false; # Fetch collection data $cinfo = get_collection($collection); if ($cinfo === false) { exit("Collection not found."); } # Check access if (!$cinfo["request_feedback"]) { exit("Access denied."); } # Check that comments have been added. $comments = get_collection_comments($collection); if (count($comments) == 0 && $feedback_resource_select == false) { $errors = $lang["feedbacknocomments"]; } if (getval("save", "") != "") { # Save comment $comment = trim(getvalescaped("comment", ""));
include "../include/collections_functions.php"; include "../include/resource_functions.php"; include "../include/search_functions.php"; include "../include/image_processing.php"; $ref=getvalescaped("ref","",true); $offset=getval("offset",0); $find=getvalescaped("find",""); $col_order_by=getvalescaped("col_order_by","name"); $order_by=getvalescaped("order_by",""); $sort=getval("sort","ASC"); $backto=getval("backto","");$backto=str_replace("\"","",$backto);#Prevent injection $done=false; # 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); if (getval("tweak","")!="") { $tweak=getval("tweak",""); switch($tweak) { case "rotateclock": foreach ($resources as $resource){