------------------------------------------------------- CLASSNAME: Suggestions GENERATION DATE: 21.09.2010 CLASS FILE: /home/maintenance/iphoneAdmin/emallAdmin/lib/classes/phpClass/generated_classes/Suggestions.Class.php5 FOR MYSQL TABLE: suggestions FOR MYSQL DB: emall -------------------------------------------------------
Esempio n. 1
0
 function launch()
 {
     global $interface;
     global $user;
     global $configArray;
     $suggestions = Suggestions::getSuggestions();
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     /** @var SearchObject_Solr $solrDb */
     $solrDb = new $class($url);
     $resourceList = array();
     $curIndex = 0;
     if (is_array($suggestions)) {
         foreach ($suggestions as $suggestion) {
             $interface->assign('resultIndex', ++$curIndex);
             $record = $solrDb->getRecord($suggestion['titleInfo']['id']);
             /** @var IndexRecord $recordDriver */
             $recordDriver = RecordDriverFactory::initRecordDriver($record);
             $resourceEntry = $interface->fetch($recordDriver->getSearchResult());
             $resourceList[] = $resourceEntry;
         }
     }
     $interface->assign('resourceList', $resourceList);
     //Check to see if the user has rated any titles
     $interface->assign('hasRatings', $user->hasRatings());
     $interface->setPageTitle('Recommended for you');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('suggestedTitles.tpl');
     $interface->display('layout.tpl');
 }
Esempio n. 2
0
 static function getNovelistRecommendations($userRating, $isbn, $resource, $allRatedTitles, &$suggestions, $notInterestedTitles)
 {
     //We now have the title, we can get the related titles from Novelist
     $novelist = NovelistFactory::getNovelist();
     //Use loadEnrichmentInfo even though there is more data than we need since it uses caching.
     $enrichmentInfo = $novelist->loadEnrichment($isbn);
     $numRecommendations = 0;
     if (isset($enrichmentInfo['similarTitleCountOwned']) && $enrichmentInfo['similarTitleCountOwned'] > 0) {
         //For each related title
         foreach ($enrichmentInfo['similarTitles'] as $similarTitle) {
             if ($similarTitle['libraryOwned']) {
                 Suggestions::addTitleToSuggestions($userRating, $resource->title, $resource->record_id, $similarTitle, $allRatedTitles, $suggestions, $notInterestedTitles);
                 $numRecommendations++;
             }
         }
     }
     return $numRecommendations;
 }
