Jump to content

Display Issues


everlifefree

Recommended Posts

Ok I have 2 areas that display but only one works to show it the events work but the bulletins doesn't yet if I switch it so that the events is drawing info for the bulletin from the mysql then the bulletins will work in the events area and the events won't work in the bulletins area I was wondering if some one would be kind enough to review my php code and let me know what I did wrong.

 

Php code involved in getting events and bulletins

// NEXT X EVENTS //////////////////////////////////////////////////////////////////
	/*
		Select the next 5 events
	*/
	$nextEventsSelect = myQ("
		SELECT `id`,`date`,`title`
		FROM `[x]events` 
		WHERE (
			(`display`='private' AND `user`='".me("id")."')
			OR
			(`display`='shared' AND ($contacts `user`='".me("id")."' )) 
			OR
			(`display`='public')
			OR
			(`display`='system')
		)
		AND `date` > '".date("U")."'
		ORDER BY `date` ASC
		LIMIT 5
	");

	/*
		Loop in the results, create the looping array
	*/
	$i=0;
	while ($nextEventRow = myF($nextEventsSelect)) {
		$nextEventsReplacementArray[$i]["event.title"] = _fnc("strtrim", $nextEventRow["title"], 30);
		$nextEventsReplacementArray[$i]["event.date"] = date($CONF["LOCALE_SHORT_DATE"], $nextEventRow["date"]);
		$nextEventsReplacementArray[$i]["event.id"] = $nextEventRow["id"];

		$i++;
	}

	/*
		Assign the array to the loop engine
	*/
	if (isset($nextEventsReplacementArray)) $tpl->Loop("nextEvents", $nextEventsReplacementArray);
        if (isset($nextEventsReplacementArray)) {$tpl -> Zone("hasContact", "gotEvent");}
        if (!isset($nextEventsReplacementArray)) {$tpl -> Zone("hasContact", "noEvent");}

	// NEXT X BULLETINS //////////////////////////////////////////////////////////////////
	/*
		Select the next 5 bulletins
	*/
	$nextBulletinsSelect = myQ("
	SELECT `id`,`username`,`title`,`date`
		FROM `[x]bulletins` 
		WHERE (
			(`display`='private' AND `user`='".me("id")."')
			OR
			(`display`='shared' AND ($contacts `user`='".me("id")."' )) 
			OR
			(`display`='public')
			OR
			(`display`='system')
		)
		AND `date` > '".date("U")."'
		ORDER BY `date` ASC
		LIMIT 5
	");

	/*
		Loop in the results, create the looping array
	*/
	$i=0;
	while ($nextBulletinRow = myF($nextBulletinsSelect)) {
		$nextBulletinsReplacementArray[$i]["bulletin.title"] = _fnc("strtrim", $nextBulletinRow["title"], 30);
		$nextBulletinsReplacementArray[$i]["bulletin.username"] = $nextBulletinRow["username"];
		$nextBulletinsReplacementArray[$i]["bulletin.date"] = date($CONF["LOCALE_SHORT_DATE"], $nextBulletinRow["date"]);
		$nextBulletinsReplacementArray[$i]["bulletin.id"] = $nextBulletinRow["id"];

		$i++;
	}

	/*
		Assign the array to the loop engine
	*/
	if (isset($nextBulletinsReplacementArray)) $tpl->Loop("nextBulletins", $nextBulletinsReplacementArray);
        if (isset($nextBulletinsReplacementArray)) {$tpl -> Zone("hasContacts", "gotBulletin");}
        if (!isset($nextBulletinsReplacementArray)) {$tpl -> Zone("hasContacts", "noBulletin");}

 

 

This code is used in both of them to display the event to contact of the user if the submitter only wanted his contacts to see it (used entirely on bulletin and a little on events works fine with the events side of thing...

$userContactsArray = unpk(me("contacts")); 

$i=0; 

/* 
We will only act if the usercontactsarray is ... an array! 
If it is, start looping! 
*/ 
if (is_array($userContactsArray)) foreach($userContactsArray as $userContactGroup => $contactsUsersArray) { 

/* 
Loop in the users array if it is an array 
*/ 
if (is_array($contactsUsersArray)) foreach($contactsUsersArray as $contactsUserID) { 

/* 
Now things starts being tricky  -- We will get the 
third party user contacts array and verity that this 
user is also in the other user's contacts ... If 
both are in a relationship, we will show that user 
on the profile page 
*/ 
$thirdUserContactsArray = unpk(_fnc("user", $contactsUserID, "contacts")); 

/* 
if it's an array, and that the user is in... 
*/ 
if (is_array($thirdUserContactsArray) && _fnc("in_multiarray", $thirdUserContactsArray, me("id"))) { 

/* 
If "i" is zero, it means this is the first 
successful cycle, we will enable the contact 
tab in the template. 
*/ 
if ($i==0) $tpl->Zone("contactsTab", "enabled"); 

/* 
Generate this entity' entry in the contacts array. 
*/ 
$contactEntityArray[$i]["contact.id"] = $contactsUserID; 
$contacts = $contacts . "`user`='" . $contactsUserID . "'" . " OR "; 

$i++; 
} 
} 
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.