Browse Source

More fixes

Julio Montoya 12 years ago
parent
commit
58ef871330

+ 156 - 0
main/admin/extra_field_options.php

@@ -0,0 +1,156 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ *  @package chamilo.admin
+ */
+
+// Language files that need to be included.
+$language_file = array('admin');
+
+$cidReset = true;
+require_once '../inc/global.inc.php';
+
+$this_section = SECTION_PLATFORM_ADMIN;
+
+api_protect_admin_script();
+
+//Add the JS needed to use the jqgrid
+$htmlHeadXtra[] = api_get_jqgrid_js();
+
+// setting breadcrumbs
+$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
+
+$tool_name = null;
+
+$action = isset($_GET['action']) ? $_GET['action'] : null;
+$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : null;
+$type = 'session';
+
+if (empty($field_id)) {
+    api_not_allowed();
+}
+
+$extra_field = new ExtraField($type);
+$extra_field_info = $extra_field->get($field_id);
+
+
+$check = Security::check_token('request');
+$token = Security::get_token();    
+
+if ($action == 'add') {
+    $interbreadcrumb[]=array('url' => 'session_fields.php','name' => get_lang('SessionFields'));
+    $interbreadcrumb[]=array('url' => '#','name' => get_lang('Add'));
+} elseif ($action == 'edit') {
+    $interbreadcrumb[]=array('url' => 'session_fields.php','name' => get_lang('SessionFields'));    
+    $interbreadcrumb[]=array('url' => '#','name' => get_lang('Edit'));
+} else {
+    $interbreadcrumb[]=array('url' => 'session_fields.php','name' => get_lang('SessionFields'));
+    $interbreadcrumb[]=array('url' => 'session_fields.php?action=edit&id='.$extra_field_info['id'],'name' => $extra_field_info['field_display_text']);
+    $interbreadcrumb[]=array('url' => '#','name' => get_lang('EditOptions'));
+}
+
+//jqgrid will use this URL to do the selects
+$params = 'field_id='.$field_id.'&type='.$type;
+$url            = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_extra_field_options&'.$params;
+
+//The order is important you need to check the the $column variable in the model.ajax.php file 
+$columns        = array(get_lang('Name'), get_lang('Value'),  get_lang('Order'), get_lang('Actions'));
+  
+//Column config
+$column_model   = array(
+                        array('name'=>'option_display_text', 'index'=>'option_display_text',      'width'=>'180',   'align'=>'left'),
+                        array('name'=>'option_value',       'index'=>'option_value',          'width'=>'',  'align'=>'left','sortable'=>'false'),
+                        array('name'=>'option_order',         'index'=>'option_order',              'width'=>'',  'align'=>'left','sortable'=>'false'),
+                        array('name'=>'actions',            'index'=>'actions',                 'width'=>'100',  'align'=>'left','formatter'=>'action_formatter','sortable'=>'false')
+                       );            
+//Autowidth             
+$extra_params['autowidth'] = 'true';
+//height auto 
+$extra_params['height'] = 'auto'; 
+
+//With this function we can add actions to the jgrid (edit, delete, etc)
+$action_links = 'function action_formatter(cellvalue, options, rowObject) {
+                         return \'<a href="?action=edit&'.$params.'&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
+                         '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&'.$params.'&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
+                         '\'; 
+                 }';
+$htmlHeadXtra[]='
+<script>
+$(function() {
+    // grid definition see the $obj->display() function
+    '.Display::grid_js('extra_field_options',  $url, $columns, $column_model, $extra_params, array(), $action_links,true).'
+    
+});
+</script>';
+
+// The header.
+Display::display_header($tool_name);
+
+$obj = new ExtraFieldOption($type);
+
+// Action handling: Add
+switch ($action) {
+    case 'add':
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
+            api_not_allowed();
+        }        
+        $url  = api_get_self().'?action='.Security::remove_XSS($_GET['action']);
+        $form = $obj->return_form($url, 'add');
+
+        // The validation or display
+        if ($form->validate()) {          
+            if ($check) {
+                $values = $form->exportValues();       
+                $res    = $obj->save($values);            
+                if ($res) {
+                    Display::display_confirmation_message(get_lang('ItemAdded'));
+                }
+            }        
+            $obj->display();
+        } else {
+            echo '<div class="actions">';
+            echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
+            echo '</div>';            
+            $form->addElement('hidden', 'sec_token');
+            $form->setConstants(array('sec_token' => $token));
+            $form->display();
+        }
+        break;
+    case 'edit':
+        // Action handling: Editing 
+        $url  = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
+        $form = $obj->return_form($url, 'edit');    
+
+        // The validation or display
+        if ($form->validate()) {            
+            if ($check) {
+                $values = $form->exportValues();                
+                $res    = $obj->update($values);                
+                Display::display_confirmation_message(sprintf(get_lang('ItemUpdated'), $values['name']), false);                
+            }            
+            $obj->display();
+        } else {
+            echo '<div class="actions">';
+            echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
+            echo '</div>';
+            $form->addElement('hidden', 'sec_token');
+            $form->setConstants(array('sec_token' => $token));
+            $form->display();
+        }
+        break;
+    case 'delete':
+        // Action handling: delete
+        if ($check) {
+            $res = $obj->delete($_GET['id']);
+            if ($res) {
+                Display::display_confirmation_message(get_lang('ItemDeleted'));
+            }
+        }
+        $obj->display();
+        break;
+    default:
+        $obj->display();   
+        break;
+}
+Display :: display_footer();

