Ticket #29: mysms.html.php

File mysms.html.php, 37.1 KB (added by axel, 3 years ago)

Fixed missing translation, send by spidermank@…

Line 
1<?php
2/**
3 *
4 * $Id:$
5 *
6* @author Axel Sauerhᅵfer <axel@willcodejoomlaforfood.de>
7* @copyright Copyright &copy; 2007, Axel Sauerhᅵfer
8* @version 0.8
9* @package MySMS
10*
11* All rights reserved.  MySMS Component for Joomla!
12*
13* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
14* MySMS! is free software. This version may have been modified pursuant
15* to the GNU General Public License, and as distributed it includes or
16* is derivative of works licensed under the GNU General Public License or
17* other free or open source software licenses.
18*
19* This program is distributed in the hope that it will be useful,
20* but WITHOUT ANY WARRANTY; without even the implied warranty of
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22*
23**/
24
25/**
26 * restrict direct access
27 * and start session
28*/
29defined( '_VALID_MOS' ) or die( 'Restricted access' );
30
31
32/**
33*  mySmsFrontendHtml is the html frontend class for com_mysms
34*
35* @package MySMS
36* @subpackage Frontend
37**/
38class mySmsFrontendHtml
39{
40
41/**
42*  This function returns the java script code for the frontend
43*  adlen +1 because \n
44*
45**/
46  function JS()
47  {
48?>
49  <script type="text/javascript">
50  function SMSCharCount(adlen){
51    var maxlen = 160 - (adlen+1);
52
53    var cc = document.getElementById('sms_charcounter');
54    var sb = document.getElementById('sms_body');
55    var len = sb.value.length;
56    var text = sb.value;
57
58    if( len <= maxlen ){
59      var nLen = maxlen - len;
60      cc.value = nLen;
61    }else{
62         alert( maxlen + ' Zeichen ᅵberschritten');
63         sb.value = text.substring(0,maxlen);
64         return;
65    }
66  }
67
68  function checkInput(adlen){
69     var maxlen = 160 - (adlen+1);
70     var body = document.getElementById('sms_body');
71
72     if( body.value.length > maxlen ){
73       alert('Maximal' + maxlen + 'Zeichen');
74       return false;
75     }
76
77     var sender = document.getElementById('sms_send');
78
79     if( sender.value.length <= 0 ){
80       alert('Bitte Absender eintragen');
81       return false;
82     }
83
84     var recv = document.getElementById('sms_recv');
85
86     if( recv.value.length <= 0 ){
87       alert('Bitte Empfᅵnger eintragen');
88       return false;
89     }
90
91
92     return true;
93  }
94
95  function getReceiverField(){
96    return document.getElementById('sms_recv');
97  }
98
99  function getPhoneBookField(){
100     return document.getElementById('phonebookentry');
101  }
102
103  function resetGroupBox(){
104    //get groupBox
105     var groupBox = document.getElementById('usergroups');
106
107     //check groupbox
108     if( groupBox ){
109         //loop over all elements, reset selected flag
110         for( var y=0; y<=groupBox.length; y++){
111            var element = groupBox[y];
112            if(element){
113              element.selected=0;
114            }
115         }
116     }
117  }
118
119  function resetPhoneBook(){
120    var phoneBook =  getPhoneBookField();
121    if( phoneBook ){
122        for( var i=0; i<phoneBook.length; i++){
123             var element = phoneBook[i];
124             if( element ){
125                 element.selected = 0;
126             }
127        }
128    }
129  }
130
131  function addReceiver(number){
132    if( number ){
133        var recv = getReceiverField();
134        recv.value += number;
135        recv.value += ';';
136    }
137  }
138
139  function resetReceiver(){
140    var recv =  getReceiverField();
141    recv.value = '';
142  }
143
144
145
146  function updateRecv()
147  {
148   //single send mode
149   //var si = document.getElementById('phonebookentry').selectedIndex;
150   //var num = document.getElementById('phonebookentry').options[si].value;
151   //document.getElementById('sms_recv').value = num;
152
153   //reset group box and recv field
154   resetGroupBox();
155   resetReceiver();
156
157   //get phonebook and recv field
158   var phoneBook = getPhoneBookField();
159
160   //check all items in phonebook if selected, if true add number to recv field
161   for( var i=0; i<phoneBook.length; i++){
162       var element = phoneBook[i];
163       if( element ){
164           if( element.selected ){
165               addReceiver( element.value );
166            }
167       }
168   }
169  }
170
171  function updateGroupRecv(){
172
173    //first reset our phonebook
174    resetPhoneBook();
175    resetReceiver();
176
177    var selectedIndex = document.getElementById('usergroups').selectedIndex;
178    var groupid = document.getElementById('usergroups').options[selectedIndex].value;
179
180    //group_1 = 1;3;24; semicolon seperated list
181    var dummy = "group_"+groupid;
182    var numbers =  document.getElementById(dummy).value.split(";");
183
184    var recv = document.getElementById('sms_recv');
185
186   //reset recv
187   recv.value='';
188
189    for(var i=0; i<numbers.length; i++){
190      dummy = "pb_"+numbers[i];
191      if( document.getElementById(dummy) ){
192        //get our pb entry pb_1 = 0049.... and append to recv field
193        var number = document.getElementById(dummy);
194        recv.value += number.value;
195        recv.value += ';';
196
197        //get phonebook and check if a number in phonebook is equal our current number, it true
198        //mark selected in phonebook
199         var phoneBook =  getPhoneBookField();
200         for( var x=0; x<phoneBook.length; x++){
201           var element = phoneBook[x];
202           if( element.value == number.value ){
203              element.selected = 1;
204           }
205         }//for
206
207      }//if
208    }
209  }//function
210
211
212</script>
213
214<?php
215}  //end function JS
216
217/**
218* This function shows an error panel with variable messages
219*
220*  @param string msg
221**/
222 function showSMSSendErrorMessage( &$msg )
223 {
224  ?>
225    <div class="componentheading">
226            <?php echo _MYSMS_ERROR; ?>:
227    </div>
228
229    <table border="0" width="100%">
230           <tr>
231               <td align="center" valign="top">
232                   <p>
233                      <b>
234                            <?php echo $msg; ?>
235                      </b>
236                   </p>
237               </td>
238           </tr>
239    </table>
240  <?php
241}  //end function    showSMSSendErrorMessage
242
243
244
245/**
246* This function shows the user config panel
247*
248*  @param mosParameters params
249**/
250function showConfigPanel( &$params )
251{
252    $mosParameters  = $params['mosParameters'];
253        $option                 = $params['option'];
254        $Itemid                 = $params['ItemId'];
255?>
256        <br/>
257        <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
258        <?php echo _MYSMS_MY_CONFIG;?>:
259    </div>
260    <br/>
261
262        <!--  configuration form -->
263    <form action="index.php" method="post">
264    <input type="hidden" name="option" value="<?php echo $option; ?>" />
265    <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
266    <input type="hidden" name="task" value="configuration" />
267    <input type="hidden" name="boxchecked" value="0" />
268    <input type="hidden" name="hidemainmenu" value="0" />
269    <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
270         <tr>
271            <td width="10%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
272            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
273            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
274            <td width="40%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
275          </tr>
276
277          <tr>
278              <td >       </td>
279
280          <td align="center" valign="top">
281              <img align="center" src="./administrator/images/config.png" border="0" alt=" <?php echo _MYSMS_MY_CONFIG;?>">
282          </td>
283
284          <td align="left" valign="center">
285            <b> <?php echo _MYSMS_MY_CONFIG;?></b>
286            </td>
287
288            <td align="center" valign="center">
289                <input type="submit" name="config_button" value="<?php echo _MYSMS_EDIT;?>">
290            </td>
291
292          </tr>
293          </table>
294          </form>
295
296        <!-- smsarchiv task -->
297        <form action="index.php" method="post">
298    <input type="hidden" name="option" value="<?php echo $option; ?>" />
299    <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
300    <input type="hidden" name="task" value="smsarchiv" />
301    <input type="hidden" name="boxchecked" value="0" />
302    <input type="hidden" name="hidemainmenu" value="0" />
303    <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
304         <tr>
305            <td width="10%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
306            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
307            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
308            <td width="40%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
309          </tr>
310          <tr>
311          <td></td>
312          <td align="center" valign="top">
313              <img align="center" src="./administrator/images/archive_f2.png" border="0" alt="<?php echo _MYSMS_SMSARCHIVE; ?>">
314          </td>
315
316          <td align="left" valign="center">
317            <b><?php echo _MYSMS_SMSARCHIVE; ?></b>
318            </td>
319
320            <td align="center" valign="center">
321                <input type="submit" name="smsarchiv_button" value="<?php echo _MYSMS_SHOW;?>">
322            </td>
323
324          </tr>
325        </table>
326       </form>
327
328        <!--  phonebook -->
329        <form action="index.php" method="post">
330    <input type="hidden" name="option" value="<?php echo $option; ?>" />
331    <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
332    <input type="hidden" name="task" value="phonebook" />
333    <input type="hidden" name="boxchecked" value="0" />
334    <input type="hidden" name="hidemainmenu" value="0" />
335    <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
336         <tr>
337            <td width="10%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
338            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
339            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
340            <td width="40%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
341          </tr>
342
343           <tr>
344               <td ></td>
345               <td align="center" valign="top">
346                   <img align="center" src="./administrator/images/user.png" border="0" alt="<?php echo _MYSMS_EDIT; ?>">
347               </td>
348               <td align="left" valign="center">
349                   <b><?php echo _MYSMS_MY_PHONEBOOK;?> </b>
350               </td>
351               <td align="center" valign="center">
352                    <input type="submit" name="telefonbuch_button" value="<?php echo _MYSMS_EDIT; ?>">
353               </td>
354          </tr>
355          </table>
356          </form>
357
358<!--  user groups -->
359        <form action="index.php" method="post">
360    <input type="hidden" name="option" value="<?php echo $option; ?>" />
361    <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
362    <input type="hidden" name="task" value="usergroup" />
363    <input type="hidden" name="boxchecked" value="0" />
364    <input type="hidden" name="hidemainmenu" value="0" />
365    <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
366         <tr>
367            <td width="10%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
368            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
369            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
370            <td width="40%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
371          </tr>
372          <tr>
373               <td ></td>
374               <td align="center" valign="top">
375                   <img align="center" src="./administrator/images/addusers.png" border="0" alt="<?php echo _MYSMS_USER_GROUP;?>">
376               </td>
377               <td align="left" valign="center">
378                   <b><?php echo _MYSMS_USER_GROUP;?> </b>
379               </td>
380               <td align="center" valign="center">
381                    <input type="submit" name="gruppen_button" value="<?php echo _MYSMS_EDIT;?>">
382               </td>
383          </tr>
384          </table>
385       </form>
386
387<?php
388}     //end function showConfigPanel
389
390
391/**
392* This function shows the send panel
393*
394*  @param mosParameters params
395*  @param class user
396*  @param string msg
397**/
398function showSendPanel( $smsUser , $params  )
399{
400        $mosParameters  = $params['mosParameters'];
401        $option                 = $params['option'];
402        $Itemid                 = $params['ItemId'];
403        $msg                    = isset( $params['msg'] )?$params['msg']:'';
404        $tok                    = $params['token'];
405
406        $this->JS();
407
408    $phonebook = $smsUser->_phoneBook->getEntries();
409    $config             = new mySmsConfig();
410    $ad = mySmsConfig::Get( 'advertisment' );
411    $adLen = strlen( $ad );
412?>
413    <form action="index.php" method="post" onsubmit="return checkInput();">
414    <input type="hidden" name="option" value="<?php echo $option; ?>" />
415    <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
416    <input type="hidden" name="task" value="sendSMS" />
417    <input type="hidden" name="boxchecked" value="0" />
418    <input type="hidden" name="hidemainmenu" value="0" />
419    <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
420<?php
421     //check if a msg is given, if show it
422     if( strlen( $msg ) > 1 ){
423       echo $msg;
424     }
425?>
426       <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
427            SMS <?php echo _MYSMS_DISPATCH;?>: <?php echo $smsUser->_name; ?> ( <?php echo _MYSMS_BALANCE;?>: <?php echo $smsUser->balance(); ?> )
428       </div>
429
430      <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
431                <tr>
432                <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
433                <td width="45%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
434                <td width="10%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
435                <td  width="30%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
436                </tr>
437        <tr>
438                <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
439                <br/><i>SMS <?php echo _MYSMS_MESSAGE;?></i>
440            </td>
441            <td align="center" valign="top"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
442                <br/><textarea onkeyup="SMSCharCount( <?php echo $adLen; ?> );"  onkeypress="SMSCharCount( <?php echo $adLen; ?> );"; onkeydown="SMSCharCount( <?php echo $adLen; ?> );"  id="sms_body" name="sms_body" rows="10" cols="35" maxlength="160"></textarea>
443            </td>
444            <td align="right" valign="top"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
445               &nbsp;&nbsp;&nbsp;<input onclick="SMSCharCount( <?php echo $adLen; ?> );"  value="<?php echo (160 - $adLen); ?> " size="3" type="text" name="sms_charcounter" id="sms_charcounter" readonly="readonly">
446            </td>
447            <td rowspan="6" valign="top" align="center"  >
448                <b><?php echo _MYSMS_CONTACTS; ?></b>
449                <select multiple onchange="updateRecv();"  id="phonebookentry" name="phonebookentry" size="<?php echo count($phonebook)+2;?>">
450<?php
451                        $hidden = '';
452                        $maxLen = 0;  //maxlen is needed to get the groupbox same length as phonebook (optical reasons)
453                             //create phonebook
454                        foreach($phonebook as $entry){
455
456                                //collect the whole phonebook in hidden values, needed by java script later
457                                $hidden .= "<input type=\"hidden\" name=\"pb_$entry->id\"  id=\"pb_$entry->id\" value=\"$entry->number\">";
458                                $str = "$entry->name ($entry->number)";
459                                        if( strlen($str) > $maxLen){
460                                        $maxLen = strlen($str);
461                                        }
462?>
463                        <option value="<?php echo $entry->number; ?>">
464                <?php echo $str; ?>
465                        </option>
466<?php
467
468                             } //end loop
469?>
470                        </select>
471<?php
472                    //show our hidden phonebook and reset hidden variable
473                echo $hidden;
474                    $hidden = '';
475
476                //get all groups from user
477                $groups = $smsUser->_groups->getEntries();
478?>
479                <br/><br/>
480                <b><?php echo _MYSMS_GROUPNAME ?>:</b><br/>
481                <select onclick="updateGroupRecv()" id="usergroups" name="usergroups" size="<?php echo count($groups)+2;?>" >
482<?php
483                    //check array
484                if( count($groups) > 0 ){
485                    //create hidden group fields, needed by java script later
486                    //data structure is groupid = phonebookuserid;phonebookuserid;phonebookuserid;phonebookuserid
487                //example group_1 = 12;23;1;
488                        foreach($groups as $g){
489                                $lst = '';
490                                foreach($g->_members as $mem ){
491                                        if( !is_object($mem) ){
492                                                continue;
493                                        }
494                            $lst .= $mem->id . ";";
495                                }
496                                $hidden .= "<input type=\"hidden\" name=\"group_$g->_id\" id=\"group_$g->_id\"value=\"$lst\">";
497                        }//end foreach
498
499               //now create our select field option value = groupid
500               //shown is group name
501                        foreach($groups as $g){
502?>
503                        <option value="<?php echo $g->_id; ?>"><?php echo $g->_name;?></option>
504<?php
505                        }//end foreach
506                }//end if
507
508            //append dummy string to get same length as phonebook box
509            $d ='';
510            for($i=0; $i<($maxLen*2); $i++){
511              $d .="&nbsp;";
512            }
513?>
514                <option><?php echo $d;?></option>
515                </select>
516<?php
517                     //show our groupid phonbookuserid mapping
518                echo $hidden;
519?>
520
521            </td>
522          </tr>
523
524          <?php if($adLen > 0){?>
525                    <tr>
526               <td colspan="3"><br/>
527               </td>
528          </tr>
529
530          <tr>
531          <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
532          <?php echo _MYSMS_ADVERTISMENT;?>:
533          </td>
534          <td colspan="3">
535          <textarea name="ad" id="ad" readonly="readonly" rows="1" cols="35"><?php echo  $ad; ?></textarea>
536          </td>
537          </tr>
538                    <tr>
539               <td colspan="3"><br/>
540               </td>
541          </tr>
542          <?php } ?>
543          <tr>
544            <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
545                <i><?php echo _MYSMS_SENDER;?></i>
546            </td>
547            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
548                <input readonly=readonly type="text" id="sms_send" name="sms_send" size="47" value="<?php echo $smsUser->number(); ?>">
549            </td>
550            <td   class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
551            </td>
552
553          </tr>
554
555          <tr>
556               <td colspan="3"><br/>
557               </td>
558          </tr>
559
560          <tr>
561            <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
562                <i><?php echo _MYSMS_RECIPIENT; ?></i>
563            </td>
564            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
565                <input type="text" id="sms_recv" name="sms_recv" size="47">
566            </td>
567            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
568
569            </td>
570          </tr>
571                  <tr>
572               <td colspan="3"><br/>
573               </td>
574          </tr>
575
576          <tr>
577
578              <td>          </td>
579              <td>
580              <input type="submit" name="send_button" value="<?php echo _MYSMS_SEND;?>">
581              </td>
582              <td>
583
584              </td>
585          </tr>
586
587          </table>
588       </form>
589<?php
590}      //end function       showSendPanel
591
592
593/**
594*  This function is for showing the user config panel.
595*
596*  @param mosParameters params
597*  @param array row
598**/
599function showUserConfigPanel($smsUser, $params)
600{
601        $mosParameters  = $params['mosParameters'];
602        $option                 = $params['option'];
603        $Itemid                 = $params['ItemId'];
604
605    $this->JS();
606?>
607       <form action="index.php" method="post" onsubmit="return checkUserInput();">
608       <input type="hidden" name="option" value="<?php echo $option; ?>" />
609       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
610       <input type="hidden" name="task" value="saveConfiguration" />
611       <input type="hidden" name="boxchecked" value="0" />
612       <input type="hidden" name="hidemainmenu" value="0" />
613
614
615 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
616           <?php echo _MYSMS_MY_CONFIG; ?>: <?php echo $smsUser->userName(); ?>
617       </div>
618                 <br/>
619         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
620          <tr>
621            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
622            <td width="45%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
623            <td width="40%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"></td>
624          </tr>
625
626          <tr>
627            <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
628                <i><?php echo _MYSMS_PHONENUMBER;?>:</i>
629            </td>
630            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
631                <input type="text" name="myphonenumber" id="myphonenumber" size="20" value="<?php echo $smsUser->number();?>">
632            </td>
633
634            <td>
635
636            </td>
637          </tr>
638
639          <tr>
640          <td colspan="3">
641          <br/>
642          </td>
643          </tr>
644           <tr>
645            <td align="center" valign="top" class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
646                <i><?php echo _MYSMS_COMMENT;?>:</i>
647            </td>
648            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
649                <input type="text" name="mycomment" id="mycomment" size="20" value="<?php echo $smsUser->comment();?>">
650            </td>
651
652            <td>
653
654            </td>
655          </tr>
656
657          <tr>
658          <td>
659
660          </td>
661            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
662                <input type="submit" name="change_button" value="<?php echo _MYSMS_SAVE;?>">
663                <input type="submit" name="cancel_button" value="<?php echo _MYSMS_CANCEL;?>">
664            </td>
665          </tr>
666
667          </table>
668
669          </form>
670
671<?php
672
673}  //end fucntion showUserConfigPanel
674
675/**
676*  This function is for showing the sms archive
677*
678*
679*  @param mosParameters params
680*  @param array rows
681**/
682function showSendSMS($rows, $params, $user)
683{
684        $mosParameters  = $params['mosParameters'];
685        $option                 = $params['option'];
686        $Itemid                 = $params['ItemId'];
687?>
688     <form action="index.php" method="post">
689       <input type="hidden" name="option" value="<?php echo $option; ?>" />
690       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
691       <input type="hidden" name="task" value="default" />
692       <input type="hidden" name="boxchecked" value="0" />
693       <input type="hidden" name="hidemainmenu" value="0" />
694
695 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
696           <?php echo _MYSMS_SMSARCHIVE;?>: <?php echo $user->userName() ?>
697       </div>
698                 <br/>
699         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
700          <tr>
701            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_DATE;?></b></td>
702            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_RECIPIENT;?></b></td>
703            <td width="60%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_MESSAGE;?></b></td>
704          </tr>
705
706<?php
707        foreach($rows as $sms )
708        {
709?>
710        <tr>
711           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
712           <?php echo $sms->senddate; ?>
713            </td>
714            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
715           <?php echo $sms->to; ?>
716            </td>
717            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
718
719           <?php echo $sms->text; ?>
720
721           &nbsp;&nbsp;&nbsp;
722           <br/>
723           <br/>
724            </td>
725
726        </tr>
727        <tr>
728
729        <td colspan="3" style="border-bottom: 1px solid #cccccc;" >
730
731        </td>
732        </tr>
733
734<?php
735        }
736?>
737          <tr>
738          <td>
739
740          </td>
741            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
742               <br/> <input type="submit" name="back_button" value="<?php echo _MYSMS_BACK;?> ">
743            </td>
744          </tr>
745
746          </table>
747
748          </form>
749<?php
750}
751
752/**
753*  This function is for the phonebook config panel
754*
755*  @param mosParameters params
756*  @param array rows
757**/
758function showPhonebook($rows, $params, $user)
759{
760        $mosParameters  = $params['mosParameters'];
761        $option                 = $params['option'];
762        $Itemid                 = $params['ItemId'];
763        $tok                    = $params['token'];
764
765?>
766       <form action="index.php" method="post">
767       <input type="hidden" name="option" value="<?php echo $option; ?>" />
768       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
769       <input type="hidden" name="task" value="deletePhonebookEntry" />
770       <input type="hidden" name="boxchecked" value="0" />
771       <input type="hidden" name="hidemainmenu" value="0" />
772       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
773
774 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
775           <?php echo _MYSMS_MY_PHONEBOOK;?>: <?php echo $user->userName() ?>
776       </div>
777                 <br/>
778         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
779          <tr>
780            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_NAME; ?></b></td>
781            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_PHONENUMBER; ?></b></td>
782            <td width="60%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b></b></td>
783          </tr>
784
785<?php
786       $ids = '';
787        foreach($rows as $entry )
788        {
789          $ids .= $entry->id .';';
790?>
791        <tr>
792           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
793           <?php echo $entry->name; ?>
794            </td>
795            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
796           <?php echo $entry->number; ?>
797            </td>
798            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
799           <input type="submit" name="delete_button_<?php echo $entry->id; ?>" value="<?php echo _MYSMS_DELETE;?>">
800            </td>
801
802        </tr>
803        <tr>
804
805        <td colspan="3" style="border-bottom: 1px solid #cccccc;" >
806
807        </td>
808        </tr>
809
810<?php
811        }
812?>
813          </table>
814          <input type="hidden" name="ids" value="<?php echo $ids; ?>">
815          </form>
816
817
818          <br/><br/>
819
820
821       <form action="index.php" method="post">
822       <input type="hidden" name="option" value="<?php echo $option; ?>" />
823       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
824       <input type="hidden" name="task" value="addPhonebookEntry" />
825       <input type="hidden" name="boxchecked" value="0" />
826       <input type="hidden" name="hidemainmenu" value="0" />
827       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
828
829 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
830       <?php echo _MYSMS_NEW_ENTRY; ?>:
831       </div>
832                 <br/>
833         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
834
835        <tr>
836           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
837           <?php echo _MYSMS_NAME;?>
838            </td>
839            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
840           <input type="text" name="contactname">
841            </td>
842            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
843
844            </td>
845
846        </tr>
847
848                <tr>
849           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
850           <?php echo _MYSMS_PHONENUMBER; ?>:
851            </td>
852            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
853           <input type="text" name="contactnumber">
854            </td>
855            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
856
857            </td>
858
859        </tr>
860
861
862          <tr>
863          <td>
864
865          </td>
866            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
867
868               <br/> <input type="submit" name="save_button" value="<?php echo _MYSMS_SEND; ?>">&nbsp;&nbsp;<input type="submit" name="back_button" value="<?php echo _MYSMS_BACK; ?>">
869            </td>
870          </tr>
871          </table>
872          </form>
873
874           <form action="index.php" method="post" enctype="multipart/form-data">
875       <input type="hidden" name="option" value="<?php echo $option; ?>" />
876       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
877       <input type="hidden" name="task" value="importPhonebook" />
878       <input type="hidden" name="boxchecked" value="0" />
879       <input type="hidden" name="hidemainmenu" value="0" />
880       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
881
882 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
883       <?php echo _MYSMS_IMPORT_PHONEBOOK; ?>:
884       </div>
885                 <br/>
886         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
887
888        <tr>
889           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
890           <?php echo _MYSMS_NAME;?>
891            </td>
892            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
893                        <input name="phonebook" type="file">
894            </td>
895            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
896            </td>
897        </tr>
898        <tr>
899                <td>
900                </td>
901            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
902               <br/> <input type="submit" name="save_button" value="<?php echo _MYSMS_SEND; ?>">
903            </td>
904          </tr>
905
906          </table>
907
908          </form>
909
910           <form action="index2.php" method="post" enctype="multipart/form-data">
911           <input type="hidden" name="no_html" value="1" />
912       <input type="hidden" name="option" value="<?php echo $option; ?>" />
913       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
914       <input type="hidden" name="task" value="exportPhonebook" />
915       <input type="hidden" name="boxchecked" value="0" />
916       <input type="hidden" name="hidemainmenu" value="0" />
917       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
918
919                <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
920       <?php echo _MYSMS_EXPORT_PHONEBOOK; ?>:
921       </div>
922                 <br/>
923         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
924
925
926        <tr>
927                <td>
928                </td>
929            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
930               <br/> <input type="submit" name="save_button" value="<?php echo _MYSMS_EXPORT;?>">
931            </td>
932          </tr>
933
934          </table>
935
936          </form>
937<?php
938} //end function phonebook
939
940
941/**
942*  This function is for user groups
943*
944*  @param mosParameters params
945*  @param array rows
946**/
947function showUserGroups($phoneBookRows, $groupRows, $params, $user)
948{
949          $mosParameters    = $params['mosParameters'];
950          $option                       = $params['option'];
951          $Itemid                       = $params['ItemId'];
952          $tok                          = $params['token'];
953?>
954       <form action="index.php" method="post">
955       <input type="hidden" name="option" value="<?php echo $option; ?>" />
956       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
957       <input type="hidden" name="task" value="deleteUserGroup" />
958       <input type="hidden" name="boxchecked" value="0" />
959       <input type="hidden" name="hidemainmenu" value="0" />
960       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
961
962 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
963           <?php echo _MYSMS_USER_GROUP;?>: <?php echo $user->userName(); ?>
964       </div>
965                 <br/>
966         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
967          <tr>
968            <td width="25%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_NAME; ?></b></td>
969            <td width="60%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_MEMBERS;?></b></td>
970            <td width="15%" class="sectiontableheader<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>"><b><?php echo _MYSMS_ACTION;?></b></td>
971          </tr>
972
973<?php
974       $ids = '';
975       if( count($groupRows) > 0 ){
976           foreach($groupRows as $entry )
977           {
978
979
980         $ids .= $entry->_id .';';
981?>
982        <tr>
983           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
984           <?php echo $entry->_name; ?>
985            </td>
986            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
987<?php
988            foreach($entry->_members as $key=>$val){
989               echo $val->name . ",";
990            }
991?>
992            </td>
993
994              <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
995           <input type="submit" name="delete_button_<?php echo $entry->_id; ?>" value="<?php echo _MYSMS_DELETE;?>">
996            </td>
997
998        </tr>
999        <tr>
1000
1001        <td colspan="3" style="border-bottom: 1px solid #cccccc;" >
1002
1003        </td>
1004        </tr>
1005
1006<?php
1007        } //foreach
1008        }//if count > 0
1009?>
1010
1011          </table>
1012          <input type="hidden" name="ids" value="<?php echo $ids; ?>">
1013          </form>
1014
1015          <br/><br/>
1016
1017       <form action="index.php" method="post">
1018       <input type="hidden" name="option" value="<?php echo $option; ?>" />
1019       <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
1020       <input type="hidden" name="task" value="addUserGroup" />
1021       <input type="hidden" name="boxchecked" value="0" />
1022       <input type="hidden" name="hidemainmenu" value="0" />
1023       <input type="hidden" name="prtoken" value="<?php echo $tok; ?>" />
1024
1025 <div class="componentheading<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1026      <?php echo _MYSMS_CREATE_NEW_GROUP;?>:
1027       </div>
1028                 <br/>
1029         <table border="0" class="adminform" width="100%" cellpadding="0" cellspacing="0">
1030
1031        <tr>
1032           <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1033           <?php echo _MYSMS_GROUPNAME;?>
1034            </td>
1035            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1036           <input type="text" name="groupname">
1037            </td>
1038            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1039
1040            </td>
1041
1042        </tr>
1043
1044           <tr>
1045           <td valign="top"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1046           <?php echo _MYSMS_MEMBERS;?>
1047            </td>
1048            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1049<?php
1050            //get min and max id for faster searching in dispatcher
1051            $maxID = 0;
1052            $minID = 0;
1053
1054
1055            foreach($phoneBookRows as $pbEntry){
1056             if( $maxID < $pbEntry->id ){
1057               $maxID = $pbEntry->id;
1058             }
1059
1060             if( $minID > $pbEntry->id ){
1061               $minID = $pbEntry->id;
1062             }
1063
1064?>
1065            <input type="checkbox" name="userid_<?php echo $pbEntry->id;?>" value="<?php echo$pbEntry->id;?>"><?php echo $pbEntry->name .'&nbsp;&nbsp;('.$pbEntry->number.').';?><br>
1066<?php
1067            }
1068
1069?>
1070            <input type="hidden" name="maxID" value="<?php echo $maxID;?>">
1071            <input type="hidden" name="minID" value="<?php echo $minID;?>">
1072            </td>
1073            <td  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1074
1075            </td>
1076
1077        </tr>
1078
1079
1080          <tr>
1081          <td>
1082
1083          </td>
1084            <td colspan="2"  class="sectiontableentry<?php echo $mosParameters->get( 'pageclass_sfx' ); ?>">
1085
1086               <br/> <input type="submit" name="save_button" value="<?php echo _MYSMS_SAVE;?>">&nbsp;&nbsp;<input type="submit" name="back_button" value="<?php echo _MYSMS_BACK;?>">
1087            </td>
1088          </tr>
1089
1090          </table>
1091
1092          </form>
1093<?php
1094} //end function phonebook
1095
1096}//end class
1097?>