5 require_once("include/text.php");
7 function manage_post(App $a) {
14 $orig_record = $a->user;
16 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
17 $r = q("select * from user where uid = %d limit 1",
18 intval($_SESSION['submanage'])
20 if (dbm::is_result($r)) {
21 $uid = intval($r[0]['uid']);
26 $r = q("SELECT * FROM `manage` WHERE `uid` = %d",
32 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
40 if (dbm::is_result($submanage)) {
41 foreach ($submanage as $m) {
42 if ($identity == $m['mid']) {
43 $limited_id = $m['mid'];
50 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
54 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
56 dbesc($orig_record['email']),
57 dbesc($orig_record['password'])
61 if (! dbm::is_result($r)) {
65 unset($_SESSION['authenticated']);
66 unset($_SESSION['uid']);
67 unset($_SESSION['visitor_id']);
68 unset($_SESSION['administrator']);
69 unset($_SESSION['cid']);
70 unset($_SESSION['theme']);
71 unset($_SESSION['mobile-theme']);
72 unset($_SESSION['page_flags']);
73 unset($_SESSION['return_url']);
74 if (x($_SESSION, 'submanage')) {
75 unset($_SESSION['submanage']);
77 if (x($_SESSION, 'sysmsg')) {
78 unset($_SESSION['sysmsg']);
80 if (x($_SESSION, 'sysmsg_info')) {
81 unset($_SESSION['sysmsg_info']);
84 require_once('include/security.php');
85 authenticate_success($r[0], true, true);
88 $_SESSION['submanage'] = $original_id;
92 call_hooks('home_init',$ret);
94 goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
100 function manage_content(App $a) {
102 if (! local_user()) {
103 notice( t('Permission denied.') . EOL);
107 if ($_GET['identity']) {
108 $_POST['identity'] = $_GET['identity'];
113 $identities = $a->identities;
115 //getting additinal information for each identity
116 foreach ($identities as $key=>$id) {
117 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
121 $identities[$key]['thumb'] = $thumb[0]['thumb'];
123 $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
127 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
128 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
130 if (dbm::is_result($r)) {
131 $notifications = sizeof($r);
134 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
137 if (dbm::is_result($r)) {
138 $notifications = $notifications + sizeof($r);
141 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
144 if (dbm::is_result($r)) {
145 $notifications = $notifications + $r[0]["introductions"];
148 $identities[$key]['notifications'] = $notifications;
151 $o = replace_macros(get_markup_template('manage.tpl'), array(
152 '$title' => t('Manage Identities and/or Pages'),
153 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
154 '$choose' => t('Select an identity to manage: '),
155 '$identities' => $identities,
156 '$submit' => t('Submit'),