Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F2111450
reviews_tag_processor.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Nov 18, 11:54 AM
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Nov 20, 11:54 AM (1 h, 50 m)
Engine
blob
Format
Raw Data
Handle
992305
Attached To
rINP In-Portal
reviews_tag_processor.php
View Options
<?php
class
ReviewsTagProcessor
extends
kDBTagProcessor
{
/**
* Returns a link for editing product
*
* @param Array $params
* @return string
*/
function
ItemEditLink
(
$params
)
{
$item_prefix
=
$params
[
'item_prefix'
];
$id_field
=
$this
->
Application
->
getUnitOption
(
$item_prefix
,
'IDField'
);
$object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
,
$params
);
$item_id
=
$object
->
GetDBField
(
$id_field
);
return
$this
->
Application
->
HREF
(
$params
[
'edit_template'
],
''
,
Array
(
'm_opener'
=>
'd'
,
$item_prefix
.
'_mode'
=>
't'
,
$item_prefix
.
'_event'
=>
'OnEdit'
,
$item_prefix
.
'_id'
=>
$item_id
,
'pass'
=>
'all,'
.
$item_prefix
),
'index.php'
);
}
/**
* Get's reuested field value
*
* @param Array $params
* @return string
* @access public
*/
function
Field
(
$params
)
{
$field
=
$this
->
SelectParam
(
$params
,
'name,field'
);
$object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
,
$params
);
if
(
$field
==
'ReviewText'
)
{
if
(
$object
->
GetDBField
(
'TextFormat'
)
==
1
)
{
$params
[
'no_special'
]
=
'no_special'
;
}
else
{
unset
(
$params
[
'no_special'
]);
}
}
return
parent
::
Field
(
$params
);
}
function
AlreadyReviewed
(
$params
)
{
$user_id
=
$this
->
getUserID
();
$object
=&
$this
->
getObject
(
Array
(
'skip_autoload'
=>
true
)
);
$product_info
=
$object
->
getLinkedInfo
();
$sql
=
' SELECT * FROM '
.
TABLE_PREFIX
.
'SpamControl
WHERE ItemResourceId='
.
$product_info
[
'ParentId'
].
'
AND IPaddress="'
.
$_SERVER
[
'REMOTE_ADDR'
].
'"
AND PortalUserId='
.
$user_id
.
'
AND DataType="Review"'
;
$res
=
$this
->
Conn
->
GetRow
(
$sql
);
if
(
$res
[
'Expire'
]
>
adodb_mktime
())
{
$ret
=
1
;
}
else
{
$sql
=
'DELETE FROM '
.
TABLE_PREFIX
.
'SpamControl
WHERE ItemResourceId='
.
$product_info
[
'ParentId'
].
'
AND IPaddress="'
.
$_SERVER
[
'REMOTE_ADDR'
].
'"
AND PortalUserId='
.
$user_id
.
'
AND DataType="Review"'
;
$this
->
Conn
->
Query
(
$sql
);
$ret
=
0
;
}
return
$ret
;
}
function
HasError
(
$params
)
{
$object
=&
$this
->
Application
->
recallObject
(
$this
->
getPrefixSpecial
(),
$this
->
Prefix
,
$params
);
if
(
method_exists
(
$object
,
'GetErrorMsg'
))
{
return
parent
::
HasError
(
$params
);
}
else
{
return
0
;
}
}
/**
* Returns current user id for reviews, for logic ask Kostja T.
*
* @return int
*/
function
getUserID
()
{
$user_id
=
$this
->
Application
->
RecallVar
(
'user_id'
);
if
(
$user_id
==
0
)
{
$user_id
=
-
2
;
}
return
$user_id
;
}
}
?>
Event Timeline
Log In to Comment