Beispiel #1
0
	static function addFriend( $friendUID, $uID=0, $status=''){
		if( !intval($friendUID) ) return false;
		if( !intval($uID) ){
			$u = new User();
			if(!$u || !intval($u->uID)) return false;
			$uID=$u->uID;
		}
		$db = Loader::db();			
		if( UsersFriends::isFriend( $friendUID, $uID ) ){
			$vals = array( $status, $friendUID, $uID );
			$sql = 'UPDATE UsersFriends SET status=? WHERE friendUID=? AND uID=?'; 
		}else{ 
			$vals = array( $friendUID, $uID, $status, date("Y-m-d H:i:s")); 
			$sql = 'INSERT INTO UsersFriends ( friendUID, uID, status, uDateAdded ) values (?, ?, ?, ?)'; 
		}			
		$db->query($sql,$vals); 
		Events::fire('on_user_friend_add', $uID, $friendUID);
		return true;
	}	
Beispiel #2
0
 public function remove_friend($fuID = 0, $token = "")
 {
     /** @type ValidationTokenHelper $token_helper */
     $token_helper = Loader::helper('validation/token');
     $user_id = intval($fuID);
     if ($token_helper->validate("profile.remove_friend.{$user_id}", $token)) {
         $user = User::getByUserID($user_id);
         if (!$user->isError()) {
             UsersFriends::removeFriend($user->getUserID());
         } else {
             $this->error->add(t('Invalid User ID'));
         }
     } else {
         $this->error->add('Invalid Token.');
     }
     if ($this->error->has()) {
         $this->set('error', $this->error);
     }
     $this->view();
 }
Beispiel #3
0
 public function getFriends()
 {
     $friends = UsersFriends::model()->approved()->getUserFriends($this->id);
     $out = [];
     foreach ($friends as $item) {
         if ($item->first_user == $this->id) {
             $out[] = ["id" => $item->second_user];
         } else {
             $out[] = ["id" => $item->first_user];
         }
     }
     return $out;
 }
Beispiel #4
0
<?php  $av = Loader::helper('concrete/avatar'); ?>
<div id="ccm-profile-sidebar">
	<div class="ccm-profile-header">
		<a href="<?php echo View::url('/profile',$profile->getUserID())?>"><?php echo  $av->outputUserAvatar($profile)?></a><br />
		<a href="<?php echo View::url('/profile',$profile->getUserID())?>"><?php echo  $profile->getUsername()?></a>
	</div>
	<div style="margin-top:16px; padding-bottom:4px; margin-bottom:0px; font-weight:bold"><?php echo t('Member Since')?></div>
	<?php echo date(DATE_APP_GENERIC_MDY_FULL, strtotime($profile->getUserDateAdded('user')))?>
	
	<?php  
	$u = new User();
	if ($u->isRegistered() && $u->getUserID() != $profile->getUserID()) { ?>
	<div style="margin-top:16px;">
		<div>
		<?php  if( !UsersFriends::isFriend( $profile->getUserID(), $u->uID ) ){ ?>
			<a href="<?php echo View::url('/profile/friends','add_friend', $profile->getUserID())?>">
				<?php echo t('Add to My Friends') ?>
			</a>
		<?php  }else{ ?>
			<a href="<?php echo View::url('/profile/friends','remove_friend', $profile->getUserID() )?>">
				<?php echo t('Remove from My Friends') ?>
			</a>
		<?php  } ?>
		
		</div>
		<?php  if ($profile->getUserProfilePrivateMessagesEnabled() == 1) { ?>
			<a href="<?php echo $this->url('/profile/messages', 'write', $profile->getUserID())?>"><?php echo t('Send Private Message')?></a>	
		<?php  } ?>
		
	</div>
	<?php  } ?>
Beispiel #5
0
 public function remove_friend($fuID = 0)
 {
     UsersFriends::removeFriend(intval($fuID));
     $this->view();
 }
 public function actionDecline()
 {
     if (!isset($_GET['id'])) {
         throw new CHttpException(500, "err");
     }
     $friend = Users::model()->findByPk($_GET['id']);
     if (!$friend) {
         throw new CHttpException(404, "Друг не найден");
     }
     $friendsip = UsersFriends::model()->getFriendship(Yii::app()->user->id, $friend->id);
     if (!$friendsip) {
         throw new CHttpException(404, "Дружба не найдена");
     }
     if ($friendsip->second_user != Yii::app()->user->id) {
         throw new CHttpException(403, "Не ломай!");
     }
     $friendsip->approved = UsersFriends::DECLINED;
     $friendsip->since = time();
     $friendsip->save();
     Yii::app()->user->setFlash("success", "Вы больше не друзья");
     $this->redirect($friend->getProfileLink());
 }
