6 use Friendica\Core\Addon;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Database\DBM;
11 require_once "include/text.php";
13 function manage_post(App $a) {
20 $orig_record = $a->user;
22 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
23 $r = q("select * from user where uid = %d limit 1",
24 intval($_SESSION['submanage'])
26 if (DBM::is_result($r)) {
27 $uid = intval($r[0]['uid']);
32 $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
38 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
46 if (DBM::is_result($submanage)) {
47 foreach ($submanage as $m) {
48 if ($identity == $m['mid']) {
49 $limited_id = $m['mid'];
56 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
60 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
62 dbesc($orig_record['email']),
63 dbesc($orig_record['password'])
67 if (! DBM::is_result($r)) {
71 unset($_SESSION['authenticated']);
72 unset($_SESSION['uid']);
73 unset($_SESSION['visitor_id']);
74 unset($_SESSION['administrator']);
75 unset($_SESSION['cid']);
76 unset($_SESSION['theme']);
77 unset($_SESSION['mobile-theme']);
78 unset($_SESSION['page_flags']);
79 unset($_SESSION['return_url']);
80 if (x($_SESSION, 'submanage')) {
81 unset($_SESSION['submanage']);
83 if (x($_SESSION, 'sysmsg')) {
84 unset($_SESSION['sysmsg']);
86 if (x($_SESSION, 'sysmsg_info')) {
87 unset($_SESSION['sysmsg_info']);
90 require_once('include/security.php');
91 authenticate_success($r[0], true, true);
94 $_SESSION['submanage'] = $original_id;
98 Addon::callHooks('home_init',$ret);
100 goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
106 function manage_content(App $a) {
108 if (! local_user()) {
109 notice(L10n::t('Permission denied.') . EOL);
113 if ($_GET['identity']) {
114 $_POST['identity'] = $_GET['identity'];
119 $identities = $a->identities;
121 //getting additinal information for each identity
122 foreach ($identities as $key=>$id) {
123 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
127 $identities[$key]['thumb'] = $thumb[0]['thumb'];
129 $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
133 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
134 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
136 if (DBM::is_result($r)) {
137 $notifications = sizeof($r);
140 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
143 if (DBM::is_result($r)) {
144 $notifications = $notifications + sizeof($r);
147 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
150 if (DBM::is_result($r)) {
151 $notifications = $notifications + $r[0]["introductions"];
154 $identities[$key]['notifications'] = $notifications;
157 $o = replace_macros(get_markup_template('manage.tpl'), [
158 '$title' => L10n::t('Manage Identities and/or Pages'),
159 '$desc' => L10n::t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
160 '$choose' => L10n::t('Select an identity to manage: '),
161 '$identities' => $identities,
162 '$submit' => L10n::t('Submit'),