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

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

Last change on this file since 10310 was 10310, checked in by nagasawa, 11 years ago

#3295:fixed send message was made to correspond to i18n

File size: 2.3 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 __($text)
14  {
15    return sfContext::getInstance()->getI18N()->__($text);
16  }
17
18  public static function sendMessage($send_id, $receive_id, $message, $target_id)
19  {
20    $messageData = new SendMessageData();
21    $messageData->setMemberId($send_id);
22    $url = sfContext::getInstance()->getController()->genUrl('member/profile?id=' . $target_id, true);
23    $body = self::__('The member introduce message had received.') . "\n"
24          . "\n"
25          . self::__('Message:') . "\n"
26          . $message . "\n"
27          . "\n"
28          . self::__("This member's URL:") . "\n"
29          . $url;
30    $messageData->setSubject(self::__('The member introduce message'));
31    $messageData->setBody($body);
32    $messageData->setIsSend(true);
33    $messageData->setMessageType(MessageTypePeer::getMessageTypeIdByName('invite_friend'));
34    $messageData->save();
35
36    $messageSendList = new MessageSendList();
37    $messageSendList->setMemberId($receive_id);
38    $messageSendList->setMessageId($messageData->getId());
39    $messageSendList->save();
40  }
41
42  public static function sendMessageByList($send_id, $array_receive_id, $message, $target_id)
43  {
44    foreach($array_receive_id as $receive_id)
45    {
46      self::sendMessage($send_id, intval($receive_id), $message, $target_id);
47    }
48  }
49
50  public static function getNotFriendMembers($send_id, $target_id)
51  {
52    $relations = MemberRelationshipPeer::retrievesByMemberIdFrom($send_id);
53    $c = new Criteria();
54    $c->add(MemberRelationshipPeer::MEMBER_ID_FROM, $send_id);
55    $c->add(MemberRelationshipPeer::MEMBER_ID_TO, $target_id, Criteria::NOT_EQUAL);
56    $c->add(MemberRelationshipPeer::IS_FRIEND, true);
57    $relations = MemberRelationshipPeer::doSelect($c);
58
59    $members = array();
60    foreach($relations as $relation)
61    {
62      $re = MemberRelationshipPeer::retrieveByFromAndTo($target_id, $relation->getMemberIdTo());
63      if (!$re || $re && !$re->getIsFriend())
64      {
65        $members[] = MemberPeer::retrieveByPk($relation->getMemberIdTo());
66      }
67    }
68
69    return count($members) ? $members : false;
70  }
71}
Note: See TracBrowser for help on using the repository browser.