Beispiel #7
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
?>
<div id="ccm-profile-wrapper">
   <?php 
Loader::element('profile/sidebar', array('profile' => $profile));
?>
    <div id="ccm-profile-body">
        <h1><?php 
echo t('My Friends');
?>
</h1>
        <?php 
$friendsData = UsersFriends::getUsersFriendsData($profile->getUserID());
if (!$friendsData) {
    ?>
			<div style="padding:16px 0px;">
				<?php 
    echo t('No results found.');
    ?>
			</div>
		<?php 
} else {
    foreach ($friendsData as $friendsData) {
        $friendUID = $friendsData['friendUID'];
        $friendUI = UserInfo::getById($friendUID);
        if (!is_object($friendUI)) {
            ?>

			<div class="ccm-users-friend" style="margin-bottom:16px;">
Beispiel #8
0
        <div class="col-md-12">
            <h2>Друзья</h2>
            <hr/>
            <ul class="nav nav-tabs">
                <li class="active"><a>Все друзья</a></li>
                <li class="pull-right"><a href="<?php 
echo $this->createUrl("denied");
?>
">Отклоненные</a></li>
                <li class="pull-right"><a href="<?php 
echo $this->createUrl("pending");
?>
">В ожидании</a></li>
            </ul>
            <?php 
$f = UsersFriends::model()->with("u1", "u2")->approved()->getUserFriends(Yii::app()->user->id);
$online = [];
$offline = [];
foreach ($f as $item) {
    if ($item->first_user == Yii::app()->user->id) {
        if (Yii::app()->redis->get("online_" . mb_strtolower($item->u2->username))) {
            $online[] = $item->u2->id;
        } else {
            $offline[] = $item->u2->id;
        }
    } else {
        if (Yii::app()->redis->get("online_" . mb_strtolower($item->u1->username))) {
            $online[] = $item->u1->id;
        } else {
            $offline[] = $item->u1->id;
        }
Beispiel #9
0
            <hr/>
            <ul class="nav nav-tabs">
                <li><a href="<?php 
echo $this->createUrl("friends");
?>
">Все друзья</a></li>
                <li class="pull-right"><a href="<?php 
echo $this->createUrl("declined");
?>
">Отклоненные</a></li>
                <li class="active pull-right"><a>В ожидании</a></li>
            </ul>
            <div class="row">
                <div class="col-md-12" style="padding: 20px">
                    <?php 
$f = UsersFriends::model()->pending()->getUserFriends(Yii::app()->user->id);
if (count($f) > 0) {
    ?>
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th width="40%">Кто</th>
                                <th width="30%">Действие</th>
                                <th width="30%">Отправелено в</th>
                            </tr>
                            </thead>
                            <?php 
    foreach ($f as $item) {
        ?>
                                <tr>
                                    <td><?php 
Beispiel #10
0
?>
        <h2><?php 
echo $model->username;
?>
</h2>

        <?php 
echo $model->getOnline();
?>

        <?php 
if (!Yii::app()->user->isGuest && Yii::app()->user->getId() != $model->id) {
    /**
     * @var $fr UsersFriends
     */
    $fr = UsersFriends::model()->getFriendship(Yii::app()->user->getId(), $model->id);
    if ($fr) {
        if ($fr->approved == UsersFriends::APPROVED) {
            ?>
                    <div class="btn-group actions">
                        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                            Вы уже друзья <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li>
                                <a href="<?php 
            echo $this->createUrl("/personal/friends/DeleteFriend", ["id" => $model->id]);
            ?>
"
                                   class="text-bold">Удалить из друзей</a></li>
                        </ul>
Beispiel #11
0
            <hr/>
            <ul class="nav nav-tabs">
                <li><a href="<?php 
echo $this->createUrl("friends");
?>
">Все друзья</a></li>
                <li class="active pull-right"><a>Отклоненные</a></li>
                <li class="pull-right"><a href="<?php 
echo $this->createUrl("pending");
?>
">В ожидании</a></li>
            </ul>
            <div class="row">
                <div class="col-md-12" style="padding: 20px">
                    <?php 
$f = UsersFriends::model()->declined()->getUserFriends(Yii::app()->user->id);
if (count($f) > 0) {
    ?>
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th width="40%">Друг</th>
                                <th width="30%">Действие</th>
                                <th width="30%">Отказано в</th>
                            </tr>
                            </thead>
                            <?php 
    foreach ($f as $item) {
        ?>
                                <tr>
                                    <td><?php