From 93e5449c0843494c49ae799fa044299ca5cdeb6d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 12 Nov 2015 20:22:36 -0800 Subject: really basic photo album widget for content regions --- include/widgets.php | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 0f61a04a0..5a135ae52 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1221,3 +1221,81 @@ function widget_admin($arr) { return $o; } + + + +function widget_album($args) { + + $owner_uid = get_app()->profile_uid; + $sql_extra = permissions_sql($owner_uid); + + if($args['album']) + $album = $args['album']; + if($args['title']) + $title = $args['title']; + + $order = 'DESC'; + + $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN + (SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph + ON (p.resource_id = ph.resource_id AND p.scale = ph.scale) + ORDER BY created $order ", + intval($owner_uid), + dbesc($album), + intval(PHOTO_NORMAL), + intval(PHOTO_PROFILE) + ); + + //edit album name + $album_edit = null; + + + $photos = array(); + if($r) { + $twist = 'rotright'; + foreach($r as $rr) { + + if($twist == 'rotright') + $twist = 'rotleft'; + else + $twist = 'rotright'; + + $ext = $phototypes[$rr['type']]; + + $imgalt_e = $rr['filename']; + $desc_e = $rr['description']; + + $imagelink = (z_root() . '/photos/' . get_app()->profile['channel_address'] . '/image/' . $rr['resource_id']); + + + $photos[] = array( + 'id' => $rr['id'], + 'twist' => ' ' . $twist . rand(2,4), + 'link' => $imagelink, + 'title' => t('View Photo'), + 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext, + 'alt' => $imgalt_e, + 'desc'=> $desc_e, + 'ext' => $ext, + 'hash'=> $rr['resource_id'], + 'unknown' => t('Unknown') + ); + } + } + + + $tpl = get_markup_template('photo_album.tpl'); + $o .= replace_macros($tpl, array( + '$photos' => $photos, + '$album' => (($title) ? $title : $album), + '$album_edit' => array(t('Edit Album'), $album_edit), + '$can_post' => false, + '$upload' => array(t('Upload'), z_root() . '/photos/' . get_app()->profile['channel_address'] . '/upload/' . bin2hex($album)), + '$order' => false, + '$upload_form' => $upload_form, + '$usage' => $usage_message + )); + + return $o; +} + -- cgit v1.2.3 From a06f7fbe2e78de428489d824c1329ef29c4d1f42 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 17 Nov 2015 15:03:27 -0800 Subject: photo album widget permissions issue --- include/widgets.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 5a135ae52..fc6fee2ef 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1229,6 +1229,10 @@ function widget_album($args) { $owner_uid = get_app()->profile_uid; $sql_extra = permissions_sql($owner_uid); + + if(! perm_is_allowed($owner_uid,get_observer_hash(),'view_storage')) + return ''; + if($args['album']) $album = $args['album']; if($args['title']) -- cgit v1.2.3 From 68da4d90dcbda1240ae014768a66a164fd5d2b36 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 17 Nov 2015 20:44:57 -0800 Subject: fix admin plugin hooks --- include/widgets.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index fc6fee2ef..2b1fb2859 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1238,6 +1238,23 @@ function widget_album($args) { if($args['title']) $title = $args['title']; + /** + * This may return incorrect permissions if you have multiple directories of the same name. + * It is a limitation of the photo table using a name for a photo album instead of a folder hash + */ + + if($album) { + $x = q("select hash from attach where filename = '%s' and uid = %d limit 1", + dbesc($album), + intval($owner_uid) + ); + if($x) { + $y = attach_can_view_folder($owner_uid,get_observer_hash(),$x[0]['hash']); + if(! $y) + return ''; + } + } + $order = 'DESC'; $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN -- cgit v1.2.3 From 106b3257e42b25e0e103a4d6e3cb1609a2004de6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 18 Nov 2015 02:45:22 -0800 Subject: wsod viewing photo widget --- include/widgets.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 2b1fb2859..3f8e1f18c 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -7,6 +7,7 @@ require_once('include/dir_fns.php'); require_once('include/contact_widgets.php'); +require_once('include/attach.php'); function widget_profile($args) { -- cgit v1.2.3 From e4145deeb7a72ac321113fde672e1b499ecb0d2d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 18 Nov 2015 23:50:42 +0100 Subject: some events refacturing --- include/widgets.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 2b1fb2859..5358fcbb9 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -661,6 +661,21 @@ function widget_conversations($arr) { return $o; } +function widget_eventsmenu($arr) { + if (! local_channel()) + return; + + return replace_macros(get_markup_template('events_side.tpl'), array( + '$title' => t('Events Menu'), + '$day' => t('Day'), + '$week' => t('Week'), + '$month' => t('Month'), + '$today' => t('Today'), + '$export' => t('Export'), + '$upload' => t('Import'), + '$submit' => t('Submit') + )); +} function widget_design_tools($arr) { $a = get_app(); -- cgit v1.2.3 From a17f280f7da6d99287f2ed837f4ca9cc14a74da9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 19 Nov 2015 00:10:32 +0100 Subject: rename some menus --- include/widgets.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 2724b42aa..f979ef2c4 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -668,9 +668,9 @@ function widget_eventsmenu($arr) { return replace_macros(get_markup_template('events_side.tpl'), array( '$title' => t('Events Menu'), - '$day' => t('Day'), - '$week' => t('Week'), - '$month' => t('Month'), + '$day' => t('Day View'), + '$week' => t('Week View'), + '$month' => t('Month View'), '$today' => t('Today'), '$export' => t('Export'), '$upload' => t('Import'), -- cgit v1.2.3 From ba52af786e0e2f27c36e82df9086dfb8d33d9062 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 19 Nov 2015 11:38:34 +0100 Subject: move today button from aside to section title --- include/widgets.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index f979ef2c4..a3f7444ec 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -671,7 +671,6 @@ function widget_eventsmenu($arr) { '$day' => t('Day View'), '$week' => t('Week View'), '$month' => t('Month View'), - '$today' => t('Today'), '$export' => t('Export'), '$upload' => t('Import'), '$submit' => t('Submit') -- cgit v1.2.3