1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Request; |
|
|
|
|
20
|
|
|
use XoopsModules\Suico\{ |
21
|
|
|
FriendrequestHandler, |
22
|
|
|
FriendshipHandler |
23
|
|
|
}; |
24
|
|
|
|
25
|
|
|
require __DIR__ . '/header.php'; |
26
|
|
|
/** |
27
|
|
|
* Factory of friendrequests created |
28
|
|
|
*/ |
29
|
|
|
$friendrequestFactory = new FriendrequestHandler($xoopsDB); |
30
|
|
|
$friendshipFactory = new FriendshipHandler($xoopsDB); |
31
|
|
|
/** |
32
|
|
|
* Getting the uid of the user which user want to canel friend request |
33
|
|
|
*/ |
34
|
|
|
$friendrequestto_uid = Request::getInt( |
35
|
|
|
'friendrequestto_uid', |
36
|
|
|
0, |
37
|
|
|
'POST' |
38
|
|
|
); |
39
|
|
|
$friendrequester_uid = (int)$xoopsUser->getVar('uid'); |
40
|
|
|
$criteria_friend1 = new Criteria('friendrequestto_uid', $friendrequestto_uid); |
41
|
|
|
$criteria_friend2 = new Criteria('friendrequester_uid', $friendrequester_uid); |
42
|
|
|
$criteria_delete1 = new CriteriaCompo($criteria_friend1); |
43
|
|
|
$criteria_delete1->add($criteria_friend2); |
44
|
|
|
$friendrequestFactory->deleteAll($criteria_delete1); |
45
|
|
|
$criteria_friend1 = new Criteria('friendrequestto_uid', $friendrequester_uid); |
46
|
|
|
$criteria_friend2 = new Criteria('friendrequester_uid', $friendrequestto_uid); |
47
|
|
|
$criteria_delete1 = new CriteriaCompo($criteria_friend1); |
48
|
|
|
$criteria_delete1->add($criteria_friend2); |
49
|
|
|
$friendrequestFactory->deleteAll($criteria_delete1); |
50
|
|
|
redirect_header('index.php?uid=' . $friendrequestto_uid . '', 3, _MD_SUICO_FRIENDREQUEST_CANCELLED); |
51
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
52
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: