db =& JFactory :: getDBO(); $this -> log =& JLog :: getInstance(); } public function getAtomUrn() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'atomUrn\';'); $atomUrn = $this -> db -> loadResult(); if ($atomUrn === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving Atom URN: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Atom URN is $atomUrn")); return $atomUrn; } public function setAtomUrn($atomUrn) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = '$atomUrn' WHERE `key` = 'atomUrn';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting Atom URN to $atomUrn: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set Atom URN to $atomUrn")); } public function getJdbcUri() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'jdbcUri\';'); $jdbcUri = $this -> db -> loadResult(); if ($jdbcUri === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving JDBC URI: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "JDBC URI is $jdbcUri")); return $jdbcUri; } public function setJdbcUri($jdbcUri) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = '$jdbcUri' WHERE `key` = 'jdbcUri';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting JDBC URI to $jdbcUri: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set JDBC URI to $jdbcUri")); } public function getNewsCategory() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'newsCategory\';'); $newsCategory = $this -> db -> loadResult(); if ($newsCategory === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving news category:" . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "News category is $newsCategory")); return $newsCategory; } public function setNewsCategory($newsCategory) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = $newsCategory WHERE `key` = 'newsCategory';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting news category to $newsCategory: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set news category to $newsCategory")); } public function getNewsSection() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'newsSection\';'); $newsSection = $this -> db -> loadResult(); if ($newsSection === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving news section:" . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "News section is $newsSection")); return $newsSection; } public function setNewsSection($newsSection) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = $newsSection WHERE `key` = 'newsSection';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting news section to $newsSection: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set news section to $newsSection")); } public function getNewsUser() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'newsUser\';'); $newsUser = $this -> db -> loadResult(); if ($newsUser === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving news section:" . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "News user is $newsUser")); return $newsUser; } public function setNewsUser($newsUser) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = $newsUser WHERE `key` = 'newsUser';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting news user to $newsUser: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set news user to $newsUser")); } public function getTwitterAccessToken() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'twitterAccessToken\';'); $twitterAccessToken = $this -> db -> loadResult(); if ($twitterAccessToken === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ('Error retrieving twitter access token: ' . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "twitter access token is $twitterAccessToken")); return $twitterAccessToken; } public function setTwitterAccessToken($twitterAccessToken) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = '$twitterAccessToken' WHERE `key` = 'twitterAccessToken';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting twitter access token to $twitterAccessToken: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set twitter access token to $twitterAccessToken")); } public function getTwitterAccessTokenSecret() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'twitterAccessTokenSecret\';'); $twitterAccessTokenSecret = $this -> db -> loadResult(); if ($twitterAccessTokenSecret === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving twitter access token secret: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "twitter access token secret is $twitterAccessTokenSecret")); return $twitterAccessTokenSecret; } public function setTwitterAccessTokenSecret($twitterAccessTokenSecret) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = '$twitterAccessTokenSecret' WHERE `key` = 'twitterAccessTokenSecret';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting twitter access token secret to $twitterAccessTokenSecret: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set twitter access token secret to $twitterAccessTokenSecret")); } public function getPageSize() { $this -> db -> setQuery('SELECT `value` FROM `#__openaire` WHERE `key` = \'subscriptionsPageSize\';'); $pageSize = $this -> db -> loadResult(); if ($pageSize === NULL) $this -> log -> addEntry(array('level' => 'error', 'comment' => ('Error retrieving page size: ' . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Page size is $pageSize")); return $pageSize; } public function setPageSize($pageSize) { $this -> db -> setQuery("UPDATE `#__openaire` SET `value` = '$pageSize' WHERE `key` = 'subscriptionsPageSize';"); if ($this -> db -> query() === FALSE) $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error setting page size to $pageSize: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); else $this -> log -> addEntry(array('level' => 'info', 'comment' => "Set page size to $pageSize")); } public function getSections() { $this -> db -> setQuery('SELECT `id`, `title` FROM `#__sections`;'); $sections = $this -> db -> loadAssocList(); if ($sections === NULL) { $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving sections: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); return array(); } else { $result = array(); foreach ($sections as $section) $result[$section['id']] = $section['title']; $this -> log -> addEntry(array('level' => 'info', 'comment' => ('Retrieved ' . count($result) . ' sections'))); return $result; } } public function getCategories() { $this -> db -> setQuery('SELECT `section`, `id`, `title` FROM `#__categories`;'); $categories = $this -> db -> loadAssocList(); if ($categories === NULL) { $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving categories: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); return array(); } else { $result = array(); foreach ($categories as $category) $result[$category['section']][$category['id']] = $category['title']; $this -> log -> addEntry(array('level' => 'info', 'comment' => ('Retrieved ' . count($categories) . ' categories'))); return $result; } } public function getUsers() { $this -> db -> setQuery('SELECT `id`, `name` FROM `#__users`;'); $users = $this -> db -> loadAssocList(); if ($users === NULL) { $this -> log -> addEntry(array('level' => 'error', 'comment' => ("Error retrieving users: " . $this -> db -> getErrorMsg() . ' (' . $this -> db -> getErrorNum() . ')'))); return array(); } else { $result = array(); foreach ($users as $user) $result[$user['id']] = $user['name']; $this -> log -> addEntry(array('level' => 'info', 'comment' => ('Retrieved ' . count($result) . ' users'))); return $result; } } } ?>