add default album names to photos
This commit is contained in:
parent
93d0ef4042
commit
4b39cc5f9b
|
@ -91,15 +91,15 @@ function dfrn_confirm_post(&$a) {
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = hash('md5',uniqid(mt_rand(),true));
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale` )
|
||||||
`height`, `width`, `data`, `scale` )
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
||||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
|
||||||
intval($local_uid),
|
intval($local_uid),
|
||||||
intval($dfrn_record),
|
intval($dfrn_record),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($r[0]['photo'])),
|
dbesc(basename($r[0]['photo'])),
|
||||||
|
dbesc( t('Contact Photos') ),
|
||||||
intval($img->getHeight()),
|
intval($img->getHeight()),
|
||||||
intval($img->getWidth()),
|
intval($img->getWidth()),
|
||||||
dbesc($img->imageString())
|
dbesc($img->imageString())
|
||||||
|
@ -108,25 +108,24 @@ function dfrn_confirm_post(&$a) {
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$img->scaleImage(80);
|
$img->scaleImage(80);
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale` )
|
||||||
`height`, `width`, `data`, `scale` )
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
||||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
intval($local_uid),
|
||||||
intval($local_uid),
|
|
||||||
intval($dfrn_record),
|
intval($dfrn_record),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($r[0]['photo'])),
|
dbesc(basename($r[0]['photo'])),
|
||||||
intval($img->getHeight()),
|
dbesc( t('Contact Photos')),
|
||||||
intval($img->getWidth()),
|
intval($img->getHeight()),
|
||||||
dbesc($img->imageString())
|
intval($img->getWidth()),
|
||||||
);
|
dbesc($img->imageString())
|
||||||
|
);
|
||||||
if($r === false)
|
if($r === false)
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
|
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
|
||||||
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
|
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
@ -320,39 +319,38 @@ function dfrn_confirm_post(&$a) {
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = hash('md5',uniqid(mt_rand(),true));
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale` )
|
||||||
`height`, `width`, `data`, `scale` )
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
|
||||||
intval($local_uid),
|
intval($local_uid),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($r[0]['photo'])),
|
dbesc(basename($r[0]['photo'])),
|
||||||
intval($img->getHeight()),
|
dbesc( t('Contact Photos') ),
|
||||||
|
intval($img->getHeight()),
|
||||||
intval($img->getWidth()),
|
intval($img->getWidth()),
|
||||||
dbesc($img->imageString())
|
dbesc($img->imageString())
|
||||||
);
|
);
|
||||||
if($r === false)
|
if($r === false)
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
$img->scaleImage(80);
|
$img->scaleImage(80);
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale` )
|
||||||
`height`, `width`, `data`, `scale` )
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
intval($local_uid),
|
||||||
intval($local_uid),
|
dbesc($hash),
|
||||||
dbesc($hash),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
dbesc(basename($r[0]['photo'])),
|
||||||
dbesc(basename($r[0]['photo'])),
|
dbesc( t('Contact Photos') ),
|
||||||
intval($img->getHeight()),
|
intval($img->getHeight()),
|
||||||
intval($img->getWidth()),
|
intval($img->getWidth()),
|
||||||
dbesc($img->imageString())
|
dbesc($img->imageString())
|
||||||
);
|
);
|
||||||
if($r === false)
|
if($r === false)
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
|
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
|
||||||
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
|
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
@ -371,7 +369,7 @@ function dfrn_confirm_post(&$a) {
|
||||||
intval($contact_id)
|
intval($contact_id)
|
||||||
);
|
);
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice( t("Unable to set contact photo info.") . EOL);
|
notice( t('Unable to set contact photo.') . EOL);
|
||||||
|
|
||||||
goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
|
goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
|
||||||
return; //NOTREACHED
|
return; //NOTREACHED
|
||||||
|
|
|
@ -7,15 +7,17 @@ function profile_photo_init(&$a) {
|
||||||
if(! local_user()) {
|
if(! local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once("mod/profile.php");
|
require_once("mod/profile.php");
|
||||||
profile_load($a,$a->user['nickname']);
|
profile_load($a,$a->user['nickname']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function profile_photo_post(&$a) {
|
function profile_photo_post(&$a) {
|
||||||
|
|
||||||
if(! local_user()) {
|
if(! local_user()) {
|
||||||
notice ( "Permission denied." . EOL );
|
notice ( t('Permission denied.') . EOL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +26,7 @@ function profile_photo_post(&$a) {
|
||||||
// phase 2 - we have finished cropping
|
// phase 2 - we have finished cropping
|
||||||
|
|
||||||
if($a->argc != 2) {
|
if($a->argc != 2) {
|
||||||
notice( "Image uploaded but image cropping failed." . EOL );
|
notice( t('Image uploaded but image cropping failed.') . EOL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,39 +55,41 @@ function profile_photo_post(&$a) {
|
||||||
$im = new Photo($base_image['data']);
|
$im = new Photo($base_image['data']);
|
||||||
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
|
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
|
||||||
|
|
||||||
$ret = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$ret = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale`, `profile` )
|
`height`, `width`, `data`, `scale`, `profile` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4, 1 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 4, 1 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($base_image['resource-id']),
|
dbesc($base_image['resource-id']),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc($base_image['filename']),
|
dbesc($base_image['filename']),
|
||||||
|
dbesc( t('Profile Photos') ),
|
||||||
intval($im->getHeight()),
|
intval($im->getHeight()),
|
||||||
intval($im->getWidth()),
|
intval($im->getWidth()),
|
||||||
dbesc($im->imageString())
|
dbesc($im->imageString())
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice ("Image size reduction (175) failed." . EOL );
|
notice ( t('Image size reduction (175) failed.') . EOL );
|
||||||
|
|
||||||
$im->scaleImage(80);
|
$im->scaleImage(80);
|
||||||
|
|
||||||
$ret = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$ret = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale`, `profile` )
|
`height`, `width`, `data`, `scale`, `profile` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5, 1 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 5, 1 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($base_image['resource-id']),
|
dbesc($base_image['resource-id']),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc($base_image['filename']),
|
dbesc($base_image['filename']),
|
||||||
|
dbesc( t('Profile Photos') ),
|
||||||
intval($im->getHeight()),
|
intval($im->getHeight()),
|
||||||
intval($im->getWidth()),
|
intval($im->getWidth()),
|
||||||
dbesc($im->imageString())
|
dbesc($im->imageString())
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice("Image size reduction (80) failed." . EOL);
|
notice( t('Image size reduction (80) failed.') . EOL );
|
||||||
|
|
||||||
// Unset the profile photo flag from any other photos I own
|
// Unset the profile photo flag from any other photos I own
|
||||||
|
|
||||||
|
@ -107,7 +111,7 @@ function profile_photo_post(&$a) {
|
||||||
$ph = new Photo($imagedata);
|
$ph = new Photo($imagedata);
|
||||||
|
|
||||||
if(! ($image = $ph->getImage())) {
|
if(! ($image = $ph->getImage())) {
|
||||||
notice("Unable to process image." . EOL);
|
notice( t('Unable to process image.') . EOL );
|
||||||
@unlink($src);
|
@unlink($src);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -128,21 +132,22 @@ function profile_photo_post(&$a) {
|
||||||
$str_image = $ph->imageString();
|
$str_image = $ph->imageString();
|
||||||
$smallest = 0;
|
$smallest = 0;
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 0 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 0 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($filename)),
|
dbesc(basename($filename)),
|
||||||
|
dbesc( t('Profile Photos') ),
|
||||||
intval($height),
|
intval($height),
|
||||||
intval($width),
|
intval($width),
|
||||||
dbesc($str_image));
|
dbesc($str_image));
|
||||||
if($r)
|
if($r)
|
||||||
notice("Image uploaded successfully." . EOL);
|
notice( t('Image uploaded successfully.') . EOL );
|
||||||
else
|
else
|
||||||
notice("Image upload failed." . EOL);
|
notice( t('Image upload failed.') . EOL );
|
||||||
|
|
||||||
if($width > 640 || $height > 640) {
|
if($width > 640 || $height > 640) {
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
|
@ -150,20 +155,21 @@ function profile_photo_post(&$a) {
|
||||||
$width = $ph->getWidth();
|
$width = $ph->getWidth();
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 1 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 1 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($filename)),
|
dbesc(basename($filename)),
|
||||||
|
dbesc( t('Profile Photos') ),
|
||||||
intval($ph->getHeight()),
|
intval($ph->getHeight()),
|
||||||
intval($ph->getWidth()),
|
intval($ph->getWidth()),
|
||||||
dbesc($ph->imageString())
|
dbesc($ph->imageString())
|
||||||
);
|
);
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice("Image size reduction (640) failed." . EOL );
|
notice( t('Image size reduction (640) failed.') . EOL );
|
||||||
else
|
else
|
||||||
$smallest = 1;
|
$smallest = 1;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +185,7 @@ if(! function_exists('profile_photo_content')) {
|
||||||
function profile_photo_content(&$a) {
|
function profile_photo_content(&$a) {
|
||||||
|
|
||||||
if(! local_user()) {
|
if(! local_user()) {
|
||||||
notice("Permission denied." . EOL );
|
notice( t('Permission denied.') . EOL );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,15 @@ function wall_upload_post(&$a) {
|
||||||
if($width > 640 || $height > 640) {
|
if($width > 640 || $height > 640) {
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 1 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 1 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($filename)),
|
dbesc(basename($filename)),
|
||||||
|
dbesc( t('Wall Photos') ),
|
||||||
intval($ph->getHeight()),
|
intval($ph->getHeight()),
|
||||||
intval($ph->getWidth()),
|
intval($ph->getWidth()),
|
||||||
dbesc($ph->imageString())
|
dbesc($ph->imageString())
|
||||||
|
@ -73,14 +74,15 @@ function wall_upload_post(&$a) {
|
||||||
if($width > 320 || $height > 320) {
|
if($width > 320 || $height > 320) {
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, `album`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 2 )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', 2 )",
|
||||||
intval($_SESSION['uid']),
|
intval($_SESSION['uid']),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
dbesc(basename($filename)),
|
dbesc(basename($filename)),
|
||||||
|
dbesc( t('Wall Photos') ),
|
||||||
intval($ph->getHeight()),
|
intval($ph->getHeight()),
|
||||||
intval($ph->getWidth()),
|
intval($ph->getWidth()),
|
||||||
dbesc($ph->imageString())
|
dbesc($ph->imageString())
|
||||||
|
|
Loading…
Reference in a new issue