fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9032] registration: approve pending users


From: Sigurd Nes
Subject: [Fmsystem-commits] [9032] registration: approve pending users
Date: Mon, 26 Mar 2012 13:47:10 +0000

Revision: 9032
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9032
Author:   sigurdne
Date:     2012-03-26 13:47:10 +0000 (Mon, 26 Mar 2012)
Log Message:
-----------
registration: approve pending users

Modified Paths:
--------------
    trunk/registration/inc/class.bopending.inc.php
    trunk/registration/inc/class.boreg.inc.php
    trunk/registration/inc/class.sopending.inc.php
    trunk/registration/inc/class.soreg.inc.php
    trunk/registration/inc/class.uipending.inc.php
    trunk/registration/js/yahoo/pending.index.js
    trunk/registration/templates/base/pending_users.xsl

Added Paths:
-----------
    trunk/registration/templates/base/user_edit.xsl

Modified: trunk/registration/inc/class.bopending.inc.php
===================================================================
--- trunk/registration/inc/class.bopending.inc.php      2012-03-25 19:28:01 UTC 
(rev 9031)
+++ trunk/registration/inc/class.bopending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -67,8 +67,8 @@
 
                        $start                                  = 
phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $query                                  = 
phpgw::get_var('query');
-                       $sort                                   = 
phpgw::get_var('sort');
-                       $order                                  = 
phpgw::get_var('order');
+                       $sort                                   = 
phpgw::get_var('dir');
+                       $order                                  = 
phpgw::get_var('sort');
                        $filter                                 = 
phpgw::get_var('filter', 'int');
                        $status_id                              = 
phpgw::get_var('status_id', 'int');
                        $allrows                                = 
phpgw::get_var('allrows', 'bool');
@@ -87,7 +87,7 @@
 
                function read_sessiondata()
                {
-                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','location');
+                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','pending_user');
 
                        $this->start                    = 
isset($data['start'])?$data['start']:'';
                        $this->filter                   = 
isset($data['filter'])?$data['filter']:'';
@@ -102,7 +102,7 @@
                {
                        if ($this->use_session)
                        {
-                               
$GLOBALS['phpgw']->session->appsession('session_data','location',$data);
+                               
$GLOBALS['phpgw']->session->appsession('session_data','pending_user',$data);
                        }
                }
 
@@ -183,47 +183,61 @@
                        return $values;
                }
 
-
                /**
-                * Arrange attributes within groups
+                * Approve a list of pending users
                 *
-                * @param string  $location    the name of the location of the 
attribute
-                * @param array   $attributes  the array of the attributes to 
be grouped
+                * @param array   $values  the array users to change status
                 *
-                * @return array the grouped attributes
+                * @return array receipt
                 */
 
-
-               function 
save($location,$values_attribute,$action='',$type_id='',$location_code_parent='')
+               function approve_users($values)
                {
-                       if(is_array($values_attribute))
-                       {
-                               $values_attribute = 
$this->custom->convert_attribute_save($values_attribute);
-                       }
+                       $receipt = $this->so->approve_users($values);
 
-                       if ($action=='edit')
+                       $criteria = array
+                               (
+                                       'appname'       => 'registration',
+                                       'location'      => ".pending.approve",
+                                       'allrows'       => true
+                               );
+
+                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+                       foreach ( $custom_functions as $entry )
                        {
-                               if 
($this->so->check_location($location['location_code'],$type_id))
+                               // prevent path traversal
+                               if ( preg_match('/\.\./', $entry['file_name']) )
                                {
-                                       $receipt = 
$this->so->edit($location,$values_attribute,$type_id);
+                                       continue;
                                }
-                               else
+
+                               $file = PHPGW_SERVER_ROOT . 
"/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+                               if ( $entry['active'] && is_file($file) )
                                {
-                                       
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
+                                       require_once $file;
                                }
                        }
-                       else
-                       {
-                               if(!$receipt['error'])
-                               {
-                                       $receipt = 
$this->so->add($location,$values_attribute,$type_id);
-                               }
-                       }
 
+                       return $receipt;
+               }
+               /**
+                * Edit single user
+                *
+                * @param array   $values  the array of values to edit
+                *
+                * @return array receipt
+                */
+
+
+               function edit($values)
+               {
+                       $receipt = $this->so->edit($values);
+
                        $criteria = array
                                (
-                                       'appname'       => 'property',
-                                       'location'      => 
".location.{$type_id}",
+                                       'appname'       => 'registration',
+                                       'location'      => ".pending.edit",
                                        'allrows'       => true
                                );
 

Modified: trunk/registration/inc/class.boreg.inc.php
===================================================================
--- trunk/registration/inc/class.boreg.inc.php  2012-03-25 19:28:01 UTC (rev 
9031)
+++ trunk/registration/inc/class.boreg.inc.php  2012-03-26 13:47:10 UTC (rev 
9032)
@@ -256,6 +256,20 @@
                        $ui->welcome_screen();
                }
 
