本文整理汇总了PHP中Network::get_mothership_info方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::get_mothership_info方法的具体用法?PHP Network::get_mothership_info怎么用?PHP Network::get_mothership_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::get_mothership_info方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_network_info
function get_network_info()
{
if (CURRENT_NETWORK_URL_PREFIX != 'www' && CURRENT_NETWORK_URL_PREFIX != '') {
// not mother (home) network
$network_info = Network::get_network_by_address(CURRENT_NETWORK_URL_PREFIX);
} else {
// home network
$network_info = Network::get_mothership_info();
}
return $network_info;
}
示例2: safe_updates
function safe_updates()
{
global $network_info;
PA::$network_info = $network_info = Network::get_mothership_info();
PA::$extra = unserialize(PA::$network_info->extra);
$this->create_announce_tables();
$this->add_all_users_to_mother_network();
// run project specific updates and init settings
if (!empty(PA::$config->project_safe_updates)) {
// see if the settings file exists
$file_path = PA::$core_dir . "/web/extra/" . PA::$config->project_safe_updates . "_safe_updates.php";
if (file_exists($file_path)) {
include $file_path;
}
}
}
示例3: testUserRegistration
function testUserRegistration()
{
$login = "testuser_" . rand(10000, 99999);
$firstName = 'Test';
$lastName = 'User';
$email = "{$login}@myelin.co.nz";
$password = 'testuser';
$home_network = Network::get_mothership_info();
$orig_member_count = $home_network->member_count;
// register a new user
$reg = new User_Registration();
$this->assertTrue($reg->register(array('login_name' => $login, 'first_name' => $firstName, 'last_name' => $lastName, 'email' => $email, 'password' => $password, 'confirm_password' => $password), $home_network));
$this->assertEquals(Network::get_member_count($home_network->network_id), $orig_member_count + 1);
// test the user
$new_user = $reg->newuser;
$new_uid = (int) $new_user->user_id;
$this->assertEquals($new_user->first_name, $firstName);
$this->assertEquals($new_user->last_name, $lastName);
$this->assertEquals($new_user->email, $email);
// reload user and make sure it works
$user = new User();
$user->load($new_uid);
$this->assertEquals($user->first_name, $firstName);
$this->assertEquals($user->last_name, $lastName);
$this->assertEquals($user->email, $email);
// now delete the user
User::delete($new_uid);
// and try to load again
$user_fail = new User();
try {
$user_fail->load($new_uid);
} catch (PAException $e) {
$this->assertEquals($e->getCode(), USER_NOT_FOUND);
}
// make sure member_count is correct
$this->assertEquals(Network::get_member_count($home_network->network_id), $orig_member_count);
}
示例4: register
function register($params, $network_info = NULL)
{
$core_id = null;
$picture = null;
$picture_dimensions = null;
$avatar = null;
$avatar_dimensions = null;
$avatar_small = null;
$avatar_small_dimensions = null;
$this->newuser = new User();
// set API call variable
$this->newuser->api_call = $this->api_call;
// filter input parameters (this is the same as filter_all_post())
$params = Validation::get_input_filter(FALSE)->process($params);
$this->error = false;
$mother_network_info = Network::get_mothership_info();
$mother_extra = unserialize($mother_network_info->extra);
if (@$mother_extra['captcha_required'] == NET_YES) {
// added by Z.Hron - if captcha is required
//Providing the capcha check
if (md5(strtoupper($_POST['txtNumber'])) != $_SESSION['image_random_value']) {
$_SESSION['image_is_logged_in'] = true;
$_SESSION['image_random_value'] = '';
$error_login = true;
$this->error = true;
$this->msg .= "\nPlease enter correct code";
}
}
if (!$this->error) {
$login_name = trim($params['login_name']);
$first_name = trim($params['first_name']);
$last_name = trim(@$params['last_name']);
// not mandatory
$email = trim($params['email']);
$password = trim($params['password']);
$confirm_password = trim($params['confirm_password']);
if ($this->api_call == true) {
$core_id = $params['core_id'];
// TODO: validate URL
$picture = trim($params['profile_picture_url']);
$picture_dimensions = $params['profile_picture_dimensions'];
$avatar = trim($params['profile_avatar_url']);
$avatar_dimensions = $params['profile_avatar_dimensions'];
$avatar_small = trim($params['profile_avatar_small_url']);
$avatar_small_dimensions = $params['profile_avatar_small_dimensions'];
}
$date_created = !empty($params['date_created']) ? $params['date_created'] : null;
$_years = PA::getYearsList();
$dob_day = !empty($params['dob_day']) ? trim($params['dob_day']) : null;
// General data (why? should be personal)
$dob_month = !empty($params['dob_month']) ? trim($params['dob_month']) : null;
// General data (why? should be personal)
$dob_year = !empty($params['dob_year']) ? $_years[(int) trim($params['dob_year'])] : null;
// General data (why? should be personal)
$homeAddress1 = !empty($params['homeAddress1']) ? trim($params['homeAddress1']) : null;
// General data
$homeAddress2 = !empty($params['homeAddress2']) ? trim($params['homeAddress2']) : null;
// General data
$city = !empty($params['city']) ? trim($params['city']) : null;
// General data
$state = null;
if ($params['state'] == -1) {
// State/Province: Other selected
$state = !empty($params['stateOther']) ? trim($params['stateOther']) : null;
// General data
} else {
if ($params['state'] > 0) {
// one of US States selected
$state = !empty($params['state']) ? $this->states[(int) $params['state']] : null;
// General data
}
}
$country = $params['country'] > 0 ? $this->countries[(int) $params['country']] : null;
// General data
$postal_code = !empty($params['postal_code']) ? trim($params['postal_code']) : null;
// General data
$phone = !empty($params['phone']) ? trim($params['phone']) : null;
// General data
$validate_array = array('login_name' => 'Login name', 'first_name' => 'First name', 'password' => 'Password', 'confirm_password' => 'Confirm password', 'email' => 'Email');
$this->msg = '';
$this->error = FALSE;
foreach ($validate_array as $key => $value) {
if (empty($params[$key])) {
$this->msg .= "\n" . $value . " is mandatory";
$this->error = TRUE;
header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED));
}
}
if (strlen($this->msg) > 0) {
$this->msg = "\n" . "Fields marked with * must not be left empty" . $this->msg;
}
}
//$error_login = FALSE;
if (!$this->error) {
if (empty($login_name)) {
$error_login = TRUE;
$this->error = TRUE;
}
if (is_numeric($login_name)) {
// Here we check the login name is numeric or not
//.........这里部分代码省略.........
示例5: join
/**
* let the user join network
* @access public
* @param id of the network,uid of user
* @return flag for joining request moderated or success message
*/
static function join($network_id, $uid, $user_type = null)
{
// function modified just to have crude functionality for time being
//TODO : when some one joins network do something
global $default_sender;
Logger::log("Enter: static function Network::join");
if (Network::member_exists($network_id, $uid)) {
//then make an entry for the network to be joined and user_id
throw new PAException(OPERATION_NOT_PERMITTED, "Already a member of this network.");
}
$user_created = Dal::query_first("SELECT created FROM users WHERE user_id=?", array($uid));
//find type of the network
$type = Network::find_network_type($network_id);
if ($type == PRIVATE_NETWORK_TYPE) {
$user_type = empty($user_type) ? NETWORK_WAITING_MEMBER : $user_type;
// see if user has already applied for the network
$res = Dal::query("SELECT * FROM {networks_users} WHERE network_id = ? AND user_id = ? AND user_type = ? ", array($network_id, $uid, $user_type));
if ($res->numRows() > 0) {
throw new PAException(OPERATION_NOT_PERMITTED, "You have already requested to join this network.");
}
} else {
$user_type = NETWORK_MEMBER;
}
$res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($network_id, $uid, $user_type, $user_created));
//getting Mother network informaton
$network_data = Network::get_mothership_info();
//get the network_info of mother network such as network_id
if (!Network::member_exists($network_data->network_id, $uid)) {
//if not a member of mother network ie directly joining a network then make an entry for mother network_id and user_id
$res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($network_data->network_id, $uid, NETWORK_MEMBER, $user_created));
}
// Update cached member count
Network::update_network_member_count($network_id);
return TRUE;
}
示例6: testEmailNotification
function testEmailNotification()
{
// test requires xdebug and xdebug_get_declared_vars().
if (!extension_loaded('xdebug')) {
echo ($msg = "Need xdebug extension for email notification test") . "\n";
$this->markTestIncomplete($msg);
}
if (ini_get('xdebug.collect_vars') != 1) {
echo ($msg = "need to set xdebug.collect_vars = 1") . "\n";
$this->markTestIncomplete($msg);
}
$this->assertEquals($GLOBALS['this_test_requires_globals'], "test", "xdebug not working - or need to update phpunit? see http://pear.php.net/bugs/bug.php?id=5053 for more info.");
// hook mail()
global $mail_testing_callback;
$mail_testing_callback = array("EmailNotificationTest", "mail_hook");
// load main network and get a fake owner user
global $network_info, $owner;
$network_info = Network::get_mothership_info();
$owner = Test::get_test_user();
// override destination so we get an e-mail
$extra = unserialize($network_info->extra);
$extra['notify_owner']['announcement']['value'] = NET_EMAIL;
$extra['notify_owner']['content_to_homepage']['value'] = NET_EMAIL;
$network_info->extra = serialize($extra);
$this->assertEquals(count(EmailNotificationTest::$messages), 0);
// now trigger a fake network announcement
$owner_name = 'John Q. NetworkOwner';
announcement(array('params' => array('aid' => "whatever"), 'owner_name' => $owner_name));
$this->assertEquals(count(EmailNotificationTest::$messages), 1);
$msg = EmailNotificationTest::$messages[0];
$this->assertContains("nnouncement", $msg[1]);
$this->assertContains("network", $msg[1]);
$this->assertContains($owner_name, $msg[2]);
$this->assertContains("nnouncement", $msg[2]);
// now trigger a fake content posting to community blog
$comm_blog_post = array('owner_name' => $owner_name, 'params' => array('first_name' => "Firstname", 'network_name' => "Network Name", 'user_id' => $owner->user_id, 'user_image' => $owner->picture, 'cid' => '1234', 'content_title' => 'Fake content title'));
content_posted_to_comm_blog($comm_blog_post);
$this->assertEquals(count(EmailNotificationTest::$messages), 2);
$msg = EmailNotificationTest::$messages[1];
$this->assertContains("Community Blog", $msg[1]);
$this->assertContains("posted", $msg[1]);
$this->assertContains($owner_name, $msg[2]);
$this->assertContains("Firstname has posted", $msg[2]);
echo "The site name is " . PA::$site_name . "\n";
$this->assertContains(PA::$site_name, $msg[2]);
/* The following test won't work yet -- as the site name is
inserted in the messages early, so changing it now won't
have any effect.
// now change the site name and make sure it shows up properly
$old_config_site_name = PA::$site_name;
$new_config_site_name = PA::$site_name = "Test site name - for EmailNotificationTest";
content_posted_to_comm_blog($comm_blog_post);
$this->assertEquals(count(EmailNotificationTest::$messages), 3);
$msg = EmailNotificationTest::$messages[2];
$this->assertContains("Community Blog", $msg[1]);
$this->assertContains("posted", $msg[1]);
$this->assertContains($owner_name, $msg[2]);
$this->assertContains("Firstname has posted", $msg[2]);
echo "The site name is ". PA::$site_name ."\n";
$this->assertContains(PA::$site_name, $msg[2]);
$this->assertNotContains($old_config_site_name, $msg[2]);
$this->assertNotContains("PeopleAggregator", $msg[2]);
*/
}
示例7: unset
$level_1 = $navigation_links['level_1'];
unset($level_1['highlight']);
if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
$network_name = sprintf(__("%s Platform"), PA::$site_name);
} else {
$network_name = ucfirst(PA::$network_info->name) . ' Network';
}
$level_2 = $navigation_links['level_2'];
if (!empty(PA::$config->simple['use_simplenav'])) {
$level_3 = array();
$left_user_public_links = array();
} else {
$level_3 = $navigation_links['level_3'];
$left_user_public_links = $navigation_links['left_user_public_links'];
}
$mother_network = Network::get_mothership_info();
$extra = unserialize($mother_network->extra);
$mothership_info = mothership_info();
?>
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu">
<li class="header">MAIN NAVIGATION</li>
<li class="treeview">
<a href="<?php
echo PA::$url . PA_ROUTE_HOME_PAGE;
?>
">
<i class="fa fa-dashboard"></i> <span>Dashboard</span>
</a>
</li>
<?php
示例8: 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;
//.........这里部分代码省略.........
示例9: 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";
}
//.........这里部分代码省略.........
示例10: testAddUpdateDeleteEvent
public function testAddUpdateDeleteEvent()
{
// Dal::register_query_callback("explain_query");
echo "getting a user\n";
$user = Test::get_test_user();
$testusername = $user->first_name . " " . $user->last_name;
echo "test user = {$testusername}\n";
/* setup some times and time strings */
$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$tomorrow = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"));
$yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
$nextmonth = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y"));
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
$oneday = 60 * 60 * 24;
$simple_dateformat = "Y-m-d";
/* use the constants in the format parameter */
// something like: Mon, 15 Aug 2005 15:12:46 UTC
$now_rfc822 = date(DATE_RFC822);
// something like: 2000-07-01T00:00:00+00:00
// $now_atom = date(DATE_ATOM);
// create an Event
echo "create and save Event\n";
$e = new Event();
$e->content_id = "http://myevent.info/1";
// anything basically
$e->user_id = $user->user_id;
$e->event_title = "Test Event for {$testusername}";
$now = time();
$nowplusoneday = $now + $oneday;
$e->start_time = date(DATE_ATOM, $now);
$e->end_time = date(DATE_ATOM, $now + 60 * 60);
// duration 1h
$e->event_data = array('description' => "This Event takes place to test the class Event", 'start' => $now, 'end' => $now + 60 * 60);
$e->save();
// print_r($e);
// see if we got it
echo "Retrieving Event {$e->event_id}\n";
$e2 = new Event();
$e2->load($e->event_id);
echo "Testing integrity of dates\n";
// print_r($e2);
// see if the stored timestamps match
$this->assertEquals($now, $e2->event_data['start']);
// see if our dates survived the DB conversion roundtrip
$this->assertEquals($now, strtotime($e2->start_time));
$this->assertEquals($now + 60 * 60, strtotime($e2->end_time));
// create two EventAssociations
$ea1 = new EventAssociation();
$ea2 = new EventAssociation();
$ea1->user_id = $user->user_id;
$ea2->user_id = $user->user_id;
// user EventAssocoiation
$ea1->assoc_target_type = 'user';
$ea1->assoc_target_id = $user->user_id;
// could very well be other user
$ea1->assoc_target_name = $testusername;
$ea1->event_id = $e->event_id;
$ea1->save();
// network EventAssocoiation
// find a network the user is member of
// $networks = Network::get_user_networks($user->user_id);
$network = Network::get_mothership_info();
// use the mothership
// print_r($network);
$ea2->assoc_target_type = 'network';
$ea2->assoc_target_id = $network->network_id;
// could very well be other user
$ea2->assoc_target_name = $network->name;
$ea2->event_id = $e->event_id;
$ea2->save();
echo "Testing EventAssociations for Event {$e->event_id}\n";
$assoc_ids = EventAssociation::find_for_event($e->event_id);
// print_r($assoc_ids);
$a_cnt = count($assoc_ids);
$this->assertEquals($a_cnt, 2, "expected 2 assocs, got {$a_cnt}\n");
echo "Testing EventAssociations::find_for_target_and_delta for Network\n";
$assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id);
// find_for_target_and_delta($target_type, $target_id, $range_start = NULL, $range_end = NULL)
// print_r($assoc_ids);
$a_cnt = count($assoc_ids);
// we expect at least one (or more, the user might have others too)
$this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
echo "Testing EventAssociations::find_for_target_and_delta for Today\n";
/*
echo "yesterday = " . date(DATE_ATOM, $yesterday) . "\n";
echo "today = " . date(DATE_ATOM, $today) . "\n";
echo "event start_time = " . date(DATE_ATOM, strtotime($e2->start_time)) . "\n";
echo "event end_time = " . date(DATE_ATOM, strtotime($e2->end_time)) . "\n";
echo "tomorrow = " . date(DATE_ATOM, $tomorrow) . "\n";
*/
$assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id, date(DATE_ATOM, $today), date(DATE_ATOM, $tomorrow));
print_r($assoc_ids);
/*
$assocs = EventAssociation::load_in_list($assoc_ids);
print_r($assocs);
*/
$a_cnt = count($assoc_ids);
// we expect at least one (or more, the user might have others too)
$this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
//.........这里部分代码省略.........