ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/plugins/opInviteFriendPlugin/trunk/lib/model/InviteFriendPeer.php @ 10301

Last change on this file since 10301 was 10301, checked in by nagasawa, 12 years ago

#3295:added opInviteFriendPlugin

File size: 2.1 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11class InviteFriendPeer
12{
13  public static function sendMessage($send_id, $receive_id, $message, $target_id)
14  {
15    $messageData = new SendMessageData();
16    $messageData->setMemberId($send_id);
17    $body = 'The member introduce message had received.' . "\n"
18          . "\n"
19          . 'Message:' . "\n"
20          . $message . "\n"
21          . "\n"
22          . 'This member\'s URL:' . "\n";
23//          . link_to('', 'member/profile?id=' . $target_id);
24    $messageData->setBody($body);
25    $messageData->setIsSend(true);
26    $messageData->setMessageType(MessageTypePeer::getMessageTypeIdByName('invite_friend'));
27    $messageData->save();
28
29    $messageSendList = new MessageSendList();
30    $messageSendList->setMemberId($receive_id);
31    $messageSendList->setMessageId($messageData->getId());
32    $messageSendList->save();
33  }
34
35  public static function sendMessageByList($send_id, $array_receive_id, $message, $target_id)
36  {
37    foreach($array_receive_id as $receive_id)
38    {
39      self::sendMessage($send_id, intval($receive_id), $message, $target_id);
40    }
41  }
42
43  public static function getNotFriendMembers($send_id, $target_id)
44  {
45    $relations = MemberRelationshipPeer::retrievesByMemberIdFrom($send_id);
46    $c = new Criteria();
47    $c->add(MemberRelationshipPeer::MEMBER_ID_FROM, $send_id);
48    $c->add(MemberRelationshipPeer::MEMBER_ID_TO, $target_id, Criteria::NOT_EQUAL);
49    $c->add(MemberRelationshipPeer::IS_FRIEND, true);
50    $relations = MemberRelationshipPeer::doSelect($c);
51
52    $members = array();
53    foreach($relations as $relation)
54    {
55      $re = MemberRelationshipPeer::retrieveByFromAndTo($target_id, $relation->getMemberIdTo());
56      if (!$re || $re && !$re->getIsFriend())
57      {
58        $members[] = MemberPeer::retrieveByPk($relation->getMemberIdTo());
59      }
60    }
61
62    return count($members) ? $members : false;
63  }
64}
Note: See TracBrowser for help on using the repository browser.