4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
7 require_once("include/text.php");
9 function manage_post(App $a) {
16 $orig_record = $a->user;
18 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
19 $r = q("select * from user where uid = %d limit 1",
20 intval($_SESSION['submanage'])
22 if (DBM::is_result($r)) {
23 $uid = intval($r[0]['uid']);
28 $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
34 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
42 if (DBM::is_result($submanage)) {
43 foreach ($submanage as $m) {
44 if ($identity == $m['mid']) {
45 $limited_id = $m['mid'];
52 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
56 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
58 dbesc($orig_record['email']),
59 dbesc($orig_record['password'])
63 if (! DBM::is_result($r)) {
67 unset($_SESSION['authenticated']);
68 unset($_SESSION['uid']);
69 unset($_SESSION['visitor_id']);
70 unset($_SESSION['administrator']);
71 unset($_SESSION['cid']);
72 unset($_SESSION['theme']);
73 unset($_SESSION['mobile-theme']);
74 unset($_SESSION['page_flags']);
75 unset($_SESSION['return_url']);
76 if (x($_SESSION, 'submanage')) {
77 unset($_SESSION['submanage']);
79 if (x($_SESSION, 'sysmsg')) {
80 unset($_SESSION['sysmsg']);
82 if (x($_SESSION, 'sysmsg_info')) {
83 unset($_SESSION['sysmsg_info']);
86 require_once('include/security.php');
87 authenticate_success($r[0], true, true);
90 $_SESSION['submanage'] = $original_id;
94 call_hooks('home_init',$ret);
96 goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
102 function manage_content(App $a) {
104 if (! local_user()) {
105 notice( t('Permission denied.') . EOL);
109 if ($_GET['identity']) {
110 $_POST['identity'] = $_GET['identity'];
115 $identities = $a->identities;
117 //getting additinal information for each identity
118 foreach ($identities as $key=>$id) {
119 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
123 $identities[$key]['thumb'] = $thumb[0]['thumb'];
125 $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
129 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
130 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
132 if (DBM::is_result($r)) {
133 $notifications = sizeof($r);
136 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
139 if (DBM::is_result($r)) {
140 $notifications = $notifications + sizeof($r);
143 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
146 if (DBM::is_result($r)) {
147 $notifications = $notifications + $r[0]["introductions"];
150 $identities[$key]['notifications'] = $notifications;
153 $o = replace_macros(get_markup_template('manage.tpl'), array(
154 '$title' => t('Manage Identities and/or Pages'),
155 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
156 '$choose' => t('Select an identity to manage: '),
157 '$identities' => $identities,
158 '$submit' => t('Submit'),