Changeset 15
- Timestamp:
- Oct 19, 2008, 8:16:37 PM (16 years ago)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
base.php
r14 r15 4 4 { 5 5 global $Database, $Types, $Config; 6 7 //if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 6 8 7 9 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; … … 32 34 { 33 35 if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded 34 $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 36 $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 35 37 if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order 36 38 $_SESSION['OrderDirection'] = 0; … … 63 65 } 64 66 } 65 $Output .= '<td><a href="?Action=ViewItem&Table='.$List['TableName'].'&Item='.$DbRow['I d'].'">Zobrazit</a> <a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['Id'].'">Editovat</a> <a href="?Action=DeleteItem&Table='.$List['TableName'].'&Item='.$DbRow['Id'].'">Smazat</a></td></tr>';67 $Output .= '<td><a href="?Action=ViewItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Zobrazit</a> <a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Editovat</a> <a href="?Action=DeleteItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Smazat</a></td></tr>'; 66 68 } 67 69 $Output .= '</table>'; … … 74 76 function ShowHistory($List, $Id, $Title = '') 75 77 { 76 global $Database, $Types, $Config ;78 global $Database, $Types, $Config, $TypeNames; 77 79 78 80 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; … … 125 127 } 126 128 } 127 $Item = array('Name' => 'Author', 'Type' => 'PointerOneToOne:User'); 128 $ItemType = explode(':', $Item['Type']); 129 echo($TypeNames['PointerOneToUser']); 130 $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerOneToUser']); 131 $ItemType = explode('|', $Types[$Item['Type']]['Parameters']); 129 132 $Type = $Types[$ItemType[0]]; 130 133 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); … … 146 149 global $Database, $Types; 147 150 148 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);151 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 149 152 while($DbRow = $DbResult->fetch_array()) 150 153 { … … 181 184 global $Database, $Types, $System, $LogActionType; 182 185 183 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);186 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 184 187 while($DbRow = $DbResult->fetch_array()) 185 188 { … … 205 208 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']); 206 209 $Output = 'Změny uloženy.'; 207 $Output .= ShowViewItem($List, $ NewId);210 $Output .= ShowViewItem($List, $Id); 208 211 $Form->Values['Column'] = $_POST['Column']; 209 212 ExecuteListEvent($List['TableName'], 'OnEdit', $Form->Values); … … 279 282 ); 280 283 $Form->LoadValuesFromForm(); 281 $ System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values);284 $NewItemId = $System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values); 282 285 $NewId = $Database->insert_id; 283 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']);286 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']); 284 287 $Output = 'Položka přidána'; 285 $Output .= ShowViewItem($List, $NewI d);288 $Output .= ShowViewItem($List, $NewItemId); 286 289 $Form->Values['Column'] = $_POST['Column']; 287 290 ExecuteListEvent($List['TableName'], 'OnAdd', $Form->Values); … … 294 297 295 298 $Output = ''; 296 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);299 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 297 300 while($DbRow = $DbResult->fetch_array()) 298 301 { … … 312 315 ); 313 316 $Output .= $Form->ShowReadOnlyForm(); 314 $Output .= '<a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['I d'].'">Editovat</a> ';317 $Output .= '<a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Editovat</a> '; 315 318 316 319 if(($Column != '') and ($ColumnValue != 0)) … … 328 331 { 329 332 $SubList = $Lists[$Types[$Item['Type']]['Parameters'][0]]; 330 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['I d'], $Item['TextBefore']).'<br /><br />';333 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />'; 331 334 } 332 335 } … … 418 421 global $Database, $Lists; 419 422 420 $DbResult = $Database-> select('SystemList', '*');423 $DbResult = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)'); 421 424 while($DbRow = $DbResult->fetch_assoc()) 422 425 { 423 426 $Items = array(); 424 $DbResult2 = $Database-> select('SystemListItem', '`Id`, `Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`, `VisibleInPointer`', 'List='.$DbRow['Id']);427 $DbResult2 = $Database->query('SELECT t1.* FROM `SystemListItem` AS t1 LEFT JOIN `SystemListItem` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND t1.List='.$DbRow['ItemId']); 425 428 while($DbRow2 = $DbResult2->fetch_assoc()) 426 429 { … … 437 440 $Lists[$List['TableName']] = $List; 438 441 } 442 //print_r($Lists); 439 443 } 440 444 … … 445 449 $Types = array(); 446 450 $TypeNames = array(); 447 $DbResult = $Database-> select('SystemType', '*');451 $DbResult = $Database->query('SELECT t1.* FROM `SystemType` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)'); 448 452 while($DbRow = $DbResult->fetch_assoc()) 449 453 { 450 454 $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); 451 455 $DbRow['BaseType'] = $DbRow['Name']; 452 $Types[$DbRow['I d']] = $DbRow;453 $TypeNames[$DbRow['Name']] = $DbRow['I d'];456 $Types[$DbRow['ItemId']] = $DbRow; 457 $TypeNames[$DbRow['Name']] = $DbRow['ItemId']; 454 458 } 455 459 … … 483 487 //echo($Callback.','); 484 488 if(is_callable($Callback)) return($Callback($Parameters)); 485 else return($Callback );489 else return($Callback.'('.$Type.')'); 486 490 } 487 491 … … 497 501 } 498 502 503 function CheckPermission($Right, $ListId, $ItemId = 0) 504 { 505 global $Database; 506 507 $DbResult = $Database->query('SELECT t1.* FROM `Permission` AS t1 LEFT JOIN `Permission` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND t1.PermissionGroup = (SELECT PermissionGroup.Id FROM PermissionGroup WHERE PermissionGroup.Id=(SELECT User.PermissionGroup FROM User WHERE User.ItemId='.$System->Modules['User']->User['Id'].' ORDER BY User.Id DESC LIMIT 1) ORDER BY PermissionGroup.Id DESC LIMIT 1) AND t1.DeletionTime IS NULL AND t1.List='.$ListId); 508 if($DbResult->num_rows > 0) 509 { 510 $DbRow = $DbResult->fetch_assoc(); 511 switch($DbRow['Right']) 512 { 513 case 0: return(array('Read' => FALSE, 'Write' => FALSE)); 514 case 1: return(array('Read' => TRUE, 'Write' => FALSE)); 515 case 2: return(array('Read' => TRUE, 'Write' => TRUE)); 516 } 517 } 518 } 519 499 520 ?> -
database_list.php
r13 r15 15 15 $Values['ItemId'] = $AutoincrementId + 1; 16 16 $this->Database->insert($TableName, $Values); 17 return($Values['ItemId']); 17 18 } 18 19 19 20 function DeleteItem($TableName, $Id) 20 21 { 21 $this->Database->update($TableName, 'Id='.$Id, array('DeletionTime' => 'NOW()')); 22 $DbResult = $this->Database->select($TableName, 'Id', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 23 $DbRow = $DbResult->fetch_assoc(); 24 $this->Database->update($TableName, 'Id='.$DbRow['Id'], array('DeletionTime' => 'NOW()')); 22 25 } 23 26 24 27 function EditItem($TableName, $Values, $Id) 25 28 { 26 $DbResult = $this->Database->select($TableName, 'ItemId', 'Id='.$Id); 27 $DbRow = $DbResult->fetch_assoc(); 28 $Values['ItemId'] = $DbRow['ItemId']; 29 $this->DeleteItem($TableName, $Id); 30 $Values['ItemId'] = $Id; 29 31 $Values['Author'] = $this->System->Modules['User']->User['Id']; 30 32 $Values['CreationTime'] = 'NOW()'; -
global.php
r14 r15 172 172 } 173 173 174 function SystemMessage($Title, $Text) 175 { 176 return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>'); 177 //ShowFooter(); 178 //die(); 179 } 180 174 181 ?> -
page.php
r9 r15 9 9 10 10 function SystemMessage($Title, $Text) 11 { 11 { 12 12 return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>'); 13 13 //ShowFooter(); -
style.css
r14 r15 44 44 background-color: white; 45 45 margin: 0px 0px 5px 0px; 46 width: auto; 46 47 } 47 48 -
types/PointerOneToOne.php
r12 r15 5 5 global $Database, $Lists; 6 6 7 //print_r($Item); 7 8 $Columns = ''; 8 9 $TargetTable = $Type['Parameters'][0]; … … 10 11 foreach($Lists[$TargetTable]['Items'] as $ListItem) 11 12 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 12 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, I d';13 $DbResult = $Database->select($TargetTable, $Columns, 'I d='.$Item['Value']);13 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 14 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 14 15 //echo($Database->LastQuery); 15 16 if($DbResult->num_rows > 0) … … 28 29 foreach($Lists[$TargetTable]['Items'] as $ListItem) 29 30 if($ListItem['VisibleInPointer'] == 1) $Columns .= 't1.`'.$ListItem['Name'].'`," ",'; 30 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId ';31 $DbResult = $Database->query('SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)');31 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime'; 32 $DbResult = $Database->query('SELECT t3.* FROM (SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)) AS t3 WHERE t3.DeletionTime IS NULL'); 32 33 //echo($Database->LastQuery); 33 34 if($DbResult->num_rows > 0) … … 47 48 $TargetTable = $Type['Parameters'][0]; 48 49 $TargetName = GetTablePointerName($Type, $Item); 49 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['I d'].'">'.$TargetName['Name'].'</a>';50 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['ItemId'].'">'.$TargetName['Name'].'</a>'; 50 51 return($Output); 51 52 } … … 61 62 foreach($TargetNameList as $TargetName) 62 63 { 63 if($Item['Value'] == $TargetName['I d']) $Selected = ' selected="1"'; else $Selected = '';64 $Output .= '<option value="'.$TargetName['I d'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';64 if($Item['Value'] == $TargetName['ItemId']) $Selected = ' selected="1"'; else $Selected = ''; 65 $Output .= '<option value="'.$TargetName['ItemId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 65 66 } 66 67 $Output .= '</select>'; -
user.php
r9 r15 69 69 { 70 70 $this->Database->delete($this->TableUserOnline, 'User='.$DbRow['User']); 71 $this->System->Modules['Log']->NewRecord('User', 'Logout');71 //$this->System->Modules['Log']->Add('User', 'Logout'); 72 72 } 73 73 //$this->LoadPermission($this->User['Role']); … … 102 102 mail($Email, $Subject, $Message, $AdditionalHeaders); 103 103 $Result = USER_REGISTRATED; 104 $this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Nick);104 //$this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Nick); 105 105 } 106 106 } … … 119 119 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Locked' => 0)); 120 120 $Output = USER_REGISTRATION_CONFIRMED; 121 $this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'UserName='.$Row['Name']);121 //$this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'UserName='.$Row['Name']); 122 122 } else $Output = PASSWORDS_UNMATCHED; 123 123 } else $Output = USER_NOT_FOUND; … … 141 141 // načtení stavu stromu 142 142 $Result = USER_LOGGED_IN; 143 $this->System->Modules['Log']->NewRecord('User', 'Login', 'Nick='.$Nick.',Host='.gethostbyaddr(GetRemoteAddress()));143 //$this->System->Modules['Log']->NewRecord('User', 'Login', 'Nick='.$Nick.',Host='.gethostbyaddr(GetRemoteAddress())); 144 144 } 145 145 } else $Result = USER_NOT_REGISTRED; … … 154 154 $SID = session_id(); 155 155 $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => 0)); 156 $this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Name']);156 //$this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Name']); 157 157 $this->Check(); 158 158 return(USER_LOGGED_OUT); 159 }160 161 function LoadRoles()162 {163 $this->Roles = array();164 $DbResult = $this->Database->select('UserRole', '*');165 while($DbRow = $DbResult->fetch_array())166 $this->Roles[] = $DbRow;167 }168 169 function LoadPermission($Role)170 {171 $this->User['Permission'] = array();172 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role);173 if($DbResult->num_rows > 0)174 while($DbRow = $DbResult->fetch_array())175 $this->User['Permission'][$DbRow['Operation']] = $DbRow;176 }177 178 function PermissionMatrix()179 {180 $Result = array();181 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`');182 while($DbRow = $DbResult->fetch_array())183 {184 $Value = '';185 if($DbRow['Read']) $Value .= 'R';186 if($DbRow['Write']) $Value .= 'W';187 $Result[$DbRow['Description']][$DbRow['Title']] = $Value;188 }189 return($Result);190 }191 192 function CheckGroupPermission($GroupId, $OperationId)193 {194 // Check group-group relation195 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `Type`="Group"');196 while($DbRow = $DbResult->fetch_array())197 {198 if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);199 }200 201 // Check group-operation relation202 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');203 if($DbResult->num_rows > 0) return(true);204 return(false);205 }206 207 function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)208 {209 $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$Module.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"');210 if($DbResult->num_rows > 0)211 {212 $DbRow = $DbResult->fetch_array();213 $OperationId = $DbRow['Id'];214 215 // Check user-operation relation216 $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this->User['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');217 if($DbResult->num_rows > 0) return(true);218 219 // Check user-group relation220 $DbResult = $this->Database->select('PermissionUserAssignment', 'GroupOrOperation', '`User`="'.$this->User['Id'].'" AND `Type`="Group"');221 while($DbRow = $DbResult->fetch_array())222 {223 if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);224 }225 return(false);226 } else return(false);227 159 } 228 160 … … 242 174 mail($Row['Email'], $Subject, $Message, $AdditionalHeaders); 243 175 $Output = USER_PASSWORD_RECOVERY_SUCCESS; 244 $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'UserName='.$Name.',Email='.$Email);176 //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'UserName='.$Name.',Email='.$Email); 245 177 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 246 178 return($Output); … … 258 190 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Password' => sha1($NewPassword), 'Locked' => 0)); 259 191 $Output = USER_PASSWORD_RECOVERY_CONFIRMED; 260 $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']);192 //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']); 261 193 } else $Output = PASSWORDS_UNMATCHED; 262 194 } else $Output = USER_NOT_FOUND;
Note:
See TracChangeset
for help on using the changeset viewer.