本文整理汇总了PHP中is_friend函数的典型用法代码示例。如果您正苦于以下问题:PHP is_friend函数的具体用法?PHP is_friend怎么用?PHP is_friend使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_friend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPerm
function checkPerm($permission, $contentOwnerID)
{
$currUserID = wp_get_current_user();
$currUserID = $currUserID->ID;
$privacySettings = get_usermeta($contentOwnerID, 'privacy_settings');
if ($privacySettings) {
foreach ($privacySettings as $key => $perm) {
if ($key == $permission) {
$permission = $perm;
}
}
}
$friendList = new userFriends();
$friends = $friendList->get_friends($contentOwnerID);
if ($permission['status'] == 'friends' && is_friend($contentOwnerID)) {
return true;
}
if ($permission['status'] == 'all_members' && is_user_logged_in()) {
return true;
}
if ($permission['status'] == 'public') {
return true;
}
if ($currUserID == $contentOwnerID) {
return true;
}
return false;
// If someone hasn't set their privacy then we default to private
}
示例2: get_all
public function get_all()
{
$this->db->order_by("date", "desc");
$query = $this->db->get('statusupdates');
$users = array();
foreach ($query->result() as $row) {
$this->load->helper('misc_helper');
//check if it is a friend
if (is_friend($row->userid) or $row->userid == get_user()->get_id()) {
array_push($users, $this->prep_status($row));
}
}
return $users;
}
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER, $exporter;
$userid = $instance->get_view()->get('owner');
if (!$userid) {
// 'My Friends' doesn't make sense for group/site views
return '';
}
$limit = isset($exporter) ? false : MAXFRIENDDISPLAY;
$friends = get_friends($userid, $limit, 0);
if ($friends['count']) {
self::build_myfriends_html($friends, $userid, $instance);
} else {
$friends = false;
}
$smarty = smarty_core();
$smarty->assign('friends', $friends);
$smarty->assign('searchingforfriends', array('<a href="' . get_config('wwwroot') . 'user/find.php">', '</a>'));
// If the user has no friends, try and display something useful, such
// as a 'request friendship' button
if (!$friends) {
$loggedinid = $USER->get('id');
$is_friend = is_friend($userid, $loggedinid);
if ($is_friend) {
$relationship = 'existingfriend';
} else {
if (record_exists('usr_friend_request', 'requester', $loggedinid, 'owner', $userid)) {
$relationship = 'requestedfriendship';
} else {
$relationship = 'none';
$friendscontrol = get_account_preference($userid, 'friendscontrol');
if ($friendscontrol == 'auto') {
require_once 'pieforms/pieform.php';
$newfriendform = pieform(array('name' => 'myfriends_addfriend', 'successcallback' => 'addfriend_submit', 'autofocus' => false, 'renderer' => 'div', 'elements' => array('add' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-default', 'value' => '<span class="icon icon-user-plus icon-lg prs"></span>' . get_string('addtomyfriends', 'group')), 'id' => array('type' => 'hidden', 'value' => $userid))));
$smarty->assign('newfriendform', $newfriendform);
}
$smarty->assign('friendscontrol', $friendscontrol);
}
}
$smarty->assign('relationship', $relationship);
}
$smarty->assign('loggedin', is_logged_in());
$smarty->assign('lookingatownpage', $USER->get('id') == $userid);
$smarty->assign('USERID', $userid);
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
示例4: permitted
function permitted($another_id)
{
return $another_id == current_user()['id'] || is_friend($another_id);
}
示例5: select_thumbnail_image
?>
">
<img src="<?php
echo select_thumbnail_image($row->id, $row->hasimage);
?>
" alt="" />
</a>
<a href="<?php
echo profile_route($row->id);
?>
"><?php
echo $row->firstname . ' ' . $row->lastname;
?>
</a>
<?php
if (!is_friend($row->id)) {
?>
- <a href="<?php
echo friends_add_route($row->id);
?>
">add as friend</a>
<?php
}
?>
</li>
<?php
}
?>
</ul>
<?php
}
示例6: foreach
foreach (prefectures() as $pref) {
?>
<option <?php
h($profile['pref'] == $pref ? 'selected' : '');
?>
><?php
h($pref);
?>
</option>
<?php
}
?>
</select>
</div>
<div><input type="submit" value="更新" /></div>
</form>
</div>
<?php
} elseif (!is_friend($owner['id'])) {
?>
<h2>あなたは友だちではありません</h2>
<div id="profile-friend-form">
<form method="POST" action="/friends/<?php
h($owner['account_name']);
?>
">
<input type="submit" value="このユーザと友だちになる" />
</form>
</div>
<?php
}
示例7: addfriend_submit
function addfriend_submit(Pieform $form, $values)
{
global $USER, $SESSION;
$user = get_record('usr', 'id', $values['id']);
$loggedinid = $USER->get('id');
if (is_friend($loggedinid, $user->id)) {
$SESSION->add_info_msg(get_string('alreadyfriends', 'group', display_name($user)));
delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $user->id);
redirect(profile_url($user));
}
// friend db record
$f = new StdClass();
$f->ctime = db_format_timestamp(time());
// notification info
$n = new StdClass();
$n->url = profile_url($USER, false);
$n->users = array($user->id);
$lang = get_user_language($user->id);
$displayname = display_name($USER, $user);
$n->urltext = $displayname;
$f->usr1 = $values['id'];
$f->usr2 = $loggedinid;
db_begin();
delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $user->id);
insert_record('usr_friend', $f);
db_commit();
$n->subject = get_string_from_language($lang, 'addedtofriendslistsubject', 'group', $displayname);
$n->message = get_string_from_language($lang, 'addedtofriendslistmessage', 'group', $displayname, $displayname);
require_once 'activity.php';
activity_occurred('maharamessage', $n);
handle_event('addfriend', array('user' => $f->usr2, 'friend' => $f->usr1));
$SESSION->add_ok_msg(get_string('friendformaddsuccess', 'group', display_name($user)));
redirect(profile_url($user));
}
示例8: define
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'groups/findfriends');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
$id = param_integer('id');
if (!is_friend($id, $USER->get('id')) || !($user = get_record('usr', 'id', $id, 'deleted', 0))) {
throw new AccessDeniedException(get_string('cantremovefriend', 'group'));
}
$user->introduction = get_field('artefact', 'title', 'artefacttype', 'introduction', 'owner', $id);
define('TITLE', get_string('removefromfriends', 'group', display_name($id)));
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
示例9: select_profile_image
<div id="profile-left-item">
<div class="float-left">
<img src="<?php
echo select_profile_image($user->id, $user->hasimage);
?>
" alt="" width="180px"/>
</div>
<div class="float-left" style="margin-bottom: 14px;">
<h4>
<?php
echo $user->firstname . ' ' . $user->lastname;
?>
</h4>
<?php
if (!is_friend($user->id)) {
?>
<a href="<?php
echo friends_add_route($user->id, TRUE);
?>
">add as friend</a>
<?php
}
?>
</div>
<div class="clear"></div>
<div class="left-menu-line"></div>
</div>
<div id="profile-left-item">
<div class="float-left">
<h3>Friends</h3>
示例10: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
$userid = $instance->get_view()->get('owner');
if (!$userid) {
// 'My Friends' doesn't make sense for group/site views
return '';
}
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?
ORDER BY ' . db_random() . '
LIMIT ?', array($userid, $userid, MAXFRIENDDISPLAY));
// get the friends into a 4x4 array
if ($records) {
$friends = array();
for ($i = 0; $i < 4; $i++) {
if (isset($records[4 * $i])) {
$friends[$i] = array();
for ($j = 4 * $i; $j < ($i + 1) * 4; $j++) {
if (isset($records[$j])) {
if ($records[$j]->usr1 == $userid) {
$friends[$i][] = $records[$j]->usr2;
} else {
$friends[$i][] = $records[$j]->usr1;
}
}
}
}
}
} else {
$friends = false;
}
$smarty->assign('friends', $friends);
// If the user has no friends, try and display something useful, such
// as a 'request friendship' button
$loggedinid = $USER->get('id');
$is_friend = is_friend($userid, $loggedinid);
if ($is_friend) {
$relationship = 'existingfriend';
} else {
if (record_exists('usr_friend_request', 'requester', $loggedinid, 'owner', $userid)) {
$relationship = 'requestedfriendship';
} else {
$relationship = 'none';
$friendscontrol = get_account_preference($userid, 'friendscontrol');
if ($friendscontrol == 'auto') {
$newfriendform = pieform(array('name' => 'myfriends_addfriend', 'successcallback' => 'addfriend_submit', 'autofocus' => false, 'renderer' => 'div', 'elements' => array('add' => array('type' => 'submit', 'value' => get_string('addtomyfriends', 'group')), 'id' => array('type' => 'hidden', 'value' => $userid))));
$smarty->assign('newfriendform', $newfriendform);
}
$smarty->assign('friendscontrol', $friendscontrol);
}
}
$smarty->assign('relationship', $relationship);
$smarty->assign_by_ref('USER', $USER);
$smarty->assign('USERID', $userid);
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
示例11: redirect
}
if ($userid == 0) {
redirect();
}
// Get the user's details
if (!isset($user)) {
if (!($user = get_record('usr', 'id', $userid, 'deleted', 0))) {
if ($USER->is_logged_in()) {
throw new UserNotFoundException("User with id {$userid} not found");
} else {
// For logged-out users we show "access denied" in order to prevent an enumeration attack
throw new AccessDeniedException(get_string('youcannotviewthisusersprofile', 'error'));
}
}
}
$is_friend = is_friend($userid, $loggedinid);
if ($loggedinid == $userid) {
$view = $USER->get_profile_view();
} else {
$userobj = new User();
$userobj->find_by_id($userid);
$view = $userobj->get_profile_view();
}
# access will either be logged in (always) or public as well
if (!$view) {
// No access, so restrict profile view
throw new AccessDeniedException(get_string('youcannotviewthisusersprofile', 'error'));
}
$viewid = $view->get('id');
// Special behaviour: Logged in users who the page hasn't been shared with, see a special page
// with the user's name, icon, and little else.
示例12: define
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'groups/findfriends');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'pieforms/pieform.php';
$id = param_integer('id');
$returnto = param_alpha('returnto', 'myfriends');
if (is_friend($id, $USER->get('id')) || get_friend_request($id, $USER->get('id')) || get_account_preference($id, 'friendscontrol') != 'auth' || $id == $USER->get('id') || !($user = get_record('usr', 'id', $id, 'deleted', 0))) {
throw new AccessDeniedException(get_string('cantrequestfriendship', 'group'));
}
$user->introduction = get_field('artefact', 'title', 'artefacttype', 'introduction', 'owner', $id);
define('TITLE', get_string('sendfriendshiprequest', 'group', display_name($id)));
$form = pieform(array('name' => 'requestfriendship', 'autofocus' => false, 'elements' => array('message' => array('type' => 'textarea', 'title' => get_string('message'), 'cols' => 50, 'rows' => 4), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('requestfriendship', 'group'), get_string('cancel')), 'goto' => get_config('wwwroot') . ($returnto == 'find' ? 'user/find.php' : ($returnto == 'view' ? 'user/view.php?id=' . $id : 'user/myfriends.php'))))));
$smarty = smarty();
$smarty->assign('heading', TITLE);
$smarty->assign('form', $form);
$smarty->assign('user', $user);
$smarty->display('user/requestfriendship.tpl');
function requestfriendship_submit(Pieform $form, $values)
{
global $USER, $SESSION, $id;
$loggedinid = $USER->get('id');
$user = get_record('usr', 'id', $id);
示例13: session_write_close
if (isset($options['query']['0']) && in_array($options['query']['0'], $submodules_allowed)) {
$submodule = $options['query']['0'];
$template = 'user_favorite_' . $submodule;
require 'modules/user/favorite_' . $submodule . '.php';
} else {
session_write_close();
header('Location: ' . $config['BASE_URL'] . '/error/invalid_module');
die;
}
} else {
$template = 'user_' . $module;
require 'modules/user/' . $module . '.php';
}
} else {
$prefs = get_user_prefs($uid);
$is_friend = is_friend($uid);
$friends = get_user_friends($uid, $prefs['show_friends'], $is_friend);
$playlist = get_user_playlist($uid, $prefs['show_playlist'], $is_friend);
$favorites = get_user_favorites($uid, $prefs['show_favorites'], $is_friend);
$subscriptions = get_user_subscriptions($uid, $prefs['show_subscriptions'], $is_friend);
$subscribers = get_user_subscribers($uid, $prefs['show_subscribers'], $is_friend);
$albums = get_user_albums($uid);
$photos = get_user_favorite_photos($uid, $prefs['show_favorites'], $is_friend);
$games = get_user_favorite_games($uid, $prefs['show_favorites'], $is_friend);
$show_wall = false;
$wall_public = $prefs['wall_public'];
$walls = array();
$walls_total = 0;
if ($wall_public == '1') {
$show_wall = true;
} else {
示例14: profile_route
<a href="<?php
echo profile_route($row->id);
?>
"><img src="<?php
echo select_thumbnail_image($row->id, $row->hasimage);
?>
" /></a>
<a href="<?php
echo profile_route($row->id);
?>
"><?php
echo $row->firstname . ' ' . $row->lastname;
?>
</a>
<?php
if (!is_friend(get_user()->get_id(), $row->id)) {
?>
- <a href="<?php
echo friends_add_route($row->id);
?>
">add as friend</a>
<?php
}
?>
</li>
<?php
}
?>
</ul>
<?php
}
示例15: can_send_message
/**
* can a user send a message to another?
*
* @param int/object from the user to send the message
* @param int/object to the user to receive the message
* @return boolean whether userfrom is allowed to send messages to userto
*/
function can_send_message($from, $to)
{
if (empty($from)) {
return false;
// not logged in
}
if (!is_object($from)) {
$from = get_record('usr', 'id', $from);
}
if (is_object($to)) {
$to = $to->id;
}
$messagepref = get_account_preference($to, 'messages');
return is_friend($from->id, $to) && $messagepref == 'friends' || $messagepref == 'allow' || $from->admin;
}