Changeset 6


Ignore:
Timestamp:
Apr 14, 2020, 11:06:28 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Check existence of Log module.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r1 r6  
    66// and system will need database update.
    77
    8 $Revision = 1;
    9 $DatabaseRevision = 1;
    10 $ReleaseTime = strtotime('2016-08-03');
     8$Revision = 6;
     9$DatabaseRevision = 6;
     10$ReleaseTime = strtotime('2020-04-14');
  • trunk/Modules/Ride/Ride.php

    r5 r6  
    11<?php
     2
     3include_once(dirname(__FILE__).'/RideModel.php');
    24
    35class ModuleRide extends AppModule
     
    7173  `Sequence` int(11) NOT NULL,
    7274  `Price` int(11) NOT NULL,
     75  `PassengerCount` int(11) NOT NULL,
    7376  PRIMARY KEY (`Id`),
    7477  KEY `Ride` (`Ride`)
     
    8386  `RideStopFrom` int(11) NOT NULL,
    8487  `RideStopTo` int(11) NOT NULL,
    85   `PassengerCount` int(11) NOT NULL,
    8688  PRIMARY KEY (`Id`),
    8789  KEY `User` (`User`),
     
    125127  {
    126128
     129  }
     130
     131  function InsertSampleData()
     132  {
     133    $Cities = array('Praha', 'Brno', 'Ostrava', 'Olomouc', 'Liberec', 'Plzeň',
     134      'Humpolec', 'Zlín', 'Přerov', 'České Budějovice', 'Jihlava', 'Ústí nad Labem',
     135      'Hradec Králové', 'Pardubice', 'Mohelnice', 'Břeclav', 'Znojmo', 'Semily',
     136      'Tábor', 'Opava', 'Karviná', 'Pelhřimov', 'Osoblaha', 'Broumov', 'Jirkov',
     137      'Aš', 'Kutná Hora', 'Kolín', 'Strakonice', 'Tachov', 'Domažlice', 'Beroun',
     138      'Most', 'Chomutov', 'Mělník', 'Mladá Boleslav', 'Svitavy', 'Šumperk',
     139      'Litomyšl', 'Chrudim', 'Blansko', 'Hodonín', 'Rosice', 'Uherský Brod',
     140      'Vsetín', 'Nový Jičín', 'Prostějov', 'Vyškov', 'Mohelnice', 'Ústí nad Orlicí');
     141
     142    for($I = 0; $I < 100; $I++)
     143    {
     144      $Stops = array_fill(0, random(5), '');
     145      for($J = 0; $J < count($Stops); $J++)
     146        $Stops[$J] = $Cities[random(count($Cities))];
     147
     148      $Ride = new Ride();
     149      $StartTime = time() - random(60*60*24*365);
     150      $StopCount = random(5);
     151      $Ride->Add($Stops, $StartTime, $SeatCount);
     152    }
    127153  }
    128154
     
    389415  );
    390416
     417  $ret = array();
    391418  foreach($bit as $k => $v)
    392419    if($v > 0)$ret[] = $v . $k;
     
    401428    if (!array_key_exists('step', $_GET))
    402429    {
    403       $Output = '<form method="get" action="'.$this->System->Link('/nova-jizda/').'">'.
     430      $Output = '<script>
     431function insertAfter(referenceNode, newNode)
     432{
     433    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
     434}
     435
     436function add_before(name)
     437{
     438    var objTo = document.getElementById(name)
     439    var divtest = document.createElement("div");
     440    divtest.innerHTML = \'<tr><td>Zastávka:</td><td><input type="text" name="ridestop1"/></td></tr>\';
     441
     442    objTo.parentNode.insertBefore(divtest, objTo.childNodes[0])
     443}
     444
     445function add_after(name)
     446{
     447    var objTo = document.getElementById(name)
     448    var divtest = document.createElement("div");
     449    divtest.innerHTML = \'<tr><td>Zastávka:</td><td><input type="text" name="ridestop1"/></td></tr>\';
     450
     451    insertAfter(objTo, divtest)
     452}
     453          </script>'.
     454        '<form method="get" action="'.$this->System->Link('/nova-jizda/').'">'.
    404455        '<table>'.
     456        '<tr><td colspan="2"><strong>Trasa:</strong></td></tr>'.
     457
    405458        '<tr><td>Počátek:</td><td><input type="text" name="from"/></td></tr>'.
     459        '<tr><td>Zastávka:</td><td><input type="text" name="middle"/></td></tr>'.
    406460        '<tr><td>Konec:</td><td><input type="text" name="to"/></td></tr>'.
     461
     462        '<tr><td colspan="2"><br><strong>Parametry jízdy:</strong></td></tr>'.
    407463        '<tr><td>Čas odjezdu:</td><td><input type="text" name="time-from"/></td></tr>'.
    408464        '<tr><td>Počet míst pro cestující:</td><td><input type="text" name="seats"/></td></tr>'.
  • trunk/Modules/User/UserModel.php

    r5 r6  
    119119    {
    120120      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    121       if($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
     121      if(($DbRow['User'] != null) and $this->System->ModuleManager->ModulePresent('Log'))
     122        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
    122123    }
    123124    //$this->LoadPermission($this->User['Role']);
     
    174175
    175176            $Result = USER_REGISTRATED;
    176             if(array_key_exists('Log', $this->System->ModuleManager->Modules))
     177            if($this->System->ModuleManager->ModulePresent('Log'))
    177178              $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
    178179          }
     
    194195        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    195196        $Output = USER_REGISTRATION_CONFIRMED;
    196         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
    197           $Row['Login'].', Id='.$Row['Id']);
     197        if($this->System->ModuleManager->ModulePresent('Log'))
     198          $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
     199            $Row['Login'].', Id='.$Row['Id']);
    198200      } else $Output = PASSWORDS_UNMATCHED;
    199201    } else $Output = USER_NOT_FOUND;
     
    242244    $SID = session_id();
    243245    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null));
    244     if(array_key_exists('Log', $this->System->ModuleManager->Modules))
     246    if($this->System->ModuleManager->ModulePresent('Log'))
    245247      $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
    246248    $this->Check();
     
    397399
    398400      $Output = USER_PASSWORD_RECOVERY_SUCCESS;
    399       $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
     401      if($this->System->ModuleManager->ModulePresent('Log'))
     402        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
    400403    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    401404    return($Output);
     
    415418        $this->Database->update('User', 'Id='.$Row['Id'], array('Password' => $PasswordHash->Hash($NewPassword, $Salt),
    416419          'Salt' => $Salt, 'Locked' => 0));
    417         $Output = USER_PASSWORD_RECOVERY_CONFIRMED;
    418         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
     420        if($this->System->ModuleManager->ModulePresent('Log'))
     421          $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
    419422      } else $Output = PASSWORDS_UNMATCHED;
    420423    } else $Output = USER_NOT_FOUND;
Note: See TracChangeset for help on using the changeset viewer.