static function getByUserID($user_id, $service)
{
if (empty($user_id) || empty($service)) {
- return null;
+ throw new ServerException('Empty user_id or service for Foreign_link::getByUserID');
}
$flink = new Foreign_link();
-
$flink->service = $service;
$flink->user_id = $user_id;
$flink->limit(1);
- $result = $flink->find(true);
+ if (!$flink->find(true)) {
+ throw new NoResultException($flink);
+ }
- return empty($result) ? null : $flink;
+ return $flink;
}
static function getByForeignID($foreign_id, $service)
{
if (empty($foreign_id) || empty($service)) {
- return null;
- } else {
- $flink = new Foreign_link();
- $flink->service = $service;
- $flink->foreign_id = $foreign_id;
- $flink->limit(1);
+ throw new ServerException('Empty foreign_id or service for Foreign_link::getByForeignID');
+ }
- $result = $flink->find(true);
+ $flink = new Foreign_link();
+ $flink->service = $service;
+ $flink->foreign_id = $foreign_id;
+ $flink->limit(1);
- return empty($result) ? null : $flink;
+ if (!$flink->find(true)) {
+ throw new NoResultException($flink);
}
+
+ return $flink;
}
- function set_flags($noticesend, $noticerecv, $replysync, $friendsync)
+ function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync)
{
if ($noticesend) {
$this->noticesync |= FOREIGN_NOTICE_SEND;
$this->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
}
+ if ($repeatsync) {
+ $this->noticesync |= FOREIGN_NOTICE_SEND_REPEAT;
+ } else {
+ $this->noticesync &= ~FOREIGN_NOTICE_SEND_REPEAT;
+ }
+
if ($friendsync) {
$this->friendsync |= FOREIGN_FRIEND_RECV;
} else {
function getUser()
{
- return User::getKV($this->user_id);
+ return Profile::getByID($this->user_id)->getUser();
}
function getProfile()
{
- return Profile::getKV('id', $this->user_id);
+ return Profile::getByID($this->user_id);
}
// Make sure we only ever delete one record at a time