Commit a5257c07 authored by asmecher's avatar asmecher
Browse files

#3871# Referral plugin fixes

parent ee1a0c89
......@@ -25,22 +25,6 @@ class Referral extends DataObject {
// Get/set methods
//
/**
* Get the ID of the referral.
* @return int
*/
function getReferralId() {
return $this->getData('referralId');
}
/**
* Set the ID of the referral.
* @param $referralId int
*/
function setReferralId($referralId) {
return $this->setData('referralId', $referralId);
}
/**
* Get the article ID of the referral.
* @return int
......
......@@ -50,7 +50,7 @@ class ReferralDAO extends DAO {
*/
function &_returnReferralFromRow(&$row) {
$referral = new Referral();
$referral->setReferralId($row['referral_id']);
$referral->setId($row['referral_id']);
$referral->setArticleId($row['article_id']);
$referral->setStatus($row['status']);
$referral->setUrl($row['url']);
......@@ -106,7 +106,7 @@ class ReferralDAO extends DAO {
*/
function updateLocaleFields(&$referral) {
$this->updateDataObjectSettings('referral_settings', $referral, array(
'referral_id' => $referral->getReferralId()
'referral_id' => $referral->getId()
));
}
......@@ -131,9 +131,9 @@ class ReferralDAO extends DAO {
(int) $referral->getLinkCount()
)
);
$referral->setReferralId($this->getInsertReferralId());
$referral->setId($this->getInsertObjectId());
$this->updateLocaleFields($referral);
return $referral->getReferralId();
return $referral->getId();
}
/**
......@@ -157,7 +157,7 @@ class ReferralDAO extends DAO {
(int) $referral->getArticleId(),
$referral->getUrl(),
(int) $referral->getLinkCount(),
(int) $referral->getReferralId()
(int) $referral->getId()
)
);
$this->updateLocaleFields($referral);
......@@ -171,7 +171,7 @@ class ReferralDAO extends DAO {
* @return boolean
*/
function deleteReferral($referral) {
return $this->deleteReferralById($referral->getTypeId());
return $this->deleteReferralById($referral->getId());
}
/**
......@@ -180,8 +180,8 @@ class ReferralDAO extends DAO {
* @return boolean
*/
function deleteReferralById($referralId) {
$this->update('DELETE FROM referral_settings WHERE referral_id = ?', $referralId);
return $this->update('DELETE FROM referrals WHERE referral_id = ?', $referralId);
$this->update('DELETE FROM referral_settings WHERE referral_id = ?', (int) $referralId);
return $this->update('DELETE FROM referrals WHERE referral_id = ?', (int) $referralId);
}
/**
......@@ -233,7 +233,7 @@ class ReferralDAO extends DAO {
* Get the ID of the last inserted referral.
* @return int
*/
function getInsertReferralId() {
function getInsertObjectId() {
return $this->getInsertId('referrals', 'referral_id');
}
}
......
......@@ -113,7 +113,7 @@ class ReferralForm extends Form {
$referral->setStatus($this->getData('status'));
// Update or insert referral
if ($referral->getReferralId() != null) {
if ($referral->getId() != null) {
$referralDao->updateReferral($referral);
} else {
$referralDao->insertReferral($referral);
......
......@@ -107,6 +107,7 @@ class ReferralPlugin extends GenericPlugin {
HookRegistry::register ('TemplateManager::include', array(&$this, 'handleReaderTemplateInclude'));
case 'article/interstitial.tpl':
case 'article/pdfInterstitial.tpl':
case 'article/view.tpl':
$this->logArticleRequest($templateMgr);
break;
case 'author/index.tpl':
......
......@@ -40,7 +40,7 @@
<td>{$referral->getReferralName()|truncate:50|escape}</td>
<td>{translate key=$referral->getStatusKey()}</td>
<td align="right">
<a class="action" href="{url page="referral" op="editReferral" path=$referral->getReferralId()}">{translate key="common.edit"}</a>&nbsp;|&nbsp;<a class="action" onclick="return confirm('{translate|escape:"jsparam" key="plugins.generic.referral.confirmDelete"}')" href="{url page="referral" op="deleteReferral" path=$referral->getReferralId()}">{translate key="common.delete"}</a>
<a class="action" href="{url page="referral" op="editReferral" path=$referral->getId()}">{translate key="common.edit"}</a>&nbsp;|&nbsp;<a class="action" onclick="return confirm('{translate|escape:"jsparam" key="plugins.generic.referral.confirmDelete"}')" href="{url page="referral" op="deleteReferral" path=$referral->getId()}">{translate key="common.delete"}</a>
</td>
</tr>
<tr valign="top">
......@@ -71,4 +71,4 @@
</tr>
{/if}
</table>
</div>
\ No newline at end of file
</div>
......@@ -15,7 +15,7 @@
<ul class="plain">
{iterate from=referrals item=referral}
<li>&#187; <a href="{$referral->getUrl()|escape}">{$referral->getReferralName()|escape}</a></li>
<li>&#187; <a href="{$referral->getUrl()|escape}" target="_parent">{$referral->getReferralName()|escape}</a></li>
{/iterate}
{if $referrals->wasEmpty()}
<li>{translate key="plugins.generic.referral.all.empty"}</li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment