phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] sms/inc class.uiautoreplay.inc.php


From: Sigurd Nes
Subject: [Phpgroupware-cvs] sms/inc class.uiautoreplay.inc.php
Date: Tue, 30 May 2006 13:26:49 +0000

CVSROOT:        /sources/phpgroupware
Module name:    sms
Branch:         
Changes by:     Sigurd Nes <address@hidden>     06/05/30 13:26:48

Modified files:
        inc            : class.uiautoreplay.inc.php 

Log message:
        

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/sms/inc/class.uiautoreplay.inc.php.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: sms/inc/class.uiautoreplay.inc.php
diff -u sms/inc/class.uiautoreplay.inc.php:1.2 
sms/inc/class.uiautoreplay.inc.php:1.3
--- sms/inc/class.uiautoreplay.inc.php:1.2      Mon May 29 21:21:47 2006
+++ sms/inc/class.uiautoreplay.inc.php  Tue May 30 13:26:48 2006
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package sms
        * @subpackage autoreplay
-       * @version $Id: class.uiautoreplay.inc.php,v 1.2 2006/05/29 21:21:47 
sigurdne Exp $
+       * @version $Id: class.uiautoreplay.inc.php,v 1.3 2006/05/30 13:26:48 
sigurdne Exp $
        */
 
        /**
@@ -22,6 +22,10 @@
                        'index'         => True,
                        'add'           => True,
                        'add_yes'       => True,
+                       'add_scenario'  => True,
+                       'add_scenario_yes'      => True,
+                       'edit_scenario' => True,
+                       'edit_scenario_yes'     => True,
                        'manage'        => True,
                        'delete'        => True,
                        'delete_scenario' => true
@@ -220,7 +224,8 @@
                        
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
                }
 
-               function manage()
+
+               function add_scenario()
                {
                
                        if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
@@ -232,6 +237,312 @@
                        }
                        
                        
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('SMS').' - '.lang('Add SMS autoreply scenario');
+                       $GLOBALS['phpgw']->common->phpgw_header();
+
+                       echo parse_navbar();
+
+                       $err    = urldecode(get_var('err',array('POST','GET')));
+                       $autoreply_id   = 
get_var('autoreply_id',array('POST','GET'));
+                       $add_autoreply_scenario_result  = 
get_var('add_autoreply_scenario_result',array('POST','GET'));
+
+
+                       $sql = "SELECT * FROM phpgw_sms_featautoreply WHERE 
autoreply_id='$autoreply_id'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $autoreply_code = $this->db->f('autoreply_code');
+
+                       if ($err)
+                       {
+                           $content = "<p><font color=red>$err</font><p>";
+                       }
+
+
+                       $add_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uiautoreplay.add_scenario_yes',
+                               'autoreply_id' => $autoreply_id
+                               );
+                               
+                       $add_url = 
$GLOBALS['phpgw']->link('/index.php',$add_data);
+
+
+                       $content .= "
+                           <p>
+                           <p>SMS autoreply code: <b>$autoreply_code</b>
+                           <p>
+                           <form action=$add_url method=post>
+                       ";
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           ${"add_autoreply_scenario_param".$i} = 
strtoupper(get_var("add_autoreply_scenario_param$i",array('POST','GET')));
+                           $content .= "<p>SMS autoreply scenario param $i: 
<input type=text size=20 maxlength=20 name=add_autoreply_scenario_param$i 
value=\"".${"add_autoreply_scenario_param".$i}."\">\n";                      
+                       }
+
+                       $content .= "
+                           <p>SMS autoreply scenario return: <input type=text 
size=60 maxlength=130 name=add_autoreply_scenario_result 
value=\"$add_autoreply_scenario_result\">
+                           <p><input type=submit class=button value=Add>
+                           </form>
+                       ";
+
+                       $done_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uiautoreplay.manage',
+                               'autoreply_id'  => $autoreply_id);
+                               
+                       $done_url = 
$GLOBALS['phpgw']->link('/index.php',$done_data);
+
+                       $content .= "
+                           <p><li>
+                           <a href=\"$done_url\">Back</a>
+                           <p>
+                       ";
+                       echo $content;
+               }
+
+               function add_scenario_yes()
+               {
+               
+                       if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
+                       {
+                               $links = 
$this->menu->links('.config.autoreplay');
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
+                               $this->bocommon->no_access($links);
+                               return;
+                       }
+
+                       $autoreply_id   = 
get_var('autoreply_id',array('POST','GET'));
+                       $add_autoreply_scenario_result  = 
get_var('add_autoreply_scenario_result',array('POST','GET'));
+
+                       $ok = 0;
+                       
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           ${"add_autoreply_scenario_param".$i} = 
strtoupper(get_var("add_autoreply_scenario_param$i",array('POST','GET')));
+                           if(${"add_autoreply_scenario_param".$i})
+                           {
+                               $ok++;
+                           }
+
+                       }
+                       if ($add_autoreply_scenario_result && ($ok > 0))
+                       {
+                           for ($i=1;$i<=7;$i++)
+                           {
+                               $autoreply_scenario_param_list .= 
"autoreply_scenario_param$i,";
+                           }
+                           for ($i=1;$i<=7;$i++)
+                           {
+                               $autoreply_scenario_code_param_entry .= 
"'".${"add_autoreply_scenario_param".$i}."',";
+                           }
+                           $sql = "
+                               INSERT INTO phpgw_sms_featautoreply_scenario 
+                               
(autoreply_id,".$autoreply_scenario_param_list."autoreply_scenario_result) 
VALUES 
('$autoreply_id',$autoreply_scenario_code_param_entry'$add_autoreply_scenario_result')";
+                           
+                               $this->db->transaction_begin();
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $new_uid = 
$this->db->get_last_insert_id(phpgw_sms_featautoreply_scenario,'autoreply_scenario_id');
+                               $this->db->transaction_commit();
+                                       
+                               if ($new_uid)
+                           {
+                                       $error_string = "SMS autoreply scenario 
has been added";
+                           }
+                           else
+                           {
+                               $error_string = "Fail to add SMS autoreply 
scenario";
+                           }
+                       }
+                       else
+                       {
+                           $error_string = "You must fill at least one field 
and the scenario result!";
+                       }
+                       $target = 'add_scenario';
+                       
+                       $add_data = array(
+                               'menuaction'                                    
=> $this->currentapp.'.uiautoreplay.' . $target,
+                               'autoreply_id'                                  
=> $autoreply_id,
+                               'err'                                           
        => urlencode($error_string),
+                               'add_autoreply_scenario_result' => 
$add_autoreply_scenario_result
+                               );
+
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           $add_data["add_autoreply_scenario_param".$i] = 
strtoupper(get_var("add_autoreply_scenario_param$i",array('POST')));
+                       }
+
+                       
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
+               }
+
+
+               function edit_scenario()
+               {
+               
+                       if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
+                       {
+                               $links = 
$this->menu->links('.config.autoreplay');
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
+                               $this->bocommon->no_access($links);
+                               return;
+                       }
+                       
+                       
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('SMS').' - '.lang('Edit SMS autoreply scenario');
+                       $GLOBALS['phpgw']->common->phpgw_header();
+
+                       echo parse_navbar();
+
+                       $err    = urldecode(get_var('err',array('POST','GET')));
+                       $autoreply_id   = 
get_var('autoreply_id',array('POST','GET'));
+                       $autoreply_scenario_id  = 
get_var('autoreply_scenario_id',array('POST','GET'));
+                       $add_autoreply_scenario_result  = 
get_var('add_autoreply_scenario_result',array('POST','GET'));
+
+                       $sql = "SELECT * FROM phpgw_sms_featautoreply WHERE 
autoreply_id='$autoreply_id'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $autoreply_code = $this->db->f('autoreply_code');
+
+                       if ($err)
+                       {
+                           $content = "<p><font color=red>$err</font><p>";
+                       }
+
+
+                       $edit_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uiautoreplay.edit_scenario_yes',
+                               'autoreply_id' => $autoreply_id,
+                               'autoreply_scenario_id' => 
$autoreply_scenario_id
+                               );
+                               
+                       $edit_url = 
$GLOBALS['phpgw']->link('/index.php',$edit_data);
+
+
+                       $content .= "
+                           <p>
+                           <p>SMS autoreply code: <b>$autoreply_code</b>
+                           <p>
+                           <form action=$edit_url method=post>
+                       ";
+                       $sql = "SELECT * FROM phpgw_sms_featautoreply_scenario 
WHERE autoreply_id='$autoreply_id' AND 
autoreply_scenario_id='$autoreply_scenario_id'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           ${"edit_autoreply_scenario_param".$i} =  
$this->db->f("autoreply_scenario_param$i");
+                       }
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           $content .= "<p>SMS autoreply scenario param $i: 
<input type=text size=20 maxlength=20 name=edit_autoreply_scenario_param$i 
value=\"".${"edit_autoreply_scenario_param".$i}."\">\n";
+                       }
+                       $edit_autoreply_scenario_result = 
$this->db->f('autoreply_scenario_result');
+                       $content .= "
+                           <p>SMS autoreply scenario result: <input type=text 
size=60 maxlength=130 name=edit_autoreply_scenario_result 
value=\"$edit_autoreply_scenario_result\">
+                           <p><input type=submit class=button value=\"Save\">
+                           </form>
+                       ";
+                       $done_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uiautoreplay.manage',
+                               'autoreply_id'  => $autoreply_id);
+                               
+                       $done_url = 
$GLOBALS['phpgw']->link('/index.php',$done_data);
+
+                       $content .= "
+                           <p><li>
+                           <a href=\"$done_url\">Back</a>
+                           <p>
+                       ";
+                       echo $content;
+               }
+
+
+
+               function edit_scenario_yes()
+               {
+               
+                       if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
+                       {
+                               $links = 
$this->menu->links('.config.autoreplay');
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
+                               $this->bocommon->no_access($links);
+                               return;
+                       }
+
+                       $autoreply_scenario_id  = 
get_var('autoreply_scenario_id',array('POST','GET'));
+                       $autoreply_id   = 
get_var('autoreply_id',array('POST','GET'));
+                       $edit_autoreply_scenario_result = 
get_var('edit_autoreply_scenario_result',array('POST','GET'));
+                       
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           ${"edit_autoreply_scenario_param".$i} = 
strtoupper(get_var("edit_autoreply_scenario_param$i",array('POST','GET')));
+                           if(${"edit_autoreply_scenario_param".$i})
+                           {
+                               $ok++;
+                           }
+                       }
+
+                       if ($edit_autoreply_scenario_result  && ($ok > 0))
+                       {
+                           for ($i=1;$i<=7;$i++)
+                           {
+                                       $autoreply_scenario_param_list .= 
"autoreply_scenario_param$i='".${"edit_autoreply_scenario_param".$i}."',";
+                           }
+                           $sql = "
+                               UPDATE phpgw_sms_featautoreply_scenario 
+                               SET 
".$autoreply_scenario_param_list."autoreply_scenario_result='$edit_autoreply_scenario_result'
 
+                               WHERE autoreply_id='$autoreply_id' AND 
autoreply_scenario_id='$autoreply_scenario_id'
+                           ";
+
+                               $this->db->transaction_begin();
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               if ($this->db->affected_rows())
+                           {
+                                       $error_string = "SMS autoreply scenario 
has been edited";
+                           }
+                           else
+                           {
+                               $error_string = "Fail to edit SMS autoreply 
scenario";
+                           }
+
+                               $this->db->transaction_commit();
+
+                       }
+                       else
+                       {
+                           $error_string = "You must fill at least one field 
and the scenario result!";
+                       }
+
+                       $target = 'edit_scenario';
+                       
+                       $add_data = array(
+                               'menuaction'                                    
=> $this->currentapp.'.uiautoreplay.' . $target,
+                               'autoreply_id'                                  
=> $autoreply_id,
+                               'autoreply_scenario_id'                 => 
$autoreply_scenario_id,
+                               'err'                                           
        => urlencode($error_string),
+                               'edit_autoreply_scenario_result' => 
$edit_autoreply_scenario_result
+                               );
+
+                       for ($i=1;$i<=7;$i++)
+                       {
+                           $add_data["edit_autoreply_scenario_param".$i] = 
strtoupper(get_var("edit_autoreply_scenario_param$i",array('POST')));
+                       }
+
+                       
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
+
+               }
+
+
+               function manage()
+               {               
+                       if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
+                       {
+                               $links = 
$this->menu->links('.config.autoreplay');
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
True;
+                               $this->bocommon->no_access($links);
+                               return;
+                       }
+                                       
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('SMS').' - '.lang('Manage SMS autoreply');
                        $GLOBALS['phpgw']->common->phpgw_header();
 
@@ -285,18 +596,29 @@
                            $list_of_param = "";
                            for ($i=1;$i<=7;$i++)
                            { 
-                               $list_of_param .= 
$this->db->f("autoreply_scenario_param$i")."&nbsp";
+                                       $list_of_param .= 
$this->db->f("autoreply_scenario_param$i")."&nbsp;";
                            }
 
                                $content .= "[<a href=" . 
$GLOBALS['phpgw']->link('/index.php','menuaction=sms.uiautoreplay.edit_scenario&autoreply_id='
 . $this->db->f('autoreply_id') . '&autoreply_scenario_id=' 
.$this->db->f('autoreply_scenario_id')) . ">e</a>] ";
                                $content .= "[<a href=" . 
$GLOBALS['phpgw']->link('/index.php','menuaction=sms.uiautoreplay.delete_scenario&autoreply_id='
 . $this->db->f('autoreply_id') . '&autoreply_scenario_id=' . 
$this->db->f('autoreply_scenario_id')) . ">x</a>] ";
-                               $content .= " <b>Param:</b> 
".$list_of_param."&nbsp;<br><b>Return:</b> 
".$db_row[autoreply_scenario_result]."&nbsp;&nbsp;<b>User:</b> $owner<br><br>";
+                               $content .= " <b>Param:</b> 
".$list_of_param."&nbsp;<br><b>Return:</b> 
".$this->db->f('autoreply_scenario_result')."&nbsp;&nbsp;<b>User:</b> 
$owner<br><br>";
                        }
                        $content .= "
                            <p>
                            <a href=\"$add_url\">[ Add SMS autoreply scenario 
]</a>
                            <p>
                        ";
+
+                       $done_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uiautoreplay.index');
+                               
+                       $done_url = 
$GLOBALS['phpgw']->link('/index.php',$done_data);
+
+                       $content .= "
+                           <p><li>
+                           <a href=\"$done_url\">Back</a>
+                           <p>
+                       ";
                        echo $content;
                
                }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]