Index: /extensions/user_custom_fields/admin.php =================================================================== --- /extensions/user_custom_fields/admin.php (revision 31534) +++ /extensions/user_custom_fields/admin.php (revision 31534) @@ -0,0 +1,207 @@ +add('ucf', l10n('User custom fields'), UCF_ADMIN . '-define_custom'); + $tabsheet->select($page['tab']); + $tabsheet->assign(); + +switch ($page['tab']) { + case 'define_custom': + $admin_base_url = UCF_ADMIN . '-define_custom'; + $template->assign( + 'addinfotemplate', array( + 'addinfo' => l10n('addinfo'), + )); + + $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); + if($PAED['state'] == 'active'){ + add_event_handler('AP_render_content', 'get_user_language_desc'); + $template->assign('useED',1); + }else{ + $template->assign('useED',0); + } + + $tab_user_custom_fields = tab_user_custom_fields(); + + if (pwg_db_num_rows($tab_user_custom_fields)) { + while ($user_custom_fields = pwg_db_fetch_assoc($tab_user_custom_fields)) { + $items = array( + 'IDUCF' => $user_custom_fields['id_ucf'], + 'UCFORDER' => $user_custom_fields['order_ucf'], + 'UCFACTIVE' => $user_custom_fields['active'], + 'UCFEDIT' => $user_custom_fields['edit'], + 'UCFADMINONLY' => $user_custom_fields['adminonly'], + 'UCFOBLIGATORY' => $user_custom_fields['obligatory'], + 'U_HIDE' => $admin_base_url . '&hide=' . $user_custom_fields['id_ucf'], + 'U_SHOW' => $admin_base_url . '&show=' . $user_custom_fields['id_ucf'], + 'U_ADMINONLYHIDE' => $admin_base_url . '&adminonlyh=' . $user_custom_fields['id_ucf'], + 'U_ADMINONLYSHOW' => $admin_base_url . '&adminonlys=' . $user_custom_fields['id_ucf'], + 'U_OBLIGATORYHIDE' => $admin_base_url . '&obligatoryh=' . $user_custom_fields['id_ucf'], + 'U_OBLIGATORYSHOW' => $admin_base_url . '&obligatorys=' . $user_custom_fields['id_ucf'], + ); + if($user_custom_fields['id_ucf']==1){ + $items['UCFWORDING'] = l10n('Username'); + $items['UCFOBLO'] = 0; + }else if($user_custom_fields['id_ucf']==2){ + $items['UCFWORDING'] = l10n('Password'); + $items['UCFOBLO'] = 0; + }else if($user_custom_fields['id_ucf']==3){ + $items['UCFWORDING'] = l10n('Email address'); + $items['UCFOBLO'] = 1; + }else if($user_custom_fields['id_ucf']==4){ + $items['UCFWORDING'] = l10n('Send my connection settings by email'); + $items['UCFOBLO'] = 1; + }else{ + $items['UCFWORDING'] = trigger_change('AP_render_content',$user_custom_fields['wording']); + $items['UCFOBLO'] = 1; + } + $template->append('user_custom_fields', $items); + } + } + + if (isset($_POST['submitManualOrderInfo'])){ + + asort($_POST['infoOrd'], SORT_NUMERIC); + + $data = array(); + foreach ($_POST['infoOrd'] as $id =>$val){ + + $data[] = array('id_ucf' => $id, 'order_ucf' => $val+1); + } + $fields = array('primary' => array('id_ucf'), 'update' => array('order_ucf')); + mass_updates(UCF_TABLE, $fields, $data); + + $page['infos'][] = l10n('Properties manual order was saved'); + redirect($admin_base_url); + } + + if (isset($_POST['submitUCF'])) { + if(!isset($_POST['inseractive'])){ + $active = 1; + }else{ + $active = 0; + } + if(!isset($_POST['adminonly'])){ + $adminonly = 0; + }else{ + $adminonly = 1; + } + if(!isset($_POST['obligatory'])){ + $obligatory = 0; + }else{ + $obligatory = 1; + } + if ($_POST['invisibleID'] == 0) { + $result = pwg_query('SELECT MAX(order_ucf) FROM '. UCF_TABLE ); + $row = pwg_db_fetch_assoc($result); + $or = ($row['MAX(order_ucf)'] + 1); + + $q = ' + INSERT INTO ' . $prefixeTable . 'user_custom_fields(wording,order_ucf,active,edit,adminonly,obligatory)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $active . '",1,'.$adminonly.','.$obligatory.');'; + pwg_query($q); + $_SESSION['page_infos'] = array(l10n('Custom fields add')); + } else { + $q = ' + UPDATE ' . $prefixeTable . 'user_custom_fields' + . ' set wording ="' . $_POST['inserwording'] . '" ' + . ' ,active=' . $active + . ' ,adminonly=' . $adminonly + . ' ,obligatory=' . $obligatory + . ' WHERE id_ucf=' . $_POST['invisibleID'] . ';'; + pwg_query($q); + $_SESSION['page_infos'] = array(l10n('Custom fields update')); + } + redirect($admin_base_url); + } + + if (isset($_GET['delete'])) { + check_input_parameter('delete', $_GET, false, PATTERN_ID); + $query = 'DELETE FROM ' . UCF_TABLE . ' WHERE id_ucf = ' . $_GET['delete'] . ';'; + pwg_query($query); + $query = 'DELETE FROM ' . UCFD_TABLE . ' WHERE id_ucf = ' . $_GET['delete'] . ';'; + pwg_query($query); + + $_SESSION['page_infos'] = array(l10n('Custom fields delete')); + redirect($admin_base_url); + } + + if (isset($_GET['hide'])) { + check_input_parameter('hide', $_GET, false, PATTERN_ID); + $query = 'UPDATE ' . UCF_TABLE . ' SET active = 0 WHERE id_ucf=' . $_GET['hide'] . ';'; + pwg_query($query); + } + + if (isset($_GET['show'])) { + check_input_parameter('show', $_GET, false, PATTERN_ID); + $query = 'UPDATE ' . UCF_TABLE . ' SET active = 1 WHERE id_ucf=' . $_GET['show'] . ';'; + pwg_query($query); + } + + if (isset($_GET['adminonlyh'])) { + check_input_parameter('adminonlyh', $_GET, false, PATTERN_ID); + $query = 'UPDATE ' . UCF_TABLE . ' SET adminonly = 1 WHERE id_ucf=' . $_GET['adminonlyh'] . ';'; + pwg_query($query); + } + if (isset($_GET['adminonlys'])) { + check_input_parameter('adminonlys', $_GET, false, PATTERN_ID); + $query = 'UPDATE ' . UCF_TABLE . ' SET adminonly = 0 WHERE id_ucf=' . $_GET['adminonlys'] . ';'; + pwg_query($query); + } + if (isset($_GET['obligatoryh'])) { + check_input_parameter('obligatoryh', $_GET, false, PATTERN_ID); + if($_GET['obligatoryh']==3){ + conf_update_param('obligatory_user_mail_address', true); + } + $query = 'UPDATE ' . UCF_TABLE . ' SET obligatory = 1 WHERE id_ucf=' . $_GET['obligatoryh'] . ';'; + pwg_query($query); + } + if (isset($_GET['obligatorys'])) { + check_input_parameter('obligatorys', $_GET, false, PATTERN_ID); + if($_GET['obligatorys']==3){ + conf_update_param('obligatory_user_mail_address', false); + } + $query = 'UPDATE ' . UCF_TABLE . ' SET obligatory = 0 WHERE id_ucf=' . $_GET['obligatorys'] . ';'; + pwg_query($query); + } + break; + } + + +$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); +$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); +?> Index: /extensions/user_custom_fields/admin.tpl =================================================================== --- /extensions/user_custom_fields/admin.tpl (revision 31534) +++ /extensions/user_custom_fields/admin.tpl (revision 31534) @@ -0,0 +1,274 @@ +{combine_script id='jquery.ui.sortable' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.sortable.min.js'} +{combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'} +{footer_script} +jQuery(document).ready(function(){ + jQuery(".drag_button").show(); + jQuery(".categoryLi").css("cursor","move"); + jQuery(".categoryUl").sortable({ + axis: "y", + opacity: 0.8, + update : function() { + jQuery("#manualOrderInfo").show(); + } + }); + + jQuery("#infoOrdering").submit(function(){ + ar = jQuery('.categoryUl').sortable('toArray'); + for(i=0;i < ar.length ;i++) { + iord = ar[i].split('iord_'); + document.getElementsByName('infoOrd[' + iord[1] + ']')[0].value = i; + } + }); + + jQuery("#cancelManualOrderInfo").click(function(){ + jQuery(".categoryUl").sortable("cancel"); + jQuery("#manualOrderInfo").hide(); + }); + + jQuery('.categoryLi').mouseover(function(){ + jQuery(this).children('span').show(); + }); + jQuery('.categoryLi').mouseout(function(){ + jQuery(this).children('span').hide(); + }); + + jQuery('#aip_sumit').click(function(){ + jQuery("#add_info_edit").show(); + jQuery("#leg_add").show(); + jQuery("#leg_edit").hide(); + jQuery('#aip_add').empty(); + jQuery('#aip_hide').attr('checked', false); + jQuery('#aip_adminonly').attr('checked', false); + jQuery('#hideid').val(0); + jQuery("textarea[name=inserwording]").focus(); + }); + + jQuery("#addinfoClose").click(function(){ + jQuery("#add_info_edit").hide(); + }); + + jQuery('.pphide').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link2'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#pphide'+id).hide(); + jQuery('#ppshow'+id).show(); + jQuery('#iord_'+id).css("opacity","0.4"); + $('#edit_libinfo'+id).attr('data-hide', 0); + } + }); + }); + jQuery('.ppshow').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link2'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#pphide'+id).show(); + jQuery('#ppshow'+id).hide(); + jQuery('#iord_'+id).css("opacity","1"); + $('#edit_libinfo'+id).attr('data-hide', 1); + } + }); + }); + jQuery('.ppadminonlyh').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link3'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#ppadminonlyh'+id).hide(); + jQuery('#ppadminonlys'+id).show(); + $('#edit_libinfo'+id).attr('data-adminonly', 1); + } + }); + }); + jQuery('.ppadminonlys').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link3'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#ppadminonlyh'+id).show(); + jQuery('#ppadminonlys'+id).hide(); + $('#edit_libinfo'+id).attr('data-adminonly', 0); + } + }); + }); + + jQuery('.ppobligatoryh').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link4'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#ppobligatoryh'+id).hide(); + jQuery('#ppobligatorys'+id).show(); + $('#edit_libinfo'+id).attr('data-obligatory', 1); + } + }); + }); + jQuery('.ppobligatorys').click(function(){ + var id= $(this).data('id'); + var link= $(this).data('link4'); + $.ajax({ + method: 'POST', + url: link, + success: function(Datalc,textStatus,jqXHR) { + jQuery('#ppobligatoryh'+id).show(); + jQuery('#ppobligatorys'+id).hide(); + $('#edit_libinfo'+id).attr('data-obligatory', 0); + } + }); + }); + + jQuery('.edit_libinfo').click(function(){ + var id_prop_photo=$(this).data('id'); + var lib=$(this).data('lib'); + var hide=$(this).data('hide'); + var adminonly=$(this).data('adminonly'); + var obligatory=$(this).data('obligatory'); + jQuery("#add_info_edit").show(); + jQuery("#leg_add").hide(); + jQuery("#leg_edit").show(); + jQuery('#hideid').val(id_prop_photo); + jQuery('#aip_add').text(lib); + if(hide==1){ + jQuery('#aip_hide').prop('checked', false); + }else{ + jQuery('#aip_hide').prop('checked', true); + } + if(adminonly==0){ + jQuery('#aip_adminonly').prop('checked', false); + }else{ + jQuery('#aip_adminonly').prop('checked', true); + } + if(obligatory==0){ + jQuery('#aip_obligatory').prop('checked', false); + }else{ + jQuery('#aip_obligatory').prop('checked', true); + } + jQuery("textarea[name=inserwording]").focus(); + + }); + +}); +{/footer_script} +{html_style} +.mouse:hover{ + cursor:pointer; +} +{/html_style} + + +
+ {'Create new custom filds'|@translate} +
+ + +{/if} +{if isset ($gestionD)} +