- Timestamp:
- Feb 28, 2022, 8:53:22 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r915 r922 3 3 $ConfigFileName = dirname(__FILE__).'/../Config/Config.php'; 4 4 if (file_exists($ConfigFileName)) include_once($ConfigFileName); 5 else 6 { 7 $ConfigFileName = '/etc/isp-central/Config.php'; 8 if (file_exists($ConfigFileName)) include_once($ConfigFileName); 9 } 5 10 6 11 include_once(dirname(__FILE__).'/Version.php'); -
trunk/Application/Version.php
r921 r922 1 1 <?php 2 2 3 $Revision = 92 1; // Subversion revision3 $Revision = 922; // Subversion revision 4 4 $DatabaseRevision = 921; // SQL structure revision 5 $ReleaseTime = strtotime('2022-02-2 4');5 $ReleaseTime = strtotime('2022-02-28'); -
trunk/Common/Form/Form.php
r914 r922 2 2 3 3 include_once(dirname(__FILE__).'/Types/Type.php'); 4 include_once(dirname(__FILE__).'/FormManager.php'); 4 5 5 6 /* … … 19 20 */ 20 21 21 22 22 class Form 23 23 { … … 67 67 { 68 68 $Item = $this->Definition['Items'][$Index]; 69 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 70 { 71 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 72 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 73 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 74 $UseType = 'OneToMany'; 75 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 76 $UseType = 'Enumeration'; 77 } else $UseType = $Item['Type']; 69 $UseType = $this->GetItemType($Item); 78 70 return $this->FormManager->Type->ExecuteTypeEvent($UseType, $Event, 79 80 81 71 array('Value' => $this->Values[$Index], 'Name' => $Index, 72 'Type' => $Item['Type'], 'Values' => $this->Values, 73 'Filter' => $this->Values[$Index])); 82 74 } 83 75 … … 94 86 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 95 87 { 96 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 97 { 98 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 99 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 100 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 101 $UseType = 'OneToMany'; 102 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 103 $UseType = 'Enumeration'; 104 } else $UseType = $Item['Type']; 88 $UseType = $this->GetItemType($Item); 105 89 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView', 106 90 array('Value' => $this->Values[$Index], 'Name' => $Index, … … 150 134 else unset($Parameters['OnPreset']); 151 135 152 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 153 { 154 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 155 $this->FormManager->Type->RegisterType($Item['Type'], '', 156 $this->FormManager->FormTypes[$Item['Type']]); 157 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 158 { 159 $UseType = 'OneToMany'; 160 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 161 $UseType = 'Enumeration'; 162 } else $UseType = $Item['Type']; 136 $UseType = $this->GetItemType($Item); 163 137 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters); 164 138 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; … … 182 156 } 183 157 158 function GetItemType($Item): string 159 { 160 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 161 { 162 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 163 $this->FormManager->Type->RegisterType($Item['Type'], '', 164 $this->FormManager->FormTypes[$Item['Type']]); 165 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 166 $UseType = 'OneToMany'; 167 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 168 $UseType = 'Enumeration'; 169 } else $UseType = $Item['Type']; 170 171 return $UseType; 172 } 173 184 174 function LoadValuesFromDatabase(string $Id): void 185 175 { 186 176 foreach ($this->Definition['Items'] as $Index => $Item) 187 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 188 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 189 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 190 { 191 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 192 { 193 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 194 $this->FormManager->Type->RegisterType($Item['Type'], '', 195 $this->FormManager->FormTypes[$Item['Type']]); 196 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 197 $UseType = 'OneToMany'; 198 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 199 $UseType = 'Enumeration'; 200 } else $UseType = $Item['Type']; 201 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 202 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 203 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', 204 array('Name' => $Index, 'Type' => $Item['Type'], 'SQL' => $Item['SQL'])); 177 { 178 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 179 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 180 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 181 { 182 $UseType = $this->GetItemType($Item); 183 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 184 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 185 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', 186 array('Name' => $Index, 'Type' => $Item['Type'], 'SQL' => $Item['SQL'])); 187 } 205 188 } 206 189 $Columns = implode(',', $Columns); … … 211 194 $DbRow = $DbResult->fetch_array(); 212 195 foreach ($this->Definition['Items'] as $Index => $Item) 213 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 214 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 215 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 216 { 217 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 218 { 219 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 220 $this->FormManager->Type->RegisterType($Item['Type'], '', 221 $this->FormManager->FormTypes[$Item['Type']]); 222 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 223 $UseType = 'OneToMany'; 224 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 225 $UseType = 'Enumeration'; 226 } else $UseType = $Item['Type']; 196 { 197 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 198 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 199 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 200 { 201 $UseType = $this->GetItemType($Item); 227 202 $this->Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoadDb', 228 229 203 array('Value' => $DbRow[$Index], 'Name' => $Index, 204 'Type' => $Item['Type'], 'Values' => $this->Values)); 230 205 $this->ValuesFilter[$Index] = $DbRow[$Index.'_Filter']; 206 } 231 207 } 232 208 } … … 244 220 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 245 221 'Type' => $Item['Type'], 'Values' => $this->Values); 246 247 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 248 { 249 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 250 $this->FormManager->Type->RegisterType($Item['Type'], '', 251 $this->FormManager->FormTypes[$Item['Type']]); 252 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 253 { 254 $UseType = 'OneToMany'; 255 } 256 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 257 $UseType = 'Enumeration'; 258 } else $UseType = $Item['Type']; 222 $UseType = $this->GetItemType($Item); 259 223 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 260 224 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); … … 264 228 { 265 229 $Values['Id'] = $Id; 266 $ DbResult = $this->Database->insert($this->Definition['Table'], $Values);230 $this->Database->insert($this->Definition['Table'], $Values); 267 231 } else 268 $DbResult = $this->Database->update($this->Definition['Table'], 'Id='.$Id, $Values); 232 $this->Database->update($this->Definition['Table'], 'Id='.$Id, $Values); 233 } 234 235 function HasAllPostVariables(): bool 236 { 237 $Result = array_key_exists('submit', $_POST); 238 239 foreach ($this->Definition['Items'] as $Index => $Item) 240 { 241 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 242 if ($Item['ReadOnly'] == false) 243 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 244 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 245 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 246 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 247 { 248 $UseType = $this->GetItemType($Item); 249 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnCanLoad', 250 array('Value' => $this->Values[$Index], 'Name' => $Index, 251 'Type' => $Item['Type'], 'Values' => $this->Values, 252 'Filter' => $this->Values[$Index]))) 253 { 254 $Result = false; 255 break; 256 } 257 } 258 } 259 260 return $Result; 269 261 } 270 262 … … 290 282 { 291 283 //if (array_key_exists($Context.$Index, $_POST)) 292 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 293 { 294 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 295 $this->FormManager->Type->RegisterType($Item['Type'], '', 296 $this->FormManager->FormTypes[$Item['Type']]); 297 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 298 if ($CustomType == 'Reference') 299 $UseType = 'OneToMany'; 300 else if ($CustomType == 'Enumeration') 301 $UseType = 'Enumeration'; 302 } else $UseType = $Item['Type']; 284 $UseType = $this->GetItemType($Item); 303 285 $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values); 304 286 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; … … 309 291 } else 310 292 { 311 if (isset($Item['Default'])) { 293 if (isset($Item['Default'])) 294 { 312 295 if (isset($Item['Null']) and ($Item['Null'] == true)) 313 296 $Values[$Index] = null; … … 319 302 } 320 303 304 // Check if filled value is in valid form 321 305 function Validate(): bool 322 306 { 323 307 $Valid = true; 324 308 foreach ($this->Definition['Items'] as $Index => $Item) 325 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 326 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 327 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and 328 (!array_key_exists('ReadOnly', $Item) or 329 (array_key_exists('ReadOnly', $Item) and 330 ($Item['ReadOnly'] != true)))) 331 { 309 { 310 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 311 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 312 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and 313 (!array_key_exists('ReadOnly', $Item) or 314 (array_key_exists('ReadOnly', $Item) and 315 ($Item['ReadOnly'] != true)))) 316 { 332 317 //if (array_key_exists($Context.$Index, $_POST)) 333 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 334 { 335 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 336 $this->FormManager->Type->RegisterType($Item['Type'], '', 337 $this->FormManager->FormTypes[$Item['Type']]); 338 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 339 if ($CustomType == 'Reference') 340 $UseType = 'OneToMany'; 341 else if ($CustomType == 'Enumeration') 342 $UseType = 'Enumeration'; 343 } else $UseType = $Item['Type']; 344 318 $UseType = $this->GetItemType($Item); 345 319 $Parameters = array('Value' => $this->Values[$Index]); 346 320 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 347 321 else $Parameters['Null'] = false; 348 322 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 349 $Parameters)) { 350 $this->ValuesValidate[$Index] = true; 351 $Valid = false; 352 } 353 } 323 $Parameters)) 324 { 325 $this->ValuesValidate[$Index] = true; 326 $Valid = false; 327 } 328 } 329 } 354 330 if ($Valid == false) throw new Exception('not validated'); 355 331 return $Valid; 356 332 } 357 333 } 358 359 334 360 335 function MakeLink(string $Target, string $Title): string … … 386 361 return $Result; 387 362 } 388 389 class FormManager390 {391 public array $Classes;392 public array $FormTypes;393 public Database $Database;394 public Type $Type;395 public string $RootURL;396 public bool $ShowRelation;397 398 function __construct(Database $Database)399 {400 $this->Database = &$Database;401 $this->Classes = array();402 $this->FormTypes = array();403 $this->Type = new Type($this);404 $this->ShowRelation = false;405 }406 407 function RegisterClass(string $Name, array $Class): void408 {409 $this->Classes[$Name] = $Class;410 }411 412 function UnregisterClass(string $Name): void413 {414 unset($this->Classes[$Name]);415 }416 417 function RegisterFormType(string $Name, array $Class): void418 {419 $this->FormTypes[$Name] = $Class;420 }421 422 function UnregisterFormType(string $Name): void423 {424 unset($this->FormTypes[$Name]);425 }426 427 function UpdateSQLMeta(): void428 {429 $this->Database->query('DELETE FROM ModelField');430 $this->Database->query('DELETE FROM Model');431 $this->Database->query('DELETE FROM DataType WHERE Parent IS NOT NULL');432 $this->Database->query('DELETE FROM DataType');433 434 foreach ($this->Type->TypeDefinitionList as $Name => $Type)435 {436 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"');437 if ($DbResult->num_rows == 0)438 {439 $this->Database->insert('DataType', array('Name' => $Name,440 'Title' => $Type['Class']));441 } else442 {443 $DbRow = $DbResult->fetch_assoc();444 $this->Database->update('DataType', 'Id='.$DbRow['Id'], array('Name' => $Name,445 'Title' => $Type['Class']));446 }447 }448 449 foreach ($this->Classes as $Class)450 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))451 {452 if (!$this->Database->TableExists($Class['Table'])) continue;453 454 echo($Class['Table'].'<br/>');455 $Module = 1;456 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"');457 if ($DbResult->num_rows == 0)458 {459 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module));460 $Model = $this->Database->insert_id;461 } else462 {463 $DbRow = $DbResult->fetch_assoc();464 $Model = $DbRow['Id'];465 $this->Database->update('Model', 'Id='.$DbRow['Id'], array('Name' => $Class['Table'],466 'Title' => $Class['Title'], 'Module' => $Module));467 }468 469 foreach ($Class['Items'] as $Name => $Field)470 {471 echo($Name.', ');472 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"');473 if ($DbResult->num_rows > 0)474 {475 $DbRow = $DbResult->fetch_assoc();476 $Type = $DbRow['Id'];477 } else {478 $Type = $this->FormTypes[$Field['Type']];479 480 // Search parent type481 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"');482 if ($DbResult->num_rows > 0)483 {484 $DbRow = $DbResult->fetch_assoc();485 $ParentType = $DbRow['Id'];486 } else $ParentType = null;487 488 $this->Database->insert('DataType', array('Name' => $Field['Type'],489 'Title' => '', 'Parent' => $ParentType));490 $Type = $this->Database->insert_id;491 }492 493 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')');494 if ($DbResult->num_rows == 0)495 {496 $this->Database->insert('ModelField', array('Name' => $Name,497 'Title' => $Field['Caption'], 'Model' => $Model, 'Type' => $Type));498 } else499 {500 $DbRow = $DbResult->fetch_assoc();501 $this->Database->update('ModelField', 'Id='.$DbRow['Id'], array('Name' => $Name,502 'Title' => $Field['Caption'], 'Model' => $Model, 'Type' => $Type));503 }504 }505 echo('<br/>');506 }507 }508 } -
trunk/Common/Form/Types/Base.php
r887 r922 28 28 { 29 29 return ''; 30 } 31 32 function OnCanLoad(array $Item): bool 33 { 34 return array_key_exists($Item['Name'], $_POST); 30 35 } 31 36 32 37 function OnLoadDb(array $Item): ?string 33 38 { -
trunk/Common/Form/Types/Boolean.php
r887 r922 28 28 else return 0; 29 29 } 30 31 function OnCanLoad(array $Item): bool 32 { 33 return true; 34 } 30 35 } -
trunk/Common/Form/Types/Date.php
r887 r922 82 82 } 83 83 84 function OnCanLoad(array $Item): bool 85 { 86 return array_key_exists($Item['Name'].'-null', $_POST) or (array_key_exists($Item['Name'].'-day', $_POST) and 87 array_key_exists($Item['Name'].'-month', $_POST) and array_key_exists($Item['Name'].'-year', $_POST)); 88 } 89 84 90 function OnLoadDb(array $Item): ?string 85 91 { -
trunk/Common/Form/Types/DateTime.php
r887 r922 108 108 } 109 109 110 function OnCanLoad(array $Item): bool 111 { 112 return array_key_exists($Item['Name'].'-null', $_POST) or (array_key_exists($Item['Name'].'-day', $_POST) and 113 array_key_exists($Item['Name'].'-month', $_POST) and array_key_exists($Item['Name'].'-year', $_POST) and 114 array_key_exists($Item['Name'].'-hour', $_POST) and array_key_exists($Item['Name'].'-minute', $_POST) and 115 array_key_exists($Item['Name'].'-second', $_POST) 116 ); 117 } 118 110 119 function OnLoadDb(array $Item): ?string 111 120 { -
trunk/Common/Form/Types/GPS.php
r908 r922 47 47 } 48 48 49 function OnCanLoad(array $Item): bool 50 { 51 return array_key_exists($Item['Name'].'-lat-deg', $_POST) and array_key_exists($Item['Name'].'-lat-sec', $_POST) and 52 array_key_exists($Item['Name'].'-lat-min', $_POST) and array_key_exists($Item['Name'].'-lon-deg', $_POST) and 53 array_key_exists($Item['Name'].'-lon-min', $_POST) and array_key_exists($Item['Name'].'-lon-sec', $_POST); 54 } 55 56 49 57 function Explode(float $Float): array 50 58 { -
trunk/Common/Form/Types/Time.php
r887 r922 80 80 } 81 81 82 function OnCanLoad(array $Item): bool 83 { 84 return array_key_exists($Item['Name'].'-null', $_POST) or (array_key_exists($Item['Name'].'-hour', $_POST) and 85 array_key_exists($Item['Name'].'-minute', $_POST) and array_key_exists($Item['Name'].'-second', $_POST) 86 ); 87 } 88 82 89 function OnLoadDb(array $Item): ?string 83 90 { -
trunk/Modules/IS/IS.php
r920 r922 163 163 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 164 164 return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění'); 165 if (array_key_exists('o', $_GET)) 166 { 167 if ($_GET['o'] == 'save') 168 { 169 if (!array_key_exists('submit', $_POST)) 170 return $this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.'); 171 $Form = new Form($this->System->FormManager); 172 $Form->SetClass($Table); 173 $Form->LoadValuesFromForm(); 174 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 175 try 176 { 177 $Form->Validate(); 178 if (array_key_exists('BeforeModify', $Form->Definition)) 179 { 180 $Class = $Form->Definition['BeforeModify'][0]; 181 $Method = $Form->Definition['BeforeModify'][1]; 182 $Form->Values = $Class->$Method($Form, $Id); 183 } 184 $this->LogChange($Form, 'Edit', $Id, $Id); 185 $Form->SaveValuesToDatabase($Id); 186 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 187 $Output .= $this->ShowView($Table, $Id); 188 if (array_key_exists('AfterModify', $Form->Definition)) 189 { 190 $Class = $Form->Definition['AfterModify'][0]; 191 $Method = $Form->Definition['AfterModify'][1]; 192 $Form->Values = $Class->$Method($Form, $Id); 193 } 194 } catch (Exception $E) 195 { 196 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 197 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save'; 198 $Output .= $Form->ShowEditForm(); 199 $Output .= '<ul class="ActionMenu">'; 200 $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id, 201 $this->System->Link('/images/view.png')); 202 $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&t='.$Table.'&i='.$Id, 203 $this->System->Link('/images/clone.png')); 204 $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table, 205 $this->System->Link('/images/list.png')); 206 $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id, 207 $this->System->Link('/images/delete.png'), 'Opravdu smazat položku'); 208 $Output .= '</ul>'; 209 } 165 $Form = new Form($this->System->FormManager); 166 $Form->SetClass($Table); 167 if ($Form->HasAllPostVariables()) 168 { 169 $Form->LoadValuesFromForm(); 170 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 171 try 172 { 173 $Form->Validate(); 174 if (array_key_exists('BeforeModify', $Form->Definition)) 175 { 176 $Class = $Form->Definition['BeforeModify'][0]; 177 $Method = $Form->Definition['BeforeModify'][1]; 178 $Form->Values = $Class->$Method($Form, $Id); 179 } 180 $this->LogChange($Form, 'Edit', $Id, $Id); 181 $Form->SaveValuesToDatabase($Id); 182 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 183 $Output .= $this->ShowView($Table, $Id); 184 if (array_key_exists('AfterModify', $Form->Definition)) 185 { 186 $Class = $Form->Definition['AfterModify'][0]; 187 $Method = $Form->Definition['AfterModify'][1]; 188 $Form->Values = $Class->$Method($Form, $Id); 189 } 190 } catch (Exception $E) 191 { 192 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 193 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i']; 194 $Output .= $Form->ShowEditForm(); 195 $Output .= '<ul class="ActionMenu">'; 196 $Output .= '<li>'.$this->ShowAction('Prohlížet', '?a=view&t='.$Table.'&i='.$Id, 197 $this->System->Link('/images/view.png')); 198 $Output .= '<li>'.$this->ShowAction('Duplikovat', '?a=clone&t='.$Table.'&i='.$Id, 199 $this->System->Link('/images/clone.png')); 200 $Output .= '<li>'.$this->ShowAction('Seznam', '?a=list&t='.$Table, 201 $this->System->Link('/images/list.png')); 202 $Output .= '<li>'.$this->ShowAction('Odstranit', '?a=delete&t='.$Table.'&i='.$Id, 203 $this->System->Link('/images/delete.png'), 'Opravdu smazat položku'); 204 $Output .= '</ul>'; 210 205 } 211 206 } else 212 207 { 213 $Form = new Form($this->System->FormManager);214 $Form->SetClass($Table);215 208 $Form->LoadValuesFromDatabase($Id); 216 209 $this->Title .= ' - '.$Form->Definition['Title'].' úprava'; 217 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'] .'&o=save';210 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i']; 218 211 $Output .= $Form->ShowEditForm(); 219 212 $Output .= '<ul class="ActionMenu">'; … … 238 231 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 239 232 return 'Nemáte oprávnění'; 240 if (array_key_exists('o', $_GET)) 241 { 242 if ($_GET['o'] == 'save') 243 { 244 $Form = new Form($this->System->FormManager); 245 $Form->SetClass($Table); 246 $Form->LoadValuesFromForm(); 247 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 248 try 249 { 250 $Form->Validate(); 251 if (array_key_exists('BeforeInsert', $Form->Definition)) 252 { 253 $Class = $Form->Definition['BeforeInsert'][0]; 254 $Method = $Form->Definition['BeforeInsert'][1]; 255 $Form->Values = $Class->$Method($Form); 256 } 257 $Form->Validate(); 258 $Form->SaveValuesToDatabase(0); 259 $Id = $this->Database->insert_id; 260 $this->LogChange($Form, 'Clone', $Id, 0); 261 $Output .= $this->SystemMessage('Duplikování položky', 'Nová kopie položky vytvořena'); 262 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 263 if (array_key_exists('AfterInsert', $Form->Definition)) 264 { 265 $Class = $Form->Definition['AfterInsert'][0]; 266 $Method = $Form->Definition['AfterInsert'][1]; 267 $Form->Values = $Class->$Method($Form, $Id); 268 } 269 270 //$this->Database->update($Table, 'Id='.$Id, 271 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 272 // 'TimeCreate' => 'NOW()')); 273 } catch (Exception $E) 274 { 275 $Output .= $this->SystemMessage('Duplikování položky', 'Položku se nepodařilo duplikovat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 276 $Form->OnSubmit = '?a=clone&t='.$Table.'&o=save'; 277 $Output .= $Form->ShowEditForm(); 278 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 279 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 280 } 281 } 282 } else 233 $Form = new Form($this->System->FormManager); 234 $Form->SetClass($Table); 235 if ($Form->HasAllPostVariables()) 283 236 { 284 237 $Form = new Form($this->System->FormManager); 285 238 $Form->SetClass($Table); 239 $Form->LoadValuesFromForm(); 240 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 241 try 242 { 243 $Form->Validate(); 244 if (array_key_exists('BeforeInsert', $Form->Definition)) 245 { 246 $Class = $Form->Definition['BeforeInsert'][0]; 247 $Method = $Form->Definition['BeforeInsert'][1]; 248 $Form->Values = $Class->$Method($Form); 249 } 250 $Form->Validate(); 251 $Form->SaveValuesToDatabase(0); 252 $Id = $this->Database->insert_id; 253 $this->LogChange($Form, 'Clone', $Id, 0); 254 $Output .= $this->SystemMessage('Duplikování položky', 'Nová kopie položky vytvořena'); 255 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 256 if (array_key_exists('AfterInsert', $Form->Definition)) 257 { 258 $Class = $Form->Definition['AfterInsert'][0]; 259 $Method = $Form->Definition['AfterInsert'][1]; 260 $Form->Values = $Class->$Method($Form, $Id); 261 } 262 263 //$this->Database->update($Table, 'Id='.$Id, 264 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 265 // 'TimeCreate' => 'NOW()')); 266 } catch (Exception $E) 267 { 268 $Output .= $this->SystemMessage('Duplikování položky', 'Položku se nepodařilo duplikovat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 269 $Form->OnSubmit = '?a=clone&t='.$Table; 270 $Output .= $Form->ShowEditForm(); 271 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 272 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 273 } 274 } else 275 { 286 276 $Form->LoadValuesFromDatabase($Id); 287 277 $this->Title .= ' - '.$Form->Definition['Title'].' duplikování'; 288 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table .'&o=save';278 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table; 289 279 $Output .= $Form->ShowEditForm(); 290 280 $Actions[] = $this->ShowAction('Seznam', '?a=list&t='.$Table, … … 347 337 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 348 338 return 'Nemáte oprávnění'; 349 if (array_key_exists('o', $_GET)) 350 { 351 if ($_GET['o'] == 'save') 352 { 353 $Form = new Form($this->System->FormManager); 354 $Form->SetClass($Table); 355 $Form->LoadValuesFromForm(); 356 $this->Title .= ' - '.$Form->Definition['Title'].' přidání'; 357 try 358 { 359 $Form->Validate(); 360 if (array_key_exists('BeforeInsert', $Form->Definition)) 361 { 362 $Class = $Form->Definition['BeforeInsert'][0]; 363 $Method = $Form->Definition['BeforeInsert'][1]; 364 $Form->Values = $Class->$Method($Form); 365 } 366 $Form->Validate(); 367 $Form->SaveValuesToDatabase(0); 368 $Id = $this->Database->insert_id; 369 $this->LogChange($Form, 'Add', $Id, 0); 370 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 371 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 372 if (array_key_exists('AfterInsert', $Form->Definition)) 373 { 374 $Class = $Form->Definition['AfterInsert'][0]; 375 $Method = $Form->Definition['AfterInsert'][1]; 376 $Form->Values = $Class->$Method($Form, $Id); 377 } 378 // Add action to update caller form 379 if ($_GET['a'] == 'addsub') 380 { 381 $Type = $this->System->FormManager->FormTypes[$_GET['rt']]; 382 $DbResult = $this->Database->select($Table, '('.$Type['Name'].') AS Name', 'Id='.$Id); 383 $DbRow = $DbResult->fetch_assoc(); 384 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 385 $_GET['r'].'"); set_return ('.$Id.',"'. 386 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 387 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; 388 } 389 390 //$this->Database->update($Table, 'Id='.$Id, 391 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 392 // 'TimeCreate' => 'NOW()')); 393 } catch (Exception $E) 394 { 395 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 396 $Form->OnSubmit = '?a=add&t='.$Table.'&o=save'; 397 $Output .= $Form->ShowEditForm(); 398 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 399 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 400 } 339 $Form = new Form($this->System->FormManager); 340 $Form->SetClass($Table); 341 if ($Form->HasAllPostVariables()) 342 { 343 $Form->LoadValuesFromForm(); 344 $this->Title .= ' - '.$Form->Definition['Title'].' přidání'; 345 try 346 { 347 $Form->Validate(); 348 if (array_key_exists('BeforeInsert', $Form->Definition)) 349 { 350 $Class = $Form->Definition['BeforeInsert'][0]; 351 $Method = $Form->Definition['BeforeInsert'][1]; 352 $Form->Values = $Class->$Method($Form); 353 } 354 $Form->Validate(); 355 $Form->SaveValuesToDatabase(0); 356 $Id = $this->Database->insert_id; 357 $this->LogChange($Form, 'Add', $Id, 0); 358 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 359 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub'); 360 if (array_key_exists('AfterInsert', $Form->Definition)) 361 { 362 $Class = $Form->Definition['AfterInsert'][0]; 363 $Method = $Form->Definition['AfterInsert'][1]; 364 $Form->Values = $Class->$Method($Form, $Id); 365 } 366 // Add action to update caller form 367 if ($_GET['a'] == 'addsub') 368 { 369 $Type = $this->System->FormManager->FormTypes[$_GET['rt']]; 370 $DbResult = $this->Database->select($Table, '('.$Type['Name'].') AS Name', 'Id='.$Id); 371 $DbRow = $DbResult->fetch_assoc(); 372 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 373 $_GET['r'].'"); set_return ('.$Id.',"'. 374 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 375 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; 376 } 377 378 //$this->Database->update($Table, 'Id='.$Id, 379 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 380 // 'TimeCreate' => 'NOW()')); 381 } catch (Exception $E) 382 { 383 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 384 $Form->OnSubmit = '?a=add&t='.$Table; 385 $Output .= $Form->ShowEditForm(); 386 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 387 $this->System->Link('/images/list.png').'"/>Seznam</a>'; 401 388 } 402 389 } else … … 417 404 if (array_key_exists('r', $_GET)) $URL = '&r='.$_GET['r'].'&rt='.$_GET['rt']; 418 405 else $URL = ''; 419 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table. '&o=save'.$URL;406 $Form->OnSubmit = '?a='.$_GET['a'].'&t='.$Table.$URL; 420 407 $Output .= $Form->ShowEditForm(); 421 408 $Actions[] = $this->ShowAction('Seznam', '?a=list&t='.$Table, -
trunk/Modules/User/UserModel.php
r916 r922 418 418 $Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br />". 419 419 "Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.", 'text/html'); 420 print_r($Mail);421 420 $Mail->Send(); 422 421 -
trunk/Modules/User/UserPage.php
r912 r922 180 180 $Form = new Form($this->System->FormManager); 181 181 $Form->SetClass('PasswordRecovery'); 182 $Form->OnSubmit = '?Action=PasswordRecovery2';183 $Output .= $Form->ShowEditForm();184 } else185 if ($Action == 'PasswordRecovery2')186 {187 $Form = new Form($this->System->FormManager);188 $Form->SetClass('PasswordRecovery');189 $Form->LoadValuesFromForm();190 $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);191 $Output .= $this->SystemMessage('Obnova hesla', $Result);192 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)193 {182 if ($Form->HasAllPostVariables()) 183 { 184 $Form->LoadValuesFromForm(); 185 $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 186 $Output .= $this->SystemMessage('Obnova hesla', $Result); 187 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) 188 { 189 $Output .= $Form->ShowEditForm(); 190 } 191 } else 192 { 193 $Form->OnSubmit = '?Action=PasswordRecovery'; 194 194 $Output .= $Form->ShowEditForm(); 195 195 }
Note:
See TracChangeset
for help on using the changeset viewer.