当前位置: 首页>>代码示例>>PHP>>正文


PHP add_resource_to_collection函数代码示例

本文整理汇总了PHP中add_resource_to_collection函数的典型用法代码示例。如果您正苦于以下问题:PHP add_resource_to_collection函数的具体用法?PHP add_resource_to_collection怎么用?PHP add_resource_to_collection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_resource_to_collection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateResource

 public function updateResource()
 {
     $rid = $this->resourceId();
     // resource does not exist - create it
     if ($rid == 0) {
         $rid = create_resource($this->type);
     } else {
         update_resource_type($rid, $this->type);
     }
     foreach ($this->fields as $k => $v) {
         update_field($rid, $k, $v);
     }
     if (file_exists($this->filename)) {
         $extension = explode(".", $this->filename);
         if (count($extension) > 1) {
             $extension = trim(strtolower($extension[count($extension) - 1]));
         } else {
             $extension = "";
         }
         $path = get_resource_path($rid, true, "", true, $extension);
         copy($this->filename, $path);
         create_previews($rid, false, $extension);
         # add file extension
         sql_query("update resource set file_extension='" . escapeString($extension) . "' where ref='" . escapeString($rid) . "'");
     }
     # add resource to collection (if the collection exists)
     if ($this->collection != null) {
         $col_ref = sql_value("select ref as value from collection where name='" . escapeString($this->collection) . "'", 0);
         if (isset($col_ref)) {
             add_resource_to_collection($rid, $col_ref);
         }
     }
     # set access rights
     if ($this->access != null) {
         sql_query("update resource set access='" . escapeString($this->access) . "' where ref='" . escapeString($rid) . "'");
     }
 }
开发者ID:superdol,项目名称:xlsimport,代码行数:37,代码来源:resource.php

示例2: copy_collection

