3 require_once("include/text.php");
6 function manage_post(&$a) {
12 $orig_record = $a->user;
14 if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
15 $r = q("select * from user where uid = %d limit 1",
16 intval($_SESSION['submanage'])
18 if (dbm::is_result($r)) {
19 $uid = intval($r[0]['uid']);
24 $r = q("select * from manage where uid = %d",
30 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
37 if(count($submanage)) {
38 foreach($submanage as $m) {
39 if($identity == $m['mid']) {
40 $limited_id = $m['mid'];
47 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
52 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
54 dbesc($orig_record['email']),
55 dbesc($orig_record['password'])
59 if (! dbm::is_result($r)) {
63 unset($_SESSION['authenticated']);
64 unset($_SESSION['uid']);
65 unset($_SESSION['visitor_id']);
66 unset($_SESSION['administrator']);
67 unset($_SESSION['cid']);
68 unset($_SESSION['theme']);
69 unset($_SESSION['mobile-theme']);
70 unset($_SESSION['page_flags']);
71 unset($_SESSION['return_url']);
72 if(x($_SESSION,'submanage'))
73 unset($_SESSION['submanage']);
74 if(x($_SESSION,'sysmsg'))
75 unset($_SESSION['sysmsg']);
76 if(x($_SESSION,'sysmsg_info'))
77 unset($_SESSION['sysmsg_info']);
79 require_once('include/security.php');
80 authenticate_success($r[0],true,true);
83 $_SESSION['submanage'] = $original_id;
86 call_hooks('home_init',$ret);
88 goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
94 function manage_content(&$a) {
97 notice( t('Permission denied.') . EOL);
101 if ($_GET['identity']) {
102 $_POST['identity'] = $_GET['identity'];
107 $identities = $a->identities;
109 //getting additinal information for each identity
110 foreach ($identities as $key=>$id) {
111 $thumb = q("SELECT `thumb` FROM `contact` WHERE `uid` = '%s' AND `self` = 1",
115 $identities[$key][thumb] = $thumb[0][thumb];
117 $identities[$key]['selected'] = (($id['nickname'] === $a->user['nickname']) ? true : false);
121 $r = q("SELECT DISTINCT(`parent`) FROM `notify` WHERE `uid` = %d AND NOT `seen` AND NOT (`type` IN (%d, %d))",
122 intval($id['uid']), intval(NOTIFY_INTRO), intval(NOTIFY_MAIL));
124 $notifications = sizeof($r);
126 $r = q("SELECT DISTINCT(`convid`) FROM `mail` WHERE `uid` = %d AND NOT `seen`",
129 $notifications = $notifications + sizeof($r);
131 $r = q("SELECT COUNT(*) AS `introductions` FROM `intro` WHERE NOT `blocked` AND NOT `ignore` AND `uid` = %d",
134 $notifications = $notifications + $r[0]["introductions"];
136 $identities[$key]['notifications'] = $notifications;
139 $o = replace_macros(get_markup_template('manage.tpl'), array(
140 '$title' => t('Manage Identities and/or Pages'),
141 '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
142 '$choose' => t('Select an identity to manage: '),
143 '$identities' => $identities,
144 '$submit' => t('Submit'),