4 use Friendica\Core\Addon;
5 use Friendica\Core\System;
6 use Friendica\Database\DBM;
8 require_once("include/text.php");
10 function manage_post(App $a) {
17 $orig_record = $a->user;
19 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
20 $r = q("select * from user where uid = %d limit 1",
21 intval($_SESSION['submanage'])
23 if (DBM::is_result($r)) {
24 $uid = intval($r[0]['uid']);
29 $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
35 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
43 if (DBM::is_result($submanage)) {
44 foreach ($submanage as $m) {
45 if ($identity == $m['mid']) {
46 $limited_id = $m['mid'];
53 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
57 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
59 dbesc($orig_record['email']),
60 dbesc($orig_record['password'])
64 if (! DBM::is_result($r)) {
68 unset($_SESSION['authenticated']);
69 unset($_SESSION['uid']);
70 unset($_SESSION['visitor_id']);
71 unset($_SESSION['administrator']);
72 unset($_SESSION['cid']);
73 unset($_SESSION['theme']);
74 unset($_SESSION['mobile-theme']);
75 unset($_SESSION['page_flags']);
76 unset($_SESSION['return_url']);
77 if (x($_SESSION, 'submanage')) {
78 unset($_SESSION['submanage']);
80 if (x($_SESSION, 'sysmsg')) {
81 unset($_SESSION['sysmsg']);
83 if (x($_SESSION, 'sysmsg_info')) {
84 unset($_SESSION['sysmsg_info']);
87 require_once('include/security.php');
88 authenticate_success($r[0], true, true);
91 $_SESSION['submanage'] = $original_id;
95 Addon::callHooks('home_init',$ret);
97 goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
103 function manage_content(App $a) {
105 if (! local_user()) {
106 notice( t('Permission denied.') . EOL);
110 if ($_GET['identity']) {
111 $_POST['identity'] = $_GET['identity'];
116 $identities = $a->identities;
118 //getting additinal information for each identity
119 foreach ($identities as $key=>$id) {
120 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
124 $identities[$key]['thumb'] = $thumb[0]['thumb'];
126 $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
130 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
131 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
133 if (DBM::is_result($r)) {
134 $notifications = sizeof($r);
137 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
140 if (DBM::is_result($r)) {
141 $notifications = $notifications + sizeof($r);
144 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
147 if (DBM::is_result($r)) {
148 $notifications = $notifications + $r[0]["introductions"];
151 $identities[$key]['notifications'] = $notifications;
154 $o = replace_macros(get_markup_template('manage.tpl'), [
155 '$title' => t('Manage Identities and/or Pages'),
156 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
157 '$choose' => t('Select an identity to manage: '),
158 '$identities' => $identities,
159 '$submit' => t('Submit'),