Exemple #1
0
     // @TODO: has it sense that the user add a follower?. Then the follower should also be notified to add the current user as following
     // When the request comes from another user adding a following, the action is ran as there authentication is not needed
     $remote_user = SMOBTools::remote_user($u);
     if (!$remote_user) {
         die;
     }
     $local_user = SMOBTools::user_uri();
     $follow = "<{$remote_user}> sioc:follows <{$local_user}> . ";
     $local = "INSERT INTO <" . SMOB_ROOT . "data/followers> { {$follow} }";
     error_log("DEBUG: Added follower {$remote_user} with the query {$local}", 0);
     SMOBStore::query($local);
 } elseif ($t == 'following') {
     if (!SMOBAuth::check()) {
         die;
     }
     $remote_user = SMOBTools::remote_user($u);
     if (!$remote_user) {
         SMOBTemplate::header('');
         print "<a href='{$u}'>{$u}</a> is not a valid Hub, user cannot be added";
         SMOBTemplate::footer();
     } else {
         // @TODO: check that the user were not already a following?
         // Store the new relationship in local repository
         $local_user = SMOBTools::user_uri();
         $follow = "<{$local_user}> sioc:follows <{$remote_user}> . ";
         $local = "INSERT INTO <" . SMOB_ROOT . "data/followings> { {$follow} }";
         SMOBStore::query($local);
         error_log("DEBUG: Added following {$remote_user} with the query: {$local}", 0);
         SMOBTemplate::header('');
         // Subscribe to the hub
         // Get the Publisher (following) Hub