+               public function get_pending_user($reg_id)
+               {
+                       $so = createobject('registration.soreg');
+                       $reg_info = $so->valid_reg($reg_id);
+                       if($reg_info['reg_info'])
+                       {
+                               $reg_info['reg_info'] = 
unserialize(base64_decode($reg_info['reg_info']));
+                               unset($reg_info['reg_info']['passwd']);
+                               unset($reg_info['reg_info']['passwd_confirm']);
+                       }
+                       
+                       return $reg_info;
+               }
+
                //
                // username
                //

Modified: trunk/registration/inc/class.sopending.inc.php
===================================================================
--- trunk/registration/inc/class.sopending.inc.php      2012-03-25 19:28:01 UTC 
(rev 9031)
+++ trunk/registration/inc/class.sopending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -38,29 +38,16 @@
                var $total_records;
                protected $global_lock = false;
 
-               function __construct($bocommon = '')
+               function __construct()
                {
                        $this->account                  = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->soadmin_location = 
CreateObject('property.soadmin_location');
-                       if(!$bocommon || !is_object($bocommon))
-                       {
-                               $this->bocommon                 = 
CreateObject('property.bocommon');
-                       }
-                       else
-                       {
-                               $this->bocommon = $bocommon;
-                       }
-                       $this->custom           = 
createObject('property.custom_fields');
-
                        $this->db           = & $GLOBALS['phpgw']->db;
-                       $this->socommon         = & $this->bocommon->socommon;
-
                        $this->join                     = & $this->db->join;
                        $this->left_join        = & $this->db->left_join;
                        $this->like                     = & $this->db->like;
                }
 
-               function read($data)
+               public function read($data)
                {
                        $start                                  = 
isset($data['start']) && $data['start'] ? $data['start'] : 0;
                        $filter                                 = 
isset($data['filter']) && $data['filter'] ? $data['filter'] : 0;
@@ -139,4 +126,38 @@
                        }
                        return $values;
                }
+
+               public function approve_users($data)
+               {
+                       $delete_approval = array();
+                       $add_approval = array();
+                       foreach($data['pending_users_orig'] as $id)
+                       {
+                               if(!in_array($id, $data['pending_users']))
+                               {
+                                       $delete_approval[] = $id;
+                               }
+                       }
+
+                       foreach($data['pending_users'] as $id)
+                       {
+                               if(!in_array($id, $data['pending_users_orig']))
+                               {
+                                       $add_approval[] = $id;
+                               }
+                       }
+
+                       $this->db->transaction_begin();
+                       foreach ($delete_approval as $reg_id)
+                       {
+                               $this->db->query("UPDATE phpgw_reg_accounts SET 
reg_approved = NULL WHERE reg_id = '{$reg_id}'",__LINE__,__FILE__);             
        
+                       }
+
+                       foreach ($add_approval as $reg_id)
+                       {
+                               $this->db->query("UPDATE phpgw_reg_accounts SET 
reg_approved = 1 WHERE reg_id = '{$reg_id}'",__LINE__,__FILE__);                
        
+                       }
+
+                       return $this->db->transaction_commit();
+               }
        }

Modified: trunk/registration/inc/class.soreg.inc.php
===================================================================
--- trunk/registration/inc/class.soreg.inc.php  2012-03-25 19:28:01 UTC (rev 
9031)
+++ trunk/registration/inc/class.soreg.inc.php  2012-03-26 13:47:10 UTC (rev 
9032)
@@ -17,7 +17,7 @@
 
        /* $Id$ */
 
-       class soreg
+       class registration_soreg
        {
                var $reg_id;
                var $db;
@@ -216,10 +216,11 @@
                        if ($this->db->f('reg_id'))
                        {
                                return array(
-                                       'reg_id'   => $this->db->f('reg_id'),
-                                       'reg_lid'  => $this->db->f('reg_lid'),
-                                       'reg_info' => $this->db->f('reg_info'),
-                                       'reg_dla'  => $this->db->f('reg_dla')
+                                       'reg_id'                => 
$this->db->f('reg_id'),
+                                       'reg_lid'               => 
$this->db->f('reg_lid'),
+                                       'reg_info'              => 
$this->db->f('reg_info'),
+                                       'reg_dla'               => 
$this->db->f('reg_dla'),
+                                       'reg_approved'  => 
$this->db->f('reg_approved')
                                );
                        }
                        else

Modified: trunk/registration/inc/class.uipending.inc.php
===================================================================
--- trunk/registration/inc/class.uipending.inc.php      2012-03-25 19:28:01 UTC 
(rev 9031)
+++ trunk/registration/inc/class.uipending.inc.php      2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -2,8 +2,7 @@
        /**
        * phpGroupWare - registration
        *
-       * @author Erink Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
+       * @author Sigurd Nes <address@hidden>
        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
        * This file is part of phpGroupWare.
        *
@@ -29,8 +28,6 @@
 
        phpgw::import_class('phpgwapi.yui');
        phpgw::import_class('registration.uicommon');
-//     phpgw::import_class('registration.socontrol_area');
-
 /*
        include_class('registration', 'check_list', 'inc/model/');
        include_class('registration', 'date_generator', 'inc/component/');
@@ -60,12 +57,7 @@
                (
                        'index'                                                 
        => true,
                        'query'                                                 
        => true,
-                       'view_locations_for_control'            => true,
-                       'register_control_to_location'          => true,
-                       'register_control_to_location_2'        => true,
-                       'get_locations_for_control'                     => true,
-                       'get_location_category'                         => true,
-                       'get_district_part_of_town'                     => true
+                       'edit'                                                  
        => true
                );
 
                function __construct()
@@ -73,63 +65,26 @@
                        parent::__construct();
                
                        $this->bo                                       = 
CreateObject('registration.bopending',true);
-                       $this->bocommon                         = & 
$this->bo->bocommon;
-
-                       $this->type_id                          = 
$this->bo->type_id;
-               
                        $this->start                            = 
$this->bo->start;
                        $this->query                            = 
$this->bo->query;
                        $this->sort                                     = 
$this->bo->sort;
                        $this->order                            = 
$this->bo->order;
                        $this->filter                           = 
$this->bo->filter;
-                       $this->cat_id                           = 
$this->bo->cat_id;
-                       $this->part_of_town_id          = 
$this->bo->part_of_town_id;
-                       $this->district_id                      = 
$this->bo->district_id;
-                       $this->status                           = 
$this->bo->status;
+                       $this->status_id                        = 
$this->bo->status_id;
                        $this->allrows                          = 
$this->bo->allrows;
-                       $this->lookup                           = 
$this->bo->lookup;
-                       $this->location_code            = 
$this->bo->location_code;
                
                        self::set_active_menu('registration::pending');
                }
 
                function index()
                {
-                       if(phpgw::get_var('save_location'))
+                       if($values = phpgw::get_var('values'))
                        {
-                               //add component to control using component item 
ID
-                               $items_checked = array();
-                               $items = phpgw::get_var('values_assign');
-                               $item_arr = explode('|',$items);
-                               foreach($item_arr as $item)
-                               {
-                                       $items_checked[] = explode(';',$item);
-                               }
-                               //var_dump($items_checked);
-
-                               $control_id = phpgw::get_var('control_id');
-                               //$location_code = 
phpgw::get_var('location_code');
-                       
-                               $control_location  = null;
-                               $control_location_id = 0;
-                       
-                               foreach($items_checked as $location_code)
-                               {
-                                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code[0]);
+                               $values['pending_users'] = 
isset($values['pending_users']) && $values['pending_users'] ? 
array_unique($values['pending_users']) : array();
+                               $values['pending_users_orig'] = 
isset($values['pending_users_orig']) && $values['pending_users_orig'] ? 
array_unique($values['pending_users_orig']) : array();
                                
-                                       if($control_location == null )
-                                       {                               
-                                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code[0]);
-                                       }
-                               }
-                       
-/*                             if($control_location_id > 0)
-                                       return json_encode( array( "status" => 
"saved" ) );
-                               else
-                                       return json_encode( array( "status" => 
"not_saved" ) );
-*/
+                               $receipt = $this->bo->approve_users($values);
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'registration.uipending.index'));
-
                        }
                        else
                        {
@@ -165,6 +120,10 @@
                                                'source' => 
self::link(array('menuaction' => 'registration.uipending.query', 
'phpgw_return_as' => 'json')),
                                                'field' => array(
                                                        array(
+                                                               'key' => 'id',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
                                                                'key' => 
'reg_id',
                                                                'label' => 
lang('id'),
                                                                'sortable'      
=> true,
@@ -183,13 +142,14 @@
                                                        array(
                                                                'key' => 
'reg_approved',
                                                                'label' => 
lang('approved'),
-                                                               'sortable'      
=> true
+                                                               'sortable'      
=> true,
+                                                               'formatter' => 
'FormatterCenter'
                                                        ),
                                                        array(
                                                                        'key' 
=> 'checked',
                                                                        'label' 
=> lang('approve'),
                                                                        
'sortable' => false,
-                                                                       
'formatter' => 'YAHOO.widget.DataTable.formatCheckbox',
+                                                                       
'formatter' => 'formatterCheckPending',
                                                                        
'className' => 'mychecks'
                                                        ),
                                                        array(
@@ -221,122 +181,116 @@
                        }       
                }
        
-               // Returns locations for a control
-               public function get_locations_for_control()
+
+               public function edit()
                {
-                       $control_id = phpgw::get_var('control_id');
-               
-                       if(is_numeric($control_id) & $control_id > 0)
+                       $id = phpgw::get_var('id', 'string');
+                       $bo = createobject('registration.boreg');
+
+                       if(isset($_POST['save']) && $id) // The user has 
pressed the save button
                        {
-                               $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
-               
-                               foreach($locations_for_control_array as 
$location)
+                               if(isset($control_item)) // Add new values to 
the control item
                                {
-                                       $results['results'][]= $location;
+                                       $values = phpgw::get_var('values');
+                                       $values['id'] = $id;
+
+                                       $this->bo->update_pending_user($values);
+
+                                       
if($this->bo->update_pending_user($values))
+                                       {
+                                               $message = 
lang('messages_saved_form');
+                                       }
+                                       else
+                                       {
+                                               $error = 
lang('messages_form_error');
+                                       }
+
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'registration.uipending.index'));
                                }
-                       
-                               $results['total_records'] = count( 
$locations_for_control_array );
-                               $results['start'] = 1;
-                               $results['sort'] = 'location_code';
                        }
+                       else if(isset($_POST['cancel'])) // The user has 
pressed the cancel button
+                       {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'registration.uipending.index'));
+                       }
                        else
                        {
-                               $results['total_records'] = 0;
-                       }                       
-               
-                       return $this->yui_results($results);
+                               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);
+                               }
+                               
+                               $fields = $bo->fields;
+                               
+                               $user_data = array();
+                               $user_data[] = array
+                               (
+                                       'text'  => 'username',
+                                       'value' => $user['reg_lid']
+                               );
+                               
+                               foreach ($fields as $key => $field_info)
+                               {
+                                       
if($user['reg_info'][$field_info['field_name']])
+                                       {
+                                               $user_data[] = array
+                                               (
+                                                       'text'  => 
$field_info['field_text'],
+                                                       'value' => 
$user['reg_info'][$field_info['field_name']]
+                                               );
+                                       }
+                               }
+_debug_array($user_data);
+_debug_array($fields);
+die();
+
+
+                               $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');
+
+//                             
$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');
+
+                               self::render_template_xsl('user_edit', $data);
+                       }
                }
        
                public function query()
                {
                        $status_id = phpgw::get_var('status_id');
 
-                       $this->bo->sort = "ASC";
                        $this->bo->start = phpgw::get_var('startIndex');
                
                        $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)
                        {
                                $results['results'][]= $user;
                        }