+ 0 - 175
main/admin/fields_options.php

@@ -1,175 +0,0 @@
-<?php
-
-/* For licensing terms, see /license.txt */
-/**
- * 	@package chamilo.admin
- */
-// name of the language file that needs to be included
-$language_file = array('admin', 'registration');
-
-// resetting the course information
-$cidReset = true;
-
-// including the global library
-require '../inc/global.inc.php';
-
-// section for the tabs
-$this_section = SECTION_PLATFORM_ADMIN;
-
-// user permissions
-api_protect_admin_script();
-
-// breadcrumbs
-$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array('url' => 'user_fields.php', 'name' => get_lang('UserFields'));
-$interbreadcrumb[] = array('url' => 'user_fields_add.php?action=edit&field_id=' . Security::remove_XSS($_GET['field_id']) . '&amp;sec_token=' . $_SESSION['sec_token'], 'name' => get_lang('EditUserFields'));
-
-// name of the tools
-$tool_name = get_lang('UserFieldsSortOptions');
-
-// display header
-Display::display_header($tool_name);
-
-if (isset($_GET['action'])) {
-    $check = Security::check_token('get');
-    if ($check) {
-        switch ($_GET['action']) {
-            case 'moveup' :
-                if (api_is_platform_admin() && !empty($_GET['option_id'])) {
-                    if (move_user_field_option('moveup', $_GET['option_id'])) {
-                        Display :: display_confirmation_message(get_lang('FieldOptionMovedUp'));
-                    } else {
-                        Display :: display_error_message(get_lang('CannotMoveFieldOption'));
-                    }
-                }
-                break;
-            case 'movedown' :
-                if (api_is_platform_admin() && !empty($_GET['option_id'])) {
-                    if (move_user_field_option('movedown', $_GET['option_id'])) {
-                        Display :: display_confirmation_message(get_lang('FieldOptionMovedDown'));
-                    } else {
-                        Display :: display_error_message(get_lang('CannotMoveFieldOption'));
-                    }
-                }
-                break;
-        }
-    }
-}
-
-// getting all the information of the field
-$field_info = UserManager::get_extra_field_information($_GET['field_id']);
-echo Display::page_header($field_info['3']);
-
-// the total number of options (used in the actions_filter function but declared here for performance reasons)
-$number_of_options = get_number_of_options();
-
-// displaying the sortable table
-$parameters['sec_token'] = Security::get_token();
-$parameters['field_id'] = Security::remove_XSS($_GET['field_id']);
-$table = new SortableTable('options', 'get_number_of_options', 'get_options_data', 2);
-$table->set_additional_parameters($parameters);
-$table->set_header(0, get_lang('DisplayOrder'), false);
-$table->set_header(1, get_lang('OptionText'), false);
-$table->set_header(2, get_lang('Actions'), false);
-$table->set_column_filter(2, 'actions_filter');
-$table->display();
-
-// display footer
-Display::display_footer();
-
-function get_options_data($from, $number_of_items, $column, $direction) {
-    // Database table definition
-    $table_userfields_options = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
-
-    // The sql statement
-    $sql = "SELECT
-				option_order 		AS col0,
-				option_display_text	AS col1,
-				id 					AS col2
-			FROM $table_userfields_options WHERE field_id='" . Database::escape_string($_GET['field_id']) . "' ORDER BY option_order ASC";
-    $sql .= " LIMIT $from,$number_of_items";
-    $res = Database::query($sql);
-    $return = array();
-    while ($option = Database::fetch_row($res)) {
-        $return[] = $option;
-    }
-    return $return;
-}
-
-function get_number_of_options($from = null, $number_of_items = null, $column = null, $direction = null) {
-    // Database table definition
-    $table_userfields_options = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
-
-    // The sql statement
-    $sql = "SELECT count(id) as total FROM $table_userfields_options WHERE field_id='" . Database::escape_string($_GET['field_id']) . "' ";
-    $res = Database::query($sql);
-    $row = Database::fetch_row($res);
-    return $row[0];
-}
-
-function actions_filter($option_id, $url_params, $row) {
-    global $number_of_options;
-
-    if ($row[0] <> 1) {
-        $return .= '<a href="' . api_get_self() . '?action=moveup&amp;option_id=' . $option_id . '&amp;field_id=' . Security::remove_XSS($_GET['field_id']) . '&amp;sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('up.gif', get_lang('Up')) . '</a>';
-    } else {
-        $return .= Display::return_icon('blank.gif', '', array('width' => '21px'));
-    }
-
-    // the down icon only has to appear when the row can be moved down (all but the last row)
-    if ($row[0] <> $number_of_options) {
-        $return .= '<a href="' . api_get_self() . '?action=movedown&amp;option_id=' . $option_id . '&amp;field_id=' . Security::remove_XSS($_GET['field_id']) . '&amp;sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('down.gif', get_lang('Down')) . '</a>';
-    }
-    return $return;
-}
-
-/**
- * Move a user defined field option up or down
- *
- * @param string $direction the direction we have to move the field to (up or down)
- * @param unknown_type $field_id
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
- * @version July 2008
- * @since Dokeos 1.8.6
- */
-function move_user_field_option($direction, $option_id) {
-    // Database table definition
-    $table_userfields_options = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
-
-    // check the parameters
-    if (!in_array($direction, array('moveup', 'movedown')) OR !is_numeric($option_id)) {
-        return false;
-    }
-
-    // determine the SQL sort direction
-    if ($direction == 'moveup') {
-        $sortdirection = 'DESC';
-    } else {
-        $sortdirection = 'ASC';
-    }
-
-    $found = false;
-
-    $sql = "SELECT id, option_order FROM $table_userfields_options  WHERE field_id='" . Database::escape_string($_GET['field_id']) . "' ORDER BY option_order $sortdirection";
-    $result = Database::query($sql);
-    while ($row = Database::fetch_array($result)) {
-        if ($found) {
-            $next_id = $row['id'];
-            $next_order = $row['option_order'];
-            break;
-        }
-
-        if ($option_id == $row['id']) {
-            $this_id = $row['id'];
-            $this_order = $row['option_order'];
-            $found = true;
-        }
-    }
-
-    $sql1 = "UPDATE " . $table_userfields_options . " SET option_order = '" . Database::escape_string($next_order) . "' WHERE id =  '" . Database::escape_string($this_id) . "'";
-    $sql2 = "UPDATE " . $table_userfields_options . " SET option_order = '" . Database::escape_string($this_order) . "' WHERE id =  '" . Database::escape_string($next_id) . "'";
-    Database::query($sql1);
-    Database::query($sql2);
-    return true;
-}

