@@ -6,14 +6,14 @@ discard block |
||
| 6 | 6 | class ext extends \phpbb\extension\base |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function enable_step($old_state) |
|
| 10 | - { |
|
| 11 | - global $phpbb_root_path; |
|
| 12 | - |
|
| 13 | - switch ($old_state) { |
|
| 14 | - case '': |
|
| 15 | - $db = new \florinp\messenger\libs\database(); |
|
| 16 | - $db->exec(" |
|
| 9 | + public function enable_step($old_state) |
|
| 10 | + { |
|
| 11 | + global $phpbb_root_path; |
|
| 12 | + |
|
| 13 | + switch ($old_state) { |
|
| 14 | + case '': |
|
| 15 | + $db = new \florinp\messenger\libs\database(); |
|
| 16 | + $db->exec(" |
|
| 17 | 17 | CREATE TABLE IF NOT EXISTS messages ( |
| 18 | 18 | `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 19 | 19 | `sender_id` INTEGER NOT NULL, |
@@ -33,87 +33,87 @@ discard block |
||
| 33 | 33 | ); |
| 34 | 34 | "); |
| 35 | 35 | |
| 36 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 37 | - if (!is_dir($messengerDir)) { |
|
| 38 | - mkdir($messengerDir, 0777); |
|
| 39 | - $filesDir = $messengerDir . '/files'; |
|
| 40 | - if (!is_dir($filesDir)) { |
|
| 41 | - mkdir($filesDir, 0777); |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - return 'notifications'; |
|
| 45 | - break; |
|
| 46 | - |
|
| 47 | - case 'notifications': |
|
| 48 | - $phpbb_notifications = $this->container->get('notification_manager'); |
|
| 49 | - $phpbb_notifications->enable_notifications('florinp.messenger.notification.type.friend_request'); |
|
| 50 | - return 'step2'; |
|
| 51 | - break; |
|
| 52 | - |
|
| 53 | - default: |
|
| 54 | - return parent::enable_step($old_state); |
|
| 55 | - break; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function disable_step($old_state) |
|
| 61 | - { |
|
| 62 | - switch ($old_state) { |
|
| 63 | - case '': |
|
| 64 | - $phpbb_notifications = $this->container->get('notification_manager'); |
|
| 65 | - $phpbb_notifications->disable_notifications('florinp.messenger.notification.type.friend_request'); |
|
| 66 | - return 'notifications'; |
|
| 67 | - break; |
|
| 68 | - |
|
| 69 | - default: |
|
| 70 | - |
|
| 71 | - return parent::disable_step($old_state); |
|
| 72 | - break; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - public function purge_step($old_state) |
|
| 77 | - { |
|
| 78 | - global $phpbb_root_path; |
|
| 79 | - |
|
| 80 | - $database = $phpbb_root_path . 'store/messenger.db'; |
|
| 81 | - if (is_file($database)) { |
|
| 82 | - unlink($database); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 86 | - if (is_dir($messengerDir)) { |
|
| 87 | - $objects = scandir($messengerDir); |
|
| 88 | - foreach ($objects as $object) { |
|
| 89 | - if ($object != '.' && $object != '..') { |
|
| 90 | - if (filetype($messengerDir . "/" . $object) == "dir") { |
|
| 91 | - $dir = $messengerDir . "/" . $object; |
|
| 92 | - $subObjects = scandir($dir); |
|
| 93 | - if(count($subObjects) > 0) { |
|
| 94 | - foreach($subObjects as $subObject) { |
|
| 95 | - if($subObject != '.' && $subObject != '..') { |
|
| 96 | - if(filetype($dir . '/' . $subObject) != 'dir') { |
|
| 97 | - unlink($dir . '/' . $subObject); |
|
| 98 | - } |
|
| 99 | - } else { |
|
| 100 | - continue; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - } |
|
| 105 | - rmdir($messengerDir . "/" . $object); |
|
| 106 | - } else { |
|
| 107 | - unlink($messengerDir . "/" . $object); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - reset($objects); |
|
| 112 | - rmdir($messengerDir); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return parent::purge_step($old_state); |
|
| 116 | - |
|
| 117 | - } |
|
| 36 | + $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 37 | + if (!is_dir($messengerDir)) { |
|
| 38 | + mkdir($messengerDir, 0777); |
|
| 39 | + $filesDir = $messengerDir . '/files'; |
|
| 40 | + if (!is_dir($filesDir)) { |
|
| 41 | + mkdir($filesDir, 0777); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + return 'notifications'; |
|
| 45 | + break; |
|
| 46 | + |
|
| 47 | + case 'notifications': |
|
| 48 | + $phpbb_notifications = $this->container->get('notification_manager'); |
|
| 49 | + $phpbb_notifications->enable_notifications('florinp.messenger.notification.type.friend_request'); |
|
| 50 | + return 'step2'; |
|
| 51 | + break; |
|
| 52 | + |
|
| 53 | + default: |
|
| 54 | + return parent::enable_step($old_state); |
|
| 55 | + break; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function disable_step($old_state) |
|
| 61 | + { |
|
| 62 | + switch ($old_state) { |
|
| 63 | + case '': |
|
| 64 | + $phpbb_notifications = $this->container->get('notification_manager'); |
|
| 65 | + $phpbb_notifications->disable_notifications('florinp.messenger.notification.type.friend_request'); |
|
| 66 | + return 'notifications'; |
|
| 67 | + break; |
|
| 68 | + |
|
| 69 | + default: |
|
| 70 | + |
|
| 71 | + return parent::disable_step($old_state); |
|
| 72 | + break; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + public function purge_step($old_state) |
|
| 77 | + { |
|
| 78 | + global $phpbb_root_path; |
|
| 79 | + |
|
| 80 | + $database = $phpbb_root_path . 'store/messenger.db'; |
|
| 81 | + if (is_file($database)) { |
|
| 82 | + unlink($database); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 86 | + if (is_dir($messengerDir)) { |
|
| 87 | + $objects = scandir($messengerDir); |
|
| 88 | + foreach ($objects as $object) { |
|
| 89 | + if ($object != '.' && $object != '..') { |
|
| 90 | + if (filetype($messengerDir . "/" . $object) == "dir") { |
|
| 91 | + $dir = $messengerDir . "/" . $object; |
|
| 92 | + $subObjects = scandir($dir); |
|
| 93 | + if(count($subObjects) > 0) { |
|
| 94 | + foreach($subObjects as $subObject) { |
|
| 95 | + if($subObject != '.' && $subObject != '..') { |
|
| 96 | + if(filetype($dir . '/' . $subObject) != 'dir') { |
|
| 97 | + unlink($dir . '/' . $subObject); |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + continue; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + } |
|
| 105 | + rmdir($messengerDir . "/" . $object); |
|
| 106 | + } else { |
|
| 107 | + unlink($messengerDir . "/" . $object); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + reset($objects); |
|
| 112 | + rmdir($messengerDir); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return parent::purge_step($old_state); |
|
| 116 | + |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | ); |
| 34 | 34 | "); |
| 35 | 35 | |
| 36 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 36 | + $messengerDir = $phpbb_root_path.'store/messenger'; |
|
| 37 | 37 | if (!is_dir($messengerDir)) { |
| 38 | 38 | mkdir($messengerDir, 0777); |
| 39 | - $filesDir = $messengerDir . '/files'; |
|
| 39 | + $filesDir = $messengerDir.'/files'; |
|
| 40 | 40 | if (!is_dir($filesDir)) { |
| 41 | 41 | mkdir($filesDir, 0777); |
| 42 | 42 | } |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | global $phpbb_root_path; |
| 79 | 79 | |
| 80 | - $database = $phpbb_root_path . 'store/messenger.db'; |
|
| 80 | + $database = $phpbb_root_path.'store/messenger.db'; |
|
| 81 | 81 | if (is_file($database)) { |
| 82 | 82 | unlink($database); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
| 85 | + $messengerDir = $phpbb_root_path.'store/messenger'; |
|
| 86 | 86 | if (is_dir($messengerDir)) { |
| 87 | 87 | $objects = scandir($messengerDir); |
| 88 | 88 | foreach ($objects as $object) { |
| 89 | 89 | if ($object != '.' && $object != '..') { |
| 90 | - if (filetype($messengerDir . "/" . $object) == "dir") { |
|
| 91 | - $dir = $messengerDir . "/" . $object; |
|
| 90 | + if (filetype($messengerDir."/".$object) == "dir") { |
|
| 91 | + $dir = $messengerDir."/".$object; |
|
| 92 | 92 | $subObjects = scandir($dir); |
| 93 | - if(count($subObjects) > 0) { |
|
| 94 | - foreach($subObjects as $subObject) { |
|
| 95 | - if($subObject != '.' && $subObject != '..') { |
|
| 96 | - if(filetype($dir . '/' . $subObject) != 'dir') { |
|
| 97 | - unlink($dir . '/' . $subObject); |
|
| 93 | + if (count($subObjects) > 0) { |
|
| 94 | + foreach ($subObjects as $subObject) { |
|
| 95 | + if ($subObject != '.' && $subObject != '..') { |
|
| 96 | + if (filetype($dir.'/'.$subObject) != 'dir') { |
|
| 97 | + unlink($dir.'/'.$subObject); |
|
| 98 | 98 | } |
| 99 | 99 | } else { |
| 100 | 100 | continue; |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | - rmdir($messengerDir . "/" . $object); |
|
| 105 | + rmdir($messengerDir."/".$object); |
|
| 106 | 106 | } else { |
| 107 | - unlink($messengerDir . "/" . $object); |
|
| 107 | + unlink($messengerDir."/".$object); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |