Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

[Notice] Undefined variable: _SESSION


Go to End
Reply


2 Posts   2490 Views

Avatar
Terminator4

Community Member, 81 Posts

20 November 2009 at 11:28pm

Hey guys,
I am using the latest build of SS 2.4rc1 and I have run into the following issue with trying to extend the member table. Once I uncomment the following line I get an error that I cannot resolve. Please can you assist. Thanks

Object::add_extension('Member', 'PersonnelExtension');

[Notice] Undefined variable: _SESSION
GET /evertrade/silverstripe/dev/viewcode/show/PersonnelExtension

Line 120 in C:\xampp\htdocs\evertrade\silverstripe\sapphire\core\control\Director.php

<?php

class PersonnelExtension extends DataObjectDecorator {

function extraStatics() {
return array(
'db' => array(
"IDNumber" => "Varchar",
"TelNumber" => "Varchar",
"MobileNumber" => "Varchar",
'PersonnelCode' => 'Varchar',
'Notes' => 'HTMLText'
),
'has_one' => array(
'Avatar' => 'Image',
'Town' => 'Town'
),
);
}

/**
* Update the database data, migrating EcomMember into Member, if necessary
*/
function augmentDefaultRecords() {
$exist = DB::query("SHOW TABLES LIKE 'EcomMember'")->numRecords();
if($exist > 0) {
DB::query("UPDATE `Member`, `EcomMember` " .
"SET `Member`.`ClassName` = 'Member'," .
"`Member`.`IDNumber` = `EcomMember`.`IDNumber`," .
"`Member`.`TelNumber` = `EcomMember`.`TelNumber`," .
"`Member`.`MobileNumber` = `EcomMember`.`MobileNumber`," .
"`Member`.`PersonnelCode` = `EcomMember`.`PersonnelCode`," .
"`Member`.`Notes` = `EcomMember`.`Notes`" .
"WHERE `Member`.`ID` = `EcomMember`.`ID`"
);
echo("<div style=\"padding:5px; color:white; background-color:blue;\">The data transfer has succeeded. However, to complete it, you must delete the PersonnelExtension table. To do this, execute the query \"DROP TABLE 'PersonnelExtension'\".</div>");
}
}

public function updateCMSFields(FieldSet &$fields) {
$fields->push(new NumericField($name = "IDNumber",$title = "ID number"));
$fields->push(new PhoneNumberField($name = "TelNumber",$title = "Telephone number"));
$fields->push(new PhoneNumberField($name = "MobileNumber",$title = "Mobile number"));
$fields->push(new TextField('PersonnelCode', 'Personnel Code (If applicable)'));

$tablefield = new HasOneDataObjectManager(
$this,
'Town',
'Town',
array(
'TownName' => 'Town Name',
'ProvinceName' => 'Province Name'
),
'getCMSFields'
);

$tablefield->setPermissions(array("show"));

$fields->push($tablefield);

$fields->push(new ImageField('Avatar', 'Profile Image'));
}

function getTownName() {

$sqlQuery = new SQLQuery(
"TownName",
"Town",
"ID=$this->TownID"
);

return $sqlQuery->execute()->value();

}
}

?>

Avatar
baba-papa

Community Member, 279 Posts

21 November 2009 at 8:30pm

The notice "Undefined variable: _SESSION" might be the result of wrong access rights for the folder silverstripe-cache.