USER_ON_EVENT Mod
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexAdd-Ons & Blocks
Author Message
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: USER_ON_EVENT Mod
Posted: Sun Aug 02, 2009 4:35 pm
Reply with quote

I've manged to get DJSpAcEDeViL's 'USER_ON_EVENT' mod working for CPGNuCalendar (download here). It's a superb mod that allows your users to add themselves to events and show up as attending on the calendar page. It'll be very useful on my site so big thanks to DJSpAcEDeViL!

Some of the changes I've made to make it more multi-lingual and to allow different database prefixes (which were originally hard coded). I made the following changes referring to the user_on_event.txt file:

In cpgnucalendar/index.php

Two new lines added to the forms, the delete image file changed and language definitions used in place of hard coded German:

Code:
//User on Event Mod begin
		echo '<td rowspan="3"><fieldset><legend>'._USER_ON_EVENT.'</legend>';
		$sql = "SELECT uoe_id, user_id, user_name, event_id, event_date FROM ".$cal_prefix."_user_on_event WHERE event_id =".$id." AND event_date =".$date;
		$res = $db->sql_query ($sql);
		  if ( $res ) {
			while ($row = $db->sql_fetchrow ($res)) {
			$uoe_id = $row[0];
			$user_id = $row[1];
			$user_name = $row[2];
			$event_id = $row[3];
			$event_date = $row[4];  
			echo '<div style="float:left"><table><a href="'.getlink('Your_Account').'&amp;profile='.$user_name.'">'.$user_name.'</a>';
			//Delete function
			if ($user_name == $userinfo['username'] || can_admin($module_name) || in_group($cal_config['admin_events']-3)) {
			echo ' <form method="post" action="'.getlink("coppermine&amp;file=delete").'">
  				<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
	  			<input type="hidden" name="what" value="del_user_on_event" />
	  			<input type="hidden" name="uoe_id" value="'.$uoe_id.'" />
	  			<input name="submit" title="Delete" type="image" src="/images/delete.gif" />
				</form>';}
			//Delete function
			echo '</table></div> '; };}
		echo'</fieldset></ br>';
		if (is_user($user)){
		echo'<div style="float:left"><form method="post" name="post" action="'.getlink('coppermine&amp;file=db_input').'" enctype="multipart/form-data" accept-charset="utf-8">
  			<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
			<input type="hidden" name="event" value="add_user_on_event" />
  			<input type="hidden" name="event_id" value="'.$id.'" />
			<input type="hidden" name="user_id" value="'.$user_id.'" />
			<input type="hidden" name="user_name" value="'.$user_name.'" />
			<input type="hidden" name="event_date" value="'.$date.'" />
  			<input type="submit" class="comment_button" name="submit" value="'._WILL_ATTEND.'" />
			</form></div>'; }
		else {
		echo'<div style="float:left"><form method="post" name="post" action="'.getlink('Your_Account&amp;file=register').'" enctype="multipart/form-data" accept-charset="utf-8">
  			<input type="submit" class="comment_button" name="submit" value="'._WILL_ATTEND.'" />
			</form></div>';  }
//User on Event Mod end

There is no image file called 'noaccess.gif' so you need to supply one or just copy the delete.gif from the coppermine images folder and use that.

In modules/coppermine/delete.php

cal_prefix variable added and language redefines used:
Code:
//User on Event

case 'del_user_on_event':
		$uoe_id = intval($_POST['uoe_id']);
		$cal_prefix = Fix_Quotes($_POST['cal_prefix']);
  
			$result = $db->sql_query("SELECT event_id, event_date FROM ". $cal_prefix. "_user_on_event WHERE uoe_id='$uoe_id'", false, __FILE__, __LINE__);

			if (!$db->sql_numrows($result)) {
				cpg_die(_CRITICAL_ERROR, NON_EXIST_EVENT, __FILE__, __LINE__);
			} else {
				$ev_data = $db->sql_fetchrow($result);
			} 
			$redirect = getlink("CPGNuCalendar&amp;view=event&amp;id=".$ev_data["event_id"]."&amp;date=".$ev_data["event_date"]);
			if(isset($_POST['cancel'])) {
				url_redirect($redirect);
			}
			if (!isset($_POST['confirm'])) {
			$msg = CONFIRM_DELETE_ATTEND;
			cpg_delete_msg(getlink("&amp;file=delete"),$msg,'<input type="hidden" name="what" value="del_user_on_event" /><input type="hidden" name="uoe_id" value="'.$uoe_id.'" /><input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />');		
		
			} else {  
			if (is_admin()) {
				$query = "DELETE FROM ". $cal_prefix. "_user_on_event WHERE uoe_id='$uoe_id'";
			} elseif (is_user()) {
				$query = "DELETE FROM ". $cal_prefix. "_user_on_event WHERE uoe_id='$uoe_id' AND user_id=".is_user();
			} 
			$result = $db->sql_query($query, false, __FILE__, __LINE__);

			pageheader(INFO, $redirect);
			msg_box(INFO, ATTEND_DELETED, CONTINU, $redirect);
			pagefooter();
		}
		break;

In modules/coppermine/db_input.php

cal_prefix variable added and language redefines used:
Code:
//User on Event
	
	case 'add_user_on_event':
		if (!(USER_CAN_POST_COMMENTS)) cpg_die(_ERROR, PERM_DENIED, __FILE__, __LINE__);
		$cal_prefix = Fix_Quotes($_POST['cal_prefix']);
		$uoe_id = intval($_POST['uoe_id']);
		$user_id = intval($_POST['user_id']);
		$event_id = intval($_POST['event_id']);
		$event_date = intval($_POST['event_date']);
		$user_name = intval($_POST['user_name']);


		
		$result = $db->sql_query("SELECT user_id FROM ".$cal_prefix."_user_on_event WHERE event_id = '$event_id' ORDER BY uoe_id");
			if ($db->sql_numrows($result)) {
				$ev_data = $db->sql_fetchrow($result);
				$redirect = getlink("CPGNuCalendar&amp;view=event&amp;id=".$event_id."&amp;date=".$event_date);
				if ((USER_ID && $ev_data['user_id'] == USER_ID)) {
					pageheader(_ERROR, $redirect);
					msg_box(_ERROR, USER_ALREADY_ON_EVENT, CONTINU, $redirect);
					pagefooter();
				}
			} 


		 // Registered users, we can use Location to redirect
		$insert = $db->sql_query("INSERT INTO ".$cal_prefix."_user_on_event (user_id, user_name, event_id , event_date) VALUES ('".USER_ID."', '".CPG_USERNAME."','".$event_id."', '".$event_date."')");
			
			$redirect = getlink("CPGNuCalendar&amp;view=event&amp;id=".$event_id."&amp;date=".$event_date);

			
			pageheader(ATTEND_ADDED, $redirect);
			msg_box(INFO, ATTEND_ADDED, CONTINU, $redirect);
			pagefooter();
		
		break;

In modules/CPGNuCalendar/includes/functions.inc

cal_prefix variable added, correction to allow for apostrophe in tip and language redefines used:

Code:
//Print the specified event for the monthly view calendar
	function print_month_event ( $event, $date ) {
		global $db, $cal_prefix, $cal_module_name, $repeated_descriptions, $cal_config, $calcategories, $userinfo;

		$id = $event['eid'];
		$time = $event['time'];
		$duration = $event['duration'];
		$priority = $event['priority'];
		$view = $event['view'];
		$name = $event['name'];
		$description = $event['description'];
		$image = $event['image'];
		$categoryid = $event['category'];
		$result2 = $db->sql_query("select title FROM ". $cal_prefix. "_categories WHERE catid = '".$categoryid."'",false,__FILE__,__LINE__);
		$row3 = $db->sql_fetchrow($result2);
		$category= $row3['title'];
		$content = "";
		//Print event if...
		//is any user OR
		//is in the specified $view group OR
		//is a registered user OR
		//is a Calendar Admin
		//BBcode by SpAcEDeViL Emsland-Party.de
		$description = decode_bbcode(set_smilies(encode_bbcode(preg_replace("/\r|\n/s", "&nbsp;",$description))),1);
		$alttext = ($description) ? substr(htmlentities(strip_tags(stripslashes($description))),0,75): "";
			$content .= '
<script language="JavaScript" type="text/javascript">
<!--';
$content .= "
maketip('tip_".addslashes($name)."','".addslashes($name)."','".addslashes($description)."');
";
$content .= '// -->
</script>';
		if ($view == 0 || in_group($view) || is_user() || can_admin($cal_module_name)) {
			$content .= "<div><table width='100%' cellspacing='1' cellpadding='3' border='0'><tr><td><a onmouseover=\"tip('tip_".addslashes($name)."')\" onmouseout=\"untip()\"  href=\"".getlink($cal_module_name . "&amp;view=event&amp;id=$id&amp;date=$date") . "\"";
			$content .= (!empty($description) ? " title=\"\"" : "") . "><img src=\"modules/$cal_module_name/images/$image\" alt=\"Event\" style=\" vertical-align: middle; border:0;\" /> ";

			if ($cal_config['show_time'] == '1') {
				$timestr = "";
				if ( $time >= 0 ) {
					$timestr = display_time ( $time );
					$content .= $timestr . " ";
					if ( $duration > 0 ) {
						// calc end time
						$h = (int) ( $time / 10000 );
						$m = ( $time / 100 ) % 100;
						$m += $duration;
						$d = $duration;
						while ( $m >= 60 ) {
							$h++;
							$m -= 60;
						}
						$end_time = sprintf ( "%02d%02d00", $h, $m );
						$content .= " - " . display_time ( $end_time ) . " ";
					}
				}
			}
			$descs = count($repeated_descriptions);
			for ( $i = 0; $i < $descs; $i++ ) {
				if ($repeated_descriptions[$i]['eid'] == $id && $repeated_descriptions[$i]['date'] == $date){
					$name = $repeated_descriptions[$i]['name'];
					break;
				}
			}
		//	if ($calcategories[$category]['display'] == 1 || $image == "circle.gif" || $image == "blank.gif" )
				$content .= $name;

			$content .= "</a></td>";

//Add - Delete function
$getid = $db->sql_query("SELECT uoe_id, event_id, user_id, user_name, event_date FROM ". $cal_prefix. "_user_on_event WHERE event_id=".$id." AND event_date=".$date."");
while ($row1 = $db->sql_fetchrow($getid)) {
$uoe_id = $row1['uoe_id'];
$eid1 = $row1['event_id'];
$event_date = $row1['event_date'];
$user_id = $row1['user_id'];
$uoe_uname = $row1['user_name'];
//Besucherz�hler? $anzahl = mysql_affected_rows(); 
}

if (is_user($user)) {
			if ( $userinfo['user_id'] == $user_id && $event_id != $id && $date == $event_date) {
			$content .='<td><div align="right"><form method="post" action="'.getlink("coppermine&amp;file=delete").'">
  				<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
	  			<input type="hidden" name="what" value="del_user_on_event" />
	  			<input type="hidden" name="uoe_id" value="'.$uoe_id.'" />
	  			<input name="submit" title="'._WONT_ATTEND.'" type="image" src="images/checked_sm.gif" />
				</form></div></td>'; }
			else {
			$content .= '<td><div align="right"><form method="post" name="post" action="'.getlink('coppermine&amp;file=db_input').'" enctype="multipart/form-data" accept-charset="utf-8">
  			<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
			<input type="hidden" name="event" value="add_user_on_event" />
  			<input type="hidden" name="event_id" value="'.$id.'" />
			<input type="hidden" name="user_id" value="'.$userinfo['user_id'].'" />
			<input type="hidden" name="user_name" value="'.$username.'" />
			<input type="hidden" name="event_date" value="'.$date.'" />
  			<input name="submit" title="'._WILL_ATTEND.'" type="image" src="images/unchecked_sm.gif" /></form></div></td>'; } }
//Add - Delete function


			$content .= "</tr></table></div>";
		}
		return $content;
	}

in language/cpgnucalendar.php

Following definitions added:

Code:
# user_on_event
define("_USER_ON_EVENT", "Attendees");
define("_WILL_ATTEND", "Count Me In");
define("_WONT_ATTEND", "Cancel Attendance");
define("_ATTENDANCE", "will attend/attended these events:");
define("_NO_EVENTS", "is not listed at any events.");
define("_MORE_EVENTS", "More Events");

in language/coppermine.php

Following definitions added:

Code:
define('NON_EXIST_EVENT', 'The selected event does not exist.');
define('USER_ALREADY_ON_EVENT', 'You are already attending this event');
define('ATTEND_ADDED', 'You have been added to this event');
define('ATTEND_DELETED', 'You have been removed from this event');
define('CONFIRM_DELETE_ATTEND', 'Are you sure you no longer wish to attend this event?');

in Your_Account/blocks/5Events.php

cal_prefix variable added, table not produced if no result and language redefines used:

Code:
<?php
if (!defined('CPG_NUKE')) { exit; }

global $prefix, $cal_prefix, $db, $CONFIG;

$cpg_dir = 'CPGNuCalendar';

if (!is_active($cpg_dir)) {
   echo 'ERROR';
   return trigger_error($cpg_dir.' module is inactive', E_USER_WARNING);
}

$cpg_block = true;
$cpg_block = false;
$length=20; //Anzahl der Events
$userinfo = getusrdata($username);


// END USER DEFINABLES
$getaid = $db->sql_query("select event_id, user_id, event_date FROM ".$cal_prefix."_user_on_event where user_id = '".$userinfo['user_id']."' GROUP BY event_id ORDER BY event_id DESC LIMIT $length");
if (!mysql_num_rows($getaid)) { echo '<center><b>'.$userinfo['username'].'</b> '._NO_EVENTS.'<br><br></center>';}
		else {
echo '<center><b>'.$userinfo['username'].'</b> '._ATTENDANCE.' <br><br><table width="70%" cellspacing="1" cellpadding="3" border="0">';
while ($row1 = $db->sql_fetchrow($getaid)) {
$eid1 = $row1['event_id'];
$event_date =$row1['event_date'];

$result = $db->sql_query("select eid, name, image, category FROM ".$prefix."_cpgnucalendar WHERE eid = '".$eid1."' ORDER BY eid DESC LIMIT $length",false,__FILE__,__LINE__);

$row2 = $db->sql_fetchrow($result);
$name = $row2['name'];
$image = $row2['image'];
$categoryid = $row2['category'];
$result2 = $db->sql_query("select title FROM ".$cal_prefix."_categories WHERE catid = '".$categoryid."'",false,__FILE__,__LINE__);
$row3 = $db->sql_fetchrow($result2);
$category= $row3['title'];

   echo '<tr><td><center><img src="modules/CPGNuCalendar/images/'.$image.'" title="'.$category.'" alt="'.$category.'"></center></td><td><a href="' . getlink("CPGNuCalendar&amp;view=event&amp;id=".$eid1."&amp;date=".$event_date) . '" title="'.$category.'">'.$name.' </td><td> '.substr ( $event_date, 6, 2 ).'/'.substr ( $event_date, 4, 2 ).'/'.substr ( $event_date, 0, 4 ).'</a></td></tr> '; 
   }

	echo'</table>';}
	echo '<br><center>| <a href="'.getlink(CPGNuCalendar).'">'._MORE_EVENTS.'</a> |</center>';

Hope that helps someone else use this great mod!


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
mierlo
Newbie


Joined: Jan 02, 2007
Posts: 8
Location: Valkenswaard, The Netherlands

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Wed Aug 05, 2009 11:37 am
Reply with quote

yes, great MOD DJSpAcEDeViL and very good/handy work Rosbif,


there is a little BUT;

when you are not logged in, you should not see the list of attenders nor can press the button in the event view window.
And yes, only logged in as admin you can't see the button.
I would reccommend this code in the

cpgnucalendar/index.php
Code:
//User on Event Mod begin
		if (is_user($user)){
		echo '<td rowspan="3"><fieldset><legend>'._USER_ON_EVENT.'</legend>';
		$sql = "SELECT uoe_id, user_id, user_name, event_id, event_date FROM ".$cal_prefix."_user_on_event WHERE event_id =".$id." AND event_date =".$date;
		$res = $db->sql_query ($sql);
		  if ( $res ) {
			while ($row = $db->sql_fetchrow ($res)) {
			$uoe_id = $row[0];
			$user_id = $row[1];
			$user_name = $row[2];
			$event_id = $row[3];
			$event_date = $row[4];  
			echo '<div style="float:left"><table><a href="'.getlink('Your_Account').'&amp;profile='.$user_name.'">'.$user_name.'</a>';
			//Delete function
			if ($user_name == $userinfo['username'] || can_admin($module_name) || in_group($cal_config['admin_events']-3)) {
			echo ' <form method="post" action="'.getlink("coppermine&amp;file=delete").'">
  				<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
	  			<input type="hidden" name="what" value="del_user_on_event" />
	  			<input type="hidden" name="uoe_id" value="'.$uoe_id.'" />
	  			<input name="submit" title="Delete" type="image" src="/images/delete.gif" />
				</form>';}
			//Delete function
			echo '</table></div> '; };}
		echo'</fieldset></ br>';
		echo'<div style="float:left"><form method="post" name="post" action="'.getlink('coppermine&amp;file=db_input').'" enctype="multipart/form-data" accept-charset="utf-8">
  			<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
			<input type="hidden" name="event" value="add_user_on_event" />
  			<input type="hidden" name="event_id" value="'.$id.'" />
			<input type="hidden" name="user_id" value="'.$user_id.'" />
			<input type="hidden" name="user_name" value="'.$user_name.'" />
			<input type="hidden" name="event_date" value="'.$date.'" />
  			<input type="submit" class="comment_button" name="submit" value="'._WILL_ATTEND.'" />
			</form></div>'; }
//		else {
//		echo'<div style="float:left"><form method="post" name="post" action="'.getlink('Your_Account&amp;file=register').'" enctype="multipart/form-data" accept-charset="utf-8">
//  			<input type="submit" class="comment_button" name="submit" value="'._WILL_ATTEND.'" />
//			</form></div>';  }
//User on Event Mod end

_________________
kind regards,

Martijn

mierlo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux 2.4.21-57/Apache 2.0/MySQL 4.1.15/PHP 5.2.4/CMS 9.2.1
Back to top
View user's profile Visit poster's website
Emsland-Party.de
Nice poster


Joined: May 24, 2005
Posts: 74
Location: Lummer Land (Germany)

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Fri Aug 07, 2009 3:40 pm
Reply with quote

Hy Thx for the praise.
mierlo,

i can not so good english,

mh, yes,

I was wondering whether I do with a purely functional. A variable has been given ... must only be used

search in includes/functions.inc:
//Besucherzähler? $anzahl = mysql_affected_rows();

this is the option to show how many people goes to the event.


Emsland-Party.de's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux / PHP: 4.4.1 / SQL: 5.0.18-log (client: 5.0.18) / 9.1.0.8 CVS
Back to top
View user's profile Visit poster's website
mierlo
Newbie


Joined: Jan 02, 2007
Posts: 8
Location: Valkenswaard, The Netherlands

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Tue Aug 11, 2009 6:30 am
Reply with quote

Hallo,

I don' know what you mean by this.

_________________
kind regards,

Martijn

mierlo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux 2.4.21-57/Apache 2.0/MySQL 4.1.15/PHP 5.2.4/CMS 9.2.1
Back to top
View user's profile Visit poster's website
Emsland-Party.de
Nice poster


Joined: May 24, 2005
Posts: 74
Location: Lummer Land (Germany)

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Tue Aug 11, 2009 11:44 am
Reply with quote

hehe sorry,

i have your thread misunderstand Wink


Emsland-Party.de's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux / PHP: 4.4.1 / SQL: 5.0.18-log (client: 5.0.18) / 9.1.0.8 CVS
Back to top
View user's profile Visit poster's website
mierlo
Newbie


Joined: Jan 02, 2007
Posts: 8
Location: Valkenswaard, The Netherlands

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Fri Aug 14, 2009 1:49 pm
Reply with quote

so now I also changed the
/modules/Your_account/Blocks/5Events.php

This because my site did not display the text properly and MORE_EVENTS was displayed but no events were attended.

Code:
<?php
if (!defined('CPG_NUKE')) { exit; }

global $db, $CONFIG, $prefix, $cal_prefix;

if (is_active('CPGNuCalendar')) {
$length = 10; //Number of Events
//$userinfo = getusrdata($username);
	get_lang('CPGNuCalendar');

// END USER DEFINABLES
$result = $db->sql_query("select event_id, user_id, event_date FROM ".$prefix."_cpgnucalendar_user_on_event where user_id = '".$userinfo['user_id']."' GROUP BY event_id ORDER BY event_id DESC LIMIT $length");
	if ($db->sql_numrows($result) > 0) {
		echo '<br />';
		OpenTable();
        echo '<div align="left"><b>'.$username.'\'s '._ATTENDANCE.'</b><ul>';
        while ($row1 = $db->sql_fetchrow($result)){
        	$eid1 = $row1['event_id'];
        	$event_date =$row1['event_date'];
        	$result1 = $db->sql_query("select eid, name, image, category FROM ".$prefix."_cpgnucalendar WHERE eid = '".$eid1."' ORDER BY eid DESC LIMIT $length",false,__FILE__,__LINE__);
        	$row2 = $db->sql_fetchrow($result1);
        	$name = $row2['name'];
       		$image = $row2['image'];
        	$categoryid = $row2['category'];
        	$result2 = $db->sql_query("select title FROM ".$prefix."_cpgnucalendar_categories WHERE catid = '".$categoryid."'",false,__FILE__,__LINE__);
        	$row3 = $db->sql_fetchrow($result2);
        	$category= $row3['title'];
        	echo '<li><img src="modules/CPGNuCalendar/images/'.$image.'" title="'.$category.'" alt="'.$category.'"> <a href="' . getlink("CPGNuCalendar&amp;view=event&amp;id=".$eid1."&amp;date=".$event_date) . '" title="'.$category.'">'.$name.' '.substr ( $event_date, 6, 2 ).'/'.substr ( $event_date, 4, 2 ).'/'.substr ( $event_date, 0, 4 ).'</a></li>'; 
   		}
        echo '</ul></div>';
        echo '<br/><Div align ="left">| <a href="'.getlink('CPGNuCalendar').'">'._MORE_EVENTS.'</a> |</div>';
        CloseTable();
	}
}

Also for the Dutch lang code in cpgnucalendar.php

Code:
define('_USER_ON_EVENT', 'Deelnemers');
define('_WILL_ATTEND', 'Ik doe mee');
define('_WONT_ATTEND', 'Annuleer deelname');
define('_ATTENDANCE', 'evenementen waar aan deelgenomen wordt:');
define('_NO_EVENTS', 'staat niet geregistreerd voor een van de evenementen.');
define('_MORE_EVENTS', 'Meer evenementen');


mierlo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux 2.4.21-57/Apache 2.0/MySQL 4.1.15/PHP 5.2.4/CMS 9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Mon Aug 17, 2009 8:58 am
Reply with quote

Have just discovered that this throws up an error 'User already on event' if you are trying to select a 'recurring' event and you are already attending one of the events of the series.

This means that the comment must be added to a combination of the event_id and the event_date. I think (please check this - it does seem to work) that you need to change this line in db_input.php:

Code:
$result = $db->sql_query("SELECT user_id FROM ".$cal_prefix."_user_on_event WHERE event_id = '$event_id' ORDER BY uoe_id");


to
Code:
$result = $db->sql_query("SELECT user_id FROM ".$cal_prefix."_user_on_event WHERE (event_id = '$event_id') AND (event_date = '$event_date') ORDER BY uoe_id");

in /modules/Your_account/Blocks/5Events.php change

Code:
$getaid = $db->sql_query("select event_id, user_id, event_date FROM ".$cal_prefix."_user_on_event where user_id = '".$userinfo['user_id']."' GROUP BY event_id ORDER BY event_id DESC LIMIT $length");

to
Code:
$getaid = $db->sql_query("select event_id, user_id, event_date FROM ".$cal_prefix."_user_on_event where user_id = '".$userinfo['user_id']."' ORDER BY event_date ASC LIMIT $length");

(I'm not sure why the 'Group By' bit was there - have I missed something?)


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Tue Aug 18, 2009 4:35 pm
Reply with quote

Made a quick change to cpgnucalendar/index.php so that multiple attendees display properly (they were printing over each other)

Code:
		  if ( $res ) {
		  	echo '<div style="float:left"><table><tr><td>';
			while ($row = $db->sql_fetchrow ($res)) {
			$uoe_id = $row[0];
			$user_id = $row[1];
			$user_name = $row[2];
			$event_id = $row[3];
			$event_date = $row[4];  
			echo '<a href="'.getlink('Your_Account').'&amp;profile='.$user_name.'">'.$user_name.'</a>';
			//Delete function
			if ($user_name == $userinfo['username'] || can_admin($module_name) || in_group($cal_config['admin_events']-3)) {
			echo ' <form method="post" action="'.getlink("coppermine&amp;file=delete").'">
  				<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
	  			<input type="hidden" name="what" value="del_user_on_event" />
	  			<input type="hidden" name="uoe_id" value="'.$uoe_id.'" />
	  			<input name="submit" title="Delete" type="image" src="/images/delete.gif" />
				</form>';}
			//Delete function
			echo '</td></tr>'; }
			echo '</table></div> ';}
		echo'</fieldset></ br>';


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Thu Sep 03, 2009 8:14 am
Reply with quote

Is there any way of getting the delete image and the username on the same line? Using the code above they always appear on different lines, presumably because of the form element?

rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Mon Sep 07, 2009 10:55 am
Reply with quote

There's an problem with the code in cpgnucalendar/functions.inc in that if more than one person is attending an event and you are not the last in the table then the monthly event block will incorrectly display the tick box. To correct this use this code..

Code:
//Add - Delete function
$userpresent = '0';
$getid = $db->sql_query("SELECT uoe_id, event_id, user_id, user_name, event_date FROM ". $cal_prefix. "_user_on_event WHERE event_id=".$id." AND event_date=".$date."");
while ($row1 = $db->sql_fetchrow($getid)) {
$uoe_id = $row1['uoe_id'];
$eid1 = $row1['event_id'];
$event_date = $row1['event_date'];
$user_id = $row1['user_id'];
$uoe_uname = $row1['user_name'];
//Besucherz�hler? $anzahl = mysql_affected_rows(); 

if (is_user($user)) {
			if ( $userinfo['user_id'] == $user_id && $event_id != $id && $date == $event_date) {
			$userpresent = '1'; }
}
}

if (is_user($user)) {
			if ( $userpresent =='1' ) {
			$content .='<td><div align="right"><form method="post" action="'.getlink("coppermine&amp;file=delete").'">
  				<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
	  			<input type="hidden" name="what" value="del_user_on_event" />
	  			<input type="hidden" name="uoe_id" value="'.$uoe_id.'" />
	  			<input name="submit" title="'._WONT_ATTEND.'" type="image" src="images/checked_sm.gif" />
				</form></div></td>'; }
			else {
			$content .= '<td><div align="right"><form method="post" name="post" action="'.getlink('coppermine&amp;file=db_input').'" enctype="multipart/form-data" accept-charset="utf-8">
  			<input type="hidden" name="cal_prefix" value="'.$cal_prefix.'" />
			<input type="hidden" name="event" value="add_user_on_event" />
  			<input type="hidden" name="event_id" value="'.$id.'" />
			<input type="hidden" name="user_id" value="'.$userinfo['user_id'].'" />
			<input type="hidden" name="user_name" value="'.$username.'" />
			<input type="hidden" name="event_date" value="'.$date.'" />
  			<input name="submit" title="'._WILL_ATTEND.'" type="image" src="images/unchecked_sm.gif" /></form></div></td>'; } }
//Add - Delete function


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Wed Dec 30, 2009 2:50 pm
Reply with quote

Have discovered that bots are throwing up multiple SQL errors with this mod like:

Quote:
On /CPGNuCalendar/view=event/id=606/MReviews=/op=show/rid=14/newlang=english.html
While executing query "SELECT uoe_id, user_id, user_name, event_id, event_date FROM chantill_cpgnucalendar_user_on_event WHERE event_id =606 AND event_date ="

the following error occured: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

In: /home/chantill/public_html/modules/CPGNuCalendar/index.php on line: 859

Any ideas what might be allowing the mix of modules in that first line (it's a random module)? Presumably it's because some definition of $module is wrong somewhere


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
layingback
Forum Admin


Joined: Apr 19, 2004
Posts: 953

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Wed Dec 30, 2009 2:54 pm
Reply with quote

The value in $module reflects the _current_ module. So if you are running as a block, then $module will not be the name of your module, but that of another! You'll probably have to use the module name.
_________________
Pro_News: The complete module for Dragonfly - now available as version 3.3

layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6 - 3.6 / 1.3.42 - 2.2.12 / 5.0.92 - 5.1.37 - 5.1.54 / 4.4.49 - 5.2.17 - 5.3 / 9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Wed Dec 30, 2009 3:03 pm
Reply with quote

Thanks LB - I am presuming that the error is in the CPGNuCalendar hack not the other modules that are throwing up the errors... Can't see where it would be though - presumably somewhere in the block code (although the error seems to come from modules/CPGNuCalendar/index.php)

rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
macuserau
Nice poster


Joined: May 18, 2006
Posts: 114
Location: South Coast Australia

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Sun Jun 13, 2010 5:38 am
Reply with quote

Does these suggested code changes work with CPGNuCalander 2.1.0 or are these meant for an older version?

macuserau's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
unix / Apache 2.2.15 / MySQL 5.0.90 / PHP 5.3.2/ CMS 9.3.2.0
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: USER_ON_EVENT Mod
Posted: Sun Jun 13, 2010 5:35 pm
Reply with quote

Works fine with the latest version..

rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexAdd-Ons & Blocks All times are GMT
Go to page 1, 2  Next
Page 1 of 2


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

stopsoftwarepatents.eu petition banner
User Info [x]

Welcome Anonymous

Nickname
Password
(Register)

Last CVS commits [x]

Languages [x]

Community [x]

Support for DragonflyCMS in a other languages:

Deutsch
Español

X-links [x]
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

Preview theme [x]
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.


You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
This page generated in 2.6034 seconds with 16 DB Queries in 0.0563 seconds
Memory Usage: 3.1 MB
Interactive software released under GNU GPL, Code Credits, Privacy Policy