function copy_collection($copied, $current, $remove_existing = false)
{
    # Get all data from the collection to copy.
    $copied_collection = sql_query("select * from collection_resource where collection='{$copied}'", "");
    if ($remove_existing) {
        #delete all existing data in the current collection
        sql_query("delete from collection_resource where collection='{$current}'");
        collection_log($current, "R", 0);
    }
    #put all the copied collection records in
    foreach ($copied_collection as $col_resource) {
        # Use correct function so external sharing is honoured.
        add_resource_to_collection($col_resource['resource'], $current, true);
    }
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:15,代码来源:collections_functions.php

示例3: sql_query

     $file_size = @filesize_unlimited($path);
     # Save alternative file data.
     sql_query("update resource_alt_files set file_name='" . escape_check($plfilename) . "',file_extension='" . escape_check($extension) . "',file_size='" . $file_size . "',creation_date=now() where resource='{$alternative}' and ref='{$aref}'");
     if ($alternative_file_previews_batch) {
         create_previews($alternative, false, $extension, false, false, $aref);
     }
     echo "SUCCESS";
     exit;
 }
 if ($replace == "" && $replace_resource == "") {
     # Standard upload of a new resource
     $ref = copy_resource(0 - $userref);
     # Copy from user template
     # Add to collection?
     if ($collection_add != "") {
         add_resource_to_collection($ref, $collection_add);
     }
     # Log this
     daily_stat("Resource upload", $ref);
     resource_log($ref, "u", 0);
     $status = upload_file($ref, getval("no_exif", "") != "", false, getval('autorotate', '') != '');
     echo "SUCCESS: " . $ref;
     exit;
 } elseif ($replace == "" && $replace_resource != "") {
     # Replacing an existing resource file
     $status = upload_file($replace_resource, getval("no_exif", "") != "", false, getval('autorotate', '') != '');
     echo "SUCCESS: {$replace_resource}";
     exit;
 } else {
     # Overwrite an existing resource using the number from the filename.
     # Extract the number from the filename
开发者ID:vongalpha,项目名称:resourcespace,代码行数:31,代码来源:upload_plupload.php

示例4: managed_collection_request

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;

	# 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)
		{
		$c=create_collection($userref,$lang["request"] . " " . date("ymdHis"));
		add_resource_to_collection($ref,$c);
		$ref=$c; # Proceed as normal
		}

	# Fomulate e-mail text
	$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();
	
	# Send the e-mail		
	$userconfirmmessage = $lang["requestsenttext"];
	$message=$lang["username"] . ": " . $username . "\n" . $message;
	$message.=$lang["viewrequesturl"] . ":\n$baseurl/?q=$request";
	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;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:71,代码来源:request_functions.php

示例5: update_field

 if (isset($filename_field)) {
     $wait = update_field($ref, $filename_field, $_FILES['userfile']['name']);
 }
 // extract metadata
 $wait = extract_exif_comment($ref, $extension);
 $resource = get_resource_data($ref);
 //create previews
 if ($camera_autorotation) {
     AutoRotateImage($filepath);
 }
 $wait = create_previews($ref, false, $extension);
 // add resource to collection
 if ($collection != "") {
     $collection_exists = sql_value("select name value from collection where ref='" . escape_check($collection) . "'", "");
     if ($collection_exists != "") {
         if (!add_resource_to_collection($ref, $collection)) {
             header("HTTP/1.0 403 Forbidden.");
             echo "HTTP/1.0 403 Forbidden. Collection is not writable by this user.\n";
             exit;
         }
     } else {
         header("HTTP/1.0 403 Forbidden.");
         echo "HTTP/1.0 403 Forbidden. Collection does not exist.\n";
         exit;
     }
 }
 // make sure non-required fields get written. Note this behavior is somewhat different than in the system since these override extracted data
 reset($_POST);
 reset($_GET);
 foreach (array_merge($_GET, $_POST) as $key => $value) {
     if (substr($key, 0, 5) == "field" && $value != "") {
开发者ID:claytondaley,项目名称:resourcespace,代码行数:31,代码来源:index.php

示例6: getvalescaped

	$to_collection = getvalescaped('toCollection', '');

	if(strpos($add,",")>0)
		{
		$addarray=explode(",",$add);
		}
	else
		{
		$addarray[0]=$add;
		unset($add);
		}	
	foreach ($addarray as $add)
		{
		hook("preaddtocollection");
		#add to current collection
		if (add_resource_to_collection($add,($to_collection === '') ? $usercollection : $to_collection,false,getvalescaped("size",""))==false)
			{ ?>
			<script language="Javascript">alert("<?php echo $lang["cantmodifycollection"]?>");</script><?php
			}
		else
			{
			# Log this	
			daily_stat("Add resource to collection",$add);
		
			# Update resource/keyword kit count
			$search=getvalescaped("search","");
			if ((strpos($search,"!")===false) && ($search!="")) {update_resource_keyword_hitcount($add,$search);}
			hook("postaddtocollection");
			}
		}	
	# Show warning?
开发者ID:artsmia,项目名称:mia_resourcespace,代码行数:31,代码来源:collections.php

示例7: do_search


//.........这里部分代码省略.........
         # Special case if a key has been provided.
         # Extract the collection number
         $collection = explode(" ", $search);
         $collection = str_replace("!collection", "", $collection[0]);
         $collection = explode(",", $collection);
         // just get the number
         $collection = $collection[0];
         # smart collections update
         global $allow_smart_collections;
         if ($allow_smart_collections) {
             $smartsearch_ref = sql_value("select savedsearch value from collection where ref={$collection}", "");
             if ($smartsearch_ref != "") {
                 $smartsearch = sql_query("select * from collection_savedsearch where ref={$smartsearch_ref}");
                 if (isset($smartsearch[0]['search'])) {
                     $smartsearch = $smartsearch[0];
                     $results = do_search($smartsearch['search'], $smartsearch['restypes'], "relevance", $smartsearch['archive'], -1, "desc", true, $smartsearch['starsearch']);
                     # results is a list of the current search without any restrictions
                     # we need to compare against the current collection contents to minimize inserts and deletions
                     $current = sql_query("select resource from collection_resource where collection={$collection}");
                     $current_contents = array();
                     $results_contents = array();
                     if (!empty($current)) {
                         foreach ($current as $current_item) {
                             $current_contents[] = $current_item['resource'];
                         }
                     }
                     if (!empty($results) && is_array($results)) {
                         foreach ($results as $results_item) {
                             $results_contents[] = $results_item['ref'];
                         }
                     }
                     for ($n = 0; $n < count($results_contents); $n++) {
                         if (!in_array($results_contents[$n], $current_contents)) {
                             add_resource_to_collection($results_contents[$n], $collection, true);
                         }
                     }
                     for ($n = 0; $n < count($current_contents); $n++) {
                         if (!in_array($current_contents[$n], $results_contents)) {
                             remove_resource_from_collection($current_contents[$n], $collection, true);
                         }
                     }
                 }
             }
         }
         return sql_query($sql_prefix . "select distinct c.date_added,c.comment,c.purchase_size,c.purchase_complete,r.hit_count score,length(c.comment) commentset, {$select} from resource r  join collection_resource c on r.ref=c.resource {$colcustperm}  where c.collection='" . $collection . "' and {$sql_filter} group by r.ref order by {$order_by}" . $sql_suffix, false, $fetchrows);
     }
     # View Related
     if (substr($search, 0, 8) == "!related") {
         # Extract the resource number
         $resource = explode(" ", $search);
         $resource = str_replace("!related", "", $resource[0]);
         $order_by = str_replace("r.", "", $order_by);
         # UNION below doesn't like table aliases in the order by.
         return sql_query($sql_prefix . "select distinct r.hit_count score, {$select} from resource r join resource_related t on (t.related=r.ref and t.resource='" . $resource . "') {$sql_join}  where 1=1 and {$sql_filter} group by r.ref \n\t\tUNION\n\t\tselect distinct r.hit_count score, {$select} from resource r join resource_related t on (t.resource=r.ref and t.related='" . $resource . "') {$sql_join}  where 1=1 and {$sql_filter} group by r.ref \n\t\torder by {$order_by}" . $sql_suffix, false, $fetchrows);
     }
     # Geographic search
     if (substr($search, 0, 4) == "!geo") {
         $geo = explode("t", str_replace(array("m", "p"), array("-", "."), substr($search, 4)));
         # Specially encoded string to avoid keyword splitting
         $bl = explode("b", $geo[0]);
         $tr = explode("b", $geo[1]);
         $sql = "select r.hit_count score, {$select} from resource r {$sql_join} where \n\n\t\t\t\t\tgeo_lat > '" . escape_check($bl[0]) . "'\n              and   geo_lat < '" . escape_check($tr[0]) . "'\t\t\n              and   geo_long > '" . escape_check($bl[1]) . "'\t\t\n              and   geo_long < '" . escape_check($tr[1]) . "'\t\t\n                          \n\t\t and {$sql_filter} group by r.ref order by {$order_by}";
         return sql_query($sql_prefix . $sql . $sql_suffix, false, $fetchrows);
     }
     # Colour search
     if (substr($search, 0, 7) == "!colour") {
开发者ID:vongalpha,项目名称:resourcespace,代码行数:67,代码来源:search_functions.php

示例8: managed_collection_request

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;
//.........这里部分代码省略.........
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:101,代码来源:request_functions.php

示例9: HookImagestreamUpload_pluploadInitialuploadprocessing


//.........这里部分代码省略.........
                        # By default, strip the colour profiles ('+' is remove the profile, confusingly)
                        #if ($imagemagick_preserve_profiles && $id!="thm" && $id!="col" && $id!="pre" && $id!="scr") {$profile="";}
                    }
                    $runcommand = $command . " +matte {$profile} " . escapeshellarg($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg");
                    $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg";
                    $output = run_command($runcommand);
                    debug("processed file" . $filenumber . ": " . $imagestream_file . "\r\n");
                    debug("Image index: " . $imageindex . ". file count: " . count($imagestream_filelist));
                    if ($filenumber == 00) {
                        $snapshotsize = getimagesize($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg");
                        list($width, $height) = $snapshotsize;
                        # Frame size must be a multiple of two
                        if ($width % 2) {
                            $width++;
                        }
                        if ($height % 2) {
                            $height++;
                        }
                    }
                    if ($imageindex == count($imagestream_filelist) - 1) {
                        $additionalfile = $filenumber + 1;
                        $additionalfile = sprintf("%03d", $additionalfile);
                        copy($imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $filenumber . ".jpg", $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg");
                        $deletion_array[] = $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream" . $additionalfile . ".jpg";
                    }
                    $filenumber++;
                }
                #end of loop for each uploadedfile
                $imageindex++;
            }
            #Add the resource and move this zip file, set extension
            # Add to collection?
            if ($collection_add != "") {
                add_resource_to_collection($ref, $collection_add);
            }
            # Log this
            daily_stat("Resource upload", $ref);
            resource_log($ref, "u", 0);
            #Change this!!!!!!!!!!!
            #$status=upload_file($ref,true,false,false));
            if (!$config_windows) {
                @chmod($imagestreamzippath, 0777);
            }
            # Store extension in the database and update file modified time.
            sql_query("update resource set file_extension='zip',preview_extension='zip',file_modified=now(), has_image=0 where ref='{$ref}'");
            #update_field($ref,$filename_field,$filename);
            update_disk_usage($ref);
            # create the mp4 version
            # Add a new alternative file
            $aref = add_alternative_file($ref, "MP4 version");
            $imagestreamqtfile = get_resource_path($ref, true, "", false, "mp4", -1, 1, false, "", $aref);
            $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile;
            echo "Running command: " . $shell_exec_cmd;
            if ($config_windows) {
                $shell_exec_cmd = $ffmpeg_fullpath . " -loglevel panic -y -r " . $imagestream_transitiontime . " -i " . $imagestream_workingfiles . DIRECTORY_SEPARATOR . "imagestream%%3d.jpg -r " . $imagestream_transitiontime . " -s {$width}x{$height} " . $imagestreamqtfile;
                file_put_contents(get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat", $shell_exec_cmd);
                $shell_exec_cmd = get_temp_dir() . DIRECTORY_SEPARATOR . "imagestreammp4" . $session_hash . ".bat";
                $deletion_array[] = $shell_exec_cmd;
            }
            run_command($shell_exec_cmd);
            debug("DEBUG created slideshow MP4 video");
            if (!$config_windows) {
                @chmod($imagestreamqtfile, 0777);
            }
            $file_size = @filesize_unlimited($imagestreamqtfile);
            # Save alternative file data.
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:67,代码来源:upload_plupload.php

示例10: HookVideo_spliceViewAfterresourceactions

function HookVideo_spliceViewAfterresourceactions()
{
    global $videosplice_resourcetype, $resource, $lang, $config_windows, $resourcetoolsGT;
    if ($resource["resource_type"] != $videosplice_resourcetype) {
        return false;
    }
    # Not the right type.
    if (getval("video_splice_cut_from_hours", "") != "") {
        # Process actions
        $error = "";
        # Receive input
        $fh = getvalescaped("video_splice_cut_from_hours", "");
        $fm = getvalescaped("video_splice_cut_from_minutes", "");
        $fs = getvalescaped("video_splice_cut_from_seconds", "");
        $th = getvalescaped("video_splice_cut_to_hours", "");
        $tm = getvalescaped("video_splice_cut_to_minutes", "");
        $ts = getvalescaped("video_splice_cut_to_seconds", "");
        $preview = getvalescaped("preview", "") != "";
        # Calculate a duration, as needed by FFMPEG
        $from_seconds = $fh * 60 * 60 + $fm * 60 + $fs;
        $to_seconds = $th * 60 * 60 + $tm * 60 + $ts;
        $seconds = $to_seconds - $from_seconds;
        # Any problems?
        if ($seconds <= 0) {
            $error = $lang["error-from_time_after_to_time"];
        }
        # Convert seconds to HH:MM:SS as required by FFmpeg.
        $dh = floor($seconds / (60 * 60));
        $dm = floor(($seconds - $dh * 60 * 60) / 60);
        $ds = floor($seconds - $dh * 60 * 60 - $dm * 60);
        # Show error message if necessary
        if ($error != "") {
            ?>
			<script type="text/javascript">
			alert("<?php 
            echo $error;
            ?>
");
			</script>
			<?php 
        } else {
            # Process video.
            $ss = $fh . ":" . $fm . ":" . $fs;
            $t = str_pad($dh, 2, "0", STR_PAD_LEFT) . ":" . str_pad($dm, 2, "0", STR_PAD_LEFT) . ":" . str_pad($ds, 2, "0", STR_PAD_LEFT);
            # Establish FFMPEG location.
            $ffmpeg_fullpath = get_utility_path("ffmpeg");
            # Work out source/destination
            global $ffmpeg_preview_extension, $ref;
            if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
                $source = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            } else {
                $source = get_resource_path($ref, true, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            }
            # Preview only?
            global $userref;
            if ($preview) {
                # Preview only.
                $target = get_temp_dir() . "/video_splice_preview_" . $userref . "." . $ffmpeg_preview_extension;
            } else {
                # Not a preview. Create a new resource.
                $newref = copy_resource($ref);
                $target = get_resource_path($newref, true, "", true, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
                # Set parent resource field details.
                global $videosplice_parent_field;
                update_field($newref, $videosplice_parent_field, $ref . ": " . $resource["field8"] . " [{$fh}:{$fm}:{$fs} - {$th}:{$tm}:{$ts}]");
                # Set created_by, archive and extension
                sql_query("update resource set created_by='{$userref}',archive=-2,file_extension='" . $ffmpeg_preview_extension . "' where ref='{$newref}'");
            }
            # Unlink the target
            if (file_exists($target)) {
                unlink($target);
            }
            if ($config_windows) {
                # Windows systems have a hard time with the long paths used for video generation.
                $target_ext = strrchr($target, '.');
                $source_ext = strrchr($source, '.');
                $target_temp = get_temp_dir() . "/vs_t" . $newref . $target_ext;
                $target_temp = str_replace("/", "\\", $target_temp);
                $source_temp = get_temp_dir() . "/vs_s" . $ref . $source_ext;
                $source_temp = str_replace("/", "\\", $source_temp);
                copy($source, $source_temp);
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source_temp) . " -ss {$ss} -t {$t} " . escapeshellarg($target_temp);
                $output = exec($shell_exec_cmd);
                rename($target_temp, $target);
                unlink($source_temp);
            } else {
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source) . " -ss {$ss} -t {$t} " . escapeshellarg($target);
                $output = exec($shell_exec_cmd);
            }
            #echo "<p>" . $shell_exec_cmd . "</p>";
            # Generate preview/thumbs if not in preview mode
            if (!$preview) {
                include_once "../include/image_processing.php";
                create_previews($newref, false, $ffmpeg_preview_extension);
                # Add the resource to the user's collection.
                global $usercollection, $baseurl;
                add_resource_to_collection($newref, $usercollection);
                ?>
				<script type="text/javascript">
				top.collections.location.href="<?php 
//.........这里部分代码省略.........
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:101,代码来源:view.php

示例11: array_values

             $counter++;
             if ($counter >= $result_limit && $result_limit != -1) {
                 break;
             }
         }
     }
 }
 //echo "Comparing results...";
 $results_contents_add = array_values(array_diff($results_contents, $current_contents));
 $current_contents_remove = array_values(array_diff($current_contents, $results_contents));
 $count_results = count($results_contents_add);
 if ($count_results > 0) {
     # Add any new resources
     debug("smart_collections_async : Adding {$count_results} resources to collection...");
     for ($n = 0; $n < $count_results; $n++) {
         add_resource_to_collection($results_contents_add[$n], $collection, true);
     }
 }
 $count_contents = count($current_contents_remove);
 if ($count_contents > 0) {
     # Remove any resources no longer present.
     debug("smart_collections_async : Removing {$count_contents} resources...");
     for ($n = 0; $n < $count_contents; $n++) {
         remove_resource_from_collection($current_contents_remove[$n], $collection, true);
     }
 }
 $endTime = microtime(true);
 $elapsed = $endTime - $startTime;
 if (RUNNING_ASYNC) {
     debug("smart_collections_async : {$elapsed} seconds for " . $smartsearch['search']);
 }
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:31,代码来源:update_smart_collection.php

示例12: managed_collection_request

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']);
//.........这里部分代码省略.........
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:101,代码来源:request_functions.php

示例13: csv_upload_process

function csv_upload_process($filename, &$meta, $resource_types, &$messages, $override = "", $max_error_count = 100, $processcsv = false)
{
    // echo "csv_upload_process(" . $filename . ", Resource types: ";
    // foreach($resource_types as $restype) {echo $restype. ", ";}
    // echo "Override:" . $override . "<br>";
    // if($processcsv){echo "Processing CSV file<br>";}
    $file = fopen($filename, 'r');
    $line_count = 0;
    if (($header = fgetcsv($file)) == false) {
        array_push($messages, "No header found");
        fclose($file);
        return false;
    }
    for ($i = 0; $i < count($header); $i++) {
        $header[$i] = strtoupper($header[$i]);
    }
    # ----- start of header row checks -----
    $resource_types_allowed = array();
    $resource_type_filter = getvalescaped("resource_type", "", true);
    if (getvalescaped("add_to_collection", "") != "") {
        include dirname(__FILE__) . "/../../../include/collections_functions.php";
        global $usercollection;
        $add_to_collection = true;
    } else {
        $add_to_collection = false;
    }
    foreach (array_keys($resource_types) as $resource_type) {
        if (!isset($meta[$resource_type])) {
            continue;
        }
        $missing_fields = array();
        foreach ($meta[$resource_type] as $field_name => $field_attributes) {
            if ($override != "" && $resource_type_filter != $resource_type && $resource_type != 0) {
                continue;
            }
            if ($field_attributes['required'] && array_search($field_name, $header) === false) {
                $meta[$resource_type][$field_name]['missing'] = true;
                array_push($missing_fields, $meta[$resource_type][$field_name]['nicename']);
            }
        }
        //if (count($missing_fields)==0 || $override==0 || ($override=="" || ($override==0 && $resource_type==$resource_type_filter)))
        if ($override == 0 || count($missing_fields) == 0 && ($override == "" || $resource_type == $resource_type_filter)) {
            array_push($messages, "Info: Found correct field headers for resource_type {$resource_type}({$resource_types[$resource_type]})");
            array_push($resource_types_allowed, $resource_type);
        } else {
            array_push($messages, "Warning: resource_type {$resource_type}({$resource_types[$resource_type]}) has missing field headers (" . implode(",", $missing_fields) . ") and will be ignored");
        }
    }
    if ($override != "" && array_search($resource_type_filter, $resource_types_allowed) === false) {
        array_push($messages, "Error: override resource_type {$resource_type_filter}({$resource_types[$resource_type_filter]}) not found or headers are incomplete");
        fclose($file);
        return false;
    } else {
        if ($override != "") {
            array_push($messages, "Info: Override resource_type {$resource_type_filter}({$resource_types[$resource_type_filter]}) is valid");
        }
    }
    if (count($header) == count(array_unique($header))) {
        array_push($messages, "Info: No duplicate header fields found");
    } else {
        array_push($messages, "Error: duplicate header fields found");
        fclose($file);
        return false;
    }
    # ----- end of header row checks, process each of the rows checking data -----
    $resource_type_index = array_search("RESOURCE_TYPE", $header);
    // index of column that contains the resource type
    $error_count = 0;
    echo "Processing " . count($header) . " columns<br>";
    while (($line = fgetcsv($file)) !== false && $error_count < $max_error_count) {
        $line_count++;
        if (!$processcsv && count($line) != count($header)) {
            array_push($messages, "Error: Incorrect number of columns(" . count($line) . ") found on line " . $line_count . " (should be " . count($header) . ")");
            $error_count++;
            continue;
        }
        // important! this is where the override happens
        if ($resource_type_index !== false && $override != 1) {
            $resource_type = $line[$resource_type_index];
            if ($override === 0 && $resource_type_filter != $resource_type) {
                continue;
            }
            // User has selected to only import a specific resource type
        } else {
            $resource_type = $resource_type_filter;
        }
        //echo "Resource type: " . $resource_type . "<br>";
        if (array_search($resource_type, $resource_types_allowed) === false) {
            if ($processcsv) {
                array_push($messages, "Skipping resource type " . $resource_type);
            }
            continue;
        }
        if ($processcsv) {
            // Create the new resource
            $newref = create_resource($resource_type);
            array_push($messages, "Created new resource: #" . $newref . " (" . $resource_types[$resource_type] . ")");
            if ($add_to_collection) {
                add_resource_to_collection($newref, $usercollection);
            }
//.........这里部分代码省略.........
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:101,代码来源:csv_functions.php

示例14: HookAutoassign_mrequestsAllAutoassign_collection_requests

function HookAutoassign_mrequestsAllAutoassign_collection_requests($user_ref, $collection_data, $message, $manage_collection_request)
{
    global $manage_request_admin, $assigned_to_user, $email_notify, $lang, $baseurl, $applicationname, $request_query, $notify_manage_request_admin;
    // Do not process this any further as this should only handle collection requests
    if (!$manage_collection_request) {
        return false;
    }
    $resources = get_collection_resources($collection_data['ref']);
    $mapped_fields = get_mapped_fields();
    $collection_resources_by_assigned_user = array();
    $collections = array();
    // Build the collections map between asigned user and resources the collection should contain
    foreach ($resources as $resource) {
        $resource_data = get_resource_field_data($resource);
        $assigned_administrator = 0;
        $resource_not_assigned = true;
        foreach ($resource_data as $r_data) {
            if (in_array($r_data['ref'], $mapped_fields)) {
                $assigned_administrator = get_mapped_user_by_field($r_data['ref'], $r_data['value']);
                if ($assigned_administrator === 0) {
                    $collection_resources_by_assigned_user['not_managed'][] = $resource;
                } else {
                    $collection_resources_by_assigned_user[$assigned_administrator][] = $resource;
                }
                $resource_not_assigned = false;
                break;
            }
        }
        if ($resource_not_assigned && !isset($manage_request_admin)) {
            $collection_resources_by_assigned_user['not_managed'][] = $resource;
        }
    }
    // Create collections based on who is supposed to handle the request
    foreach ($collection_resources_by_assigned_user as $assigned_user_id => $collection_resources) {
        if ($assigned_user_id === 'not_managed') {
            $collections['not_managed'] = create_collection($user_ref, $collection_data['name'] . ' request for unmanaged resources');
            foreach ($collection_resources as $collection_resource_id) {
                add_resource_to_collection($collection_resource_id, $collections['not_managed']);
            }
            continue;
        }
        $user = get_user($assigned_user_id);
        $collections[$assigned_user_id] = create_collection($user_ref, $collection_data['name'] . ' request - managed by ' . $user['email']);
        foreach ($collection_resources as $collection_resource_id) {
            add_resource_to_collection($collection_resource_id, $collections[$assigned_user_id]);
        }
        // Attach assigned admin to this collection
        add_collection($user['ref'], $collections[$assigned_user_id]);
    }
    if (!empty($collections)) {
        foreach ($collections as $assigned_to => $collection_id) {
            $assigned_to_user = get_user($assigned_to);
            $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',  # user\n                                     '%s',  # collection\n                                     NOW(), # created\n                                     1,     # request_mode\n                                     0,     # status\n                                     '%s',  # comments\n                                     '%s'   # assigned_to\n                                );\n                ", $user_ref, $collection_id, escape_check($message), $assigned_to);
            if ($assigned_to === 'not_managed' || !$assigned_to_user) {
                $assigned_to_user['email'] = $email_notify;
                $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',  # user\n                                         '%s',  # collection\n                                         NOW(), # created\n                                         1,     # request_mode\n                                         0,     # status\n                                         '%s'   # comments\n                                    );\n                    ", $user_ref, $collection_id, escape_check($message), $assigned_to);
            }
            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;
    }
    // If we've got this far, make sure auto assigning managed requests based on resource types won't overwrite this
    unset($manage_request_admin);
    return true;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:70,代码来源:all.php

示例15: htmlspecialchars

echo htmlspecialchars($collection);
?>
';</script>
<?php 
$add = getvalescaped("add", "");
if ($add != "") {
    if (strpos($add, ",") > 0) {
        $addarray = explode(",", $add);
    } else {
        $addarray[0] = $add;
        unset($add);
    }
    foreach ($addarray as $add) {
        hook("preaddtocollection");
        #add to current collection
        if (add_resource_to_collection($add, $usercollection, false, getvalescaped("size", "")) == false) {
            ?>
			<script language="Javascript">alert("<?php 
            echo $lang["cantmodifycollection"];
            ?>
");</script><?php 
        } else {
            # Log this
            daily_stat("Add resource to collection", $add);
            # Update resource/keyword kit count
            $search = getvalescaped("search", "");
            if (strpos($search, "!") === false && $search != "") {
                update_resource_keyword_hitcount($add, $search);
            }
            hook("postaddtocollection");
        }
开发者ID:claytondaley,项目名称:resourcespace,代码行数:31,代码来源:collections.php


注:本文中的add_resource_to_collection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。