Esempio n. 3
0
 function GetSuggestions()
 {
     global $interface;
     global $library;
     global $configArray;
     //Make sure to initialize solr
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init();
     //Get suggestions for the user
     $suggestions = Suggestions::getSuggestions();
     $interface->assign('suggestions', $suggestions);
     if (isset($library)) {
         $interface->assign('showRatings', $library->showRatings);
     } else {
         $interface->assign('showRatings', 1);
     }
     //return suggestions as json for display in the title scroller
     $titles = array();
     foreach ($suggestions as $suggestion) {
         $titles[] = array('id' => $suggestion['titleInfo']['id'], 'image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $suggestion['titleInfo']['id'] . "&issn=" . $suggestion['titleInfo']['issn'] . "&isn=" . $suggestion['titleInfo']['isbn10'] . "&size=medium&upc=" . $suggestion['titleInfo']['upc'] . "&category=" . $suggestion['titleInfo']['format_category'][0], 'title' => $suggestion['titleInfo']['title'], 'author' => $suggestion['titleInfo']['author'], 'basedOn' => $suggestion['basedOn']);
     }
     foreach ($titles as $key => $rawData) {
         $formattedTitle = "<div id=\"scrollerTitleSuggestion{$key}\" class=\"scrollerTitle\">" . '<a href="' . $configArray['Site']['path'] . "/Record/" . $rawData['id'] . '" id="descriptionTrigger' . $rawData['id'] . '">' . "<img src=\"{$rawData['image']}\" class=\"scrollerTitleCover\" alt=\"{$rawData['title']} Cover\"/>" . "</a></div>" . "<div id='descriptionPlaceholder{$rawData['id']}' style='display:none'></div>";
         $rawData['formattedTitle'] = $formattedTitle;
         $titles[$key] = $rawData;
     }
     $return = array('titles' => $titles, 'currentIndex' => 0);
     return json_encode($return);
     //return $interface->fetch('MyResearch/ajax-suggestionsList.tpl');
 }
Esempio n. 4
0
     $suggestions = new Suggestions($db, $user);
     $arr = $suggestions->get($_GET["view"] ?: 'top', (int) $_GET["limit"] ?: 10);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions/\\d+/votes'):
     $suggestions = new Suggestions($db, $user);
     $arr = $suggestions->vote($params[1], $postdata["direction"]);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions'):
     $forum = new Forum($db, $user);
     $suggestions = new Suggestions($db, $user, $forum);
     httpResponse($suggestions->create($postdata));
     break;
 case validateRoute('PATCH', 'suggestions/\\d+'):
     $suggestions = new Suggestions($db, $user);
     httpResponse($suggestions->update($params[1], $postdata));
     break;
 case validateRoute('GET', 'sweTvGuide'):
     $week = (int) $_GET["week"];
     $cacheId = 'swetvguide-' . $week;
     if ($memcache && ($cached = $memcache->get($cacheId))) {
         if ($week == 0) {
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($cached);
     } else {
         $torrent = new Torrent($db, $user);
         if ($week > 3) {
             $week = 4;
         }
 private function logError($ex)
 {
     if (is_a($ex, dbException)) {
         $dbh = Connection::get();
         // transakcia padla takze treba rollback
         // inac by spadlo aj toto pridanie dokonca bez hlasky
         $dbh->transactionRollback();
     }
     // maly hack, nasimulujem pridanie pripomienky
     $chyba = new Suggestions();
     // nastavime pozadovane parametre
     $chyba->id_pedagog = $this->controller->getUserID();
     $chyba->pripomienka_typ_id = 1;
     // chyba v systéme
     $chyba->stav = 1;
     // nova
     $chyba->text = "Exception: {$ex->backtrace[0]['class']}\n" . "Message: {$ex->getMessage()}\n";
     if (isset($ex->backtrace)) {
         foreach ($ex->backtrace as $backtrace) {
             $chyba->text .= "{$backtrace['file']} ({$backtrace['line']}) : ";
             $chyba->text .= "{$backtrace['class']} -> {$backtrace['function']}\n";
         }
     }
     $chyba->save($this->controller->getUserID());
     $notifikator = new Notificator();
     $notifikator->setController($this->controller);
     $notifikator->sendSuggestionAddedMsg($chyba);
 }
Esempio n. 6
0
 /**
  * Returns information about the titles within a list including:
  * - Title, Author, Bookcover URL, description, record id
  */
 function getListTitles($listId = NULL, Pagination $pagination = NULL)
 {
     global $configArray;
     if (!$listId) {
         if (!isset($_REQUEST['id'])) {
             return array('success' => false, 'message' => 'The id of the list to load must be provided as the id parameter.');
         }
         $listId = $_REQUEST['id'];
     }
     if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         global $user;
         $user = UserAccount::validateAccount($username, $password);
     } else {
         global $user;
     }
     if ($user) {
         $userId = $user->id;
     }
     if (is_numeric($listId) || preg_match('/list[-:](.*)/', $listId, $listInfo)) {
         if (isset($listInfo)) {
             $listId = $listInfo[1];
         }
         return $this->_getUserListTitles($listId);
     } elseif (preg_match('/search:(.*)/', $listId, $searchInfo)) {
         if (is_numeric($searchInfo[1])) {
             $titles = $this->getSavedSearchTitles($searchInfo[1]);
             if ($titles && count($titles) > 0) {
                 return array('success' => true, 'listTitle' => $listId, 'listDescription' => "Search Results", 'titles' => $titles, 'cacheLength' => 4);
             } else {
                 return array('success' => false, 'message' => 'The specified search could not be found.');
             }
         } else {
             //Do a default search
             $titles = $this->getSystemListTitles($listId);
             if (count($titles) > 0) {
                 return array('success' => true, 'listTitle' => $listId, 'listDescription' => "System Generated List", 'titles' => $titles, 'cacheLength' => 4);
             } else {
                 return array('success' => false, 'message' => 'The specified list could not be found.');
             }
         }
     } else {
         $systemList = null;
         $systemLists = $this->getSystemLists();
         foreach ($systemLists['lists'] as $curSystemList) {
             if ($curSystemList['id'] == $listId) {
                 $systemList = $curSystemList;
                 break;
             }
         }
         //The list is a system generated list
         if ($listId == 'newEpub' || $listId == 'newebooks') {
             require_once ROOT_DIR . 'sys/eContent/EContentRecord.php';
             $eContentRecord = new EContentRecord();
             $eContentRecord->orderBy('date_added DESC');
             $eContentRecord->limit(0, 30);
             $eContentRecord->find();
             $titles = array();
             while ($eContentRecord->fetch()) {
                 $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'freeEbooks') {
             if (!$pagination) {
                 $pagination = new Pagination();
             }
             require_once ROOT_DIR . 'sys/eContent/EContentRecord.php';
             $eContentRecord = new EContentRecord();
             $eContentRecord->orderBy('date_added DESC');
             $eContentRecord->whereAdd('accessType = \'free\'');
             $eContentRecord->limit($pagination->getOffset(), $pagination->getNumItemsPerPage());
             $eContentRecord->find();
             $titles = array();
             while ($eContentRecord->fetch()) {
                 $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'highestRated') {
             $query = "SELECT record_id, AVG(rating) FROM `user_rating` inner join resource on resourceid = resource.id GROUP BY resourceId order by AVG(rating) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'highestRatedEContent') {
             require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
             $econtentRating = new EContentRating();
             $records = $econtentRating->getRecordsListAvgRating("DESC", 30);
             $titles = array();
             if (!empty($records)) {
                 foreach ($records as $eContentRecord) {
                     $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
                 }
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'recentlyReviewed') {
             $query = "SELECT record_id, MAX(created) FROM `comments` inner join resource on resource_id = resource.id group by resource_id order by max(created) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'mostPopular') {
             $query = "SELECT record_id, count(userId) from user_reading_history inner join resource on resourceId = resource.id GROUP BY resourceId order by count(userId) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'recommendations') {
             if (!$user) {
                 return array('success' => false, 'message' => 'A valid user must be provided to load recommendations.');
             } else {
                 $userId = $user->id;
                 require_once ROOT_DIR . '/services/MyResearch/lib/Suggestions.php';
                 $suggestions = Suggestions::getSuggestions($userId);
                 $titles = array();
                 foreach ($suggestions as $id => $suggestion) {
                     $imageUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $id;
                     if (isset($suggestion['titleInfo']['issn'])) {
                         $imageUrl .= "&issn=" . $suggestion['titleInfo']['issn'];
                     }
                     if (isset($suggestion['titleInfo']['isbn10'])) {
                         $imageUrl .= "&isn=" . $suggestion['titleInfo']['isbn10'];
                     }
                     if (isset($suggestion['titleInfo']['upc'])) {
                         $imageUrl .= "&upc=" . $suggestion['titleInfo']['upc'];
                     }
                     if (isset($suggestion['titleInfo']['format_category'])) {
                         $imageUrl .= "&category=" . $suggestion['titleInfo']['format_category'];
                     }
                     $smallImageUrl = $imageUrl . "&size=small";
                     $imageUrl .= "&size=medium";
                     $titles[] = array('id' => $id, 'image' => $imageUrl, 'small_image' => $smallImageUrl, 'title' => $suggestion['titleInfo']['title'], 'author' => $suggestion['titleInfo']['author']);
                 }
                 return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 0);
             }
         } else {
             return array('success' => false, 'message' => 'The specified list could not be found.');
         }
     }
 }
Esempio n. 7
0
     $suggestions = new Suggestions($db, $user);
     $arr = $suggestions->vote($params[1], $postdata["direction"]);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions'):
     $forum = new Forum($db, $user);
     $suggestions = new Suggestions($db, $user, $forum);
     httpResponse($suggestions->create($postdata));
     break;
 case validateRoute('PATCH', 'suggestions/\\d+'):
     $forum = new Forum($db, $user);
     $suggestions = new Suggestions($db, $user, $forum);
     httpResponse($suggestions->update($params[1], $postdata));
     break;
 case validateRoute('DELETE', 'suggestions/\\d+'):
     $suggestions = new Suggestions($db, $user);
     httpResponse($suggestions->delete($params[1]));
     break;
 case validateRoute('GET', 'sweTvGuide'):
     $week = (int) $_GET["week"];
     $cacheId = 'swetvguide-' . $week;
     if ($memcached && ($cached = $memcached->get($cacheId))) {
         if ($week == 0) {
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($cached);
     } else {
         $torrent = new Torrent($db, $user);
         if ($week > 3) {
             $week = 4;
         }
Esempio n. 8
0
});
$app->get('/api/venues/', function () {
    $cn = new Venues();
    $cn->getVenues();
});
$app->post('/api/venues/', function () use($app) {
    $req = $app->request();
    $bdy = $req->getBody();
    $venue = json_decode($bdy);
    $cn = new Venues();
    $cn->insertVenue($venue[0]);
});
$app->get('/api/venues/:id', function ($id) {
    $cn = new Venues();
    $cn->getVenueById($id);
});
$app->put('/api/venues/:id', function ($id) use($app) {
    $req = $app->request();
    $bdy = $req->getBody();
    $contact = json_decode($bdy);
    $cn = new Venues();
    $cn->updateVenue($id, $location[0]);
});
$app->delete('/api/venues/:id', function ($id) {
    $cn = new Venues();
    $cn->deleteVenue($id);
});
$app->get('/api/venues/:id/suggestions', function ($id) {
    $cn = new Suggestions();
    $cn->getSuggestionsByVenue($id);
});
Esempio n. 9
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $library;
     global $locationSingleton;
     $location = $locationSingleton->getActiveLocation();
     $showHoldButton = 1;
     $showHoldButtonInSearchResults = 1;
     $showRatings = 1;
     if (isset($library)) {
         $showRatings = $library->showRatings;
     }
     $interface->assign('showRatings', $showRatings);
     if (isset($library) && $location != null) {
         $interface->assign('showFavorites', $library->showFavorites);
         $interface->assign('showComments', $library->showComments);
         $showHoldButton = $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0;
         $showHoldButtonInSearchResults = $location->showHoldButton == 1 && $library->showHoldButtonInSearchResults == 1 ? 1 : 0;
     } else {
         if ($location != null) {
             $interface->assign('showFavorites', 1);
             $showHoldButton = $location->showHoldButton;
         } else {
             if (isset($library)) {
                 $interface->assign('showFavorites', $library->showFavorites);
                 $showHoldButton = $library->showHoldButton;
                 $showHoldButtonInSearchResults = $library->showHoldButtonInSearchResults;
                 $interface->assign('showComments', $library->showComments);
             } else {
                 $interface->assign('showFavorites', 1);
                 $interface->assign('showComments', 1);
             }
         }
     }
     if ($showHoldButton == 0) {
         $showHoldButtonInSearchResults = 0;
     }
     $interface->assign('showHoldButton', $showHoldButtonInSearchResults);
     $interface->assign('showNotInterested', true);
     $suggestions = Suggestions::getSuggestions();
     $resourceList = array();
     $curIndex = 0;
     if (is_array($suggestions)) {
         foreach ($suggestions as $suggestion) {
             $interface->assign('resultIndex', ++$curIndex);
             /** @var IndexRecord $recordDriver */
             $recordDriver = RecordDriverFactory::initRecordDriver($suggestion['titleInfo']);
             $resourceEntry = $interface->fetch($recordDriver->getSearchResult());
             $resourceList[] = $resourceEntry;
         }
     }
     $interface->assign('resourceList', $resourceList);
     global $library;
     if (isset($library)) {
         $interface->assign('showRatings', $library->showRatings);
     } else {
         $interface->assign('showRatings', 1);
     }
     //Check to see if the user has rated any titles
     $interface->assign('hasRatings', $user->hasRatings());
     $interface->setPageTitle('Recommended for you');
     $interface->setTemplate('suggestedTitles.tpl');
     $interface->display('layout.tpl');
 }