/** * Test validating a friend with the wrong key * * @return void */ public function testValidateFriendWaitingError() { // create a fake request from sample site $f = new WpHerissonFriends(); $e = Encryption::i(); $e->generateKeyPairs(); $f->public_key = $e->public; $f->url = $this->herissonUrl; //$f->setUrl($this->herissonUrl); $f->b_wantsyou = 1; $f->save(); // Check the request is pending $friends = WpHerissonFriendsTable::getWhere('url=? and b_wantsyou=? and is_active=?', array($f->url, 1, 0)); $this->assertEquals(1, sizeof($friends)); $friend = $friends[0]; $friend->validateFriend(); $msgs = Message::i()->getErrors(); $msgs = array_reverse($msgs); $this->assertEquals(1, preg_match("/417/", $msgs[0])); }
/** * Action to send all the bookmarks data to a known friend * * This methods check the given publickey * Outputs JSON * * @return void */ function retrieveAction() { if (!sizeof($_POST)) { exit; } $key = post('key'); $friends = WpHerissonFriendsTable::getWhere("public_key=?", array($key)); foreach ($friends as $friend) { echo $friend->generateBookmarksData($_POST); // Exit au cas ou le friend est présent plusieurs fois exit; } }
/** * Action to list friends * * This is the default action * * @return void */ function indexAction() { $this->view->actives = WpHerissonFriendsTable::getWhere("is_active=1"); $this->view->youwant = WpHerissonFriendsTable::getWhere("b_youwant=1"); $this->view->wantsyou = WpHerissonFriendsTable::getWhere("b_wantsyou=1"); $this->view->errors = WpHerissonFriendsTable::getWhere("b_wantsyou!=1 and b_youwant!=1 and is_active!=1"); }