5 * Description: Diabook-red: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu
11 //change css on network and profilepages
16 * prints last community activity
18 function diabook_red_community_info(){
20 //right_aside at networkpages
23 $aside['$lastusers_title'] = t('Last users');
24 $aside['$lastusers_items'] = array();
26 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
27 $order = " ORDER BY `register_date` DESC ";
29 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
30 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
31 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
35 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
39 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
40 $entry = replace_macros($tpl,array(
42 '$profile-link' => $profile_link,
43 '$photo' => $rr[$photo],
44 '$alt-text' => $rr['name'],
46 $aside['$lastusers_items'][] = $entry;
51 // last 10 liked items
52 $aside['$like_title'] = t('Last likes');
53 $aside['$like_items'] = array();
54 $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
55 (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
56 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
57 INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
58 WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
60 ORDER BY `T1`.`created` DESC
62 $a->get_baseurl(),$a->get_baseurl()
66 $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
67 $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
69 //var_dump($rr['verb'],$rr['object-type']); killme();
71 case 'http://activitystrea.ms/schema/1.0/post':
72 switch ($rr['object-type']){
73 case 'http://activitystrea.ms/schema/1.0/event':
74 $post_type = t('event');
77 $post_type = t('status');
81 if ($rr['resource-id']){
82 $post_type = t('photo');
83 $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
86 $post_type = t('status');
89 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
91 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
97 $aside['$photos_title'] = t('Last photos');
98 $aside['$photos_items'] = array();
99 $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM
100 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`
101 WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
102 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
103 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
105 WHERE `user`.`uid` = `photo`.`uid`
106 AND `user`.`blockwall`=0
107 AND `user`.`hidewall`=0
108 ORDER BY `photo`.`edited` DESC
110 dbesc(t('Contact Photos')),
111 dbesc(t('Profile Photos'))
114 $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
116 $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
117 $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
119 $entry = replace_macros($tpl,array(
121 '$profile-link' => $photo_page,
122 '$photo' => $photo_url,
123 '$alt-text' => $rr['username']." : ".$rr['desc'],
126 $aside['$photos_items'][] = $entry;
130 $fostitJS = "javascript: (function() {
131 the_url = '".$a->get_baseurl($ssl_state)."/view/theme/diabook-red/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));
132 a_funct = function() {
133 if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url};
134 if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0)}
135 else {a_funct()}})()" ;
137 $aside['$fostitJS'] = $fostitJS;
142 $nv['directory'] = Array('directory', t('Local').' '.t('Directory'), "", "");
143 $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
144 $nv['match'] = Array('match', t('Similar Interests'), "", "");
145 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
146 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
148 $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
149 <span class="sbox_l"></span>
151 <input type="text" name="search" size="13" maxlength="50">
153 <span class="sbox_r" id="srch_clear"></span>';
159 $page = '<div id="page-sidebar-right_aside" class="widget">
160 <div class="title tool">
161 <h3>'.t("Community Pages").'<a id="close_pages_icon" onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
162 <div id="sidebar-page-list"><ul>';
166 $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
167 WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d",
168 intval($a->user['uid'])
173 // Look if the profile is a community page
174 foreach($contacts as $contact) {
175 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
181 foreach($contacts as $contact) {
182 $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">'.
183 $contact["name"]."</a></li>";
185 $page .= '</ul></div></div>';
186 //if (sizeof($contacts) > 0)
188 $aside['$page'] = $page;
194 $url = $a->get_baseurl($ssl_state);
195 $aside['$url'] = $url;
197 $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
198 $a->page['right_aside'] = replace_macros($tpl, $aside);
203 //profile_side at networkpages
204 if ($a->argv[0] === "network" && local_user()){
209 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
212 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
213 'name' => $a->user['username'],
215 $ps = array('usermenu'=>array());
216 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
217 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
218 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));
219 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
220 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
221 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
222 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
223 $ps['usermenu']['pgroups'] = Array('http://dir.friendika.com/directory/forum', t('Community Pages'), "", "");
225 $tpl = get_markup_template('profile_side.tpl');
227 $a->page['aside'] .= replace_macros($tpl, array(
228 '$userinfo' => $userinfo,
234 $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'];
236 if($ccCookie != "8") {
238 diabook_red_community_info();
241 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-red/style-network.css";
247 //right_aside at profile pages
248 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
249 if($ccCookie != "8") {
251 diabook_red_community_info();
254 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-red/style-profile.css";
259 //tabs at right_aside on settings page
260 if ($a->argv[0] === "settings"){
264 'label' => t('Account settings'),
265 'url' => $a->get_baseurl(true).'/settings',
266 'sel' => (($a->argc == 1)?'active':''),
269 'label' => t('Display settings'),
270 'url' => $a->get_baseurl(true).'/settings/display',
271 'sel' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
274 'label' => t('Edit/Manage Profiles'),
275 'url' => $a->get_baseurl(true).'/profiles',
278 'label' => t('Connector settings'),
279 'url' => $a->get_baseurl(true).'/settings/connectors',
280 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
283 'label' => t('Plugin settings'),
284 'url' => $a->get_baseurl(true).'/settings/addon',
285 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
288 'label' => t('Connections'),
289 'url' => $a->get_baseurl(true) . '/settings/oauth',
290 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
293 'label' => t('Export personal data'),
294 'url' => $a->get_baseurl(true) . '/uexport',
298 $tabtpl = file_get_contents(dirname(__file__).'/rs_common_tabs.tpl') ;
299 $a->page['aside'] = replace_macros($tabtpl, array(
305 $cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook-red/style-settings.css";
311 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
313 //load jquery.cookie.js
314 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook-red/js/jquery.cookie.js";
315 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $cookieJS);
320 $a->page['htmlhead'] .= <<< EOT
324 $('a.lightbox').fancybox(); // Select all links with lightbox class
332 $("right_aside").ready(function(){
334 if($.cookie('close_pages') == '1')
336 document.getElementById( "close_pages" ).style.display = "none";
339 if($.cookie('close_helpers') == '1')
341 document.getElementById( "close_helpers" ).style.display = "none";
344 if($.cookie('close_services') == '1')
346 document.getElementById( "close_services" ).style.display = "none";
349 if($.cookie('close_friends') == '1')
351 document.getElementById( "close_friends" ).style.display = "none";
354 if($.cookie('close_postit') == '1')
356 document.getElementById( "close_postit" ).style.display = "none";
359 if($.cookie('close_lastusers') == '1')
361 document.getElementById( "close_lastusers" ).style.display = "none";
364 if($.cookie('close_lastphotos') == '1')
366 document.getElementById( "close_lastphotos" ).style.display = "none";
369 if($.cookie('close_lastlikes') == '1')
371 document.getElementById( "close_lastlikes" ).style.display = "none";
376 function close_pages(){
377 document.getElementById( "close_pages" ).style.display = "none";
378 $.cookie('close_pages','1', { expires: 365, path: '/' });
381 function close_helpers(){
382 document.getElementById( "close_helpers" ).style.display = "none";
383 $.cookie('close_helpers','1', { expires: 365, path: '/' });
386 function close_services(){
387 document.getElementById( "close_services" ).style.display = "none";
388 $.cookie('close_services','1', { expires: 365, path: '/' });
391 function close_friends(){
392 document.getElementById( "close_friends" ).style.display = "none";
393 $.cookie('close_friends','1', { expires: 365, path: '/' });
396 function close_postit(){
397 document.getElementById( "close_postit" ).style.display = "none";
398 $.cookie('close_postit','1', { expires: 365, path: '/' });
401 function close_lastusers(){
402 document.getElementById( "close_lastusers" ).style.display = "none";
403 $.cookie('close_lastusers','1', { expires: 365, path: '/' });
406 function close_lastphotos(){
407 document.getElementById( "close_lastphotos" ).style.display = "none";
408 $.cookie('close_lastphotos','1', { expires: 365, path: '/' });
411 function close_lastlikes(){
412 document.getElementById( "close_lastlikes" ).style.display = "none";
413 $.cookie('close_lastlikes','1', { expires: 365, path: '/' });
416 function restore_boxes(){
417 $.cookie('close_pages','2', { expires: 365, path: '/' });
418 $.cookie('close_helpers','2', { expires: 365, path: '/' });
419 $.cookie('close_services','2', { expires: 365, path: '/' });
420 $.cookie('close_friends','2', { expires: 365, path: '/' });
421 $.cookie('close_postit','2', { expires: 365, path: '/' });
422 $.cookie('close_lastusers','2', { expires: 365, path: '/' });
423 $.cookie('close_lastphotos','2', { expires: 365, path: '/' });
424 $.cookie('close_lastlikes','2', { expires: 365, path: '/' });
425 alert('Right-hand column was restored. Please refresh your browser');