本文整理汇总了PHP中Network::leave方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::leave方法的具体用法?PHP Network::leave怎么用?PHP Network::leave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::leave方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
}
}
}
}
//deleting user
try {
User::delete($user_id);
} catch (PAException $e) {
Logger::log('User has been already deleted');
}
} else {
//user delete for network owner
$network_prefix = $network_info->address;
try {
User::delete_user($user_id);
Network::leave($network_info->network_id, $user_id);
//network leave
} catch (PAException $e) {
$message_array[] = $e->message;
}
}
if ($_GET['msg'] == 'own_delete') {
$location .= '?msg=7031';
} else {
$location .= '?msg=7020';
}
}
if (count($message_array)) {
Logger::log('User with user_id = ' . $user_id . ' has been deleted with some errors.' . implode(',', $message_array) . '');
}
header("Location: {$location}");
示例2: delete_users
/**
* @author Z.Hron
* @name delete_users
* @brief This function delete array of users
* @return array of error messages
*
*
*/
function delete_users($params, $true_delete = FALSE)
{
$message_array = array();
$user_id_array = $params['user_id_array'];
foreach ($user_id_array as $user_id) {
if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
$message_array[] = "UserID {$user_id} does not exists.";
continue;
}
//deleting user data from mothership
try {
User::delete_user($user_id);
Activities::delete_for_user($user_id);
} catch (CNException $e) {
$message_array[] = $e->message;
}
$user_networks = Network::get_user_networks($user_id);
if (count($user_networks)) {
foreach ($user_networks as $network) {
if ($network->user_type != NETWORK_OWNER) {
$network_prefix = $network->address;
try {
User::delete_user($user_id);
Activities::delete_for_user($user_id);
Network::leave($network->network_id, $user_id);
//leave
} catch (CNException $e) {
$message_array[] = $e->message;
}
} else {
try {
Network::delete($network->network_id);
} catch (CNException $e) {
$message_array[] = $e->message;
}
}
}
}
//deleting user
try {
User::delete($user_id, $true_delete);
} catch (CNException $e) {
Logger::log('User has been already deleted');
}
} else {
//user delete for network owner
if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
$message_array[] = "UserID {$user_id} does not exists.";
continue;
}
$network_prefix = PA::$network_info->address;
try {
User::delete_user($user_id);
Activities::delete_for_user($user_id);
Network::leave(PA::$network_info->network_id, $user_id);
//network leave
} catch (CNException $e) {
$message_array[] = $e->message;
}
}
}
return $message_array;
}
示例3: User
$requester = new User();
$requester->load((int) $_SESSION['user']['id']);
$recipient = type_cast($netinfo, 'Network');
// defined in helper_functions.php
PANotify::send("network_join", $recipient, $requester, array());
$redirect_url = "http://" . $netinfo->address . "." . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_HOME_PAGE . "/msg=7001";
header("Location:{$redirect_url}");
exit;
// $msg = "You have successfully joined the '".stripslashes($netinfo->name)."' network. Click <a href='http://".$netinfo->address.".".PA::$domain_suffix.BASE_URL_REL."/homepage.php'>here</a> to go to network.";
} else {
//$msg = "Please login first to join the network.";
header("Location: " . PA::$url . "/login.php?error=1&return=" . urlencode($_SERVER['REQUEST_URI']));
}
} else {
if ($_GET['action'] == 'leave') {
try {
if ($_SESSION['user']['id']) {
$suc = Network::leave((int) PA::$network_info->network_id, (int) $_SESSION['user']['id']);
if ($suc) {
$_SESSION['user']['action'] = 'leave network';
$redirect_url = "http://" . PA::$network_info->address . "." . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_HOME_PAGE . "/msg=7008";
header("Location:{$redirect_url}");
exit;
}
}
} catch (PAException $e) {
$msg .= $e->message;
echo "UNSUCCESS: {$msg}";
}
}
}
示例4: testNetworkCreation
function testNetworkCreation()
{
// check that we can create networks
$can = Network::can_network_be_created();
$this->assertFalse($can['error'], $can['error_msg']);
// get network owner user and figure out name etc
$user = Test::get_test_user();
$name = "testnet" . rand(10000, 99999);
$network_basic_controls = array();
// with crossed fingers, we hope that it will succeed without any of the detail here!
// make a new network
$net = new Network();
$net->set_params(array('user_id' => $user->user_id, 'name' => "auto-test network ({$name})", 'address' => $name, 'tagline' => "not much of a tagline", 'category_id' => 8, 'type' => 0, 'description' => "This network has been created automatically by a PHPUnit test. If the test succeeds, it will be deleted, too!", 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time()));
$net->save();
//default_page_setting($net->address);
// read it in again and see if it still works
$net_read = Network::get_network_by_address($net->address);
$this->assertEquals($net_read->network_id, $net->network_id);
$this->assertEquals($net_read->type, 0);
$this->assertEquals($net_read->member_count, 1);
$this->assertEquals($net_read->owner_id, $user->user_id);
// a user joins
$user2 = Test::get_test_user(2);
Network::join($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
// a user leaves
Network::leave($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// make it into a moderated network
$net->type = 2;
$net->save();
// check that it really is moderated
$net_read = Network::get_network_by_address($net->address);
$this->assertEquals($net_read->network_id, $net->network_id);
$this->assertEquals($net_read->type, 2);
// a user requests
Network::join($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// request approved
Network::approve($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
// user leaves
Network::leave($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// user requests
Network::join($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// all requests accepted (of course, there will only be the one)
Network::approve_all($net->network_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
// user leaves
Network::leave($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// user requests
Network::join($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// request denied
Network::deny($net->network_id, $user2->user_id);
$this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
// delete network
Network::delete($net->network_id);
}