fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9033] registration: approval


From: Sigurd Nes
Subject: [Fmsystem-commits] [9033] registration: approval
Date: Mon, 26 Mar 2012 19:24:40 +0000

Revision: 9033
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9033
Author:   sigurdne
Date:     2012-03-26 19:24:39 +0000 (Mon, 26 Mar 2012)
Log Message:
-----------
registration: approval

Modified Paths:
--------------
    trunk/registration/inc/class.bopending.inc.php
    trunk/registration/inc/class.sopending.inc.php
    trunk/registration/inc/class.uipending.inc.php
    trunk/registration/templates/base/user_edit.xsl

Modified: trunk/registration/inc/class.bopending.inc.php
===================================================================
--- trunk/registration/inc/class.bopending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
+++ trunk/registration/inc/class.bopending.inc.php      2012-03-26 19:24:39 UTC 
(rev 9033)
@@ -183,6 +183,12 @@
                        return $values;
                }
 
+
+               public function update_pending_user($values)
+               {
+                       return $this->so->update_pending_user($values);         
+               }
+
                /**
                 * Approve a list of pending users
                 *

Modified: trunk/registration/inc/class.sopending.inc.php
===================================================================
--- trunk/registration/inc/class.sopending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
+++ trunk/registration/inc/class.sopending.inc.php      2012-03-26 19:24:39 UTC 
(rev 9033)
@@ -160,4 +160,23 @@
 
                        return $this->db->transaction_commit();
                }
+
+               public function update_pending_user($values)
+               {
+                       $ret = false;
+                       $this->db->transaction_begin();
+                       if (isset($values['location']) && $values['location'] 
&& $values['id'])
+                       {
+                               $this->db->query("SELECT reg_info FROM 
phpgw_reg_accounts WHERE reg_id = '{$values['id']}'",__LINE__,__FILE__);
+                               if ($this->db->next_record())
+                               {
+                                       $reg_info = 
unserialize(base64_decode($this->db->f('reg_info')));
+                                       $reg_info['location_code'] = 
implode('-', $values['location']);
+                               }
+                               $ret = $this->db->query("UPDATE 
phpgw_reg_accounts SET  reg_info='" . base64_encode(serialize($reg_info)) . "' 
WHERE reg_id='{$values['id']}'",__LINE__,__FILE__);
+                       }
+                       $this->db->transaction_commit();
+                       return $ret;
+               }
+
        }

Modified: trunk/registration/inc/class.uipending.inc.php
===================================================================
--- trunk/registration/inc/class.uipending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
+++ trunk/registration/inc/class.uipending.inc.php      2012-03-26 19:24:39 UTC 
(rev 9033)
@@ -65,6 +65,7 @@
                        parent::__construct();
                
                        $this->bo                                       = 
CreateObject('registration.bopending',true);
+                       $this->bocommon                         = 
CreateObject('property.bocommon');
                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
@@ -146,6 +147,12 @@
                                                                'formatter' => 
'FormatterCenter'
                                                        ),
                                                        array(
+                                                               'key' => 
'location_code',
+                                                               'label' => 
lang('location'),
+                                                               'sortable'      
=> false
+                                                       ),
+
+                                                       array(
                                                                        'key' 
=> 'checked',
                                                                        'label' 
=> lang('approve'),
                                                                        
'sortable' => false,
@@ -187,88 +194,103 @@
                        $id = phpgw::get_var('id', 'string');
                        $bo = createobject('registration.boreg');
 
-                       if(isset($_POST['save']) && $id) // The user has 
pressed the save button
+                       if(isset($_POST['save']) && $id)
                        {
-                               if(isset($control_item)) // Add new values to 
the control item
-                               {
-                                       $values = phpgw::get_var('values');
-                                       $values['id'] = $id;
+                               $values = phpgw::get_var('values');
 
-                                       $this->bo->update_pending_user($values);
+                               $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
+                               $insert_record_entity = 
$GLOBALS['phpgw']->session->appsession('insert_record_entity','property');
 
-                                       
if($this->bo->update_pending_user($values))
+                               if(isset($insert_record_entity) && 
is_array($insert_record_entity))
+                               {
+                                       for 
($j=0;$j<count($insert_record_entity);$j++)
                                        {
-                                               $message = 
lang('messages_saved_form');
+                                               
$insert_record['extra'][$insert_record_entity[$j]]      = 
$insert_record_entity[$j];
                                        }
-                                       else
-                                       {
-                                               $error = 
lang('messages_form_error');
-                                       }
+                               }
 
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'registration.uipending.index'));
+                               $values = 
$this->bocommon->collect_locationdata($values,$insert_record);
+
+                               $values['id'] = $id;
+
+                               if($this->bo->update_pending_user($values))
+                               {
+                                       $message = lang('messages_saved_form');
+                                       phpgwapi_cache::message_set($message, 
'message');
                                }
+                               else
+                               {
+                                       $error = lang('messages_form_error');
+                                       phpgwapi_cache::message_set($message, 
'error');
+                               }
+
                        }
-                       else if(isset($_POST['cancel'])) // The user has 
pressed the cancel button
+
+                       if (isset($_POST['cancel'])) // The user has pressed 
the cancel button
                        {
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'registration.uipending.index'));
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'registration.uipending.index'));
                        }
-                       else
+
+                       if($id)
                        {
-                               if($this->flash_msgs)
-                               {
-                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
-                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
-                               }
-
-
-                               if($id)
-                               {
-                                       $user = $bo->get_pending_user($id);
-                               }
+                               $user = $bo->get_pending_user($id);
+                       }
                                
-                               $fields = $bo->fields;
+                       $fields = $bo->fields;
                                
-                               $user_data = array();
-                               $user_data[] = array
-                               (
-                                       'text'  => 'username',
-                                       'value' => $user['reg_lid']
-                               );
+                       $user_data = array();
+                       $user_data[] = array
+                       (
+                               'text'  => 'username',
+                               'value' => $user['reg_lid']
+                       );
                                
-                               foreach ($fields as $key => $field_info)
+                       foreach ($fields as $key => $field_info)
+                       {
+                               if($user['reg_info'][$field_info['field_name']])
                                {
-                                       
if($user['reg_info'][$field_info['field_name']])
-                                       {
-                                               $user_data[] = array
-                                               (
-                                                       'text'  => 
$field_info['field_text'],
-                                                       'value' => 
$user['reg_info'][$field_info['field_name']]
-                                               );
-                                       }
+                                       $user_data[] = array
+                                       (
+                                               'text'  => 
$field_info['field_text'],
+                                               'value' => 
$user['reg_info'][$field_info['field_name']]
+                                       );
                                }
+                       }
+
+                       $bolocation     = CreateObject('property.bolocation');
+                       $user['location_data'] = 
isset($user['reg_info']['location_code']) && $user['reg_info']['location_code'] 
? $bolocation->read_single($user['reg_info']['location_code'],array('view' => 
true)) : '';
+                               
+
+/*
+_debug_array($user);
 _debug_array($user_data);
 _debug_array($fields);
 die();
+*/
 
