You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							60 lines
						
					
					
						
							1.4 KiB
						
					
					
				
			
		
		
	
	
							60 lines
						
					
					
						
							1.4 KiB
						
					
					
				<?php
 | 
						|
/* For licensing terms, see /license.txt */
 | 
						|
 | 
						|
use JeroenDesloovere\VCard\VCard;
 | 
						|
 | 
						|
/**
 | 
						|
 * VCard Generator.
 | 
						|
 *
 | 
						|
 * @package chamilo.social
 | 
						|
 *
 | 
						|
 * @author José Loguercio Silva <jose.loguercio@beeznest.com>
 | 
						|
 */
 | 
						|
require_once __DIR__.'/../inc/global.inc.php';
 | 
						|
 | 
						|
api_block_anonymous_users();
 | 
						|
 | 
						|
if (isset($_REQUEST['userId'])) {
 | 
						|
    $userId = intval($_REQUEST['userId']);
 | 
						|
} else {
 | 
						|
    api_not_allowed(true);
 | 
						|
}
 | 
						|
 | 
						|
// Return User Info to vCard Export
 | 
						|
$userInfo = api_get_user_info($userId, true, false, true);
 | 
						|
 | 
						|
/* Get the relationship between current user and vCard user */
 | 
						|
$currentUserId = api_get_user_id();
 | 
						|
$hasRelation = SocialManager::get_relation_between_contacts(
 | 
						|
    $currentUserId,
 | 
						|
    $userId,
 | 
						|
    true
 | 
						|
);
 | 
						|
if ($hasRelation == 0) {
 | 
						|
    /* if has not relation, check if are admin */
 | 
						|
    api_protect_admin_script();
 | 
						|
}
 | 
						|
 | 
						|
if (empty($userInfo)) {
 | 
						|
    api_not_allowed(true);
 | 
						|
}
 | 
						|
if (api_get_user_id() != $userId && !SocialManager::get_relation_between_contacts(api_get_user_id(), $userId)) {
 | 
						|
    api_not_allowed(true);
 | 
						|
}
 | 
						|
// Pre-Loaded User Info
 | 
						|
$language = get_lang('Language').': '.$userInfo['language'];
 | 
						|
 | 
						|
// Instance the vCard Class
 | 
						|
$vcard = new VCard();
 | 
						|
// Adding the User Info to the vCard
 | 
						|
$vcard->addName($userInfo['firstname'], $userInfo['lastname']);
 | 
						|
 | 
						|
if (api_get_setting('show_email_addresses') == 'true') {
 | 
						|
    $vcard->addEmail($userInfo['email']);
 | 
						|
}
 | 
						|
 | 
						|
$vcard->addPhoneNumber($userInfo['phone'], 'CELL');
 | 
						|
$vcard->addNote($language);
 | 
						|
 | 
						|
// Generate the vCard
 | 
						|
return $vcard->download();
 | 
						|
 |