phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


From: Sigurd Nes
Subject: [Phpgroupware-cvs] sms/inc class.uipolls.inc.php
Date: Thu, 01 Jun 2006 09:43:53 +0000

CVSROOT:        /sources/phpgroupware
Module name:    sms
Branch:         
Changes by:     Sigurd Nes <address@hidden>     06/06/01 09:43:53

Modified files:
        inc            : class.uipolls.inc.php 

Log message:
        

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

Patches:
Index: sms/inc/class.uipolls.inc.php
diff -u sms/inc/class.uipolls.inc.php:1.3 sms/inc/class.uipolls.inc.php:1.4
--- sms/inc/class.uipolls.inc.php:1.3   Wed May 31 18:28:28 2006
+++ sms/inc/class.uipolls.inc.php       Thu Jun  1 09:43:53 2006
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package sms
        * @subpackage polls
-       * @version $Id: class.uipolls.inc.php,v 1.3 2006/05/31 18:28:28 
sigurdne Exp $
+       * @version $Id: class.uipolls.inc.php,v 1.4 2006/06/01 09:43:53 
sigurdne Exp $
        */
 
        /**
@@ -19,12 +19,16 @@
        class uipolls
        {
                var $public_functions = array(
-                       'index'         => True,
-                       'add'           => True,
-                       'add_yes'       => True,
-                       'view'          => True,
-                       'edit'          => True,
-                       'delete'        => True,
+                       'index'                 => True,
+                       'add'                   => True,
+                       'add_yes'               => True,
+                       'add_choice'    => True,
+                       'view'                  => True,
+                       'edit'                  => True,
+                       'edit_yes'              => True,
+                       'delete_choice' => True,
+                       'delete'                => True,
+                       'status'                => True,
                        );
 
 
@@ -209,6 +213,8 @@
                                            INSERT INTO phpgw_sms_featpoll 
(uid,poll_code,poll_title)
                                            VALUES 
('$uid','$add_poll_code','$add_poll_title')
                                        ";
+                                       $this->db->transaction_begin();
+
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
                                        $new_uid = 
$this->db->get_last_insert_id(phpgw_sms_featpoll,'poll_id');
@@ -229,7 +235,6 @@
                        {
                            $error_string = "You must fill all fields!";
                        }
-                       header ("Location: 
menu.php?inc=sms_poll&op=sms_poll_add&err=".urlencode($error_string));
 
                        $add_data = array(
                                'menuaction'    => 
$this->currentapp.'.uipolls.' . $target,
@@ -240,6 +245,105 @@
                }
 
 
+
+               function add_choice()
+               {
+               
+                       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;
+                       }
+
+                       $poll_id        = 
get_var('poll_id',array('POST','GET'));
+                       $choice_title   = 
get_var('choice_title',array('POST','GET'));
+                       $choice_code    = 
strtoupper(get_var('choice_code',array('POST','GET')));
+                       $uid = $this->account;
+                       $target = 'edit';
+
+                       if ($poll_id && $choice_title && $choice_code)
+                       {
+                               $sql = "SELECT choice_id FROM 
phpgw_sms_featpoll_choice WHERE poll_id='$poll_id' AND 
choice_code='$choice_code'";
+                               $this->db->query($sql,__LINE__,__FILE__);
+           
+                                       if (!$this->db->next_record())
+                               {
+                                               $sql = "
+                                               INSERT INTO 
phpgw_sms_featpoll_choice 
+                                               
(poll_id,choice_title,choice_code)
+                                               VALUES 
('$poll_id','$choice_title','$choice_code')
+                                                       ";
+
+                                               $this->db->transaction_begin();
+
+                                               
$this->db->query($sql,__LINE__,__FILE__);
+
+                                               $new_uid = 
$this->db->get_last_insert_id(phpgw_sms_featpoll_choice,'choice_id');
+
+                                               $this->db->transaction_commit();
+                                               if (new_uid)
+                                               {
+                                                       $error_string = "Choice 
with code `$choice_code` has been added";
+                                               }
+                               }
+                               else
+                               {
+                                               $error_string = "Choice with 
code `$choice_code` already exists";
+                               }
+                       }
+                       else
+                       {
+                               $error_string = "You must fill all fields!";    
    
+                       }
+
+                       $add_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uipolls.' . $target,
+                               'poll_id' => $poll_id,
+                               'err' => urlencode($error_string)
+                               );
+
+                       
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
+               }
+
+               function status()
+               {
+               
+                       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;
+                       }
+
+                       $poll_id        = 
get_var('poll_id',array('POST','GET'));
+                       $ps     = get_var('ps',array('POST','GET'));
+                       $uid = $this->account;
+
+                       $sql = "UPDATE phpgw_sms_featpoll SET poll_enable='$ps' 
WHERE poll_id='$poll_id'";
+                       $this->db->transaction_begin();
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+           
+                       if ($this->db->affected_rows()>0)
+                       {
+                           $error_string = "This poll status has been 
changed!";
+                       }
+                       $this->db->transaction_commit();
+       
+                       $add_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uipolls.edit',
+                               'poll_id' => $poll_id,
+                               'err' => urlencode($error_string)
+                               );
+
+                       
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
+               }
+
+
+
                function edit()
                {
                
@@ -304,11 +408,11 @@
                            $choice_id = $this->db->f('choice_id');
                            $choice_code = $this->db->f('choice_code');
                            $choice_title = $this->db->f('choice_title');
-                           $content .= "[<a href=" . 
$GLOBALS['phpgw']->link("/index.php','menuaction=sms.uipolls.choice_delete&poll_id=$poll_id&choice_id=$choice_id")
 . ">x</a>] ";
+                           $content .= "[<a href=" . 
$GLOBALS['phpgw']->link('/index.php',"menuaction=sms.uipolls.delete_choice&poll_id=$poll_id&choice_id=$choice_id")
 . ">x</a>] ";
                            $content .= "<b>Code:</b> $choice_code 
&nbsp;&nbsp;<b>Title:</b> $choice_title<br>";
                        }
 
-                       $add_data = array('menuaction'  => 
$this->currentapp.'.uipolls.choice_add',
+                       $add_data = array('menuaction'  => 
$this->currentapp.'.uipolls.add_choice',
                                        'poll_id' => $poll_id,
                                        );
                        $add_url = 
$GLOBALS['phpgw']->link('/index.php',$add_data);
@@ -324,15 +428,6 @@
                        <br>";
                        
                        echo $content;
-                       $sql = "SELECT poll_enable FROM phpgw_sms_featpoll 
WHERE poll_id='$poll_id'";
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       $this->db->next_record();
-       
-                       $poll_status = "<font color=red><b>Disable</b></font>";
-                       if ($this->db->f('poll_enable'))
-                       {
-                           $poll_status = "<font 
color=green><b>Enable</b></font>";
-                       }
 
                        $enable_data = array('menuaction'       => 
$this->currentapp.'.uipolls.status',
                                        'poll_id' => $poll_id,
@@ -346,15 +441,29 @@
                                        );
                        $disable_url = 
$GLOBALS['phpgw']->link('/index.php',$disable_data);
 
+                       $sql = "SELECT poll_enable FROM phpgw_sms_featpoll 
WHERE poll_id='$poll_id'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+       
+                       $poll_status = "<font color=red><b>Disable</b></font>";
+                       if ($this->db->f('poll_enable'))
+                       {
+                           $poll_status = "<font 
color=green><b>Enable</b></font>";
+                           $action = "<p>- <a href=\"$disable_url\">I want to 
<b>disable</b> this poll</a>";
+                       }
+                       else
+                       {
+                           $action = "<p>- <a href=\"$enable_url\">I want to 
<b>enable</b> this poll</a>";                     
+                       }
+
                        $content = "
                            <h2>Enable or disable this poll</h2>
                            <p>
                            <p>Current status: $poll_status
                            <p>What do you want to do ?
-                           <p>- <a href=\"$enable_url\">I want to 
<b>enable</b> this poll</a>
-                           <p>- <a href=\"$disable_url\">I want to 
<b>disable</b> this poll</a>
+                           $action                         
                            <br>
-                       ";
+                           ";
 
                        $done_data = array('menuaction' => 
$this->currentapp.'.uipolls.index');
                        $done_url = 
$GLOBALS['phpgw']->link('/index.php',$done_data);
@@ -367,6 +476,52 @@
                        echo $content;
                }
 
+               function edit_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;
+                       }
+
+                       $poll_id        = 
get_var('poll_id',array('POST','GET'));
+                       $poll_code      = 
get_var('poll_code',array('POST','GET'));
+                       $poll_title     = 
get_var('poll_title',array('POST','GET'));
+
+                       $uid = $this->account;
+                       $target = 'edit';
+
+                       if ($poll_id && $poll_title && $poll_code)
+                       {
+                           
+                                       $sql = "UPDATE phpgw_sms_featpoll SET 
poll_title='$poll_title',poll_code='$poll_code'
+                                                       WHERE 
poll_id='$poll_id'";
+                                       
+                                       $this->db->transaction_begin();
+
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+
+                                       if ($this->db->affected_rows()>0)
+                                       {
+                                       $error_string = "SMS poll with code 
`$edit_poll_code` has been saved";
+                                       }
+                                       $this->db->transaction_commit();        
                }
+                       else
+                       {
+                           $error_string = "You must fill all fields!";
+                       }
+
+                       $add_data = array(
+                               'menuaction'    => 
$this->currentapp.'.uipolls.' . $target,
+                               'poll_id' => $poll_id,
+                               'err' => urlencode($error_string)
+                               );
+
+                       
$GLOBALS['phpgw']->redirect_link('/index.php',$add_data);
+               }
 
                function view()
                {
@@ -540,5 +695,76 @@
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }
+
+
+               function delete_choice()
+               {
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+                       if(!$this->acl->check('run', PHPGW_ACL_READ,'admin'))
+                       {
+                               $this->bocommon->no_access($links);
+                               return;
+                       }
+
+                       $poll_id        = 
get_var('poll_id',array('POST','GET'));
+                       $choice_id      = 
get_var('choice_id',array('POST','GET'));
+                       $confirm        = get_var('confirm',array('POST'));
+
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.uipolls.edit',
+                               'poll_id' => $poll_id
+                       );
+
+                       if (get_var('confirm',array('POST')))
+                       {
+                       //      $this->bo->delete_type($autoreply_id);
+
+                               $sql = "SELECT choice_code FROM 
phpgw_sms_featpoll_choice WHERE poll_id='$poll_id' AND choice_id='$choice_id'";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->next_record();
+
+                               $choice_code = $this->db->f('choice_code');
+                               $error_string = "Fail to delete SMS poll choice 
with code `$choice_code`!";
+
+                               if ($poll_id && $choice_id && $choice_code)
+                               {
+                                       $sql = "DELETE FROM 
phpgw_sms_featpoll_choice WHERE poll_id='$poll_id' AND choice_id='$choice_id'";
+                                       $this->db->transaction_begin();
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+                                       if ($this->db->affected_rows())
+                               {
+                                               $sql = "DELETE FROM 
phpgw_sms_featpoll_result WHERE poll_id='$poll_id' AND choice_id='$choice_id'";
+                                               
$this->db->query($sql,__LINE__,__FILE__);       
+                                               $error_string = "SMS poll 
choice with code `$choice_code` and all its voters has been deleted!";
+                                       }
+
+                               $this->db->transaction_commit();
+                               }
+                                       
+                               $link_data['err'] = urlencode($error_string);
+
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
+                       }
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+                       $data = array
+                       (
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipolls.delete_choice&poll_id='
 . $poll_id . '&choice_id=' . $choice_id),
+                               'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
+                               'lang_yes'                              => 
lang('yes'),
+                               'lang_yes_statustext'   => lang('Delete the 
entry'),
+                               'lang_no_statustext'    => lang('Back to the 
list'),
+                               'lang_no'                               => 
lang('no')
+                       );
+
+                       $appname                                        = 
lang('sms');
+                       $function_msg                                   = 
lang('delete poll choice');
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+               }
        }
 ?>




reply via email to

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