<?php
/**
* XS2:
*
* This file is developed by Solutecs, LLC for the purpose of the company
* and is provided together with XS2 Framework as and inherent part of the
* system. This file can be used on the terms of License Agreement.
*
* +7 (495) 585-0833 / 13 Rusakovskaya street, Moscow 107140 Russia
*
* @link http://www.solutecs.com
* @copyright ©1998-2007 Solutecs, LLC
* @package XS2-MODCOM
* @subpackage proc-blog
* @version 1.XX
*/
xs2Fetch(array('mod'=>'users', 'met'=>'lib'));
xs2Fetch(array('mod'=>'blog', 'met'=>'lib'));
$nodeId = $_THE['PARAMS'][0];
$blog = xs2GetNode(array('NodId'=>$nodeId, 'NType'=>'blog'));
if ($GLOBALS['myBlog']['NodId'] == $blog['NodId']) {
// Добавление и удаление друзей возможно только, если это блог текущего пользователя
if ($_POST['action']=='addFriend' && $_POST['NName']) {
// Добавление в друзья
$NName = $_POST['NName'];
$_friend = array_shift(xs2GetNodes(array('condition'=>"NName='$NName'", 'NType'=>'blog')));
if ($_friend) {
$blog['Friends'][] = $_friend;
xs2UpdateNode($blog);
}
}
elseif ($_POST['action']=='removeFriend' && $_POST['friendId']) {
// Удаление из друзей
$blog['Friends'] = XSCore_removeFromArray($blog['Friends'], 'NodId', $_POST['friendId']);
xs2UpdateNode($blog);
}
}
// Друзья блога
$blog['Friends'] = XSCore_indexArray($blog['Friends'], 'NodId');
// Этот блог в друзьях у...
$blog['_friendsOf'] = xs2GetLinks(array('NodId'=> $nodeId,
'NType'=> 'blog', 'lnkField'=> 'Friends'));
// Взаимные друзья
if (count($blog['_friendsOf']) && count($blog['Friends'])) {
$_mutualFriends = array_intersect(array_map('_getNodId', array_filter($blog['Friends'])),
array_map('_getNodId', array_filter($blog['_friendsOf'])));
foreach ($blog['Friends'] as $_key=> $_friend) {
$blog['Friends'][$_key]['_isMutual'] = in_array($_friend['NodId'], $_mutualFriends);
}
foreach ($blog['_friendsOf'] as $_key=> $_friend) {
$blog['_friendsOf'][$_key]['_isMutual'] = in_array($_friend['NodId'], $_mutualFriends);
}
}
$_HTML->assign('blog', $blog);
?>
|
|