0){ print "\n"; for($cnt=0; $cnt<$numPics; $cnt++){ $currPic = $data[$cnt]; print (($cnt%$numCols == 0)?"":"")."".((($cnt%$numCols) == ($numCols-1))?"":""); } print (((($cnt-1)%$numCols) != ($numCols-1))?"":""); print "
"; $ownerId = ($ownerId_all!=""? $ownerId_all : getVal($currPic, INDEX_OWNER_ID)); $ownerName = ($ownerName_all!=""? $ownerName_all : getVal($currPic, INDEX_OWNER_NAME)); $picId = getVal($currPic, INDEX_PIC_ID); $ttDesc = getVal($currPic, INDEX_TT_DESC); $ttTitle = getVal($currPic, INDEX_TT_TITLE); $link = "/albumViewer.php?".PARAM_USERNAME."=$ownerName&".PARAM_PIC_ID."=$picId"; $src = albumImg($ownerId, $picId, ALBUM_SIZE_THUMB); if("$ttTitle$ttDesc" != ""){ print "$picId"; $toolTips[] = array( TT_ID => "tt_$picId", TT_TITLE => $ttTitle, TT_CAPTION => $ttDesc ); } else { print "$picId"; } print "
\n"; } return $toolTips; } // end albumTable() //// // Displays a select-box for choosing the album that this picture will go in. // 'albumId' is the id of the album that this picture currently belongs to. //// function albumSelectAlbum($userId, $albumId, $doJS=false){ $albums = array( // Some albums may have the same names, so use the id as the key. "-1" => "Default Album" ); $db = dil_connect(); $queryString = "SELECT id,name FROM albums WHERE user_id='$userId'"; if($result = mysql_query($queryString,$db)){ if(($numRows = mysql_num_rows($result)) && ($numRows > 0)){ for($cnt=0; $cnt<$numRows; $cnt++){ $id = mysql_result($result, $cnt, "id"); $name = mysql_result($result, $cnt, "name"); $albums[$id] = $name; } } } print "Add to album: \n"; } // end albumSelectAlbum() //// // Displays a nav bar (can be used as header or footer) that contains the // pagination links. //// function albumNav($offset, $limit, $numShown, $numTotal, $baseUrl){ // Showing X to Y of Z print "\n"; print "
\n"; // STRINGTABLES if($numShown > 0){ print "Showing "; if($numShown >= $numTotal){ print ($numShown==1?"the only match":"all $numShown matches"); } else { print ($offset+1)." to ".($offset + $numShown)." of $numTotal match"; print ($numTotal!=1?"es":""); } } else { print "No matches"; } print "\n"; if(($numShown < $numTotal) || ($offset > 0)){ pageNav($offset, $limit, $numTotal, $baseUrl); } else { print " "; // for validation } print "
\n"; } // end albumNav() //// // Returns true if it is ok for the given user to access the album owner's album, false otherwise. //// function albumAccess($userId, $ownerId){ $retVal = false; if($userId == $ownerId){ $retVal = true; } else { $securityLevel = simpleQuery("SELECT security_level FROM pages WHERE user_id=$ownerId AND pageName='Profile'"); // LOAD THE PERMISSIONS AND PASS TO VALIDATOR $albumUser = new PedlrUser(); $albumUser->loadById( $ownerId ); $retVal = validateAccess( $securityLevel, $albumUser ); } return $retVal; } // end albumAccess() //// // Returns a html string representing the error in authentication based on the users' relationship //// function albumAccessError($userId, $ownerId){ $securityLevel = simpleQuery("SELECT security_level FROM pages WHERE user_id=$ownerId AND pageName='Profile'"); $albumUser = new PedlrUser(); $albumUser->loadById( $ownerId ); return validateAccessError( $securityLevel, $albumUser ); } // end albumAccessError() //// // Returns the default album description. //// function defaultAlbumDesc($visibleName){ return "A collection of $visibleName's photos that haven't been categorized."; // STRINGTABLES } // end defaultAlbumDesc() //// // Adds a picture to the Album Maker. The picture should already be commited to Motive FS before calling this function. // Pass in the fileName returned by motive_fs_commitFile or motive_fs_saveFile // // Returns true on success, false on failure. //// function albumMaker_addPic($fileName_fs, $albumId=DEFAULT_ALBUM_ID, $userId=''){ $retVal = false; // Make the scaled versions and commit them to Motive FS $finalDir = ""; $justFile = $fileName_fs; $index = strrpos($justFile, "/"); if($index === false){ // try both slash directions to work on all operating systems. $index = strrpos($justFile, "\\"); } if($index !== false){ $finalDir = substr($justFile, 0, $index+1); $justFile = substr($justFile, $index+1); } $destName = $finalDir."scaled_$justFile"; $cmd = "convert -scale \"".ALBUM_PIC_WIDTH."x".ALBUM_PIC_HEIGHT.">\" $fileName_fs $destName"; exec($cmd); $fileName_scaled = motive_fs_commitFile($destName); $destName = $finalDir."thumb_$justFile"; $cmd = "convert -scale \"".ALBUM_THUMB_WIDTH."x".ALBUM_THUMB_HEIGHT.">\" $fileName_fs $destName"; exec($cmd); $fileName_thumb = motive_fs_commitFile($destName); // Automatically determine the date the photo was taken from the photo's headers. $exif = @exif_read_data($fileName_fs, 0, true); // TODO: This used to have an "@" sign at the front. Figure out a more graceful way to handle these errors. $dateTaken = ""; // In case only some headers are set, try several possibilities. if(isset($exif['EXIF']['DateTimeOriginal'])){ $dateTaken = $exif['EXIF']['DateTimeOriginal']; } else if(isset($exif['IFD0']['DateTime'])){ $dateTaken = $exif['IFD0']['DateTime']; } else if(isset($exif['EXIF']['DateTimeDigitized'])){ $dateTaken = $exif['EXIF']['DateTimeDigitized']; } if($dateTaken != ""){ $dateTaken = preg_replace("/^([0-9]{4}):([0-9]{2}):([0-9]{2}) /", "$1-$2-$3 ", $dateTaken); } // Insert the picture into the album_pics table. if($userId == ""){ $userId = getUser()->getId(); } $username = getUser()->getUsername(); $queryString = "INSERT INTO pictures (submittedBy_id, submittedBy_username, url_orig, url_scaled, url_thumb, album_id, "; $queryString.= ($dateTaken==""?"":"dateTaken, ")."createdOn) "; $queryString.= "VALUES ('$userId', '$username', '$fileName_fs', '$fileName_scaled', '$fileName_thumb', '$albumId', "; $queryString.= ($dateTaken==""?"":"'$dateTaken', ")."NOW())"; if(sendQuery($queryString)){ // Keep a record of which pics were uploaded (to help with knowing which to give captions to). $uploaded = array(); $key = "albumMaker_uploads"; if(isset($_SESSION[$key])){ $uploaded = $_SESSION[$key]; } $uploaded[] = mysql_insert_id(); $_SESSION[$key] = $uploaded; // Cache the number of photos in the album. if($albumId != -1){ sendQuery("UPDATE albums SET numPics=numPics+1 WHERE id='$albumId'"); } $retVal = true; } else { logQueryError('Error saving photo to album_pics in Album Maker', $queryString); } return $retVal; } // end albumMaker_addPic() ?>