Advertisement

07.03.2008 at 09:05PM PDT, ID: 23538685
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Joomla 1.5 PHP Problems

Asked by elliottreport in PHP and Databases, WebApplications, Content Management

Tags:

I am trying to install a fireboard forum latest posts module in joomla 1.5 but keep receiving the following errors on the site:

Notice: Undefined variable: tooltip_format in /home/myotctra/public_html/modules/mod_fb_latest/tmpl/default.php on line 241

Notice: Undefined index: prevvisit in /home/myotctra/public_html/modules/mod_fb_latest/tmpl/default.php on line 90

Notice: Undefined variable: content in /home/myotctra/public_html/modules/mod_fb_latest/tmpl/default.php on line 61

I was unable to attach file because it contains .php extensions so the code for the default.php file is attached in code snippet.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
<?php
/**
* Mod FB Latest by MetZ
* The module is released under the GNU.
* Created by http://www.havneliv.no
* Please SUPPORT us if you enjoy this module
* www.webme.no/dl/
* Thanks ;) and Enjoy!
*/
 
// no direct access
defined('_JEXEC') or die('Restricted access');
// Load module parameters
$num_posts = @$params->get( 'num_posts', "" );
$only_categories = @$params->get( 'only_categories', "" );
$child_categories = @$params->get( 'child_categories', "" );
$within_thread = @$params->get( 'within_thread', "" );
$show_public = @$params->get( 'show_public', "" );
$show_registered = @$params->get( 'show_registered', "" );
$show_special = @$params->get( 'show_special', "" );
$max_length = @$params->get( 'max_length', "" );
$date_format = @$params->get( 'date_format', "" );
$name_link = @$params->get( 'name_link', "" );
$written_text = $params->get( 'written_text' );
$by_text = $params->get( 'by_text' );
$module_table_text = @$params->get( 'module_table_text', "" );
$module_background = @$params->get( 'module_background', "" );
$module_text = @$params->get( 'module_text', "" );
$item_format = '<div class="items">
<div class="item_main">%S</div>
<div class="item_info"><img src="modules/mod_fb_latest/tmpl/images/icon_info.gif"> '. $written_text .' %F '. $by_text .' %N, %D</div>
</div>';
 