+                       $location_data=$bolocation->initiate_ui_location(array(
+                               'values'        => $user['location_data'],
+                               'type_id'       => -1,
+                               'no_link'       => false, // disable lookup 
links for location type less than type_id
+                               'tenant'        => false,
+                               'lookup_type'   => 'form',
+                               'lookup_entity' => false,
+                               'entity_data'   => false
+                               ));
 
-                               $data = array
-                               (
-                                       'value_id'                              
=> $id,
-                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                                       'editable'                              
=> true,
-                                       'user'                                  
=> $user_data
-                               );
 
-                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('registration') . '::' . lang('edit user');
+                       $data = array
+                       (
+                               'value_id'                              => $id,
+                               'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                               'editable'                              => true,
+                               'user_data'                             => 
$user_data,
+                               'location_data'                 => 
$location_data
+                       );
 
-//                             
$this->use_yui_editor(array('what_to_do','how_to_do'));
-                               
-                               self::add_javascript('controller', 
'controller', 'jquery.js');
-                               self::add_javascript('controller', 
'controller', 'ajax.js');
-                               self::add_javascript('controller', 
'controller', 'jquery-ui.custom.min.js');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('registration') . '::' . lang('edit user');
 
-                               self::render_template_xsl('user_edit', $data);
-                       }
+                       self::render_template_xsl('user_edit', $data);
                }
        
                public function query()
@@ -280,8 +302,10 @@
                        $user_list = $this->bo->read(array('user_id' => 
$user_id, 'role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
                                                                                
                   'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run' 
=>$dry_run));
                        
-                       foreach($user_list as $user)
+                       foreach($user_list as &$user)
                        {
+                               $reg_info = 
unserialize(base64_decode($user['reg_info']));
+                               $user['location_code'] = 
$reg_info['location_code'];
                                $results['results'][]= $user;
                        }
                        $results['total_records'] = $this->bo->total_records;

Modified: trunk/registration/templates/base/user_edit.xsl
===================================================================
--- trunk/registration/templates/base/user_edit.xsl     2012-03-26 13:47:10 UTC 
(rev 9032)
+++ trunk/registration/templates/base/user_edit.xsl     2012-03-26 19:24:39 UTC 
(rev 9033)
@@ -6,152 +6,27 @@
 <xsl:call-template name="yui_booking_i18n"/>
 <div class="identifier-header">
 <h1><img src="{img_go_home}" /> 
