5 * Description: Diabook: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu
12 //change css on network and profilepages
17 * prints last community activity
22 function diabook_community_info(){
24 //right_aside at networkpages
27 $aside['$lastusers_title'] = t('Last users');
28 $aside['$lastusers_items'] = array();
30 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
31 $order = " ORDER BY `register_date` DESC ";
33 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
34 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
35 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
39 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
43 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
44 $entry = replace_macros($tpl,array(
46 '$profile-link' => $profile_link,
47 '$photo' => $rr[$photo],
48 '$alt-text' => $rr['name'],
50 $aside['$lastusers_items'][] = $entry;
55 // last 10 liked items
56 $aside['$like_title'] = t('Last likes');
57 $aside['$like_items'] = array();
58 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
59 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
60 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
61 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
62 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
64 ORDER BY `T1`.`created` DESC
66 $a->get_baseurl(),$a->get_baseurl()
70 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
71 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
73 //var_dump($rr['verb'],$rr['object-type']); killme();
75 case 'http://activitystrea.ms/schema/1.0/post':
76 switch ($rr['object-type']){
77 case 'http://activitystrea.ms/schema/1.0/event':
78 $post_type = t('event');
81 $post_type = t('status');
85 if ($rr['resource-id']){
86 $post_type = t('photo');
87 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
90 $post_type = t('status');
93 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
95 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
101 $aside['$photos_title'] = t('Last photos');
102 $aside['$photos_items'] = array();
103 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
104 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
105 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
106 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
107 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
109 WHERE `user`.`uid` = `photo`.`uid`
110 AND `user`.`blockwall`=0
111 AND `user`.`hidewall`=0
112 ORDER BY `photo`.`edited` DESC
114 dbesc(t('Contact Photos')),
115 dbesc(t('Profile Photos'))
118 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
120 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
121 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
123 $entry = replace_macros($tpl,array(
125 '$profile-link' => $photo_page,
126 '$photo' => $photo_url,
127 '$alt-text' => $rr['username']." : ".$rr['desc'],
130 $aside['$photos_items'][] = $entry;
134 $fostitJS = "javascript: (function() {
135 the_url = '".$a->get_baseurl($ssl_state)."/view/theme/diabook/fpostit/fpostit.php?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title) + '&text=' + encodeURIComponent(''+(window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text));
136 a_funct = function() {
137 if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url};
138 if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0)}
139 else {a_funct()}})()" ;
141 $aside['$fostitJS'] = $fostitJS;
143 //right_aside FIND FRIENDS
146 $nv['directory'] = Array('directory', t('Directory'), "", "");
147 $nv['match'] = Array('match', t('Similar Interests'), "", "");
148 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
149 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
151 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
152 <span class="sbox_l"></span>
154 <input type="text" name="search" size="13" maxlength="50">
156 <span class="sbox_r" id="srch_clear"></span>';
163 $page = '<div id="page-sidebar-right_aside" class="widget">
164 <div class="title tool">
165 <h3>'.t("Community Pages").'<a id="close_pages_icon" onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
166 <div id="sidebar-page-list"><ul>';
170 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
171 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d",
172 intval($a->user['uid'])
177 // Look if the profile is a community page
178 foreach($contacts as $contact) {
179 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
185 foreach($contacts as $contact) {
186 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
187 $contact["name"]."</a></li>";
189 $page .= '</ul></div></div>';
190 //if (sizeof($contacts) > 0)
192 $aside['$page'] = $page;
197 $url = $a->get_baseurl($ssl_state);
198 $aside['$url'] = $url;
200 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
201 $a->page['right_aside'] = replace_macros($tpl, $aside);
209 //profile_side at networkpages
210 if ($a->argv[0] === "network" && local_user()){
215 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
218 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
219 'name' => $a->user['username'],
221 $ps = array('usermenu'=>array());
222 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
223 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
224 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
225 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
226 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
227 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
228 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
229 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
231 $tpl = get_markup_template('profile_side.tpl');
233 $a->page['aside'] .= replace_macros($tpl, array(
234 '$userinfo' => $userinfo,
240 $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_postit'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
242 if($ccCookie != "8") {
244 diabook_community_info();
247 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-network.css";
253 //right_aside at profile pages
254 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
255 if($ccCookie != "8") {
257 diabook_community_info();
260 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-profile.css";
266 //tabs at right_aside on settings page
267 if ($a->argv[0] === "settings"){
271 'label' => t('Account settings'),
272 'url' => $a->get_baseurl(true).'/settings',
273 'sel' => (($a->argc == 1)?'active':''),
276 'label' => t('Display settings'),
277 'url' => $a->get_baseurl(true).'/settings/display',
278 'sel' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
281 'label' => t('Edit/Manage Profiles'),
282 'url' => $a->get_baseurl(true).'/profiles',
285 'label' => t('Connector settings'),
286 'url' => $a->get_baseurl(true).'/settings/connectors',
287 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
290 'label' => t('Plugin settings'),
291 'url' => $a->get_baseurl(true).'/settings/addon',
292 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
295 'label' => t('Connections'),
296 'url' => $a->get_baseurl(true) . '/settings/oauth',
297 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
300 'label' => t('Export personal data'),
301 'url' => $a->get_baseurl(true) . '/uexport',
305 $tabtpl = file_get_contents(dirname(__file__).'/rs_common_tabs.tpl') ;
306 $a->page['aside'] = replace_macros($tabtpl, array(
312 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook/style-settings.css";
317 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
319 //load jquery.cookie.js
320 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-blue/js/jquery.cookie.js";
321 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $cookieJS);
325 $a->page['htmlhead'] .= <<< EOT
329 $('a.lightbox').fancybox(); // Select all links with lightbox class
336 $("right_aside").ready(function(){
338 if($.cookie('close_pages') == '1')
340 document.getElementById( "close_pages" ).style.display = "none";
343 if($.cookie('close_helpers') == '1')
345 document.getElementById( "close_helpers" ).style.display = "none";
348 if($.cookie('close_services') == '1')
350 document.getElementById( "close_services" ).style.display = "none";
353 if($.cookie('close_friends') == '1')
355 document.getElementById( "close_friends" ).style.display = "none";
358 if($.cookie('close_postit') == '1')
360 document.getElementById( "close_postit" ).style.display = "none";
363 if($.cookie('close_lastusers') == '1')
365 document.getElementById( "close_lastusers" ).style.display = "none";
368 if($.cookie('close_lastphotos') == '1')
370 document.getElementById( "close_lastphotos" ).style.display = "none";
373 if($.cookie('close_lastlikes') == '1')
375 document.getElementById( "close_lastlikes" ).style.display = "none";
380 function close_pages(){
381 document.getElementById( "close_pages" ).style.display = "none";
382 $.cookie('close_pages','1', { expires: 365, path: '/' });
385 function close_helpers(){
386 document.getElementById( "close_helpers" ).style.display = "none";
387 $.cookie('close_helpers','1', { expires: 365, path: '/' });
390 function close_services(){
391 document.getElementById( "close_services" ).style.display = "none";
392 $.cookie('close_services','1', { expires: 365, path: '/' });
395 function close_friends(){
396 document.getElementById( "close_friends" ).style.display = "none";
397 $.cookie('close_friends','1', { expires: 365, path: '/' });
400 function close_postit(){
401 document.getElementById( "close_postit" ).style.display = "none";
402 $.cookie('close_postit','1', { expires: 365, path: '/' });
405 function close_lastusers(){
406 document.getElementById( "close_lastusers" ).style.display = "none";
407 $.cookie('close_lastusers','1', { expires: 365, path: '/' });
410 function close_lastphotos(){
411 document.getElementById( "close_lastphotos" ).style.display = "none";
412 $.cookie('close_lastphotos','1', { expires: 365, path: '/' });
415 function close_lastlikes(){
416 document.getElementById( "close_lastlikes" ).style.display = "none";
417 $.cookie('close_lastlikes','1', { expires: 365, path: '/' });
422 function restore_boxes(){
423 $.cookie('close_pages','2', { expires: 365, path: '/' });
424 $.cookie('close_helpers','2', { expires: 365, path: '/' });
425 $.cookie('close_services','2', { expires: 365, path: '/' });
426 $.cookie('close_friends','2', { expires: 365, path: '/' });
427 $.cookie('close_postit','2', { expires: 365, path: '/' });
428 $.cookie('close_lastusers','2', { expires: 365, path: '/' });
429 $.cookie('close_lastphotos','2', { expires: 365, path: '/' });
430 $.cookie('close_lastlikes','2', { expires: 365, path: '/' });
431 alert('Right-hand column was restored. Please refresh your browser');