17 import(
'classes.publicationFormat.SalesRights');
24 parent::__construct();
33 function getById($salesRightsId, $publicationId =
null){
34 $sqlParams = array((
int) $salesRightsId);
36 $sqlParams[] = (int) $publicationId;
42 JOIN publication_formats pf ON (s.publication_format_id = pf.publication_format_id)
43 WHERE s.sales_rights_id = ?
44 ' . ($publicationId?
' AND pf.publication_id = ?':
''),
49 if ($result->RecordCount() != 0) {
50 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
63 'SELECT * FROM sales_rights WHERE publication_format_id = ?', (
int) $publicationFormatId);
75 'SELECT * FROM sales_rights WHERE row_setting = ? AND publication_format_id = ?',
76 array(1, (
int) $publicationFormatId)
80 if ($result->RecordCount() != 0) {
81 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
103 $salesRights->setId($row[
'sales_rights_id']);
104 $salesRights->setType($row[
'type']);
105 $salesRights->setROWSetting($row[
'row_setting']);
106 $salesRights->setCountriesIncluded(unserialize($row[
'countries_included']));
107 $salesRights->setCountriesExcluded(unserialize($row[
'countries_excluded']));
108 $salesRights->setRegionsIncluded(unserialize($row[
'regions_included']));
109 $salesRights->setRegionsExcluded(unserialize($row[
'regions_excluded']));
111 $salesRights->setPublicationFormatId($row[
'publication_format_id']);
113 if ($callHooks)
HookRegistry::call(
'SalesRightsDAO::_fromRow', array(&$salesRights, &$row));
124 'INSERT INTO sales_rights
125 (publication_format_id, type, row_setting, countries_included, countries_excluded, regions_included, regions_excluded)
127 (?, ?, ?, ?, ?, ?, ?)',
129 (
int) $salesRights->getPublicationFormatId(),
130 $salesRights->getType(),
131 $salesRights->getROWSetting(),
132 serialize($salesRights->getCountriesIncluded() ? $salesRights->getCountriesIncluded() : array()),
133 serialize($salesRights->getCountriesExcluded() ? $salesRights->getCountriesExcluded() : array()),
134 serialize($salesRights->getRegionsIncluded() ? $salesRights->getRegionsIncluded() : array()),
135 serialize($salesRights->getRegionsExcluded() ? $salesRights->getRegionsExcluded() : array())
140 return $salesRights->getId();
152 countries_included = ?,
153 countries_excluded = ?,
154 regions_included = ?,
156 WHERE sales_rights_id = ?',
158 $salesRights->getType(),
159 $salesRights->getROWSetting(),
160 serialize($salesRights->getCountriesIncluded() ? $salesRights->getCountriesIncluded() : array()),
161 serialize($salesRights->getCountriesExcluded() ? $salesRights->getCountriesExcluded() : array()),
162 serialize($salesRights->getRegionsIncluded() ? $salesRights->getRegionsIncluded() : array()),
163 serialize($salesRights->getRegionsExcluded() ? $salesRights->getRegionsExcluded() : array()),
164 (
int) $salesRights->getId()
174 return $this->
deleteById($salesRights->getId());
183 'DELETE FROM sales_rights WHERE sales_rights_id = ?', array((
int) $entryId)
192 return $this->
_getInsertId(
'sales_rights',
'sales_rights_id');