source: trunk/member_menu_queries.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 4.7 KB
Line 
1<?php
2
3header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
4header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
5header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
6header("Pragma: no-cache"); // HTTP/1.0
7
8require_once( 'inc/header.inc.php' );
9require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
10require_once( BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php' );
11
12bx_import('BxTemplMemberMenu');
13bx_import('BxDolPageView');
14
15$oMemberMenu = new BxTemplMemberMenu();
16
17// return member's extra menu sub block ;
18if ( isset($_GET['action']) ) {
19
20 // read data from cache file ;
21 if( file_exists($oMemberMenu -> sMenuCacheFile) && filesize($oMemberMenu -> sMenuCacheFile) ) {
22 $aMenuStructure = unserialize(file_get_contents($oMemberMenu -> sMenuCacheFile));
23 }
24
25 // if cache file defined;
26 if ($aMenuStructure) {
27
28 $iMemberId = ( isset($_COOKIE['memberID']) )
29 ? (int) $_COOKIE['memberID']
30 : 0 ;
31
32 $iMenuId = ( isset($_GET['menu_id']) )
33 ? (int) $_GET['menu_id']
34 : 0 ;
35
36 $sOutputHtml = null;
37 switch( $_GET['action'] ) {
38
39 case 'get_menu_content' :
40 if ($iMemberId && $iMenuId) {
41
42 // define the menu's sub menu code ;
43 $sSubMenuCode = null;
44 $aLinkedItems = array();
45
46 foreach($aMenuStructure as $sKey => $aItems)
47 {
48 if( isset($aMenuStructure[$sKey][$iMenuId]) ) {
49 $sSubMenuCode = $aMenuStructure[$sKey][$iMenuId]['PopupMenu'];
50 if($aMenuStructure[$sKey][$iMenuId]['linked_items']) {
51 $aLinkedItems = $aMenuStructure[$sKey][$iMenuId]['linked_items'];
52 }
53 break;
54 }
55 }
56
57 if ($sSubMenuCode) {
58 $sOutputHtml = $oMemberMenu -> getSubMenuContent ($iMemberId, $sSubMenuCode, $aLinkedItems);
59 }
60 }
61 break;
62
63 case 'get_bubbles_values' :
64 $sBubbles = ( isset($_GET['bubbles']) ) ? $_GET['bubbles'] : null;
65 if ( $sBubbles && $iMemberId ) {
66
67 $aMemberInfo = getProfileInfo($iMemberId);
68 if($aMemberInfo['UserStatus'] != 'offline') {
69 // update the date of last navigate;
70 $sQuery = "UPDATE `Profiles` SET `DateLastNav` = NOW() WHERE `ID` = '{$iMemberId}'";
71 db_res($sQuery);
72 }
73
74 $aBubbles = array();
75 $aBubblesItems = explode(',', $sBubbles);
76
77 if ( $aBubblesItems && is_array($aBubblesItems) ) {
78 foreach( $aBubblesItems as $sValue)
79 {
80 $aItem = explode(':', $sValue);
81
82 $sBubbleCode = null;
83 foreach($aMenuStructure as $sKey => $aItems)
84 {
85 foreach($aItems as $iKey => $aSubItems)
86 {
87 if( $aSubItems['Name'] == $aItem[0]) {
88 $sBubbleCode = $aSubItems['Bubble'];
89 break;
90 }
91 }
92
93 if ($sBubbleCode) {
94 break;
95 }
96 }
97
98 if ($sBubbleCode) {
99 $sCode = str_replace('{iOldCount}', $aItem[1], $sBubbleCode);
100 $sCode = str_replace('{ID}', $iMemberId, $sCode);
101
102 eval($sCode);
103 $aBubbles[$aItem[0]] = array (
104 'count' => $aRetEval['count'],
105 'messages' => $aRetEval['messages'],
106 'onlclick_script' => ( isset($aRetEval['onlclick_script'])
107 && $aRetEval['onlclick_script']) ? $aRetEval['onlclick_script'] : '',
108 );
109 }
110 }
111
112 $oJsonParser = new Services_JSON();
113 $sOutputHtml = $oJsonParser -> encode($aBubbles);
114 }
115 }
116 break;
117 }
118
119 exit($sOutputHtml);
120 }
121}
122?>
Note: See TracBrowser for help on using the repository browser.