function add_collection($user, $collection) { # Add a collection to a user's 'My Collections' // Don't add if we are anonymous - we can only have one collection global $anonymous_login, $username, $anonymous_user_session_collection; if (isset($anonymous_login) && $username == $anonymous_login && $anonymous_user_session_collection) { return false; } # Remove any existing collection first remove_collection($user, $collection); # Insert row sql_query("insert into user_collection(user,collection) values ('{$user}','{$collection}')"); #log this collection_log($collection, "S", 0, sql_value("select username as value from user where ref = {$user}", "")); }
# No collections to select. Create them a new collection. $name = get_mycollection_name($userref); $usercollection = create_collection($userref, $name); set_user_collection($userref, $usercollection); } refresh_collection_frame($usercollection); } $removeall = getvalescaped("removeall", ""); if ($removeall != "") { remove_all_resources_from_collection($removeall); refresh_collection_frame($usercollection); } $remove = getvalescaped("remove", ""); if ($remove != "") { # Remove someone else's collection from your My Collections remove_collection($userref, $remove); # Get count of collections $c = get_user_collections($userref); # If the user has just removed the collection they were using, select a new collection if ($usercollection == $remove && count($c) > 0) { # Select the first collection in the dropdown box. $usercollection = $c[0]["ref"]; set_user_collection($userref, $usercollection); } refresh_collection_frame(); } $add = getvalescaped("add", ""); if ($add != "") { # Add someone else's collection to your My Collections add_collection($userref, $add); set_user_collection($userref, $add);
function add_collection($user,$collection) { # Add a collection to a user's 'My Collections' # Remove any existing collection first remove_collection($user,$collection); # Insert row sql_query("insert into user_collection(user,collection) values ('$user','$collection')"); #log this collection_log($collection,"S",0, sql_value ("select username as value from user where ref = $user","")); }