getPage($fromUser); $transformed = $userPage->getCurrentRevision(); $pageArray = $transformed->getContent(); $p = -1; for($i = 0; $i < count($pageArray); $i++){ if(!((strpos($pageArray[$i], $BUDDY_START_DELIM)) === FALSE)){ $p = $i; } } $buddies_array = array(); if($p >= 0){ $buddies = $pageArray[$p]; $buddies = substr($buddies, strpos($buddies, $BUDDY_START_DELIM) + strlen($BUDDY_START_DELIM)); $buddies_array = split($BUDDY_DELIM, $buddies); } for($i = 0; $i < count($buddies_array); $i++){ $buddies_array[$i] = trim($buddies_array[$i]); } $buddies_array = array_filter($buddies_array, "notEmptyName"); $buddies_array = array_unique($buddies_array); return $buddies_array; } function CoAgreement($dbi, $page, $users, $active_userid){ //echo "##$page - $cur_rating - " . count($users) . "
"; $cur_page = $page; //$cur_rating = $cur_rating; $my_ratings_iter = $dbi->get_rating(0, $active_userid, $page); $my_ratings_single = $my_ratings_iter->next(); $cur_rating = $my_ratings_single['ratingvalue']; $MIDDLE_RATING = 3; if($cur_rating >= $MIDDLE_RATING){ $agreePos = 1; } else { $agreePos = 0; } foreach($users as $buddy){ //echo "analyzing $buddy on $cur_page
"; $buddy_rating_iter = $dbi->get_rating(0, $buddy, $cur_page); $buddy_rating_array = $buddy_rating_iter->next(); $buddy_rating = $buddy_rating_array['ratingvalue']; //if($buddy_rating <= ($cur_rating + $eps) && $buddy_rating >= ($cur_rating - $eps)){ if($buddy_rating == ""){ $agree = 1; }else if($agreePos && $buddy_rating >= $MIDDLE_RATING){ $agree = 1; } else if(!$agreePos && $buddy_rating < $MIDDLE_RATING){ $agree = 1; } else { $agree = 0; break; } } if($agree && $agreePos){ return 1; } else if($agree && !$agreePos){ return -1; } else { return 0; } } function notEmptyName($var){ return !($var == ""); }