-               
                        $results['total_records'] = $this->bo->total_records;
                        $results['start'] = $this->start;
                        $results['sort'] = 'location_code';
-                       $results['dir'] = "ASC";
+                       $results['dir'] = $this->bo->sort ? $this->bo->sort : 
'ASC';
                                        
                        array_walk($results['results'], array($this, 
'add_links'), array($type));
                                                
                        return $this->yui_results($results);
                }
-
-               public function register_control_to_location_2()
-               {
-                       $control_id = phpgw::get_var('control_id');
-                       $location_code = phpgw::get_var('location_code');
-               
-                       $control_location  = null;
-                       $control_location_id = 0;
-               
-                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code);
-               
-                       if($control_location == null ){
-                       
-                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code);
-                       }
-               
-                       if($control_location_id > 0)
-                               return json_encode( array( "status" => "saved" 
) );
-                       else
-                               return json_encode( array( "status" => 
"not_saved" ) );
-               }
-       
-               public function add_actions(&$value, $key, $params)
-               {
-                       unset($value['query_location']);
-               
-                       $value['ajax'] = array();
-                       $value['actions'] = array();
-                       $value['labels'] = array();
-                       $value['parameters'] = array();
-/*             
-                       $value['ajax'][] = true;
-                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'registration.uipending.register_control_to_location_2','location_code' => 
$value['location_code'], 'phpgw_return_as' => 'json')));
-                       $value['labels'][] = lang('add_location');
-                       $value['parameters'][] = "control_id";
-                       */
-               }
-       
-               /*
-                * Return categories based on chosen location
-                */
-               public function get_location_category()
-               {
-                       $type_id = phpgw::get_var('type_id');
-                       $category_types = 
$this->bocommon->select_category_list(array(
-                                                                               
                                                                
'format'=>'filter',
-                                                                               
                                                                'selected' => 0,
-                                                                               
                                                                'type' 
=>'location',
-                                                                               
                                                                'type_id' 
=>$type_id,
-                                                                               
                                                                'order'=>'descr'
-                                                                               
                                                        ));
-                       $default_value = array ('id'=>'','name'=>lang('no 
category selected'));
-                       array_unshift($category_types,$default_value);
-                       return json_encode( $category_types );
-               }
-       
-               /*
-                * Return parts of town based on chosen district
-                */
-               public function get_district_part_of_town()
-               {
-                       $district_id = phpgw::get_var('district_id');
-                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',null,$district_id);
-                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
-                       array_unshift($part_of_town_list,$default_value);
-
-                       return json_encode( $part_of_town_list );
-               }
        }

Modified: trunk/registration/js/yahoo/pending.index.js
===================================================================
--- trunk/registration/js/yahoo/pending.index.js        2012-03-25 19:28:01 UTC 
(rev 9031)
+++ trunk/registration/js/yahoo/pending.index.js        2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -7,92 +7,91 @@
                elCell.innerHTML = '<a href="' + edit_Url + '&id=' + id + 
'">Link</a>'; 
        };
 
