本文整理汇总了PHP中Network::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::join方法的具体用法?PHP Network::join怎么用?PHP Network::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::join方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handlePOST
public function handlePOST($request_data)
{
global $mothership_info;
if (!empty($request_data['request'])) {
//code for requesting
$this->error = FALSE;
$this->success = FALSE;
try {
$request_sent = Network::join(PA::$network_info->network_id, PA::$login_uid);
if (!empty($request_sent)) {
$this->success = TRUE;
}
} catch (PAException $e) {
$join_error = $e->message;
$this->error = TRUE;
}
if (!empty($this->error)) {
$this->error_msg = sprintf(__('Your request to join this network could not be sent due to following reason: %s. You can go back to the home network by clicking Return to home network'), $join_error);
} else {
$this->success_msg = __('Your request to join this network has been successfully sent to the moderator of this network. The Moderator will check this request and approve or deny the request. You can go back to mother network by clicking the button Return to home network');
}
$this->mode = 'msg_display';
}
if (!empty($request_data['back'])) {
//redirect to mother network
global $mothership_info;
$this->message = __('Return to home network successfully.');
$this->redirect2 = NULL;
$his->queryString = NULL;
$this->isError = FALSE;
$this->setWebPageMessage();
}
}
示例2: uihelper_add_default_desktopimage
User_Registration::add_default_links($newuser->user_id);
// code for adding default desktop image for user
$desk_img = uihelper_add_default_desktopimage($newuser->user_id);
if (empty($desk_img)) {
$desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
$rand_key = array_rand($desktop_images);
$desk_img = $desktop_images[$rand_key];
}
$data_array = array(0 => array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1));
$newuser->save_user_profile($data_array, GENERAL);
//sending mail to the newly created user
$msg = "User has been Added successfully";
//if new user is created in a network then he must set as a joined user
if (!empty(PA::$network_info)) {
$by_admin = true;
Network::join(PA::$network_info->network_id, $newuser->user_id, NETWORK_MEMBER, $by_admin);
// $by_admin = true overrides the
// user_waiting status if it would get set
// this is an admin action, so we want it to happen in any case
}
$form_data = array();
} catch (CNException $e) {
$msg = $e->message;
}
}
// end if
}
//end if
}
//main if
function setup_module($column, $module, $obj)
示例3: register
//.........这里部分代码省略.........
$this->newuser->picture = Storage::validateFileId(@$params['user_filename']);
}
}
if ($this->error != TRUE) {
try {
$save_error = FALSE;
$extra = unserialize($network_info->extra);
if ($mother_extra['email_validation'] == NET_NO || $this->api_call == true) {
// if email validation not required
$this->newuser->is_active = ACTIVE;
} else {
$this->newuser->is_active = UNVERIFIED;
}
$this->newuser->save();
if ($this->newuser->picture) {
Storage::link($this->newuser->picture, array("role" => "avatar", "user" => $this->newuser->user_id));
}
/* The following code should now be obsolete as this is done in User->save() */
// saving data in user profile data also -- for searching making more easier
$data_array = array(array('uid' => $this->newuser->user_id, 'name' => 'first_name', 'value' => $this->newuser->first_name, 'type' => BASIC, 'perm' => 1), array('uid' => $this->newuser->user_id, 'name' => 'last_name', 'value' => $this->newuser->last_name, 'type' => BASIC, 'perm' => 1));
$this->newuser->save_user_profile($data_array, BASIC);
// saving default notification for user from network notification setting
$user_notification = array();
$profile = array();
$user_notification = $extra['notify_members'];
$user_notification['msg_waiting_blink'] = $extra['msg_waiting_blink'];
$profile['settings']['name'] = 'settings';
$profile['settings']['value'] = serialize($user_notification);
$this->newuser->save_profile_section($profile, 'notifications');
// default notification for user ends
$desktop_images = User_Registration::get_default_desktopimage($this->newuser->user_id, $network_info);
// code for adding default desktop image for user
if ($desktop_images == "") {
$desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
$rand_key = array_rand($desktop_images);
$desk_img = $desktop_images[$rand_key];
} else {
$desk_img = $desktop_images;
}
$data_array = array(0 => array('uid' => $this->newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => NONE), 1 => array('uid' => $this->newuser->user_id, 'name' => 'dob_day', 'value' => $dob_day, 'type' => GENERAL, 'perm' => NONE), 2 => array('uid' => $this->newuser->user_id, 'name' => 'dob_month', 'value' => $dob_month, 'type' => GENERAL, 'perm' => NONE), 3 => array('uid' => $this->newuser->user_id, 'name' => 'dob_year', 'value' => $dob_year, 'type' => GENERAL, 'perm' => NONE), 4 => array('uid' => $this->newuser->user_id, 'name' => 'dob', 'value' => $dob_year . '-' . $dob_month . '-' . $dob_day, 'type' => GENERAL, 'perm' => NONE), 5 => array('uid' => $this->newuser->user_id, 'name' => 'homeAddress1', 'value' => $homeAddress1, 'type' => GENERAL, 'perm' => NONE), 6 => array('uid' => $this->newuser->user_id, 'name' => 'homeAddress2', 'value' => $homeAddress2, 'type' => GENERAL, 'perm' => NONE), 7 => array('uid' => $this->newuser->user_id, 'name' => 'city', 'value' => $city, 'type' => GENERAL, 'perm' => NONE), 8 => array('uid' => $this->newuser->user_id, 'name' => 'state', 'value' => $state, 'type' => GENERAL, 'perm' => NONE), 9 => array('uid' => $this->newuser->user_id, 'name' => 'country', 'value' => $country, 'type' => GENERAL, 'perm' => NONE), 10 => array('uid' => $this->newuser->user_id, 'name' => 'postal_code', 'value' => $postal_code, 'type' => GENERAL, 'perm' => NONE), 11 => array('uid' => $this->newuser->user_id, 'name' => 'phone', 'value' => $phone, 'type' => GENERAL, 'perm' => NONE));
//}
$this->newuser->save_user_profile($data_array, GENERAL);
if ($mother_extra['email_validation'] == NET_NO || $this->api_call == true) {
//if email validation is not required
// creating message basic folders
Message::create_basic_folders($this->newuser->user_id);
// adding default relation
if ($this->newuser->user_id != SUPER_USER_ID) {
User_Registration::add_default_relation($this->newuser->user_id, $network_info);
}
// adding default media as well as album
User_Registration::add_default_media($this->newuser->user_id, '', $network_info);
User_Registration::add_default_media($this->newuser->user_id, '_audio', $network_info);
User_Registration::add_default_media($this->newuser->user_id, '_video', $network_info);
User_Registration::add_default_blog($this->newuser->user_id);
//adding default link categories & links
User_Registration::add_default_links($this->newuser->user_id);
// adding header image
User_Registration::add_default_header($this->newuser->user_id);
// Making user member of a network if he is registering to PA from a network
if (!empty($network_info) && $network_info->type != PRIVATE_NETWORK_TYPE) {
$user_type = null;
$register_by_admin = false;
if ($this->api_call == true) {
// since this is an API call, default this member as a
// NETWORK_MEMBER since they already registered
$user_type = NETWORK_MEMBER;
// since this is an API call, act like it is registration by admin
$register_by_admin = true;
}
Network::join($network_info->network_id, $this->newuser->user_id, $user_type, $register_by_admin);
if ($this->api_call == false) {
// only send notification of network if this is NOT an API call
PANotify::send("network_join", $network_info, $this->newuser, array());
}
}
}
} catch (CNException $e) {
$this->msg = $e->message;
if ($e->code == USER_EMAIL_NOT_UNIQUE) {
$this->msg = "Email Address has already been taken, please enter other email address.";
}
$save_error = TRUE;
if ($e->message == "The email address is invalid.") {
$email_invalid = TRUE;
$this->array_of_errors['error_email'] = $email_invalid;
}
}
}
if ($this->error == TRUE || $save_error == TRUE) {
$this->msg = "Sorry! your registration failed. " . $this->msg;
return FALSE;
}
// success!
// give Login User permissions to new user is moved to Network::join() now!
/*
$this->newuser->set_user_role(array(LOGINUSER_ROLE));
*/
return TRUE;
}
示例4: Invitation
try {
$new_invite = new Invitation();
$new_invite->inv_id = $invitation_id;
$new_invite->inv_user_id = $_SESSION['user']['id'];
$new_invite->accept();
$inv_obj = Invitation::load($invitation_id);
$user_obj = new User();
$user_obj->load((int) $inv_obj->user_id);
$user_accepting_inv_obj = new User();
$user_accepting_inv_obj->load((int) $_SESSION['user']['id']);
$relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $user_accepting_inv_obj->user_id, PA::$network_info->network_id);
$relation_type = Relation::lookup_relation_type($relation_type_id);
$new_invite->inv_relation_type = $relation_type;
PANotify::send("invitation_accept", $user_obj, $user_accepting_inv_obj, $new_invite);
if (!Network::member_exists(PA::$network_info->network_id, (int) $_SESSION['user']['id'])) {
Network::join(PA::$network_info->network_id, $_SESSION['user']['id']);
PANotify::send("network_join", PA::$network_info, $user_accepting_inv_obj, array());
}
header("Location: " . PA::$url . PA_ROUTE_USER_PRIVATE . '/' . "msg_id=7016");
exit;
} catch (CNException $e) {
$msg = $e->message;
}
}
} else {
$msg = $token_arr[0] == FALSE ? $token_arr[1] : 7018;
header("Location: " . PA_ROUTE_HOME_PAGE . "/msg={$msg}");
exit;
}
}
$ConfigurableText = new ConfigurableText();
示例5: header
require_once "api/Roles/Roles.php";
if ($_GET['action'] == 'join') {
$nid = (int) $_GET['nid'];
// here we check that user is already join or not
if ($_SESSION['user']['id'] && Network::member_exists($nid, $_SESSION['user']['id'])) {
$redirect_url = "http://" . PA::$network_info->address . "." . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_HOME_PAGE . "/msg=7021";
header("Location:{$redirect_url}");
exit;
}
$error = 0;
if (!$nid) {
$error = 1;
}
if ($_SESSION['user']['id']) {
try {
$suc = Network::join($nid, $_SESSION['user']['id']);
if ($suc) {
// adding default relation
if ($_SESSION['user']['id'] != SUPER_USER_ID) {
uihelper_add_default_relation($_SESSION['user']['id']);
}
// adding default media as well as album
uihelper_add_default_media($_SESSION['user']['id']);
uihelper_add_default_media($_SESSION['user']['id'], '_audio');
uihelper_add_default_media($_SESSION['user']['id'], '_video');
uihelper_add_default_blog($_SESSION['user']['id']);
}
} catch (PAException $e) {
$msg = "{$e->message}";
}
$network = new Network();
示例6: PAException
// creating message basic folders
Message::create_basic_folders($newuser->user_id);
// adding default relation
if ($newuser->user_id != SUPER_USER_ID) {
User_Registration::add_default_relation($newuser->user_id, $network_info);
}
// adding default media as well as album
User_Registration::add_default_media($newuser->user_id, '', $network_info);
User_Registration::add_default_media($newuser->user_id, '_audio', $network_info);
User_Registration::add_default_media($newuser->user_id, '_video', $network_info);
User_Registration::add_default_blog($newuser->user_id);
//adding default link categories & links
User_Registration::add_default_links($newuser->user_id);
// Making user member of a network if he is registering to PA from a network
if (!empty($network_info)) {
Network::join($network_info->network_id, $newuser->user_id);
}
// register session
register_session($newuser->login_name, $newuser->user_id, $newuser->role, $newuser->first_name, $newuser->last_name, $newuser->email, $newuser->picture);
if (!empty($_GET['InvID'])) {
// if network invitation
$invitation_id = $_GET['InvID'];
$inv_error = "";
$error_inv = false;
try {
$is_valid = Invitation::validate_invitation_id($invitation_id);
if (!$is_valid) {
throw new PAException(INVALID_INV, "Sorry but the invitation ID you are using is no longer valid.");
}
$new_invite = new Invitation();
$new_invite->inv_id = $invitation_id;
示例7: 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);
}
示例8: User
$new_invite->inv_id = $invitation_id;
$new_invite->inv_user_id = $u;
$new_invite->accept();
$inv_obj = Invitation::load($invitation_id);
$user_obj = new User();
$user_obj->load((int) $inv_obj->user_id);
$relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $user_accepting_inv_obj->user_id, PA::$network_info->network_id);
$relation_type = Relation::lookup_relation_type($relation_type_id);
$new_invite->inv_relation_type = $relation_type;
PANotify::send("invitation_accept", $user_obj, $user_accepting_inv_obj, $new_invite);
if (!empty(PA::$network_info) && PA::$network_info->type != MOTHER_NETWORK_TYPE) {
if (!Network::member_exists(PA::$network_info->network_id, $u)) {
if (PA::$network_info->type == PRIVATE_NETWORK_TYPE && $inv_obj->user_id == PA::$network_info->owner_id) {
$user_type = NETWORK_MEMBER;
}
Network::join(PA::$network_info->network_id, $u, $user_type);
PANotify::send("network_join", PA::$network_info, $user_accepting_inv_obj, array());
}
}
} catch (CNException $e) {
$msg = "{$e->message}";
$error_inv = TRUE;
}
if ($error_inv == TRUE) {
// if error occured
$location = CNUrlHelper::url_for(PA::$url . '/cnuser_login.php', array('msg' => $msg, 'return' => $return_url), 'https');
header("Location: {$location}");
// header("Location:login.php?msg=$msg&return=$return_url");
exit;
}
$location = PA::$after_login_page . '/msg=7016';
示例9: uihelper_add_default_desktopimage
//adding default link categories & links
User_Registration::add_default_links($newuser->user_id);
// code for adding default desktop image for user
$desk_img = uihelper_add_default_desktopimage($newuser->user_id);
if (empty($desk_img)) {
$desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
$rand_key = array_rand($desktop_images);
$desk_img = $desktop_images[$rand_key];
}
$data_array = array(0 => array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1));
$newuser->save_user_profile($data_array, GENERAL);
//sending mail to the newly created user
$msg = "User has been Added successfully";
//if new user is created in a network then he must set as a joined user
if (!empty($network_info)) {
Network::join($network_info->network_id, $newuser->user_id, NETWORK_MEMBER);
}
$form_data = array();
} catch (PAException $e) {
$msg = $e->message;
}
}
// end if
}
//end if
}
//main if
function setup_module($column, $module, $obj)
{
global $paging, $form_data, $msg, $configure_permission;
if (!$configure_permission) {
示例10: handle_join
function handle_join()
{
$error_inv = false;
$invitation_id = isset($_REQUEST['InvID']) ? $_REQUEST['InvID'] : null;
$group_invitation_id = isset($_REQUEST['GInvID']) ? $_REQUEST['GInvID'] : null;
$mother_network_info = Network::get_mothership_info();
$extra = unserialize($mother_network_info->extra);
if (!$this->reg_user->register($_POST, PA::$network_info)) {
// registration failed
return;
}
// If the user is joining a network other than the
if ($mother_network_info->network_id != PA::$network_info->network_id) {
Network::join(1, $this->reg_user->newuser->user_id, NETWORK_MEMBER);
}
if ($extra['email_validation'] == NET_NO || $this->silent) {
// silent registration - no email validation!
// Success!
if (!$this->silent) {
register_session($this->reg_user->newuser->login_name, $this->reg_user->newuser->user_id, $this->reg_user->newuser->role, $this->reg_user->newuser->first_name, $this->reg_user->newuser->last_name, $this->reg_user->newuser->email, $this->reg_user->newuser->picture);
$_SESSION['login_source'] = 'password';
// password recently entered, so enable access to edit profile
PANotify::send("new_user_registered", PA::$network_info, $this->reg_user->newuser, array());
}
if ($invitation_id) {
// if an invitation to join a network
$this->inv_error = "";
$is_valid = Invitation::validate_invitation_id($invitation_id);
if (!$is_valid) {
$msg = 7017;
// invalid network invitation
}
if (empty($msg)) {
try {
// try to except invitation
$new_invite = new Invitation();
$new_invite->inv_id = $invitation_id;
$new_invite->inv_user_id = $this->reg_user->newuser->user_id;
$new_invite->accept();
$inv_obj = Invitation::load($invitation_id);
$user_obj = new User();
$user_obj->load((int) $inv_obj->user_id);
//if invitation is for private network
if (PA::$network_info->type == PRIVATE_NETWORK_TYPE) {
$user_type = NULL;
if (PA::$network_info->owner_id == $inv_obj->user_id) {
$user_type = NETWORK_MEMBER;
}
Network::join(PA::$network_info->network_id, $this->reg_user->newuser->user_id, $user_type);
}
$msg = 7016;
$relation_type = null;
$relationship_level = 2;
//default relation level id is 2 for friend
try {
$relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id, PA::$network_info->network_id);
} catch (PAException $e) {
Relation::add_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id, $relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED);
$relation_type = Relation::lookup_relation_type($relation_type_id);
}
$new_invite->inv_relation_type = $relation_type;
if (!$this->silent) {
PANotify::send("invitation_accept", $user_obj, $this->reg_user->newuser, $new_invite);
}
} catch (PAException $e) {
$this->inv_error = $e->message;
$this->reg_user->msg = "{$e->message}";
$error_inv = TRUE;
}
if ($error_inv == TRUE) {
// if invitation fails, then do login again
header("Location: " . PA::$url . "/login.php?msg=" . $this->reg_user->msg . "&return={$return_url}");
exit;
}
}
$redirect_url = PA_ROUTE_HOME_PAGE . '/msg=' . $msg;
} else {
if ($group_invitation_id) {
// if an invitation to join a group
// User registration is in response to a group invitation, so
// now that the user is registered, handle the group invitation.
try {
$is_valid_ginv = Invitation::validate_group_invitation_id($group_invitation_id);
if (!$is_valid_ginv) {
$msg = 3001;
}
} catch (PAException $e) {
$this->inv_error = "{$e->message}";
}
if (empty($msg)) {
//if group invitation is valid, and no error yet
try {
$new_invite = new Invitation();
$new_invite->inv_id = $group_invitation_id;
$new_invite->inv_user_id = $this->reg_user->newuser->user_id;
$new_invite->accept();
//get collection_id
$Ginv = Invitation::load($group_invitation_id);
$gid = $Ginv->inv_collection_id;
$relationship_level = 2;
//.........这里部分代码省略.........
示例11: handle_join
function handle_join()
{
global $network_info;
$invitation_id = isset($_REQUEST['InvID']) ? $_REQUEST['InvID'] : null;
$group_invitation_id = isset($_REQUEST['GInvID']) ? $_REQUEST['GInvID'] : null;
$mother_network_info = Network::get_mothership_info();
$extra = unserialize($mother_network_info->extra);
if (!$this->reg_user->register($_POST, $network_info)) {
// registration failed
return;
}
if ($extra['email_validation'] == NET_NO) {
// Success!
register_session($this->reg_user->newuser->login_name, $this->reg_user->newuser->user_id, $this->reg_user->newuser->role, $this->reg_user->newuser->first_name, $this->reg_user->newuser->last_name, $this->reg_user->newuser->email, $this->reg_user->newuser->picture);
if ($invitation_id) {
// if an invitation to join a network
$this->inv_error = "";
$is_valid = Invitation::validate_invitation_id($invitation_id);
if (!$is_valid) {
$msg = 7017;
// invalid network invitation
}
if (empty($msg)) {
try {
// try to except invitation
$new_invite = new Invitation();
$new_invite->inv_id = $invitation_id;
$new_invite->inv_user_id = $this->reg_user->newuser->user_id;
$new_invite->accept();
$inv_obj = Invitation::load($invitation_id);
$user_obj = new User();
$user_obj->load((int) $inv_obj->user_id);
//if invitation is for private network
if ($network_info->type == PRIVATE_NETWORK_TYPE) {
$user_type = NULL;
if ($network_info->owner_id == $inv_obj->user_id) {
$user_type = NETWORK_MEMBER;
}
Network::join($network_info->network_id, $this->reg_user->newuser->user_id, $user_type);
}
$msg = 7016;
$relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id);
$relation_type = Relation::lookup_relation_type($relation_type_id);
$invited_user_url = url_for('user_blog', array('login' => $this->reg_user->newuser->login_name));
// data for passing in common mail method
$array_of_data = array('first_name' => $this->reg_user->newuser->first_name, 'last_name' => $this->reg_user->newuser->last_name, 'user_name' => $this->reg_user->newuser->login_name, 'user_id' => $this->reg_user->newuser->user_id, 'invited_user_id' => $inv_obj->user_id, 'invited_user_name' => $user_obj->login_name, 'mail_type' => 'invite_accept_pa', 'to' => $user_obj->email, 'network_name' => $network_info->name, 'relation_type' => $relation_type, 'config_site_name' => PA::$site_name, 'invited_user_url' => $invited_user_url);
auto_email_notification_members('invitation_accept', $array_of_data);
} catch (PAException $e) {
$this->inv_error = $e->message;
$this->reg_user->msg = "{$e->message}";
$error_inv = TRUE;
}
if ($error_inv == TRUE) {
// if invitation fails, then do login again
header("Location: " . PA::$url . "/login.php?msg=" . $this->reg_user->msg . "&return={$return_url}");
exit;
}
}
$redirect_url = 'homepage.php?msg=' . $msg;
} else {
if ($group_invitation_id) {
// if an invitation to join a group
// User registration is in response to a group invitation, so
// now that the user is registered, handle the group invitation.
try {
$is_valid_ginv = Invitation::validate_group_invitation_id($group_invitation_id);
if (!$is_valid_ginv) {
$msg = 3001;
}
} catch (PAException $e) {
$this->inv_error = "{$e->message}";
}
if (empty($msg)) {
//if group invitation is valid, and no error yet
try {
$new_invite = new Invitation();
$new_invite->inv_id = $group_invitation_id;
$new_invite->inv_user_id = $this->reg_user->newuser->user_id;
$new_invite->accept();
//get collection_id
$Ginv = Invitation::load($group_invitation_id);
$gid = $Ginv->inv_collection_id;
} catch (PAException $e) {
$this->reg_user->msg = "{$e->message}";
$this->reg_user->error = TRUE;
print $this->reg_user->msg;
}
$redirect_url = "group.php?gid={$gid}&action=join&GInvID={$group_invitation_id}";
} else {
//else redirect registered user to its page.
$redirect_url = "user.php?msg_id={$msg}";
}
// end of if group invitation is valid
}
}
if (empty($redirect_url)) {
// if no url is set yet
// not a group invitation, so redirect to private user page when done
$redirect_url = "user.php";
}
//.........这里部分代码省略.........
示例12: handlePOST_addChild
//.........这里部分代码省略.........
$newuser->email = $email;
$newuser->is_active = ACTIVE;
if (!empty($_FILES['userfile']['name'])) {
$myUploadobj = new FileUploader();
//creating instance of file.
$image_type = 'image';
$file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
if ($file == false) {
$msg = $myUploadobj->error;
$error = TRUE;
} else {
$newuser->picture = $file;
}
}
if ($error == FALSE) {
try {
if ($use_parent_email) {
$newuser->save($check_unique_email = false);
} else {
$newuser->save($check_unique_email = true);
}
if (!empty($file)) {
Storage::link($file, array("role" => "avatar", "user" => $newuser->user_id));
}
// creating message basic folders
Message::create_basic_folders($newuser->user_id);
// adding default relation
if ($newuser->user_id != SUPER_USER_ID) {
User_Registration::add_default_relation($newuser->user_id, PA::$network_info);
}
// adding default media as well as album
User_Registration::add_default_media($newuser->user_id, '', PA::$network_info);
User_Registration::add_default_media($newuser->user_id, '_audio', PA::$network_info);
User_Registration::add_default_media($newuser->user_id, '_video', PA::$network_info);
User_Registration::add_default_blog($newuser->user_id);
//adding default link categories & links
User_Registration::add_default_links($newuser->user_id);
// code for adding default desktop image for user
$desk_img = uihelper_add_default_desktopimage($newuser->user_id);
if (empty($desk_img)) {
$desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
$rand_key = array_rand($desktop_images);
$desk_img = $desktop_images[$rand_key];
}
$states = array_values(PA::getStatesList());
$countries = array_values(PA::getCountryList());
$profile_keys = array('dob_day', 'dob_month', 'dob_year', 'homeAddress1', 'homeAddress2', 'city', 'state', 'country', 'postal_code', 'phone', 'use_parent_email');
$profile_data = array();
filter_all_post($_POST);
//filters all data of html
foreach ($profile_keys as $k => $pkey) {
if (!empty($_POST[$pkey])) {
if ($pkey == 'state' && $_POST[$pkey] >= 0) {
$prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $states[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
} else {
if ($pkey == 'country' && $_POST[$pkey] >= 0) {
$prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $countries[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
} else {
$prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $_POST[$pkey], 'type' => GENERAL, 'perm' => 1);
}
}
$profile_data[] = $prof_rec;
}
}
$profile_data[] = array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1);
// echo "<pre>".print_r($profile_data,1)."</pre>";
$newuser->save_user_profile($profile_data, GENERAL);
//if new user is created in a network then he must set as a joined user
if (!empty(PA::$network_info)) {
$by_admin = true;
Network::join(PA::$network_info->network_id, $newuser->user_id, NETWORK_MEMBER, $by_admin);
// $by_admin = true overrides the
// user_waiting status if it would get set
// this is an admin action, so we want it to happen in any case
}
$user_joined = $this->family->join((int) $newuser->user_id, $newuser->email, null);
if ($user_joined) {
// deal with TypedGroup Relations
require_once "api/Entity/TypedGroupEntityRelation.php";
$type = 'child';
TypedGroupEntityRelation::set_relation($newuser->user_id, $this->family->collection_id, $type);
if ($type == 'child') {
// if user type == child remove LoginUser and GroupMember roles
$newuser->delete_user_role();
// then assign 'Child' role only
$_extra = serialize(array('user' => false, 'network' => false, 'groups' => array($this->family->collection_id)));
$user_roles[] = array('role_id' => CHILD_MEMBER_ROLE, 'extra' => $_extra);
$newuser->set_user_role($user_roles);
}
}
$msg = __("Child's account was successfully created");
} catch (PAException $e) {
$msg = $e->message;
}
}
// end if
}
//end if
$error_msg = $msg;
}
示例13: default_exception
require_once "{$path_prefix}/api/Message/Message.php";
require_once "{$path_prefix}/web/includes/functions/auto_email_notify.php";
default_exception();
$parameter = js_includes("all");
$header = 'header.tpl';
//default network header while creating groups. While group editing header_group.tpl will be used.
$title = "Request to join";
html_header($title, $parameter);
$optional_parameters = "onload=\"{$onload}\"";
html_body($optional_parameters);
if (!empty($_POST['request'])) {
//code for requesting
$error = FALSE;
$success = FALSE;
try {
$request_sent = Network::join($network_info->network_id, $_SESSION['user']['id']);
if ($request_sent) {
$success = TRUE;
}
} catch (PAException $e) {
$join_error = $e->message;
$error = TRUE;
}
if ($error) {
$error_msg = "Your request to join this network could not be sent due to following reason: " . $join_error . ". You can go back to the home network by clicking 'Return to home network'";
} else {
$success_msg = "Your request to join this network has been successfully sent to the moderator of this network. The Moderator will check this request and approve or deny the request. You can go back to mother network by clicking the button 'Return to home network'";
}
}
if (!empty($_POST['back'])) {
//redirect to mother network
示例14: register
//.........这里部分代码省略.........
$this->msg = "Login name {$login_name} is already taken";
$error_login = TRUE;
$this->error = TRUE;
} elseif (User::user_existed($login_name)) {
$this->msg = "Login name {$login_name} has been used in the past; it belongs to a deleted user.";
$error_login = $this->error = TRUE;
}
$this->array_of_errors = array("error_login" => $error_login, "error_first_name" => @$error_first_name, "error_email" => @$error_email, "error_password_conf" => @$error_password_conf, "error_password_l" => @$error_password_l, "error_password_g" => @$error_password_g);
if ($this->error != TRUE) {
$this->newuser->login_name = $login_name;
//TODO: change to md5
$this->newuser->password = $password;
$this->newuser->first_name = $first_name;
$this->newuser->last_name = $last_name;
$this->newuser->email = $email;
if (!empty($params['user_filename'])) {
$user_fn_base = basename($params['user_filename']);
if (file_exists(PA::$upload_path . $user_fn_base)) {
$this->newuser->picture = $user_fn_base;
}
}
if ($this->error != TRUE) {
try {
$save_error = FALSE;
$extra = unserialize($network_info->extra);
if ($extra['email_validation'] == NET_NO) {
// if email validation not required
$this->newuser->is_active = ACTIVE;
} else {
$this->newuser->is_active = UNVERIFIED;
}
$this->newuser->save();
// saving data in user profile data also -- for searching making more easier
$data_array = array(0 => array('uid' => $this->newuser->user_id, 'name' => 'first_name', 'value' => $this->newuser->first_name, 'type' => BASIC, 'perm' => 1), 1 => array('uid' => $this->newuser->user_id, 'name' => 'last_name', 'value' => $this->newuser->last_name, 'type' => BASIC, 'perm' => 1));
$this->newuser->save_user_profile($data_array, BASIC);
// saving default notification for user from network notification setting
$user_notification = array();
$profile = array();
$user_notification = $extra['notify_members'];
$user_notification['msg_waiting_blink'] = $extra['msg_waiting_blink'];
$profile['settings']['name'] = 'settings';
$profile['settings']['value'] = serialize($user_notification);
$this->newuser->save_profile_section($profile, 'notifications');
// default notification for user ends
$desktop_images = User_Registration::get_default_desktopimage($this->newuser->user_id, $network_info);
// code for adding default desktop image for user
if ($desktop_images == "") {
$desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
$rand_key = array_rand($desktop_images);
$desk_img = $desktop_images[$rand_key];
} else {
$desk_img = $desktop_images;
}
$data_array = array(0 => array('uid' => $this->newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1));
//}
$this->newuser->save_user_profile($data_array, GENERAL);
if ($extra['email_validation'] == NET_NO) {
//if email validation is not required
// creating message basic folders
Message::create_basic_folders($this->newuser->user_id);
// adding default relation
if ($this->newuser->user_id != SUPER_USER_ID) {
User_Registration::add_default_relation($this->newuser->user_id, $network_info);
}
// adding default media as well as album
User_Registration::add_default_media($this->newuser->user_id, '', $network_info);
User_Registration::add_default_media($this->newuser->user_id, '_audio', $network_info);
User_Registration::add_default_media($this->newuser->user_id, '_video', $network_info);
User_Registration::add_default_blog($this->newuser->user_id);
//adding default link categories & links
User_Registration::add_default_links($this->newuser->user_id);
// adding header image
User_Registration::add_default_header($this->newuser->user_id);
// Making user member of a network if he is registering to PA from a network
if (!empty($network_info) && $network_info->type != PRIVATE_NETWORK_TYPE) {
Network::join($network_info->network_id, $this->newuser->user_id);
$params['uid'] = $this->newuser->user_id;
auto_email_notification('some_joins_a_network', $params);
}
}
} catch (PAException $e) {
$this->msg = $e->message;
if ($e->code == USER_EMAIL_NOT_UNIQUE) {
$this->msg = "Email Address has already been taken, please enter other email address.";
}
$save_error = TRUE;
if ($e->message == "The email address is invalid.") {
$email_invalid = TRUE;
$this->array_of_errors['error_email'] = $email_invalid;
}
}
}
}
if ($this->error == TRUE || $save_error == TRUE) {
$this->msg = "Sorry! your registration failed. " . $this->msg;
return FALSE;
}
// success!
return TRUE;
}