function test_ping_public() { $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $xml = new SimpleXMLElement("<data></data>"); $xml->addChild('remote_name', 'fred'); $xml->addChild('remote_profile', make_profile_url('fred')); $xml->addChild('remote_avatar', APP_ROOT . 'media/default_avatar.jpg'); $xml->addChild('remote_message', '@sue a message from fred'); $rmt = new mdl_remotes(); $_POST['data'] = $rmt->send_ping('http://localhost/', 'public', 'sue', $rmt_mck->get_pub_key(), $rmt_mck->get_priv_key(), $xml->asXML(), true); $msg = new ctrl_messages(); // call ping ob_start(); $msg->ping(); $result = ob_get_contents(); ob_end_clean(); $xml = $rmt->decode_ping_response($result); $this->assertTrue($xml->state == 'success'); $query = "SELECT * FROM `direct-message` WHERE `Remote_message` = '@sue a message from fred'"; $result = mysql_query($query); $this->assertEquals(mysql_num_rows($result), 1); }
function test_make_profile_url() { $result = make_profile_url('fred'); $this->assertEquals(preg_match('/http:\/\/localhost\/.+\/users\/profile\/fred/', $result), 1); }
<h2>Users on this node</h2> <div class="gap"></div> <?php display_errors(); ?> <?php if($users == array()): ?> <h4>There are no users on this node yet</h4> <?php else: ?> <?php foreach($users as $user): ?> <div class="message"> <div class="message_left"> <img src="<?php echo esc($user['Avatar']); ?>" alt="" /> </div> <div class="message_right"> <?php $latest = get_latest_by_local($user['ID']); ?> <h4><a href="<?php echo make_profile_url($user['User_name']) ?>"><?php echo esc($user['User_name']); ?></a></h4> <?php if($latest != array()): ?> <p class="msg-content"><?php echo esc($latest[0]['Message']);?></p> <p><?php echo format_time($latest[0]['Time']); ?></p> <?php else: ?> <p class="msg-content">No messages yet</p> <?php endif; ?> </div> <div style="clear: both;"></div> </div> <?php endforeach; ?> <?php endif; ?>
function destroy($rmt = false) { $this->outer_template = null; if(!isset($_SESSION['active_user'])) redirect_to(make_url('users', 'login')); if(!isset($_POST['Submit'])) redirect_to(make_profile_url($_SESSION['active_user']['name'])); $local_id = $_SESSION['active_user']['id']; // Instance models $rel = instance_model('relations'); $usr = instance_model('users'); $msg = instance_model('messages'); if($rmt == false) $rmt = instance_model('remotes'); // Get local user $user = $usr->get_user_by_id($local_id); if($user == array()) throw new no_such_user_exception(); // Get the message $message = $msg->get_by_id($local_id, $_POST['id']); if($message == array()) { new_flash('Message does not exist', 1); redirect_to(make_profile_url($_SESSION['active_user']['name'])); } // Delete $msg->delete_by_id($local_id, $_POST['id']); // Send pings to update remote caches $remote_users = $rel->get_followers($local_id); foreach($remote_users as $rmt_user) $rmt->send_ping($rmt_user['Message_pingback'], "update", 'null', $user[0]['Pub_key'], $user[0]['Priv_key'], make_follow_url($_SESSION['active_user']['name'])); // Redirect redirect_to(make_profile_url($_SESSION['active_user']['name'])); }