Merge branch 'dev' into sabre32

This commit is contained in:
Mario Vavti 2016-06-24 11:25:20 +02:00
commit c8ae04a96a
26 changed files with 5136 additions and 4965 deletions

View File

@ -5,18 +5,18 @@ namespace Zotlabs\Lib;
class AbConfig { class AbConfig {
static public function Load($chash,$xhash) { static public function Load($chan,$xhash) {
$r = q("select * from abconfig where chan = '%s' and xchan = '%s'", $r = q("select * from abconfig where chan = %d and xchan = '%s'",
dbesc($chash), intval($chan),
dbesc($xhash) dbesc($xhash)
); );
return $r; return $r;
} }
static public function Get($chash,$xhash,$family,$key) { static public function Get($chan,$xhash,$family,$key) {
$r = q("select * from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' limit 1", $r = q("select * from abconfig where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' limit 1",
dbesc($chash), intval($chan),
dbesc($xhash), dbesc($xhash),
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)
@ -28,14 +28,14 @@ class AbConfig {
} }
static public function Set($chash,$xhash,$family,$key,$value) { static public function Set($chan,$xhash,$family,$key,$value) {
$dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_array($value)) ? serialize($value) : $value);
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
if(self::Get($chash,$xhash,$family,$key) === false) { if(self::Get($chan,$xhash,$family,$key) === false) {
$r = q("insert into abconfig ( chan, xchan, cat, k, v ) values ( '%s', '%s', '%s', '%s', '%s' ) ", $r = q("insert into abconfig ( chan, xchan, cat, k, v ) values ( %d, '%s', '%s', '%s', '%s' ) ",
dbesc($chash), intval($chan),
dbesc($xhash), dbesc($xhash),
dbesc($family), dbesc($family),
dbesc($key), dbesc($key),
@ -43,9 +43,9 @@ class AbConfig {
); );
} }
else { else {
$r = q("update abconfig set v = '%s' where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ", $r = q("update abconfig set v = '%s' where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' ",
dbesc($dbvalue), dbesc($dbvalue),
dbesc($chash), dbesc($chan),
dbesc($xhash), dbesc($xhash),
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)
@ -58,10 +58,10 @@ class AbConfig {
} }
static public function Delete($chash,$xhash,$family,$key) { static public function Delete($chan,$xhash,$family,$key) {
$r = q("delete from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ", $r = q("delete from abconfig where chan = %d and xchan = '%s' and cat = '%s' and k = '%s' ",
dbesc($chash), intval($chan),
dbesc($xhash), dbesc($xhash),
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)

46
Zotlabs/Lib/Cache.php Normal file
View File

@ -0,0 +1,46 @@
<?php /** @file */
namespace Zotlabs\Lib;
/**
* cache api
*/
class Cache {
public static function get($key) {
$r = q("SELECT v FROM cache WHERE k = '%s' limit 1",
dbesc($key)
);
if ($r)
return $r[0]['v'];
return null;
}
public static function set($key,$value) {
$r = q("SELECT * FROM cache WHERE k = '%s' limit 1",
dbesc($key)
);
if($r) {
q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'",
dbesc($value),
dbesc(datetime_convert()),
dbesc($key));
}
else {
q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')",
dbesc($key),
dbesc($value),
dbesc(datetime_convert()));
}
}
public static function clear() {
q("DELETE FROM cache WHERE updated < '%s'",
dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
}
}

112
Zotlabs/Lib/SuperCurl.php Normal file
View File

@ -0,0 +1,112 @@
<?php
namespace Zotlabs\Lib;
/**
* @brief wrapper for z_fetch_url() which can be instantiated with several built-in parameters and
* these can be modified and re-used. Useful for CalDAV and other processes which need to authenticate
* and set lots of CURL options (many of which stay the same from one call to the next).
*/
class SuperCurl {
private $auth;
private $url;
private $curlopt = array();
private $headers = null;
public $filepos = 0;
public $filehandle = 0;
public $request_data = '';
private $request_method = 'GET';
private $upload = false;
private function set_data($s) {
$this->request_data = $s;
$this->filepos = 0;
}
public function curl_read($ch,$fh,$size) {
if($this->filepos < 0) {
unset($fh);
return '';
}
$s = substr($this->request_data,$this->filepos,$size);
if(strlen($s) < $size)
$this->filepos = (-1);
else
$this->filepos = $this->filepos + $size;
return $s;
}
public function __construct($opts = array()) {
$this->set($opts);
}
private function set($opts = array()) {
if($opts) {
foreach($opts as $k => $v) {
switch($k) {
case 'http_auth':
$this->auth = $v;
break;
case 'custom':
$this->request_method = $v;
break;
case 'url':
$this->url = $v;
break;
case 'data':
$this->set_data($v);
if($v) {
$this->upload = true;
}
else {
$this->upload = false;
}
break;
case 'headers':
$this->headers = $v;
break;
default:
$this->curlopts[$k] = $v;
break;
}
}
}
}
function exec() {
$opts = $this->curlopts;
if($this->auth)
$opts['http_auth'] = $this->auth;
if($this->custom)
$opts['custom'] = $this->custom;
if($this->headers)
$opts['headers'] = $this->headers;
if($this->upload) {
$opts['upload'] = true;
$opts['infile'] = $this->filehandle;
$opts['infilesize'] = strlen($this->request_data);
$opts['readfunc'] = [ $this, 'curl_read' ] ;
}
$recurse = 0;
return z_fetch_url($this->url,true,$recurse,(($opts) ? $opts : null));
}
}

View File

@ -219,7 +219,7 @@ class Connedit extends \Zotlabs\Web\Controller {
//Update profile photo permissions //Update profile photo permissions
logger('A new profile was assigned - updating profile photos'); logger('A new profile was assigned - updating profile photos');
profile_photo_set_profile_perms($profile_id); profile_photo_set_profile_perms(local_channel(),$profile_id);
} }
@ -345,7 +345,7 @@ class Connedit extends \Zotlabs\Web\Controller {
unset($clone['abook_account']); unset($clone['abook_account']);
unset($clone['abook_channel']); unset($clone['abook_channel']);
$abconfig = load_abconfig($channel['channel_hash'],$clone['abook_xchan']); $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
if($abconfig) if($abconfig)
$clone['abconfig'] = $abconfig; $clone['abconfig'] = $abconfig;

View File

@ -43,7 +43,7 @@ class Follow extends \Zotlabs\Web\Controller {
unset($clone['abook_account']); unset($clone['abook_account']);
unset($clone['abook_channel']); unset($clone['abook_channel']);
$abconfig = load_abconfig($channel['channel_hash'],$clone['abook_xchan']); $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
if($abconfig) if($abconfig)
$clone['abconfig'] = $abconfig; $clone['abconfig'] = $abconfig;

View File

@ -389,8 +389,7 @@ class Import extends \Zotlabs\Web\Controller {
if($abconfig) { if($abconfig) {
// @fixme does not handle sync of del_abconfig // @fixme does not handle sync of del_abconfig
foreach($abconfig as $abc) { foreach($abconfig as $abc) {
if($abc['chan'] === $channel['channel_hash']) set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
} }
} }

View File

@ -32,10 +32,10 @@ class Pdledit extends \Zotlabs\Web\Controller {
else { else {
$o .= '<div class="generic-content-wrapper-styled">'; $o .= '<div class="generic-content-wrapper-styled">';
$o .= '<h1>' . t('Edit System Page Description') . '</h1>'; $o .= '<h1>' . t('Edit System Page Description') . '</h1>';
$files = glob('mod/*'); $files = glob('Zotlabs/Module/*.php');
if($files) { if($files) {
foreach($files as $f) { foreach($files as $f) {
$name = basename($f,'.php'); $name = lcfirst(basename($f,'.php'));
$x = theme_include('mod_' . $name . '.pdl'); $x = theme_include('mod_' . $name . '.pdl');
if($x) { if($x) {
$o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />'; $o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />';

View File

@ -53,7 +53,22 @@ class Profile_photo extends \Zotlabs\Web\Controller {
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo'); check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) { if((array_key_exists('postfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) {
// phase 2 - we have finished cropping
if(argc() != 2) {
notice( t('Image uploaded but image cropping failed.') . EOL );
return;
}
$image_id = argv(1);
if(substr($image_id,-2,1) == '-') {
$scale = substr($image_id,-1,1);
$image_id = substr($image_id,0,-2);
}
// unless proven otherwise // unless proven otherwise
$is_default_profile = 1; $is_default_profile = 1;
@ -71,24 +86,6 @@ class Profile_photo extends \Zotlabs\Web\Controller {
} }
logger('profile: ' . $_REQUEST['profile']);
// phase 2 - we have finished cropping
if(argc() != 2) {
notice( t('Image uploaded but image cropping failed.') . EOL );
return;
}
$image_id = argv(1);
if(substr($image_id,-2,1) == '-') {
$scale = substr($image_id,-1,1);
$image_id = substr($image_id,0,-2);
}
$srcX = $_POST['xstart']; $srcX = $_POST['xstart'];
$srcY = $_POST['ystart']; $srcY = $_POST['ystart'];
$srcW = $_POST['xfinal'] - $srcX; $srcW = $_POST['xfinal'] - $srcX;
@ -111,30 +108,38 @@ logger('profile: ' . $_REQUEST['profile']);
$aid = get_account_id(); $aid = get_account_id();
$p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'], $p = [
'filename' => $base_image['filename'], 'album' => t('Profile Photos')); 'aid' => $aid,
'uid' => local_channel(),
'resource_id' => $base_image['resource_id'],
'filename' => $base_image['filename'],
'album' => t('Profile Photos')
];
$p['imgscale'] = 4; $p['imgscale'] = PHOTO_RES_PROFILE_300;
$p['photo_usage'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL); $p['photo_usage'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL);
$r1 = $im->save($p); $r1 = $im->save($p);
$im->scaleImage(80); $im->scaleImage(80);
$p['imgscale'] = 5; $p['imgscale'] = PHOTO_RES_PROFILE_80;
$r2 = $im->save($p); $r2 = $im->save($p);
$im->scaleImage(48); $im->scaleImage(48);
$p['imgscale'] = 6; $p['imgscale'] = PHOTO_RES_PROFILE_48;
$r3 = $im->save($p); $r3 = $im->save($p);
if($r1 === false || $r2 === false || $r3 === false) { if($r1 === false || $r2 === false || $r3 === false) {
// if one failed, delete them all so we can start over. // if one failed, delete them all so we can start over.
notice( t('Image resize failed.') . EOL ); notice( t('Image resize failed.') . EOL );
$x = q("delete from photo where resource_id = '%s' and uid = %d and imgscale >= 4 ", $x = q("delete from photo where resource_id = '%s' and uid = %d and imgscale in ( %d, %d, %d ) ",
dbesc($base_image['resource_id']), dbesc($base_image['resource_id']),
local_channel() local_channel(),
intval(PHOTO_RES_PROFILE_300),
intval(PHOTO_RES_PROFILE_80),
intval(PHOTO_RES_PROFILE_48)
); );
return; return;
} }
@ -184,10 +189,7 @@ logger('profile: ' . $_REQUEST['profile']);
// Now copy profile-permissions to pictures, to prevent privacyleaks by automatically created folder 'Profile Pictures' // Now copy profile-permissions to pictures, to prevent privacyleaks by automatically created folder 'Profile Pictures'
profile_photo_set_profile_perms($_REQUEST['profile']); profile_photo_set_profile_perms(local_channel(),$_REQUEST['profile']);
} }
else else
notice( t('Unable to process image') . EOL); notice( t('Unable to process image') . EOL);
@ -197,6 +199,8 @@ logger('profile: ' . $_REQUEST['profile']);
return; // NOTREACHED return; // NOTREACHED
} }
// A new photo was uploaded. Store it and save some important details
// in App::$data for use in the cropping function
$hash = photo_new_resource(); $hash = photo_new_resource();
@ -221,7 +225,7 @@ logger('profile: ' . $_REQUEST['profile']);
$os_storage = false; $os_storage = false;
foreach($i as $ii) { foreach($i as $ii) {
if(intval($ii['imgscale']) < 2) { if(intval($ii['imgscale']) < PHOTO_RES_640) {
$smallest = intval($ii['imgscale']); $smallest = intval($ii['imgscale']);
$os_storage = intval($ii['os_storage']); $os_storage = intval($ii['os_storage']);
$imagedata = $ii['content']; $imagedata = $ii['content'];
@ -240,6 +244,9 @@ logger('profile: ' . $_REQUEST['profile']);
return $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest); return $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
// This will "fall through" to the get() method, and since
// App::$data['imagecrop'] is set, it will proceed to cropping
// rather than present the upload form
} }
@ -294,11 +301,11 @@ logger('profile: ' . $_REQUEST['profile']);
} }
$havescale = false; $havescale = false;
foreach($r as $rr) { foreach($r as $rr) {
if($rr['imgscale'] == 5) if($rr['imgscale'] == PHOTO_RES_PROFILE_80)
$havescale = true; $havescale = true;
} }
// set an already loaded photo as profile photo // set an already loaded and cropped photo as profile photo
if(($r[0]['album'] == t('Profile Photos')) && ($havescale)) { if(($r[0]['album'] == t('Profile Photos')) && ($havescale)) {
// unset any existing profile photos // unset any existing profile photos
@ -319,7 +326,7 @@ logger('profile: ' . $_REQUEST['profile']);
dbesc($channel['xchan_hash']) dbesc($channel['xchan_hash'])
); );
profile_photo_set_profile_perms(); // Reset default photo permissions to public profile_photo_set_profile_perms(local_channel()); // Reset default photo permissions to public
\Zotlabs\Daemon\Master::Summon(array('Directory',local_channel())); \Zotlabs\Daemon\Master::Summon(array('Directory',local_channel()));
goaway(z_root() . '/profiles'); goaway(z_root() . '/profiles');
} }
@ -351,7 +358,7 @@ logger('profile: ' . $_REQUEST['profile']);
if($i) { if($i) {
$hash = $i[0]['resource_id']; $hash = $i[0]['resource_id'];
foreach($i as $ii) { foreach($i as $ii) {
if(intval($ii['imgscale']) < 2) { if(intval($ii['imgscale']) < PHOTO_RES_640) {
$smallest = intval($ii['imgscale']); $smallest = intval($ii['imgscale']);
} }
} }
@ -359,9 +366,14 @@ logger('profile: ' . $_REQUEST['profile']);
} }
$this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest); $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
// falls through with App::$data['imagecrop'] set so we go straight to the cropping section
} }
$profiles = q("select id, profile_name as name, is_default from profile where uid = %d",
// present an upload form
$profiles = q("select id, profile_name as name, is_default from profile where uid = %d order by id asc",
intval(local_channel()) intval(local_channel())
); );
@ -388,6 +400,9 @@ logger('profile: ' . $_REQUEST['profile']);
return $o; return $o;
} }
else { else {
// present a cropping form
$filename = \App::$data['imagecrop'] . '-' . \App::$data['imagecrop_resolution']; $filename = \App::$data['imagecrop'] . '-' . \App::$data['imagecrop_resolution'];
$resolution = \App::$data['imagecrop_resolution']; $resolution = \App::$data['imagecrop_resolution'];
$tpl = get_markup_template("cropbody.tpl"); $tpl = get_markup_template("cropbody.tpl");
@ -425,13 +440,13 @@ logger('profile: ' . $_REQUEST['profile']);
if($max_length > 0) if($max_length > 0)
$ph->scaleImage($max_length); $ph->scaleImage($max_length);
$width = $ph->getWidth(); \App::$data['width'] = $ph->getWidth();
$height = $ph->getHeight(); \App::$data['height'] = $ph->getHeight();
if($width < 500 || $height < 500) { if(\App::$data['width'] < 500 || \App::$data['height'] < 500) {
$ph->scaleImageUp(400); $ph->scaleImageUp(400);
$width = $ph->getWidth(); \App::$data['width'] = $ph->getWidth();
$height = $ph->getHeight(); \App::$data['height'] = $ph->getHeight();
} }

View File

@ -97,7 +97,7 @@ class Profperm extends \Zotlabs\Web\Controller {
//Time to update the permissions on the profile-pictures as well //Time to update the permissions on the profile-pictures as well
profile_photo_set_profile_perms($profile['id']); profile_photo_set_profile_perms(local_channel(),$profile['id']);
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = '%s'", $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_profile = '%s'",
intval(local_channel()), intval(local_channel()),

View File

@ -45,7 +45,6 @@ class CalDAVClient {
} }
private function set_data($s) { private function set_data($s) {
logger('set data called');
$this->request_data = $s; $this->request_data = $s;
$this->filepos = 0; $this->filepos = 0;
} }

View File

@ -34,7 +34,6 @@ require_once('include/text.php');
require_once('include/datetime.php'); require_once('include/datetime.php');
require_once('include/language.php'); require_once('include/language.php');
require_once('include/nav.php'); require_once('include/nav.php');
require_once('include/cache.php');
require_once('include/permissions.php'); require_once('include/permissions.php');
require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php'); require_once('include/features.php');
@ -48,7 +47,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.9' ); define ( 'STD_VERSION', '1.9' );
define ( 'ZOT_REVISION', '1.1' ); define ( 'ZOT_REVISION', '1.1' );
define ( 'DB_UPDATE_VERSION', 1178 ); define ( 'DB_UPDATE_VERSION', 1179 );
/** /**

View File

@ -1,44 +0,0 @@
<?php /** @file */
/**
* cache api
*/
class Cache {
public static function get($key){
$r = q("SELECT v FROM cache WHERE k = '%s' limit 1",
dbesc($key)
);
if ($r)
return $r[0]['v'];
return null;
}
public static function set($key,$value) {
$r = q("SELECT * FROM cache WHERE k = '%s' limit 1",
dbesc($key)
);
if($r) {
q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'",
dbesc($value),
dbesc(datetime_convert()),
dbesc($key));
}
else {
q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')",
dbesc($key),
dbesc($value),
dbesc(datetime_convert()));
}
}
public static function clear(){
q("DELETE FROM cache WHERE updated < '%s'",
dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
}
}

View File

@ -516,7 +516,7 @@ function identity_basic_export($channel_id, $items = false) {
for($x = 0; $x < count($ret['abook']); $x ++) { for($x = 0; $x < count($ret['abook']); $x ++) {
$xchans[] = $ret['abook'][$x]['abook_chan']; $xchans[] = $ret['abook'][$x]['abook_chan'];
$abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']); $abconfig = load_abconfig($channel_id,$ret['abook'][$x]['abook_xchan']);
if($abconfig) if($abconfig)
$ret['abook'][$x]['abconfig'] = $abconfig; $ret['abook'][$x]['abconfig'] = $abconfig;
} }

View File

@ -98,20 +98,20 @@ function del_aconfig($account_id, $family, $key) {
} }
function load_abconfig($chash,$xhash) { function load_abconfig($chan,$xhash) {
Zlib\AbConfig::Load($chash,$xhash); Zlib\AbConfig::Load($chan,$xhash);
} }
function get_abconfig($chash,$xhash,$family,$key) { function get_abconfig($chan,$xhash,$family,$key) {
return Zlib\AbConfig::Get($chash,$xhash,$family,$key); return Zlib\AbConfig::Get($chan,$xhash,$family,$key);
} }
function set_abconfig($chash,$xhash,$family,$key,$value) { function set_abconfig($chan,$xhash,$family,$key,$value) {
return Zlib\AbConfig::Set($chash,$xhash,$family,$key,$value); return Zlib\AbConfig::Set($chan,$xhash,$family,$key,$value);
} }
function del_abconfig($chash,$xhash,$family,$key) { function del_abconfig($chan,$xhash,$family,$key) {
return Zlib\AbConfig::Delete($chash,$xhash,$family,$key); return Zlib\AbConfig::Delete($chan,$xhash,$family,$key);
} }
function load_iconfig(&$item) { function load_iconfig(&$item) {

View File

@ -1,6 +1,8 @@
<?php /** @file */ <?php /** @file */
use Zotlabs\Lib as Zlib;
function oembed_replacecb($matches){ function oembed_replacecb($matches){
$embedurl=$matches[1]; $embedurl=$matches[1];
@ -130,7 +132,7 @@ function oembed_fetch_url($embedurl){
$txt = null; $txt = null;
if($action !== 'block') { if($action !== 'block') {
$txt = Cache::get(App::$videowidth . $embedurl); $txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $embedurl);
if(strstr($txt,'youtu') && strstr(z_root(),'https:')) { if(strstr($txt,'youtu') && strstr(z_root(),'https:')) {
$txt = str_replace('http:','https:',$txt); $txt = str_replace('http:','https:',$txt);
@ -199,7 +201,7 @@ function oembed_fetch_url($embedurl){
//save in cache //save in cache
if(! get_config('system','oembed_cache_disable')) if(! get_config('system','oembed_cache_disable'))
Cache::set(App::$videowidth . $embedurl,$txt); Zlib\Cache::set('[' . App::$videowidth . '] ' . $embedurl,$txt);
} }

View File

@ -707,28 +707,44 @@ function gps2Num($coordPart) {
return floatval($parts[0]) / floatval($parts[1]); return floatval($parts[0]) / floatval($parts[1]);
} }
function profile_photo_set_profile_perms($profileid = '') { function profile_photo_set_profile_perms($uid, $profileid = 0) {
$allowcid = ''; $allowcid = '';
if (x($profileid)) { if($profileid) {
$r = q("SELECT photo, profile_guid, id, is_default, uid
$r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.id = %d OR profile.profile_guid = '%s' LIMIT 1", intval($profileid), dbesc($profileid)); FROM profile WHERE uid = %d and ( profile.id = %d OR profile.profile_guid = '%s') LIMIT 1",
intval($profileid),
} else { dbesc($profileid)
);
logger('Resetting permissions on default-profile-photo for user'.local_channel());
$r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.uid = %d AND is_default = 1 LIMIT 1", intval(local_channel()) ); //If no profile is given, we update the default profile
} }
else {
logger('Resetting permissions on default-profile-photo for user'.local_channel());
$r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile
WHERE profile.uid = %d AND is_default = 1 LIMIT 1",
intval($uid)
); //If no profile is given, we update the default profile
}
if(! $r)
return;
$profile = $r[0]; $profile = $r[0];
if(x($profile['id']) && x($profile['photo'])) {
if($profile['id'] && $profile['photo']) {
preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id); preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id);
$resource_id = $resource_id[0]; $resource_id = $resource_id[0];
if (intval($profile['is_default']) != 1) { if (! intval($profile['is_default'])) {
$r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1", intval(local_channel()) ); $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1",
$r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ", intval($profile['id'])); //Should not be needed in future. Catches old int-profile-ids. intval($uid)
$r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", dbesc($profile['profile_guid'])); );
//Should not be needed in future. Catches old int-profile-ids.
$r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ",
intval($profile['id'])
);
$r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'",
dbesc($profile['profile_guid'])
);
$allowcid = "<" . $r0[0]['channel_hash'] . ">"; $allowcid = "<" . $r0[0]['channel_hash'] . ">";
foreach ($r1 as $entry) { foreach ($r1 as $entry) {
$allowcid .= "<" . $entry['abook_xchan'] . ">"; $allowcid .= "<" . $entry['abook_xchan'] . ">";
@ -737,10 +753,19 @@ function profile_photo_set_profile_perms($profileid = '') {
$allowcid .= "<" . $entry['abook_xchan'] . ">"; $allowcid .= "<" . $entry['abook_xchan'] . ">";
} }
q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",dbesc($allowcid),dbesc($resource_id),intval($profile['uid'])); q("UPDATE photo SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",
dbesc($allowcid),
dbesc($resource_id),
intval($uid)
);
} else { }
q("UPDATE `photo` SET allow_cid = '' WHERE profile = 1 AND uid = %d",intval($profile['uid'])); //Reset permissions on default profile picture to public else {
//Reset permissions on default profile picture to public
q("UPDATE photo SET allow_cid = '' WHERE photo_usage = %d AND uid = %d",
intval(PHOTO_PROFILE),
intval($uid)
);
} }
} }

View File

@ -376,30 +376,6 @@ function unxmlify($s) {
return $ret; return $ret;
} }
/**
* Convenience wrapper, reverse the operation "bin2hex"
* This is a built-in function in php >= 5.4
*
* @FIXME We already have php >= 5.4 requirements, so can we remove this?
*/
if(! function_exists('hex2bin')) {
function hex2bin($s) {
if(! (is_string($s) && strlen($s)))
return '';
if(strlen($s) & 1) {
logger('hex2bin: illegal hex string: ' . $s);
return $s;
}
if(! ctype_xdigit($s)) {
return($s);
}
return(pack("H*",$s));
}}
// Automatic pagination. // Automatic pagination.
// To use, get the count of total items. // To use, get the count of total items.
// Then call App::set_pager_total($number_items); // Then call App::set_pager_total($number_items);
@ -1283,7 +1259,7 @@ function normalise_link($url) {
* is https and the other isn't, or if one is www.something and the other * is https and the other isn't, or if one is www.something and the other
* isn't - and also ignore case differences. * isn't - and also ignore case differences.
* *
* @see normalis_link() * @see normalise_link()
* *
* @param string $a * @param string $a
* @param string $b * @param string $b
@ -1635,7 +1611,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
function create_export_photo_body(&$item) { function create_export_photo_body(&$item) {
if(($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) { if(($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) {
$j = json_decode($item['object'],true); $j = json_decode($item['obj'],true);
if($j) { if($j) {
$item['body'] .= "\n\n" . (($j['body']) ? $j['body'] : $j['bbcode']); $item['body'] .= "\n\n" . (($j['body']) ? $j['body'] : $j['bbcode']);
$item['sig'] = ''; $item['sig'] = '';

View File

@ -552,7 +552,7 @@ function zot_refresh($them, $channel = null, $force = false) {
unset($new_connection[0]['abook_account']); unset($new_connection[0]['abook_account']);
unset($new_connection[0]['abook_channel']); unset($new_connection[0]['abook_channel']);
$abconfig = load_abconfig($channel['channel_hash'],$new_connection['abook_xchan']); $abconfig = load_abconfig($channel['channel_id'],$new_connection['abook_xchan']);
if($abconfig) if($abconfig)
$new_connection['abconfig'] = $abconfig; $new_connection['abconfig'] = $abconfig;
@ -3335,8 +3335,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if($abconfig) { if($abconfig) {
// @fixme does not handle sync of del_abconfig // @fixme does not handle sync of del_abconfig
foreach($abconfig as $abc) { foreach($abconfig as $abc) {
if($abc['chan'] === $channel['channel_hash']) set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
} }
} }
} }

View File

@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS `abconfig` ( CREATE TABLE IF NOT EXISTS `abconfig` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`chan` char(255) NOT NULL DEFAULT '', `chan` int(10) unsigned NOT NULL DEFAULT '',
`xchan` char(255) NOT NULL DEFAULT '', `xchan` char(255) NOT NULL DEFAULT '',
`cat` char(255) NOT NULL DEFAULT '', `cat` char(255) NOT NULL DEFAULT '',
`k` char(255) NOT NULL DEFAULT '', `k` char(255) NOT NULL DEFAULT '',

View File

@ -1,6 +1,6 @@
CREATE TABLE "abconfig" ( CREATE TABLE "abconfig" (
"id" serial NOT NULL, "id" serial NOT NULL,
"chan" text NOT NULL, "chan" bigint NOT NULL,
"xchan" text NOT NULL, "xchan" text NOT NULL,
"cat" text NOT NULL, "cat" text NOT NULL,
"k" text NOT NULL, "k" text NOT NULL,

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1178 ); define( 'UPDATE_VERSION' , 1179 );
/** /**
* *
@ -2325,3 +2325,39 @@ function update_r1177() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; return UPDATE_FAILED;
} }
function update_r1178() {
$c2 = null;
$c1 = q("SELECT channel_id, channel_hash from channel where true");
if($c1) {
$c2 = q("SELECT id, chan from abconfig where true");
if($c2) {
for($x = 0; $x < count($c2); $x ++) {
foreach($c1 as $c) {
if($c['channel_hash'] == $c2[$x]['chan']) {
$c2[$x]['chan'] = $c['channel_id'];
break;
}
}
}
}
}
$r1 = q("ALTER TABLE abconfig CHANGE chan chan int(10) unsigned NOT NULL DEFAULT '0' ");
if($c2) {
foreach($c2 as $c) {
q("UPDATE abconfig SET chan = %d where id = %d",
intval($c['chan']),
intval($c['id'])
);
}
}
if($r1)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
{{/if}} {{/if}}
<div class="wall-item-head"> <div class="wall-item-head">
<div class="wall-item-info" id="wall-item-info-{{$item.id}}" > <div class="wall-item-info" id="wall-item-info-{{$item.id}}" >
<div class="wall-item-photo-wrapper{{if $item.owner_url}} wwfrom{{/if}} h-card" id="wall-item-photo-wrapper-{{$item.id}}"> <div class="wall-item-photo-wrapper{{if $item.owner_url}} wwfrom{{/if}} h-card p-author" id="wall-item-photo-wrapper-{{$item.id}}">
<a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-photo-link u-url" id="wall-item-photo-link-{{$item.id}}"><img src="{{$item.thumb}}" class="wall-item-photo{{$item.sparkle}} u-photo p-name" id="wall-item-photo-{{$item.id}}" alt="{{$item.name}}" /></a> <a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-photo-link u-url" id="wall-item-photo-link-{{$item.id}}"><img src="{{$item.thumb}}" class="wall-item-photo{{$item.sparkle}} u-photo p-name" id="wall-item-photo-{{$item.id}}" alt="{{$item.name}}" /></a>
</div> </div>
<div class="wall-item-photo-end" style="clear:both"></div> <div class="wall-item-photo-end" style="clear:both"></div>
@ -133,7 +133,7 @@
<li role="presentation"><a role="menuitem" href="#" onclick="jotShare({{$item.id}}); return false"><i class="fa fa-retweet" title="{{$item.share.0}}"></i> {{$item.share.0}}</a></li> <li role="presentation"><a role="menuitem" href="#" onclick="jotShare({{$item.id}}); return false"><i class="fa fa-retweet" title="{{$item.share.0}}"></i> {{$item.share.0}}</a></li>
{{/if}} {{/if}}
{{if $item.plink}} {{if $item.plink}}
<li role="presentation"><a role="menuitem" href="{{$item.plink.href}}" title="{{$item.plink.title}}" ><i class="fa fa-external-link"></i> {{$item.plink.title}}</a></li> <li role="presentation"><a role="menuitem" href="{{$item.plink.href}}" title="{{$item.plink.title}}" class="u-url"><i class="fa fa-external-link"></i> {{$item.plink.title}}</a></li>
{{/if}} {{/if}}
{{if $item.edpost}} {{if $item.edpost}}
<li role="presentation"><a role="menuitem" href="{{$item.edpost.0}}" title="{{$item.edpost.1}}"><i class="editpost fa fa-pencil"></i> {{$item.edpost.1}}</a></li> <li role="presentation"><a role="menuitem" href="{{$item.edpost.0}}" title="{{$item.edpost.1}}"><i class="editpost fa fa-pencil"></i> {{$item.edpost.1}}</a></li>

View File

@ -28,7 +28,7 @@
minWidth: 240, minWidth: 240,
minHeight: 87, minHeight: 87,
maxWidth: 320, maxWidth: 320,
maxHeight: 320, maxHeight: 116,
ratioDim: { x: 100, y:36 }, ratioDim: { x: 100, y:36 },
displayOnInit: true, displayOnInit: true,
onEndCrop: onEndCrop onEndCrop: onEndCrop

View File

@ -17,7 +17,7 @@
</button> </button>
{{/if}} {{/if}}
{{if $userinfo}} {{if $userinfo}}
<img class="dropdown-toggle fakelink" data-toggle="dropdown" id="avatar" src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"><span class="caret" id="usermenu-caret"></span> <img class="dropdown-toggle fakelink" data-toggle="dropdown" id="avatar" src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"><span class="caret dropdown-toggle fakelink" data-toggle="dropdown" id="usermenu-caret"></span>
{{if $localuser}} {{if $localuser}}
<ul class="dropdown-menu" role="menu" aria-labelledby="avatar"> <ul class="dropdown-menu" role="menu" aria-labelledby="avatar">
{{foreach $nav.usermenu as $usermenu}} {{foreach $nav.usermenu as $usermenu}}