File indexing completed on 2024-12-29 05:24:48
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 $gidsstring = Zend_Registry::get('config')->settings->client->default->tag_group_osuser; 0024 $gids = explode(",", $gidsstring); 0025 $model = new Default_Model_Tags(); 0026 $data = $model->getTagGroupsOSUser(); 0027 $data2 = $model->getTagsOSUser($this->member->member_id); 0028 $usertags = array(); 0029 foreach ($data2 as $t) { 0030 $usertags[$t['tag_id']][] = $t; 0031 } 0032 $groups = array(); 0033 foreach ($data as $g) { 0034 $groups[$g['group_id']][] = $g; 0035 } 0036 function custom_sort($a, $b) { 0037 return $a['tag_name'] > $b['tag_name'] ; 0038 } 0039 ?> 0040 <link rel="stylesheet" href="/tools/bootstrap-multiselect/css/bootstrap-multiselect.css" type="text/css"> 0041 <script type="text/javascript" src="/tools/bootstrap-multiselect/js/bootstrap-multiselect.js"></script> 0042 <div class="panel-collapse " id="osuser-collapse"> 0043 0044 <div class="panel-body" style="padding-top: 30px"> 0045 <?php 0046 foreach ($gids as $g) { 0047 $options = $groups[$g]; 0048 usort($options,"custom_sort"); 0049 $attr = 'data-tag-gid="'.$g.'"'; 0050 if($options[0]['is_multi_select']) 0051 { 0052 $attr.= ' multiple="multiple"'; 0053 } 0054 ?> 0055 <div class="row"> 0056 <div class="col-lg-3"> 0057 <?=$options[0]['group_display_name']?$options[0]['group_display_name']:$options[0]['group_name']?> 0058 </div> 0059 <div class="col-lg-4"> 0060 <select class="osuser-tag" <?=$attr?> style="width: 150px;"> 0061 <?php 0062 if(!$options[0]['is_multi_select']) 0063 { 0064 echo '<option></option>'; 0065 } 0066 ?> 0067 0068 <?php 0069 foreach ($options as $o) { 0070 $tag_id = $o['tag_id']; 0071 $selected = ''; 0072 if(isset($usertags[$tag_id])){ 0073 // if user selected 0074 $selected=' selected'; 0075 } 0076 ?> 0077 <option value="<?=$tag_id?>" <?=$selected?> > 0078 <?=$o['tag_fullname']?$o['tag_fullname']:$o['tag_name']?> 0079 </option> 0080 <?php 0081 } 0082 ?> 0083 </select> 0084 </div> 0085 </div> 0086 0087 <?php 0088 } 0089 ?> 0090 0091 </div> 0092 <!-- /.section-body --> 0093 </div> 0094 <script type="text/javascript"> 0095 $(document).ready(function() { 0096 $(".osuser-tag[multiple*='multiple']").multiselect(); 0097 $( "select.osuser-tag" ).change(function() { 0098 var gid = $(this).attr("data-tag-gid"); 0099 var tagid = $(this).val(); 0100 if(!$('#osuer-spinner').length) 0101 { 0102 var spin = $('<span id="osuer-spinner" class="glyphicon glyphicon-refresh spinning" style="position: relative; left: 20px;top: 0px;"></span>'); 0103 $('#osuser-collapse').prepend(spin); 0104 } 0105 $.ajax({ 0106 url: '/settings/savetags', 0107 type: 'POST', 0108 data: { 0109 tag_id: tagid, 0110 tag_group_id: gid, 0111 }, 0112 dataType: 'json', 0113 success: function (data, textStatus, jqXHR) { 0114 if (data.status != 'ok') { 0115 return; 0116 } 0117 if (data.status == 'ok') { 0118 $('#osuer-spinner').remove(); 0119 } 0120 }, 0121 error: function (jqXHR, textStatus, errorThrown) { 0122 alert("Error: " + textStatus + ", " + errorThrown); 0123 return; 0124 } 0125 }); 0126 }); 0127 }); 0128 </script>