<?php
/**
 * Open Source Social Network
 *
 * @package Open Source Social Network
 * @author    OSSN Core Team <info@openteknik.com>
 * @copyright (C) OPENTEKNIK  LLC, COMMERCIAL LICENSE
 * @license   OPENTEKNIK  LLC, COMMERCIAL LICENSE, COMMERCIAL LICENSE https://www.openteknik.com/license/commercial-license-v1
 * @link      http://www.opensource-socialnetwork.org/licence
 */
$guid              = input('guid');
$type              = input('type');
$friend            = input('friend');
$group             = input('group');
$friend_group_guid = false;
$wall              = new OssnWall();
$post              = $wall->GetPost($guid);
if($post && isset($post->item_type) && $post->item_type == 'post:share:post') {
		$guid = intval($post->item_guid);
}
if(!empty($friend)) {
		$friend_group_guid = $friend;
}
if(!empty($group)) {
		$friend_group_guid = $group;
}
if(empty($friend_group_guid) && ($type == 'friend' || $type == 'group')) {
		ossn_trigger_message(ossn_print('post:share:error'), 'error');
		redirect(REF);
}
if(share_post($type, $guid, $friend_group_guid)) {
		ossn_trigger_message(ossn_print('post:shared'));
		redirect(REF);
}
ossn_trigger_message(ossn_print('post:share:error'), 'error');
redirect(REF);