+ 2 - 2
main/admin/session_fields.php

@@ -39,7 +39,7 @@ if ($action == 'add') {
 }
 
 //jqgrid will use this URL to do the selects
-$url            = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_fields';
+$url            = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_extra_fields&type=session';
 
 //The order is important you need to check the the $column variable in the model.ajax.php file 
 $columns        = array(get_lang('Name'), get_lang('FieldLabel'),  get_lang('Type'), get_lang('FieldChangeability'), get_lang('Visibility'), get_lang('Filter'), get_lang('Actions'));
@@ -69,7 +69,7 @@ $htmlHeadXtra[]='
 <script>
 $(function() {
     // grid definition see the $obj->display() function
-    '.Display::grid_js('session_fields',  $url,$columns,$column_model,$extra_params, array(), $action_links,true).'
+    '.Display::grid_js('session_fields',  $url, $columns, $column_model, $extra_params, array(), $action_links,true).'
             
     $("#field_type").on("change", function() {      
         id = $(this).val();        

+ 35 - 12
main/inc/ajax/model.ajax.php

@@ -143,10 +143,17 @@ switch ($action) {
     case 'get_sessions':           
         $count = SessionManager::get_count_admin();
         break;
-    case 'get_session_fields':
-        $obj = new SessionField();
+    case 'get_extra_fields':
+        $type = $_REQUEST['type'];
+        $obj = new ExtraField($type);
         $count = $obj->get_count();
         break;
+    case 'get_extra_field_options':
+        $type = $_REQUEST['type'];
+        $field_id = $_REQUEST['field_id'];
+        $obj = new ExtraFieldOption($type);
+        $count = $obj->get_count_by_field_id($field_id);
+        break;    
     case 'get_timelines':
         require_once $libpath.'timeline.lib.php';
         $obj        = new Timeline();
@@ -330,7 +337,7 @@ switch ($action) {
         if(!in_array($sidx, $columns)) {
         	$sidx = 'subject';
         }
-        $result     = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));        
+        $result = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));        
         $new_result = array();
         foreach ($result as $item) {
             $language_info = api_get_language_info($item['language_id']);
@@ -407,8 +414,9 @@ switch ($action) {
         //Multidimensional sort
         msort($result, $sidx);
         break;        
-    case 'get_session_fields':
-        $obj = new SessionField();
+    
+    case 'get_extra_fields':         
+        $obj = new ExtraField($type);
         $columns = array('field_display_text', 'field_variable', 'field_type', 'field_changeable', 'field_visible', 'field_filter');
         $result  = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
         $new_result = array();
@@ -416,15 +424,29 @@ switch ($action) {
             foreach ($result as $item) {            
                 $item['field_type']         = $obj->get_field_type_by_id($item['field_type']);
                 $item['field_changeable']   = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
-                $item['field_visible']   = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
-                $item['field_filter']   = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
-                
-                
+                $item['field_visible']      = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
+                $item['field_filter']       = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                 $new_result[]        = $item;
             }
             $result = $new_result;
-        }  
-        
+        }        
+        break;
+    case 'get_extra_field_options':
+        $obj = new ExtraFieldOption($type);
+        $columns = array('option_display_text', 'option_value', 'option_order');
+        $result  = Database::select('*', $obj->table, array('where' => array("field_id = ? " => $field_id),'order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
+        /*$new_result = array();
+        if (!empty($result)) {
+            foreach ($result as $item) {            
+                $item['field_type']         = $obj->get_field_type_by_id($item['field_type']);
+                $item['field_changeable']   = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
+                $item['field_visible']      = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
+                $item['field_filter']       = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
+                $new_result[]        = $item;
+            }
+            $result = $new_result;
+        }*/  
+
         break;
     default:    
         exit;            
@@ -442,7 +464,8 @@ $allowed_actions = array('get_careers',
                          'get_grade_models', 
                          'get_event_email_template',
                          'get_user_skill_ranking',
-                         'get_session_fields'
+                         'get_extra_fields',
+                         'get_extra_field_options'
 );
                          	
 //5. Creating an obj to return a json

+ 53 - 0
main/inc/lib/extra_field.lib.php

@@ -110,6 +110,59 @@ class ExtraField extends model {
         return $types;
     }
     
+        
+    public function add_elements($form, $item_id = null) {
+        if (empty($form)) {
+            return false;
+        }   
+        $extra_data = false;
+        if (!empty($item_id)) {
+            $extra_data = self::get_handler_extra_data($item_id);            
+            if ($form) {
+                $form->setDefaults($extra_data);
+            }            
+        }        
+        $extra_fields = self::get_all();        
+        $extra = ExtraField::set_extra_fields_in_form($form, $extra_data, $this->type.'_field', false, false, $this->type, $extra_fields);        
+        return $extra;
+    }
+      
+    
+    public function get_handler_extra_data($item_id) {
+        if (empty($item_id)) {
+            return array();
+        }
+		$extra_data = array();		
+        $fields = self::get_all();        
+        $session_field_values = new ExtraFieldValue($this->type);		
+		
+		if (!empty($fields) > 0) {
+			foreach ($fields as $field) {
+                $field_value = $session_field_values->get_values_by_handler_and_field_id($item_id, $field['id']);                    
+                if ($field_value) {
+                    $field_value = $field_value['field_value'];                    
+                    
+                    switch ($field['field_type']) {
+                        case ExtraField::FIELD_TYPE_DOUBLE_SELECT:                            
+                            $selected_options = explode('::', $field_value);                            
+                            $extra_data['extra_'.$field['field_variable']]['extra_'.$field['field_variable']] = $selected_options[0];
+                            $extra_data['extra_'.$field['field_variable']]['extra_'.$field['field_variable'].'_second'] = $selected_options[1];
+                            break;
+                        case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
+                            $field_value = explode(';', $field_value);                                
+                        case ExtraField::FIELD_TYPE_RADIO:
+                            $extra_data['extra_'.$field['field_variable']]['extra_'.$field['field_variable']] = $field_value;
+                            break;
+                        default:
+                            $extra_data['extra_'.$field['field_variable']] = $field_value;
+                            break;
+                    }
+                }				
+			}
+		}        
+		return $extra_data;
+    }
+    
     public static function get_all_extra_field_by_type($field_type) {		
 		// all the information of the field
 		$sql = "SELECT * FROM  {$this->table} WHERE field_type='".Database::escape_string($field_type)."'";

+ 53 - 1
main/inc/lib/extra_field_option.lib.php

@@ -19,7 +19,12 @@ class ExtraFieldOption extends Model {
     public function get_count() {
         $row = Database::select('count(*) as count', $this->table, array(), 'first');
         return $row['count'];
-    }    
+    }  
+    
+    public function get_count_by_field_id($field_id) {
+        $row = Database::select('count(*) as count', $this->table, array('where' => array('field_id = ?', $field_id)), 'first');
+        return $row['count'];
+    }
     
     public function get_field_options_to_string($field_id) {
         $options = self::get_field_options_by_field($field_id);
@@ -241,4 +246,51 @@ class ExtraFieldOption extends Model {
     public function update($params) {
         parent::update($params);
     }
+    
+    //Form
+    
+    function display() {
+        // action links
+        echo '<div class="actions">';
+       	echo  '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'', ICON_SIZE_MEDIUM).'</a>';	   
+        //echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add_user_fields.png',get_lang('Add'),'', ICON_SIZE_MEDIUM).'</a>';               
+
+        echo '</div>';
+        echo Display::grid_html('extra_field_options');
+    }
+    
+    public function return_form($url, $action) {
+		$form_name = $this->type.'_field';
+        $form = new FormValidator($form_name, 'post', $url);
+        // Settting the form elements
+        $header = get_lang('Add');        
+        if ($action == 'edit') {
+            $header = get_lang('Modify');
+        }
+        
+        $form->addElement('header', $header);
+        $id = isset($_GET['id']) ? intval($_GET['id']) : '';
+        $form->addElement('hidden', 'id', $id);        
+        
+        $form->addElement('text', 'option_display_text', get_lang('Name'), array('class' => 'span5'));  
+        $form->addElement('text', 'option_value', get_lang('Value'), array('class' => 'span5'));  
+        
+        $defaults = array();
+        
+        if ($action == 'edit') {
+            // Setting the defaults
+            $defaults = $this->get($id);                        
+        	$form->addElement('button', 'submit', get_lang('Modify'), 'class="save"');
+        } else {            
+        	$form->addElement('button', 'submit', get_lang('Add'), 'class="save"');
+        }
+        
+        $form->setDefaults($defaults);
+    
+        // Setting the rules
+        $form->addRule('option_display_text', get_lang('ThisFieldIsRequired'), 'required');        
+        //$form->addRule('field_variable', get_lang('ThisFieldIsRequired'), 'required');
+        $form->addRule('option_value', get_lang('ThisFieldIsRequired'), 'required');        
+		return $form;
+    }    
 }

+ 4 - 52
main/inc/lib/session_field.lib.php

@@ -7,59 +7,7 @@ class SessionField extends ExtraField {
     public function __construct() {
        parent::__construct('session');
     }
-    
-    public function add_elements($form, $session_id = null) {
-        if (empty($form)) {
-            return false;
-        }   
-        $extra_data = false;
-        if (!empty($session_id)) {
-            $extra_data = self::get_session_extra_data($session_id);            
-            if ($form) {
-                $form->setDefaults($extra_data);
-            }            
-        }        
-        $extra_fields = self::get_all();        
-        $extra = ExtraField::set_extra_fields_in_form($form, $extra_data, 'session_field', false, false, 'session', $extra_fields);        
-        return $extra;
-    }
-     
-    public function get_session_extra_data($session_id) {
-        if (empty($session_id)) {
-            return array();
-        }
-		$extra_data = array();		
-        $session_fields = self::get_all();        
-        $session_field_values = new SessionFieldValue();		
-		
-		if (!empty($session_fields) > 0) {
-			foreach ($session_fields as $session_field) {
-                $field_value = $session_field_values->get_values_by_handler_and_field_id($session_id, $session_field['id']);                    
-                if ($field_value) {
-                    $field_value = $field_value['field_value'];                    
-                    
-                    switch ($session_field['field_type']) {
-                        case ExtraField::FIELD_TYPE_DOUBLE_SELECT:                            
-                            $selected_options = explode('::', $field_value);                            
-                            $extra_data['extra_'.$session_field['field_variable']]['extra_'.$session_field['field_variable']] = $selected_options[0];
-                            $extra_data['extra_'.$session_field['field_variable']]['extra_'.$session_field['field_variable'].'_second'] = $selected_options[1];
-                            break;
-                        case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
-                            $field_value = explode(';', $field_value);                                
-                        case ExtraField::FIELD_TYPE_RADIO:
-                            $extra_data['extra_'.$session_field['field_variable']]['extra_'.$session_field['field_variable']] = $field_value;
-                            break;
-                        default:
-                            $extra_data['extra_'.$session_field['field_variable']] = $field_value;
-                            break;
-                    }
-                }				
-			}
-		}        
-		return $extra_data;
-    }
 
-    
     function display() {
         // action links
         echo '<div class="actions">';
@@ -96,6 +44,10 @@ class SessionField extends ExtraField {
        
         $form->addElement('text', 'field_variable', get_lang('FieldLabel'), array('class' => 'span5'));        
         $form->addElement('text', 'field_options', get_lang('FieldPossibleValues'), array('id' => 'field_options', 'class' => 'span6'));        
+        if ($action == 'edit') {
+            $url = Display::url(get_lang('EditOptions'), 'extra_field_options.php?type=session&field_id='.$id);
+            $form->addElement('label', null, $url);
+        }
         $form->addElement('text', 'field_default_value', get_lang('FieldDefaultValue'), array('id' => 'field_default_value', 'class' => 'span5'));        
                 
         $group = array();