+
+       var formatterCheckPending = function(elCell, oRecord, oColumn, oData)
+       {
+               var checked = '';
+               var hidden = '';
+               if(oRecord.getData('reg_approved'))
+               {
+                       checked = "checked = 'checked'";
+                       hidden = "<input type=\"hidden\" class=\"orig_check\"  
name=\"values[pending_users_orig][]\" 
value=\""+oRecord.getData('reg_id')+"\"/>";
+               }
+               elCell.innerHTML = hidden + "<center><input type=\"checkbox\" 
class=\"mychecks\"" + checked + "value=\""+oRecord.getData('reg_id')+"\" 
name=\"values[pending_users][]\"/></center>";
+       }
+
+       var FormatterCenter = function(elCell, oRecord, oColumn, oData)
+       {
+               elCell.innerHTML = "<center>"+oData+"</center>";
+       }
+
        function checkAll(myclass)
        {
                controls = YAHOO.util.Dom.getElementsByClassName(myclass);
                for(i=0;i<controls.length;i++)
                {
-                       //for class=mychecks, they have to be interchanged
-                       //checkbox is located within td->div->input. To get the 
input-object, use controls[i].children[0].children[0]
-                       if(myclass=='mychecks')
+                       if(!controls[i].disabled)
                        {
-                               if(controls[i].children[0].children[0].checked)
+                               //for class=transfer_idClass, they have to be 
interchanged
+                               if(myclass=="mychecks")
                                {
-                                       
controls[i].children[0].children[0].checked = false;
+                                       if(controls[i].checked)
+                                       {
+                                               controls[i].checked = false;
+                                       }
+                                       else
+                                       {
+                                               controls[i].checked = true;
+                                       }
                                }
+                               //for the rest, always id checked
                                else
                                {
-                                       
controls[i].children[0].children[0].checked = true;
+                                       controls[i].checked = true;
                                }
                        }
-                       //for the rest, always id checked
-                       else
-                       {
-                               controls[i].children[0].children[0].checked = 
true;
-                       }
                }
        }
        