// Ensure functions are only declared once, so that module can be used as multiple copies
if (!defined( '_FBLATEST_INCLUDED' )) {
	define( '_FBLATEST_INCLUDED', '1' );
 
	function fblatest_main( $num_posts, $only_categories, $child_categories, $within_thread, $show_public, $show_registered, $show_special, $max_length, $item_format, $tooltip_format, $date_format, $name_link, $by_text, $written_text )
	{
		global $database;
 
		// Select the appropriate message board component
			$componentname = 'com_fireboard';
		
		// Get menu item ID of the forum
		$database->setQuery( "SELECT id FROM #__menu WHERE link LIKE '%".$componentname."%'" );
		$rows = $database->loadObjectList();
		$forumitemid = $rows[0]->id;
	
 		// Load posts from database
		$posts = fblatest_loadposts( $num_posts, $only_categories, $child_categories, $within_thread, $show_public, $show_registered, $show_special );
		if ($posts == null) {
			echo "None";
			return;
		}
		
		// Generate formatted items
		$items = array();
		foreach ($posts as $post)
			$items[] = fblatest_makeitem( $post, $componentname, $forumitemid, $max_length, $item_format, $tooltip_format, $date_format, $name_link );
		$content .= '<div class="fb_latest">';
		
		// Generate item layout
				foreach ($items as $item)
					$content .= $item;
		echo $content;
	}
	// Loads the latest posts from the Fireboard database
	//
	function fblatest_loadposts( $num_posts, $only_categories, $child_categories, $within_thread, $show_public, $show_registered, $show_special )
	{
		global $database, $my;
		
		$fbcookie = $_COOKIE['fboard_settings'];		  
		$prevvisit = 0;
		$readtopics = null;
		
		// If a registered user is logged in, look for their last board session
	  if ($my->id != 0) {	  	
		  $database->setQuery( "SELECT * FROM #__fb_sessions WHERE userid = ".$my->id );
	    $sessions = $database->loadObjectList();
			if ($sessions && $sessions[0]->userid) {
				$prevvisit = $sessions[0]->lasttime;
				$readtopics = $sessions[0]->readtopics;                
			}
			else
				$prevvisit = time() - 1314000; // One year ago
				
			// If there is a valid value in the cookie, use it instead
			if ($fbcookie['prevvisit'])
				$prevvisit = $fbcookie['prevvisit'];		
		}
			
		//echo date("d-m-y H:i", $prevvisit)."<br/>";
 
		// Select latest posts / topics from database
		$sqlselect = "SELECT a.id, a.name, a.userid, a.subject, a.catid, a.time AS posttime, c.name AS catname";
		
		// Categorize as unread depending on last visit and list of read topics
		if ($readtopics && $prevvisit)
			$sqlselect .= ", (a.time > $prevvisit AND a.thread NOT IN ($readtopics)) AS unread";
		else if ($prevvisit)
			$sqlselect .= ", (a.time > $prevvisit) AS unread";
		else
			$sqlselect .= ", 0 AS unread";														
 
		if ($within_thread == 0) { // Show all posts from a thread
			$sqlfrom = "FROM  #__fb_messages AS a, #__fb_categories AS c";
			$sqlwhere = "WHERE a.catid = c.id AND c.published = 1 AND a.hold = 0 AND a.moved = 0";			
		}
		else if ($within_thread == 1) { // Show only first post from a thread
			$sqlfrom = "FROM #__fb_categories AS c, #__fb_messages AS a LEFT JOIN #__fb_messages AS b ON a.thread = b.thread AND a.time > b.time";
			$sqlwhere = "WHERE b.id IS NULL AND a.catid = c.id AND a.moved = 0";
		}
		else { // Show only last post from a thread
			$sqlfrom = "FROM #__fb_categories AS c, #__fb_messages AS a LEFT JOIN #__fb_messages AS b ON a.thread = b.thread AND a.time < b.time";
			$sqlwhere = "WHERE b.id IS NULL AND a.catid = c.id AND a.moved = 0";
		}
		
		$sqlorderby = " ORDER BY a.time DESC";				
		$sqllimit = " LIMIT $num_posts";
	
		// Only include posts with specific access levels
		if ($show_public == 0 && $show_registered == 0 && $show_special == 0) { 
			$sqlwhere .= ' AND c.pub_access == 999999';
		}
		else if ($show_public == 1 && $show_registered == 0 && $show_special == 0) {
			$sqlwhere .= ' AND c.pub_access = 0';
		}
		else if ($show_public == 0 && $show_registered == 1 && $show_special == 0) {
			$sqlwhere .= ' AND c.pub_access < 0';
		}
		else if ($show_public == 1 && $show_registered == 1 && $show_special == 0) {
			$sqlwhere .= ' AND c.pub_access <= 0';
		}
		else if ($show_public == 0 && $show_registered == 0 && $show_special == 1) {
			$sqlwhere .= ' AND c.pub_access > 0';
		}	
		else if ($show_public == 1 && $show_registered == 0 && $show_special == 1) {
			$sqlwhere .= ' AND c.pub_access >= 0';
		}
		else if ($show_public == 0 && $show_registered == 1 && $show_special == 1) {
			$sqlwhere .= ' AND c.pub_access != 0';
		}
		
		// Parse category inclusion list
		if ($only_categories) {
			$inc_cats = explode( ',', $only_categories );
			$inc_cats_checked = array();
			foreach ($inc_cats as $inc_cat) {
			  // Is a possible MySQL record ID
				if (ctype_digit( $inc_cat )) 
			    $inc_cats_checked[] = $inc_cat;
				// Special value -1 indicates the active category
				else if ($inc_cat == -1) { 
				  $active_cat = mosGetParam( $_GET, 'catid', 0 );
				  if (!$active_cat)
						// Using Forum jumping puts it in the post vars
						$active_cat = mosGetParam( $_POST, 'catid', 0 );
						 
				  if ($active_cat > 0)
						$inc_cats_checked[] = $active_cat;
				}
			}
			if (count( $inc_cats_checked ) > 0) {
				$only_categories = implode( ',', $inc_cats_checked );
		
				// Limit returned posts to specified categories
				if (!$child_categories)
					$sqlwhere .= ' AND c.id IN ('.$only_categories.')';
				else
					$sqlwhere .= ' AND (c.id IN ('.$only_categories.') OR c.parent IN ('.$only_categories.'))';
			}
		}
	
		$database->setQuery( "$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit" );
		return $database->loadObjectList();
	}
	
	/**
	 * Creates a formatted HTML item in the post list
	 * @param post The post being displayed
	 */
	function fblatest_makeitem( $post, $com_name, $menuitem_id, $max_length, $item_format, $tooltip_format, $date_format, $name_link )
	{	  
		$subject = stripslashes( $post->subject );  
		if (strlen( $subject ) == 0)
			$subject = 'No subject';
		
		if (strlen( $subject ) > $max_length)
			$short_subject = substr( $subject, 0, $max_length - 4 ).'...';
		else
			$short_subject = $subject;
		
		$postname = ($name_link > 0) ? fblatest_makenamelink( $post->userid, $post->name ) : $post->name;
		$postdate = date( $date_format, $post->posttime );
		
		$item_format = str_replace( "%S", fblatest_makesubjectlink( $post, $short_subject, $com_name, $menuitem_id ), $item_format );
		$item_format = str_replace( "%L", fblatest_makesubjectlink( $post, $subject, $com_name, $menuitem_id ), $item_format );			
		$item_format = str_replace( "%N", $postname, $item_format );
		$item_format = str_replace( "%D", $postdate, $item_format );
		$item_format = str_replace( "%F", $post->catname, $item_format );
				
		$tooltip_format = str_replace( "%S", $short_subject, $tooltip_format );	
		$tooltip_format = str_replace( "%L", $subject, $tooltip_format );			
		$tooltip_format = str_replace( "%N", $postname, $tooltip_format );
		$tooltip_format = str_replace( "%D", $postdate, $tooltip_format );
		$tooltip_format = str_replace( "%F", $post->catname, $tooltip_format );
								
		
		return $item_format;
	}
	
	/**
	 * Creates a link to a specific post on the board
	 */
	function fblatest_makesubjectlink( $post, $text, $componentname, $menuitemid )
	{
		$url = 'index.php?option='.$componentname.'&amp;Itemid='.$menuitemid.'&amp;func=view&amp;catid='.$post->catid.'&amp;id='.$post->id;
		if (function_exists( 'sefRelToAbs' ))
		  $url = sefRelToAbs( $url );
		
		// Anchor part of url isn't included until after SEF conversion
		return '<a href="'.$url.'#'.$post->id.'">'.$text.'</a>';
	}
	
	/**
	 * Creates a link to a specific CB user profile
	 */	
	function fblatest_makenamelink( $userid, $name )
	{
		if ($userid > 0) {
		  $url = "index.php?option=com_comprofiler&amp;task=userProfile&amp;user=".$userid;
		  if (function_exists( 'sefRelToAbs' ))
		  	$url = sefRelToAbs( $url );
			return "<a href=\"$url\">$name</a>";
		}
		return $name;}
}
// Run module main method
fblatest_main( $num_posts, $only_categories, $child_categories, $within_thread, $show_public, $show_registered, $show_special, $max_length, $item_format, $tooltip_format, $date_format, $name_link, $by_text, $written_text );
echo "</div>";
?>
[+][-]07.03.2008 at 11:19PM PDT, ID: 21931266

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 12:00AM PDT, ID: 21931388

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 12:03AM PDT, ID: 21931400

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, WebApplications, Content Management
Tags: Notice: Undefined variable: tooltip_format in /home/myotctra/public_html/modules/mod_fb_latest/tmpl/default.php on line 241
Sign Up Now!
Solution Provided By: psimation
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.04.2008 at 12:05AM PDT, ID: 21931403

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 12:22AM PDT, ID: 21931476

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628