4 use Friendica\Core\System;
6 require_once("include/text.php");
8 function manage_post(App $a) {
15 $orig_record = $a->user;
17 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
18 $r = q("select * from user where uid = %d limit 1",
19 intval($_SESSION['submanage'])
21 if (dbm::is_result($r)) {
22 $uid = intval($r[0]['uid']);
27 $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
33 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
41 if (dbm::is_result($submanage)) {
42 foreach ($submanage as $m) {
43 if ($identity == $m['mid']) {
44 $limited_id = $m['mid'];
51 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
55 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
57 dbesc($orig_record['email']),
58 dbesc($orig_record['password'])
62 if (! dbm::is_result($r)) {
66 unset($_SESSION['authenticated']);
67 unset($_SESSION['uid']);
68 unset($_SESSION['visitor_id']);
69 unset($_SESSION['administrator']);
70 unset($_SESSION['cid']);
71 unset($_SESSION['theme']);
72 unset($_SESSION['mobile-theme']);
73 unset($_SESSION['page_flags']);
74 unset($_SESSION['return_url']);
75 if (x($_SESSION, 'submanage')) {
76 unset($_SESSION['submanage']);
78 if (x($_SESSION, 'sysmsg')) {
79 unset($_SESSION['sysmsg']);
81 if (x($_SESSION, 'sysmsg_info')) {
82 unset($_SESSION['sysmsg_info']);
85 require_once('include/security.php');
86 authenticate_success($r[0], true, true);
89 $_SESSION['submanage'] = $original_id;
93 call_hooks('home_init',$ret);
95 goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
101 function manage_content(App $a) {
103 if (! local_user()) {
104 notice( t('Permission denied.') . EOL);
108 if ($_GET['identity']) {
109 $_POST['identity'] = $_GET['identity'];
114 $identities = $a->identities;
116 //getting additinal information for each identity
117 foreach ($identities as $key=>$id) {
118 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
122 $identities[$key]['thumb'] = $thumb[0]['thumb'];
124 $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
128 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
129 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
131 if (dbm::is_result($r)) {
132 $notifications = sizeof($r);
135 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
138 if (dbm::is_result($r)) {
139 $notifications = $notifications + sizeof($r);
142 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
145 if (dbm::is_result($r)) {
146 $notifications = $notifications + $r[0]["introductions"];
149 $identities[$key]['notifications'] = $notifications;
152 $o = replace_macros(get_markup_template('manage.tpl'), array(
153 '$title' => t('Manage Identities and/or Pages'),
154 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
155 '$choose' => t('Select an identity to manage: '),
156 '$identities' => $identities,
157 '$submit' => t('Submit'),