-               <xsl:value-of select="php:function('lang', 'Control_item')" />
+               <xsl:value-of select="php:function('lang', 'edit user')" />
 </h1>
 </div>
-
-<ul class="check_list">
-                       <xsl:for-each select="check_list_array">
-                               <li>
-                                       <span>Tittel:</span><xsl:value-of 
select="title"/><span>Start dato:</span><xsl:value-of select="start_date"/>
-                               </li>
-                       </xsl:for-each>
-               </ul>                                   
-               
        <div class="yui-content">
                <div id="details">
-                       <form action="#" method="post">
+                       <form action="#" method="post" name="form">
                                <input type="hidden" name="id" value = 
"{value_id}">
                                </input>
-                               <dl class="proplist-col">
-                                       <dt>
-                                               <label 
for="title">Tittel</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <input type="text" 
name="title" id="title" value="{control_item/title}" size="80"/>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/title"/>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                       <dt>
-                                               <label 
for="required">Obligatorisk</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:variable 
name="required_item"><xsl:value-of select="control_item/required" 
/></xsl:variable>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="$required_item=1">
-                                                                       <input 
type="checkbox" name="required" id="required" checked="true"/>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                       <input 
type="checkbox" name="required" id="required"/>
-                                                               </xsl:otherwise>
-                                                       </xsl:choose>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="$required_item=1">
-                                                                       <input 
type="checkbox" name="required" id="required" checked="true" disabled="true"/>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                       <input 
type="checkbox" name="required" id="required" disabled="true" />
-                                                               </xsl:otherwise>
-                                                       </xsl:choose>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                       <dt>
-                                               <label 
for="required">Måling</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:variable 
name="measurement_item"><xsl:value-of select="control_item/type" 
/></xsl:variable>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="$measurement_item='control_item_type_2'">
-                                                                       <input 
type="checkbox" name="measurement" id="measurement" checked="true"/>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                       <input 
type="checkbox" name="measurement" id="measurement"/>
-                                                               </xsl:otherwise>
-                                                       </xsl:choose>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="$measurement_item='control_item_type_2'">
-                                                                       <input 
type="checkbox" name="measurement" id="measurement" checked="true" 
disabled="true"/>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                       <input 
type="checkbox" name="measurement" id="measurement" disabled="true" />
-                                                               </xsl:otherwise>
-                                                       </xsl:choose>
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                       <dt>
-                                               <label for="what_to_do">Hva 
skal utføres</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <textarea 
name="what_to_do" id="what_to_do" rows="5" cols="60"><xsl:value-of 
select="control_item/what_to_do" disable-output-escaping="yes" /></textarea>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/what_to_do" disable-output-escaping="yes" />
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                       <dt>
-                                               <label 
for="how_to_do">Utførelsesbeskrivelse</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <textarea 
name="how_to_do" id="how_to_do" rows="5" cols="60"><xsl:value-of 
select="control_item/how_to_do" disable-output-escaping="yes" /></textarea>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/how_to_do" disable-output-escaping="yes" />
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                       <dt>
-                                               <label 
for="control_area">Kontrollområde</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <select 
id="control_area" name="control_area">
-                                                               
<xsl:apply-templates select="control_area/options"/>
-                                                       </select>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/control_area_name" />
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>
-                                                                               
<dt>
-                                               <label 
for="control_group">Kontrollgruppe</label>
-                                       </dt>
-                                       <dd>
-                                       <xsl:choose>
-                                               <xsl:when test="editable">
-                                                       <select 
id="control_group" name="control_group">
-                                                               <option 
value="0">Ingen valgt</option>
-                                                               
<xsl:apply-templates select="control_group/options"/>
-                                                       </select>
-                                               </xsl:when>
-                                               <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/control_group_name" />
-                                               </xsl:otherwise>
-                                       </xsl:choose>
-                                       </dd>                           
-                               </dl>
-                               
+                               <table>
+                                       <xsl:for-each select="user_data">
+                                               <tr>
+                                                       <td>
+                                                               <xsl:value-of 
select="text"/>
+                                                       </td>
+                                                       <td>
+                                                               <xsl:value-of 
select="value"/>
+                                                       </td>
+                                               </tr>
+                                       </xsl:for-each>
+                                       <xsl:call-template 
name="location_form"/>                       
+                               </table>
                                <div class="form-buttons">
                                        <xsl:choose>
                                                <xsl:when test="editable">
@@ -166,9 +41,7 @@
                                                </xsl:otherwise>
                                        </xsl:choose>
                                </div>
-                               
-                       </form>
-                                               
+                       </form>                 
                </div>
        </div>
 </xsl:template>




reply via email to

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