コード例 #1
0
ファイル: QvitterPlugin.php プロジェクト: GreenLunar/qvitter
 /**
  * Insert into notification table
  */
 function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id = false)
 {
     $to_user = User::getKV('id', $to_profile_id);
     $from_profile = Profile::getKV($from_profile_id);
     // don't notify remote profiles
     if (!$to_user instanceof User) {
         return false;
     }
     // no notifications from blocked profiles
     if ($to_user->hasBlocked($from_profile)) {
         return false;
     }
     // never notify myself
     if ($to_profile_id == $from_profile_id) {
         return false;
     }
     // insert
     $notif = new QvitterNotification();
     $notif->to_profile_id = $to_profile_id;
     $notif->from_profile_id = $from_profile_id;
     $notif->ntype = $ntype;
     $notif->notice_id = $notice_id;
     $notif->created = common_sql_now();
     if (!$notif->insert()) {
         common_log_db_error($notif, 'INSERT', __FILE__);
         return false;
     }
     return true;
 }