| Conditions | 7 |
| Paths | 6 |
| Total Lines | 34 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 20 | public function __invoke(array $post) { |
||
| 21 | |||
| 22 | # Declare variables |
||
| 23 | |||
| 24 | $name = ''; |
||
| 25 | |||
| 26 | # Extract post array |
||
| 27 | |||
| 28 | extract($post); |
||
| 29 | |||
| 30 | # Check for demo mode |
||
| 31 | |||
| 32 | if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
||
| 33 | |||
| 34 | # Validate name |
||
| 35 | |||
| 36 | if (false === ($name = Filemanager\Validate::name($name))) return 'FILEMANAGER_ERROR_NAME_INVALID'; |
||
| 37 | |||
| 38 | # Check if item exists |
||
| 39 | |||
| 40 | if ((0 !== strcasecmp($this->entity->name(), $name)) && |
||
| 41 | |||
| 42 | @file_exists($this->entity->parent()->pathFull() . $name)) return 'FILEMANAGER_ERROR_EXISTS'; |
||
| 43 | |||
| 44 | # Rename item |
||
| 45 | |||
| 46 | if (!$this->entity->rename($name)) return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
||
| 47 | |||
| 48 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
||
| 49 | |||
| 50 | # ------------------------ |
||
| 51 | |||
| 52 | return true; |
||
| 53 | } |
||
| 54 | } |
||
| 56 |