コード例 #1
0
ファイル: SuggestionUtils.php プロジェクト: jkinner/ringside
 /**
  * Returns suggestions for topics from this user or their friends
  *
  * @param int $uid
  * @param array $friends
  * @return array
  */
 public static function getSuggestions($uid, array $friends)
 {
     if (!isset($uid) && !isset($friends)) {
         print "UID ({$uid}) and Friends({$friends}) must both be set!";
         return;
     }
     $friends[] = $uid;
     $friends_list = implode(',', $friends);
     $sql = "SELECT * FROM suggestions WHERE api_key ='" . Config::$api_key . "'";
     if (strlen($friends_list) > 0) {
         $sql .= " AND owneruid IN ({$friends_list})";
     }
     $sql .= " ORDER BY topic, sid";
     error_log("executing sql: {$sql}");
     $suggestionsResults = mysql_query($sql, SuggestionUtils::get_db_conn()) or print mysql_error();
     $displaySuggestions = array();
     while ($row = mysql_fetch_assoc($suggestionsResults)) {
         $displaySuggestions[] = $row;
     }
     return $displaySuggestions;
 }
コード例 #2
0
ファイル: index.php プロジェクト: jkinner/ringside
/**
 * Queries for a list of suggestions and then includes the list page
 *
 * @param int $topic Topic ID, optional parameter.
 */
function showSuggestions(RingsideRestClient $rest, $uid)
{
    $friends = $rest->delegate->friends_get();
    $friends[] = $uid;
    $suggestions = SuggestionUtils::getSuggestions($friends);
    // Now get ratings
    $iids = array();
    foreach ($suggestions as $suggestion) {
        $iids[] = $suggestion['sid'];
        $rest->items_setInfo($suggestion['sid'], 'trail4', 'trail4', null);
    }
    $ratings = array();
    if (sizeof($iids) > 0) {
        $ratings = $rest->ratings_get($iids);
    }
    include_once 'list.php';
}
コード例 #3
0
ファイル: index.php プロジェクト: jkinner/ringside
/**
 * Queries for a list of suggestions and then includes the list page
 *
 * @param int $topic Topic ID, optional parameter.
 */
function showSuggestions()
{
    global $rest;
    $suggestions = SuggestionUtils::getSuggestions();
    if (!$suggestions || count($suggestions) < 1) {
        $suggestions = array();
    }
    $iids = array();
    foreach ($suggestions as $suggestion) {
        $iids[] = $suggestion['sid'];
        $rest->items_setInfo($suggestion['sid'], 'trail5', 'trail5', null);
    }
    //Now get ratings
    $ratings = array();
    if (count($iids) > 0) {
        $ratings = $rest->ratings_get($iids);
        if (!$ratings) {
            $ratings = array();
        }
    }
    include_once 'list.php';
}
コード例 #4
0
ファイル: index.php プロジェクト: jkinner/ringside
">Display Existing Topics</a>
<br /><br />
<div class="suggest_form">
	<h3>Make Suggestions</h3>
	<br />
	<form method="post" action="display.php">
		<input type="hidden" name="uid" value="<?php 
print $userid;
?>
" />
		<div class="suggest_topic_label">New Topic:</div>
		<div class="suggest_topic_input"><input type="text" name="newtopic" size="80" maxlength="80"/></div>

<?php 
// Get the list of existing topics owned by the logged in user or their friends
$utils = new SuggestionUtils();
$suggestions = $utils->getSuggestions($userid, $friends);
$topics = array();
foreach ($suggestions as $suggestion) {
    // dont show the owner topics
    //if( !in_array( array( $suggestion['owneruid'], $suggestion['topic'] ), $topics ) ) {
    $topics[] = array($suggestion['owneruid'], $suggestion['topic']);
    //}
}
// Only display options if there are existing topics in the user's social network
if (!empty($topics)) {
    ?>
		<br />
		<div class="suggest_topic_label">Existing Topic:</div>
		<div class="suggest_topic_input">
		<select name="existingtopic">
コード例 #5
0
ファイル: SuggestionUtils.php プロジェクト: jkinner/ringside
 /**
  * Returns all the topics for this user
  *
  * @param array $uids
  * @return array
  */
 public static function getTopics(array $friends)
 {
     $friends_list = implode(',', $friends);
     $sql = "SELECT DISTINCT topic, owneruid FROM suggestions";
     if (strlen($friends_list) > 0) {
         $sql .= " WHERE owneruid IN ({$friends_list})";
     }
     $res = mysql_query($sql, SuggestionUtils::get_db_conn());
     $ret = array();
     while ($row = mysql_fetch_assoc($res)) {
         $ret[] = $row;
     }
     return $ret;
 }
コード例 #6
0
ファイル: display.php プロジェクト: jkinner/ringside
<?php

include_once 'config.php';
$utils = new SuggestionUtils();
// get the user's ID from POST or GET if it was POSTED
$uid = isset($_POST['uid']) ? $_POST['uid'] : $_GET['uid'];
$newtopic = $_POST['newtopic'];
// if the user picked an existing topic
// grab the user_id and topic from the
// string separated with a colon, example -> "100001:SomeTopicName"
if (isset($_POST['existingtopic']) && $_POST['existingtopic'] != 'none') {
    $strings = split(":", $_POST['existingtopic']);
    $owneruid = $strings[0];
    $existingtopic = $strings[1];
} else {
    // since it wasn't an existing topic
    // the logged in user created it so
    // set the logged in user as the owner_id
    $owneruid = $uid;
}
// simply ensure that the parameters necessary for
// a suggestion were POSTed
if ($utils->hasAddParams()) {
    // insert the suggestion into the database
    $result = $utils->suggestion_add($existingtopic == null ? $newtopic : $existingtopic, $_POST['suggestion'], $uid, $owneruid, Config::$api_key);
}
error_log(RingsideApiClientsConfig::$webUrl);
error_log(RingsideApiClientsConfig::$serverUrl);
error_log("before new client" . Config::$api_key);
// create new API client
$ringsideClient = new RingsideApiClients(Config::$api_key, Config::$secret);