Jump to:

5520 Posts in 1734 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [Notice] Undefined variable: _SESSION

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2347 Views
  • Terminator4
    Avatar
    Community Member
    81 Posts

    [Notice] Undefined variable: _SESSION Link to this post

    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();

    }
    }

    ?>

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: [Notice] Undefined variable: _SESSION Link to this post

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

    2347 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.