3 require_once("include/text.php");
6 function manage_post(App &$a) {
13 $orig_record = $a->user;
15 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
16 $r = q("select * from user where uid = %d limit 1",
17 intval($_SESSION['submanage'])
19 if (dbm::is_result($r)) {
20 $uid = intval($r[0]['uid']);
25 $r = q("select * from manage where uid = %d",
31 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
38 if(count($submanage)) {
39 foreach($submanage as $m) {
40 if($identity == $m['mid']) {
41 $limited_id = $m['mid'];
48 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
53 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
55 dbesc($orig_record['email']),
56 dbesc($orig_record['password'])
60 if (! dbm::is_result($r)) {
64 unset($_SESSION['authenticated']);
65 unset($_SESSION['uid']);
66 unset($_SESSION['visitor_id']);
67 unset($_SESSION['administrator']);
68 unset($_SESSION['cid']);
69 unset($_SESSION['theme']);
70 unset($_SESSION['mobile-theme']);
71 unset($_SESSION['page_flags']);
72 unset($_SESSION['return_url']);
73 if(x($_SESSION,'submanage'))
74 unset($_SESSION['submanage']);
75 if(x($_SESSION,'sysmsg'))
76 unset($_SESSION['sysmsg']);
77 if(x($_SESSION,'sysmsg_info'))
78 unset($_SESSION['sysmsg_info']);
80 require_once('include/security.php');
81 authenticate_success($r[0],true,true);
84 $_SESSION['submanage'] = $original_id;
87 call_hooks('home_init',$ret);
89 goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
95 function manage_content(App &$a) {
98 notice( t('Permission denied.') . EOL);
102 if ($_GET['identity']) {
103 $_POST['identity'] = $_GET['identity'];
108 $identities = $a->identities;
110 //getting additinal information for each identity
111 foreach ($identities as $key=>$id) {
112 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
116 $identities[$key][thumb] = $thumb[0][thumb];
118 $identities[$key]['selected'] = (($id['nickname'] === $a->user['nickname']) ? true : false);
122 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
123 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
125 $notifications = sizeof($r);
127 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
130 $notifications = $notifications + sizeof($r);
132 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
135 $notifications = $notifications + $r[0]["introductions"];
137 $identities[$key]['notifications'] = $notifications;
140 $o = replace_macros(get_markup_template('manage.tpl'), array(
141 '$title' => t('Manage Identities and/or Pages'),
142 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
143 '$choose' => t('Select an identity to manage: '),
144 '$identities' => $identities,
145 '$submit' => t('Submit'),