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; }
<?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 } ?>