Annotation of loncom/interface/loncommunicate.pm, revision 1.48

1.1       www         1: # The LearningOnline Network
                      2: # Communicate
                      3: #
1.48    ! raeburn     4: # $Id: loncommunicate.pm,v 1.47 2012/04/18 19:56:59 raeburn Exp $
1.7       albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.20      www        28: ###
                     29: 
1.1       www        30: package Apache::loncommunicate;
                     31: 
                     32: use strict;
                     33: use Apache::Constants qw(:common);
1.31      albertel   34: use Apache::lonmsgdisplay();
1.11      www        35: use Apache::loncommon;
1.16      www        36: use Apache::lonlocal;
1.28      albertel   37: use Apache::lonnet;
1.1       www        38: 
1.21      www        39: sub menu {
                     40:     my $r=shift;
1.42      diwert     41:     my $crstype = 'course';
                     42:     my $usertype = 'student';
1.34      raeburn    43:     if (defined($env{'course.'.$env{'request.course.id'}.'.type'})) {
                     44:         $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
1.46      raeburn    45:         if ($crstype eq 'Community') {
1.42      diwert     46:             $usertype = 'member';
1.34      raeburn    47:         }   
                     48:     }
1.48    ! raeburn    49: 
        !            50:     my $clientip = &Apache::lonnet::get_requestor_ip($r);
        !            51:     my %setters;
        !            52:     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
        !            53:         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);
        !            54:     if ($by_ip) {
        !            55:         my $showdom = &Apache::lonnet::domain($blockdom);
        !            56:         if ($showdom eq '') {
        !            57:             $showdom = $blockdom;
        !            58:         }
        !            59:         $r->print('<p class="LC_warning">'.
        !            60:                   &mt('Sending of LON-CAPA messages is blocked for your current IP address: [_1].',$clientip).'</p>'.
        !            61:                   '<ul><li>'.&mt('Note: communication is being blocked for certain IP address(es).').
        !            62:                   '</li><li>'.
        !            63:                   &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.',$showdom).
        !            64:                   '</li></ul><br />');
        !            65:     }
1.42      diwert     66: 
1.20      www        67: # ------------------------------------------------------------------------ Menu
1.38      albertel   68:     my ($can_srm,$can_dcm,$can_dff);
1.35      raeburn    69:     if ($env{'request.course.id'}) {
                     70:         if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'})) ||
                     71:             (&Apache::lonnet::allowed('srm',$env{'request.course.id'}.'/'.
                     72:                                            $env{'request.course.sec'}))) {
                     73:             $can_srm = 1;
                     74:         }
                     75:         if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
                     76:             (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'.
                     77:                                            $env{'request.course.sec'}))) {
                     78:             $can_dcm = 1;
                     79:         }
1.38      albertel   80:         if ((&Apache::lonnet::allowed('dff',$env{'request.course.id'})) ||
                     81:             (&Apache::lonnet::allowed('dff',$env{'request.course.id'}.'/'.
                     82:                                            $env{'request.course.sec'}))) {
                     83:             $can_dff = 1;
                     84:         }
1.48    ! raeburn    85:     }
1.42      diwert     86: 
1.48    ! raeburn    87:     my @reports;
        !            88:     unless ($by_ip) {
        !            89:         @reports = (
        !            90:             {categorytitle => 'Send Messages',
        !            91:              items => [
1.42      diwert     92:             {url => '/adm/email?compose=individual',
                     93: 			 permission => 'F',
1.45      bisitz     94: 			 icon => 'mail-message-new.png',
1.42      diwert     95:              linktext => 'New Message',
                     96:              linktitle => 'Send a message to users.'},
                     97:        
                     98:             {url => '/adm/email?compose=group',
                     99: 			 permission => "$can_srm",
                    100:              icon => 'mail-reply-all.png',
                    101:              linktext => 'New Broadcast Message',
                    102: 			 help => 'Course_Broadcast_Message',
                    103:              linktitle => "Send a broadcast message to members of this $crstype and/or other users."},
                    104: 			 
                    105: 			{url => '/adm/email?compose=upload',
                    106: 			 permission => "$can_srm",
                    107:              icon => 'fromfile.png',
1.44      diwert    108:              linktext => 'New Messages from File',
                    109: 			 linktitle => 'Create a message from file and send to users.'},
1.48    ! raeburn   110:              ]},
        !           111:         );
        !           112:     }
1.42      diwert    113: 		
1.48    ! raeburn   114:     if ($can_dff || $can_dcm ){
        !           115:         push(@reports,{categorytitle => 'Message Administration',
        !           116:              items => [
1.42      diwert    117:             {url => '/adm/email?recordftf=query',
                    118: 			 permission => "$can_dff",
                    119:              icon => 'messalog.png',
                    120:              linktext => 'Message Log for Selected Users',
                    121: 			 help => 'Course_Face_To_Face_Records,Course_Critical_Message',
                    122:              linktitle => "User notes, records of face-to-face discussions, critical messages, broadcast messages and archived messages in $crstype."},
                    123:                     
1.47      raeburn   124:             {url => '/adm/setblock?caller=email',
1.42      diwert    125: 			 permission => "$can_dcm",
                    126:              icon => 'comblock.png',
                    127: 			 linktext => 'Communication Blocking',
                    128:              linktitle => "Blocking of $usertype communication during exams."},
1.48    ! raeburn   129:              ]});
        !           130:     }
        !           131:     if (@reports) {
        !           132:         $r->print(&Apache::lonhtmlcommon::generate_menu(@reports));
        !           133:     }
        !           134:     return;
1.21      www       135: }
                    136: 
                    137: sub handler {
                    138:     my $r = shift;
                    139:     &Apache::loncommon::content_type($r,'text/html');
                    140:     $r->send_http_header;
                    141:     return OK if $r->header_only;
                    142: #
                    143: # Start document
                    144: #
                    145: 
                    146: # ----------------------------------------------------------------- Breadcrumbs
                    147:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                    148:     &Apache::lonhtmlcommon::add_breadcrumb
                    149:         ({href=>"/adm/communicate",
                    150:           text=>"Communication/Messages",
                    151:           faq=>12,bug=>'Communication Tools',});
                    152: 
                    153: # ---------------------------------------------------------------------- Header
1.31      albertel  154:     &Apache::lonmsgdisplay::header($r);
1.21      www       155:     &menu($r);
1.40      raeburn   156:     &Apache::lonmsgdisplay::disall($r);
1.30      albertel  157:     $r->print(&Apache::loncommon::end_page());
1.1       www       158:     return OK;
1.2       www       159: }
1.1       www       160: 
                    161: 1;
                    162: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>