示例#1
0
 function trendlineVisible($userID, $videoID)
 {
     // print "trendlineVisible($userID, $videoID)<br />";
     $allowAccess = false;
     // $users = new users();
     $uiConfig = $this->getUI($userID);
     // $users->close();
     // print_r($uiConfig);
     $trendlineVisibility = $uiConfig['trendline_visibility'];
     $n = $uiConfig['n'];
     $media = new media();
     $stats = $media->getViewerStatistics($userID, $videoID);
     $media->close();
     switch ($trendlineVisibility) {
         case BY_DEFAULT:
             $allowAccess = true;
             break;
         case AFTER_N_DAYS:
             // check timestamp
             $firstViewTime = strtotime($stats['first_view']);
             $currentTime = time();
             $nDays = $n * (60 * 60 * 24);
             if ($currentTime <= $firstViewTime + $nDays) {
                 $allowAccess = true;
             }
             sendEmail("stats: {$stats['first_view']}\nif ({$currentTime} <= {$firstViewTime} + {$nDays})", "trendlineVis");
             break;
         case AFTER_N_VIEWS:
             // check number of views
             if ($stats['total_views'] >= $n) {
                 $allowAccess = true;
             }
             sendEmail("({$stats['total_views']} >= {$n})", "trendlineVis");
             break;
     }
     return $allowAccess;
 }