-       function saveLocationToControl()
+       function onSave()
        {
-               var control_id_value = 
document.getElementById('control_id').value;
-               
-               if( !(control_id_value > 0) ){
-                       var choose_control_elem = 
document.getElementById('choose_control');
-                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[0];
-                                               
-                       error_elem.style.display = 'block';
-                       
-                       return false;
-               }else{
-                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[0];
-                       error_elem.style.display = 'none';
-               }
-                               
-               var divs = 
YAHOO.util.Dom.getElementsByClassName('location_submit');
+               var divs = YAHOO.util.Dom.getElementsByClassName('user_submit');
                var mydiv = divs[divs.length-1];
 
                // styles for dont show
-               
 
-               valuesForPHP = 
YAHOO.util.Dom.getElementsByClassName('mychecks');
-               var values_return = ""; //new Array(); 
-                       
+               valuesForPHP            = 
YAHOO.util.Dom.getElementsByClassName('mychecks');                    
+               valuesForPHP_orig       = 
YAHOO.util.Dom.getElementsByClassName('orig_check');
+
+               var myclone = null;
+               //add all control to form
                for(i=0;i<valuesForPHP.length;i++)
                {
-                       if(valuesForPHP[i].children[0].children[0].checked)
-                       {
-                               if(values_return != "")
-                                       values_return 
+="|"+valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
-                               else
-                                       values_return += 
valuesForPHP[i].parentNode.firstChild.firstChild.firstChild.firstChild.nodeValue+';'+valuesForPHP[i].children[0].children[0].value;
-                       }
+                       myclone = valuesForPHP[i].cloneNode(true);
+                       mydiv.appendChild(myclone);
                }
                
-               if( !(values_return.length > 0) ){
+               for(i=0;i<valuesForPHP_orig.length;i++)
+               {
+                       myclone = valuesForPHP_orig[i].cloneNode(true);
+                       mydiv.appendChild(myclone);
+               }
+
+               if( !(true) )
+               {
                        var datatable_container_elem = 
document.getElementById('datatable-container');
-                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[1];
-                                               
+                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[0];
+
                        error_elem.style.display = 'block';
-                       
+
                        return false;
-               }else{
-                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[1];
+               }
+               else
+               {
+                       var error_elem = 
YAHOO.util.Dom.getElementsByClassName('error_msg')[0];
                        error_elem.style.display = 'none';
                }
 
                mydiv.style.display = "none";
-
-               var returnfield = document.createElement('input');
-               returnfield.setAttribute('name', 'values_assign');
-               returnfield.setAttribute('type', 'text');
-               returnfield.setAttribute('value', values_return);
-               mydiv.appendChild(returnfield);
-               
-               var control_id_field = document.createElement('input');
-               control_id_field.setAttribute('name', 'control_id');
-               control_id_field.setAttribute('type', 'text');
-               control_id_field.setAttribute('value', control_id_value);
-               mydiv.appendChild(control_id_field);
        }
 

Modified: trunk/registration/templates/base/pending_users.xsl
===================================================================
--- trunk/registration/templates/base/pending_users.xsl 2012-03-25 19:28:01 UTC 
(rev 9031)
+++ trunk/registration/templates/base/pending_users.xsl 2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -82,20 +82,17 @@
 </xsl:template>
 
 <xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
-       <script type="text/javascript">
-       <![CDATA[
-       ]]>
-       </script>
        <div id="data_paginator"/>
-       <div class="error_msg" style="margin-left:20px;">Du må velge bygg før 
du kan legge til en kontroll</div>
+       <div class="error_msg" style="margin-left:20px;">Du må velge bruker for 
godkjenning</div>
        <div id="datatable-container"/>
        
        <xsl:call-template name="datasource-definition" />
        <xsl:variable name="label_submit"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
        <xsl:variable name="label_checkAll"><xsl:value-of 
select="php:function('lang', 'invert_checkboxes')" /></xsl:variable>
        <div><input type="button" id="select_all" value="{$label_checkAll}" 
onclick="checkAll('mychecks')"/></div>
-       <form action="#" name="location_form" id="location_form" method="post">
-               <div class="location_submit"><input type="submit" 
name="save_location" id="save_location" value="{$label_submit}" onclick="return 
saveLocationToControl()"/></div>
+       
+       <form action="#" name="user_form" id="user_form" method="post">
+               <div class="user_submit"><input type="submit" 
name="values[save_user]" id="save_user" value="{$label_submit}" onclick="return 
onSave()"/></div>
        </form>
 </xsl:template>
 
@@ -130,7 +127,7 @@
                var main_container = 'datatable-container';
                var main_table_id = 'datatable';
                var main_pag = 'data_paginator';
-               var related_table = new Array('locations_table');
+               var related_table = new Array('users_table');
        
                setDataSource(main_source, main_columnDefs, main_form, 
main_filters, main_container, main_pag, main_table_id, related_table ); 
                

Added: trunk/registration/templates/base/user_edit.xsl
===================================================================
--- trunk/registration/templates/base/user_edit.xsl                             
(rev 0)
+++ trunk/registration/templates/base/user_edit.xsl     2012-03-26 13:47:10 UTC 
(rev 9032)
@@ -0,0 +1,184 @@
+<!-- $Id: control_item.xsl 8913 2012-02-17 10:14:42Z erikhl $ -->
+<!-- item  -->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+
+<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')" />
+</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">
+                               <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>
+                               
+                               <div class="form-buttons">
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
+                                                       <xsl:variable 
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')" 
/></xsl:variable>
+                                                       <input type="submit" 
name="save" value="{$lang_save}" title = "{$lang_save}" />
+                                                       <input type="submit" 
name="cancel" value="{$lang_cancel}" title = "{$lang_cancel}" />
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:variable 
name="lang_edit"><xsl:value-of select="php:function('lang', 'edit')" 
/></xsl:variable>
+                                                       <input type="submit" 
name="edit" value="{$lang_edit}" title = "{$lang_edit}" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </div>
+                               
+                       </form>
+                                               
+               </div>
+       </div>
+</xsl:template>
+       
+<xsl:template match="options">
+       <option value="{id}">
+               <xsl:if test="selected != 0">
+                       <xsl:attribute name="selected" value="selected" />
+               </xsl:if>
+               <xsl:value-of disable-output-escaping="yes" select="name"/>
+       </option>
+</xsl:template>
+




reply via email to

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