Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1050783
categories_item.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
Thu, Jul 3, 3:32 PM
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jul 5, 3:32 PM (1 d, 3 h)
Engine
blob
Format
Raw Data
Handle
678973
Attached To
rINP In-Portal
categories_item.php
View Options
<?php
class
CategoriesItem
extends
kDBItem
{
function
Create
()
{
if
(!
$this
->
Validate
())
return
false
;
$this
->
SetDBField
(
'ResourceId'
,
$this
->
Application
->
NextResourceId
());
$this
->
SetDBField
(
'CreatedById'
,
$this
->
Application
->
GetVar
(
'u_id'
)
);
$this
->
SetDBField
(
'CreatedOn_date'
,
adodb_mktime
()
);
$this
->
SetDBField
(
'CreatedOn_time'
,
adodb_mktime
()
);
$this
->
SetDBField
(
'ParentId'
,
$this
->
Application
->
GetVar
(
'm_cat_id'
)
);
$ret
=
parent
::
Create
();
if
(
$ret
)
{
$sql
=
'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s'
;
$parent_path
=
$this
->
buildParentPath
();
$this
->
Conn
->
Query
(
sprintf
(
$sql
,
$this
->
TableName
,
$this
->
Conn
->
qstr
(
$parent_path
),
$this
->
GetID
()
)
);
$this
->
SetDBField
(
'ParentPath'
,
$parent_path
);
}
return
$ret
;
}
function
buildParentPath
()
{
$parent_id
=
$this
->
GetDBField
(
'ParentId'
);
$cat_table
=
$this
->
Application
->
getUnitOption
(
$this
->
Prefix
,
'TableName'
);
$sql
=
'SELECT ParentPath FROM '
.
$cat_table
.
' WHERE CategoryId = %s'
;
$parent_path
=
$this
->
Conn
->
GetOne
(
sprintf
(
$sql
,
$parent_id
)
);
if
(!
$parent_path
)
$parent_path
=
'|'
.
$parent_id
.
'|'
;
return
$parent_path
.
$this
->
GetID
().
'|'
;
}
}
?>
Event Timeline
Log In to Comment