コード例 #1
0
ファイル: Facade.php プロジェクト: rjha/sc
 function execute($endPoint, $params)
 {
     $command = NULL;
     $hash = md5($endPoint);
     if (!isset($this->map[$hash])) {
         // end point is not mapped
         $message = sprintf("end point [%s] is not mapped for session action", $endPoint);
         Logger::getInstance()->info($message);
         return;
     }
     //end point is mapped.
     $name = $this->map[$hash];
     switch ($name) {
         case "COMMENT":
             $command = new \com\indigloo\sc\command\Comment();
             break;
         case "BOOKMARK":
             $command = new \com\indigloo\sc\command\Bookmark();
             break;
         case "GRAPH":
             $command = new \com\indigloo\sc\command\SocialGraph();
             break;
         default:
             //coding error.
             $message = sprintf("Unknown session action  [%s] for endpoint [%s]", $name, $endPoint);
             trigger_error($message, E_USER_ERROR);
     }
     $response = $command->execute($params);
     return $response;
 }
コード例 #2
0
ファイル: social-graph.php プロジェクト: rjha/sc
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\sc\auth\Login;
use com\indigloo\sc\ui\Constants as UIConstants;
set_exception_handler('webgloo_ajax_exception_handler');
//use login is required for bookmarking
if (!Login::hasSession()) {
    $message = array("code" => 401, "message" => "Authentication failure: You need to login!");
    $html = json_encode($message);
    echo $html;
    exit;
}
$params = new \stdClass();
$login = Login::getLoginInSession();
$params->loginId = $login->id;
$params->name = $login->name;
$params->action = Util::tryArrayKey($_POST, "action");
$params->followerId = Util::tryArrayKey($_POST, "followerId");
$params->followingId = Util::tryArrayKey($_POST, "followingId");
//use login is required for bookmarking
if ($params->followerId == $params->followingId) {
    $message = array("code" => 200, "message" => "No need to follow yourself!");
    $html = json_encode($message);
    echo $html;
    exit;
}
$command = new \com\indigloo\sc\command\SocialGraph();
$response = $command->execute($params);
$html = json_encode($response);
echo $html;