ENHANCEMENT: made module independed from cmsworkflow module

This commit is contained in:
Frank Winkelmann 2010-07-20 03:51:15 +00:00
parent 68bdc33843
commit cbaa488c84
2 changed files with 53 additions and 40 deletions

View File

@ -128,8 +128,10 @@ class PagesDueForReviewReport extends SS_Report {
$query = singleton("SiteTree")->extendedSQL(join(' AND ', $wheres));
$query->select[] = Member::get_title_sql('Owner').' AS OwnerNames';
$query->from[] = 'LEFT JOIN "Member" AS "Owner" ON "SiteTree"."OwnerID" = "Owner"."ID"';
//$query->select[] = Member::get_title_sql('Owner').' AS OwnerNames';
//// $query->select[] = '"Owner"."Surname" AS OwnerLastNames';
//// $query->select[] = '"Owner"."FirstName" AS OwnerNames';
//// $query->from[] = 'LEFT JOIN "Member" AS "Owner" ON "SiteTree"."OwnerID" = "Owner"."ID"';
// Turn a query into records
if($sort) {
@ -151,9 +153,9 @@ class PagesDueForReviewReport extends SS_Report {
$records = singleton('SiteTree')->buildDataObjectSet($query->execute(), 'DataObjectSet', $query);
// var_dump($records);
if($records) {
foreach($records as $record) {
$record->LastEditedByName = $record->LastEditedBy() ? $record->LastEditedBy()->Title : null;
}
////////foreach($records as $record) {
//////// $record->OwnerNames = $record->OwnerNames .' '. $record->OwnerLastNames;
////////}
if($sort && $field != "LastEditedByName") $records->sort($sort);

View File

@ -12,10 +12,12 @@ class SiteTreeContentReview extends DataObjectDecorator implements PermissionPro
'db' => array(
"ReviewPeriodDays" => "Int",
"NextReviewDate" => "Date",
'ReviewNotes' => 'Text'
'ReviewNotes' => 'Text',
'LastEditedByName' => 'Varchar(255)',
'OwnerNames' => 'Varchar(255)'
),
'has_one' => array(
'Owner' => 'Member'
'Owner' => 'Member',
),
);
}
@ -24,6 +26,13 @@ class SiteTreeContentReview extends DataObjectDecorator implements PermissionPro
if($this->owner->OwnerID && $this->owner->Owner()) return $this->owner->Owner()->FirstName . ' ' . $this->owner->Owner()->Surname;
}
function getEditorName() {
if( $member = Member::currentUser() ) {
return $member->FirstName .' '. $member->Surname;
}
return NULL;
}
public function updateCMSFields(&$fields) {
if(Permission::check("EDIT_CONTENT_REVIEW_FIELDS")) {
@ -57,6 +66,8 @@ class SiteTreeContentReview extends DataObjectDecorator implements PermissionPro
if($this->owner->ReviewPeriodDays && !$this->owner->NextReviewDate) {
$this->owner->NextReviewDate = date('Y-m-d', strtotime('+' . $this->owner->ReviewPeriodDays . ' days'));
}
$this->owner->LastEditedByName=$this->owner->getEditorName();
$this->owner->OwnerNames = $this->owner->getOwnerName();
}
function providePermissions() {