]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
provide disclosure warning on private network page
[friendica.git] / mod / network.php
index 1b5ea5d651d8ffd326ccf2f7565f65258010ad94..3e6c5dc4a5821148f84260aed9488d40e25ea3e3 100644 (file)
@@ -15,18 +15,20 @@ function network_init(&$a) {
        $a->page['aside'] .= '<div id="network-new-link">';
 
        if(($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new'))
-               $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '">' . t('Normal View') . '</a>';
+               $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?cid=' . $_GET['cid'] : '') . '">' . t('Normal View') . '</a>';
        else 
-               $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . $a->cmd . '/new' . '">' . t('New Item View') . '</a>';
+               $a->page['aside'] .= '<a href="' . $a->get_baseurl() . '/' . $a->cmd . '/new' . ((x($_GET,'cid')) ? '/?cid=' . $_GET['cid'] : '') . '">' . t('New Item View') . '</a>';
 
        $a->page['aside'] .= '</div>';
 
-       $a->page['aside'] .= group_side('network','network');
+       $a->page['aside'] .= group_side('network','network',true);
 }
 
 
 function network_content(&$a, $update = 0) {
 
+       require_once('include/conversation.php');
+
        if(! local_user())
        return login(false);
 
@@ -39,6 +41,8 @@ function network_content(&$a, $update = 0) {
        $nouveau = false;
        require_once('include/acl_selectors.php');
 
+       $cid = ((x($_GET['cid'])) ? intval($_GET['cid']) : 0);
+
        if(($a->argc > 2) && $a->argv[2] === 'new')
                $nouveau = true;
 
@@ -47,10 +51,13 @@ function network_content(&$a, $update = 0) {
                        $nouveau = true;
                else {
                        $group = intval($a->argv[1]);
-                       $group_acl = array('allow_gid' => '<' . $group . '>');
+                       $def_acl = array('allow_gid' => '<' . $group . '>');
                }
        }
 
+       if($cid)
+               $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
+
        if(! $update) {
                if(group) {
                        if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
@@ -92,6 +99,30 @@ function network_content(&$a, $update = 0) {
 
                $jotplugins = '';
                $jotnets = '';
+
+               $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
+
+               $mail_enabled = false;
+               $pubmail_enabled = false;
+
+               if(! $mail_disabled) {
+                       $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
+                               intval(local_user())
+                       );
+                       if(count($r)) {
+                               $mail_enabled = true;
+                               if(intval($r[0]['pubmail']))
+                                       $pubmail_enabled = true;
+                       }
+               }
+
+               if($mail_enabled) {
+              $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
+                       $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+               . t("Post to Email") . '</div>';
+               }
+
+
                call_hooks('jot_tool', $jotplugins);
                call_hooks('jot_networks', $jotnets);
 
@@ -120,8 +151,8 @@ function network_content(&$a, $update = 0) {
                        '$jotnets' => $jotnets,
                        '$emtitle' => t('Example: bob@example.com, mary@example.com'),
                        '$lockstate' => $lockstate,
-                       '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb),
-                       '$bang' => (($group) ? '!' : ''),
+                       '$acl' => populate_acl((($group || $cid) ? $def_acl : $a->user), $celeb),
+                       '$bang' => (($group || $cid) ? '!' : ''),
                        '$profile_uid' => local_user()
                ));
 
@@ -134,6 +165,7 @@ function network_content(&$a, $update = 0) {
                        $o .= '<div id="live-network"></div>' . "\r\n";
                        $o .= "<script> var profile_uid = " . $_SESSION['uid'] 
                                . "; var netargs = '" . substr($a->cmd,8) 
+                               . ((x($_GET,'cid')) ? '/?cid=' . $_GET['cid'] : '')
                                . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
 
        }
@@ -163,7 +195,7 @@ function network_content(&$a, $update = 0) {
                                killme();
                        notice( t('No such group') . EOL );
                        goaway($a->get_baseurl() . '/network');
-                       return; // NOTREACHED
+                       // NOTREACHED
                }
 
                $contacts = expand_groups(array($group));
@@ -178,8 +210,28 @@ function network_content(&$a, $update = 0) {
                $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `contact-id` IN ( $contact_str )) ";
                $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
        }
+       elseif($cid) {
 
-       if((! $group) && (! $update))
+               $r = q("SELECT `id`,`name`,`network`,`writable` FROM `contact` WHERE `id` = %d 
+                               AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
+                       intval($cid)
+               );
+               if(count($r)) {
+                       $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `contact-id` IN ( " . intval($cid) . " )) ";
+                       $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
+                       if($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
+                               notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
+                       }
+
+               }
+               else {
+                       notice( t('Invalid contact.') . EOL);
+                       goaway($a->get_baseurl() . '/network');
+                       // NOTREACHED
+               }
+       }
+
+       if((! $group) && (! $cid) && (! $update))
                $o .= get_birthdays();
 
 
@@ -267,8 +319,6 @@ function network_content(&$a, $update = 0) {
 
        $mode = (($nouveau) ? 'network-new' : 'network');
 
-       require_once('include/conversation.php');
-
        $o .= conversation($a,$r,$mode,$update);
 
        if(! $update) {