You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			81 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			81 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
| <?php
 | |
| /*
 | |
|  *
 | |
|  * @copyright (c) 2011 animegame.eu
 | |
|  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
 | |
|  *
 | |
|  */
 | |
| 
 | |
| function revokeInvitation($user, $userid, $clan = NULL){
 | |
| 	if($user['clan'] === NULL) {
 | |
| 		return 'Du bist in keinem Clan!';
 | |
| 	}
 | |
| 
 | |
| 	if($clan === NULL) {
 | |
| 		$qry = mysql_query('Select * from clan where id = ' . $user['clan']);
 | |
| 		$clan = mysql_fetch_assoc($qry);
 | |
| 	}
 | |
| 
 | |
| 	if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
 | |
| 		return 'Nur der Leader, bzw. der Co-Leader kann Einladungen zurückziehen!!';
 | |
| 	}
 | |
| 
 | |
| 	$sql = 'DELETE FROM user_clan_invitations WHERE clanid = '.$clan['id'].' AND userid = '.$userid;
 | |
| 	//	echo $sql . '<br>';
 | |
| 	mysql_query($sql);
 | |
| 	if(mysql_affected_rows() > 0){
 | |
| 		return NULL;
 | |
| 	} else{
 | |
| 		return 'Einladung konnte nicht zurückgezogen werden!';
 | |
| 	}
 | |
| }
 | |
| 
 | |
| /**
 | |
|  *
 | |
|  * Enter description here ...
 | |
|  * @param array $user the user that wants to invite
 | |
|  * @param int $userid the id of the user that should be invited
 | |
|  * @param array $clan the optional clan array (if available)
 | |
|  */
 | |
| function inviteUser(array $user, $userid, array $clan = NULL){
 | |
| 	if($user['clan'] === NULL) {
 | |
| 		return 'Du bist in keinem Clan!';
 | |
| 	}
 | |
| 
 | |
| 	if($clan === NULL) {
 | |
| 		$qry = mysql_query('Select * from clan where id = ' . $user['clan']);
 | |
| 		$clan = mysql_fetch_assoc($qry);
 | |
| 	}
 | |
| 
 | |
| 	if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
 | |
| 		return 'Nur der Leader, bzw. der Co-Leader kann neue Member einladen!';
 | |
| 	}
 | |
| 
 | |
| 	$row = mysql_fetch_assoc(mysql_query('SELECT * FROM user where id = \''. $userid.'\''));
 | |
| 	if(!row) {
 | |
| 		return 'Fehler! Nutzer exisitiert nicht!!';
 | |
| 	}
 | |
| 	if($row['clan'] == $user['clan']){
 | |
| 		return 'Fehler! Nutzer ist schon in deinem Clan!';
 | |
| 	}
 | |
| 
 | |
| 	$sql = 'INSERT INTO user_clan_invitations(userid, clanid, valid) values('.$userid.','.$user['clan'].',TIMESTAMPADD(DAY, 5, now()))';
 | |
| 	//		echo $sql.'<br>';
 | |
| 	mysql_query($sql);
 | |
| 	if(mysql_affected_rows() <= 0){ // Fehler?
 | |
| 		$sql = 'UPDATE user_clan_invitations SET valid = TIMESTAMPADD(DAY, 5, now()) where userid = '.$userid.' and clanid = '.$user['clan'];
 | |
| 		//			echo $sql.'<br>';
 | |
| 		mysql_query($sql);
 | |
| 		if(mysql_affected_rows() <= 0){ // Fehler?
 | |
| 			return 'Fehler! Konnte Nutzer nicht einladen!';
 | |
| 		} else{
 | |
| 			sendMessage($user['id'], $userid, 'Einladung in Clan', 'Die Einladung des Clans '.$clan['clanname'].' wurde aufgefrischt! Klicke auf "Clan beitreten" um die Einladung anzunehmen!');
 | |
| 			return NULL;
 | |
| 		}
 | |
| 	} else{
 | |
| 		sendMessage($user['id'], $userid, 'Einladung in Clan', 'Du wurdest eingeladen dich dem Clan '.$clan['clanname'].' anzuschliessen! Klicke auf "Clan beitreten" um die Einladung anzunehmen!');
 | |
| 		return NULL;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| ?>
 |