function select_locations($selected, $name = 'locations') { $sel = new SelectItem($name); $list = array(); $locations = getUserLocations(); if (is_array($locations)) { foreach ($locations as $loc) { $list[$loc['uuid']] = $loc['altname']; } } else { $locations = array(); } $sel->setElements(array_values($list)); $sel->setElementsVal(array_keys($list)); $sel->setSelected($selected); return $sel; }
function getEntitiesSelectableElements($AllEntitiesValue = False) { $list = array(); $values = array(); $locations = getUserLocations(); if ($AllEntitiesValue) { if (count($locations) > 1) { $list['Pulse2ALL'] = _T('All my entities', 'pulse2'); $values['Pulse2ALL'] = ''; } } foreach ($locations as $loc) { $values[$loc['uuid']] = $loc['uuid']; if (isset($loc['completename'])) { $list[$loc['uuid']] = $loc['completename']; } else { $list[$loc['uuid']] = $loc['name']; } } return array($list, $values); }
</div> <div class="col-md-6 col-sm-6 col-xs-6"> <div class="line-title-bigdots"> <h2><span><?php _e("Locations", "javo_fr"); ?> </span></h2> </div> <div class="javo-add-item-term-area"> <?php //echo apply_filters('javo_add_item_get_terms_checkbox', 'item_location', $edit_id, "sel_location[]"); global $wpdb; $passions = $wpdb->get_results("SELECT b.term_id,b.name FROM wp_term_taxonomy as a INNER JOIN wp_terms as b ON a.term_taxonomy_id=b.term_id WHERE a.taxonomy='item_locality'"); $locationCounter = 0; foreach ($passions as $passion) { if (in_array($passion->term_id, getUserLocations())) { echo "<input type='checkbox' value='{$passion->term_id}' name='sel_category[]'> " . $passion->name . "<br>"; } $locationCounter++; } if (!$locationCounter) { echo "<font color='red' style='margin:10px;display:inline-block'>Sorry, No location opened for you, please buy locations from the membership info page.</font>"; } ?> </div> </div> </div> <div class="line-title-bigdots"> <h2><span><?php _e("Features", "javo_fr"); ?>
} } # needed in the case we have to go back to the good list. $params['from'] = $_GET['action']; $params['module'] = $_GET['module']; $params['submod'] = $_GET['submod']; $params['action'] = $_GET['action']; if (displayLocalisationBar()) { $location = getCurrentLocation(); $ajax = new AjaxLocation("modules/imaging/manage/$page.php", "container_$page", "location", $params); $list = array(); $values = array(); $locations = getUserLocations(); /*if (count($locations) > 1) { $list['Pulse2ALL'] = _T('All my entities', 'pulse2'); $values['Pulse2ALL'] = ''; }*/ foreach ($locations as $loc) { $values[$loc['uuid']] = $loc['uuid']; if (isset($loc['altname'])) { $list[$loc['uuid']] = $loc['altname']; } else { $list[$loc['uuid']] = $loc['name']; } } $ajax->setElements($list); $ajax->setElementsVal($values); if($location)
$params = array(); $params['filters']['id'] = $_GET["id"]; $result = getAllEntitiesPowered($params); if ($result['count'] != 1) { die('Unexpected error'); } $entity = $result['data'][0]; $entity_name = $entity['name']; $parent = $entity['entities_id']; $description = $entity['comment']; } $p = new PageGenerator($page_title); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->push(new Table()); $f->add(new TrFormElement(_T('Name', 'glpi'), new InputTpl('name')), array("value" => $entity_name, "required" => True)); $entities_select = new SelectItem("parent"); $entities = getUserLocations(); $entity_list = array(); foreach ($entities as $entity) { $id = str_replace('UUID', '', $entity['uuid']); $entity_list[$id] = $entity['completename']; } $entities_select->setElements(array_values($entity_list)); $entities_select->setElementsVal(array_keys($entity_list)); $f->add(new TrFormElement(_T('Parent entity', 'glpi'), $entities_select), array("value" => $parent, "required" => True)); $f->add(new TrFormElement(_T('Description', 'glpi'), new InputTpl('description')), array("value" => $description, "required" => True)); $f->pop(); $f->addValidateButton("bconfirm"); $f->display();
function _glpi_baseEdit($FH, $mode) { $username = $FH->getArrayOrPostValue("uid"); // Default profile is SuperAdmin on root entity // with recursive rights $default_user_locations = array(array('entity_id' => 1, 'is_dynamic' => 0, 'is_recursive' => 1, 'profile' => 4)); if ($mode == 'edit') { $user_locations = getLocationsForUser($username); // If not user profile, switching to default if (!count($user_locations)) { $user_locations = $default_user_locations; } } else { // Default profile is SuperAdmin on root entity // with recursive rights $user_locations = $default_user_locations; } $d = new DivForModule(_T("Entity attributes", "glpi"), "#DDF"); $f = new Table(); $d->push($f); // ================================= // Entity select // ================================= $entities_select = new SelectItem("entities[]"); $entities = getUserLocations(); $entity_list = array(); foreach ($entities as $entity) { $id = str_replace('UUID', '', $entity['uuid']); $entity_list[$id] = $entity['name']; } $entities_select->setElements(array_values($entity_list)); $entities_select->setElementsVal(array_keys($entity_list)); // ================================= // Profiles select // ================================= $profiles_select = new SelectItem("profiles[]"); $profiles = getAllUserProfiles(); $profiles_select->setElements(array_values($profiles)); $profiles_select->setElementsVal(array_keys($profiles)); // ================================= // Recursive select // ================================= $recursive_select = new SelectItem("is_recursive[]"); $recursive_select->setElements(array('Recursive', 'Not recursive')); $recursive_select->setElementsVal(array('1', '0')); // ================================= // Recursive select // ================================= $dynamic_select = new SelectItem("is_dynamic[]"); $dynamic_select->setElements(array('Dynamic', 'Not dynamic')); $dynamic_select->setElementsVal(array('1', '0')); foreach ($user_locations as $attr) { // Fields $fields = array($entities_select, $profiles_select, $recursive_select, $dynamic_select, new buttonTpl2('removeLine', _T('Remove', 'glpi'), 'removeLine')); $values = array($attr['entity_id'], $attr['profile'], $attr['is_recursive'], $attr['is_dynamic'], ''); $f->add(new TrFormElement(_T('Entity right', 'glpi'), new multifieldTpl($fields)), array("value" => $values, "required" => True)); } // Add line button $addEntityRightBtn = new buttonTpl2('addLine', _T('Add entity right', 'backuppc')); $addEntityRightBtn->setClass('btnPrimary'); $f->add(new TrFormElement('', $addEntityRightBtn), array()); print <<<EOF <script type="text/javascript"> jQuery(function(){ modelLine = jQuery('.removeLine:first').parents('tr:first').clone(); // Remove line button jQuery('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); // Add line button jQuery('#addLine').click(function(){ var newline = modelLine.clone().insertBefore(jQuery(this).parents('tr:first')); newline.find('input[type=text]').val(''); newline.find('textarea').val(''); newline.find('.removeLine').click(function(){ if (jQuery('.removeLine').length > 1) jQuery(this).parents('tr:first').remove(); }); }); }); window.toto=1; </script> EOF; return $f; }
function additionalLocation() { global $wpdb; $locations = $wpdb->get_results("Select a.name,a.term_id FROM wp_terms as a INNER JOIN wp_term_taxonomy as b ON a.term_id=b.term_taxonomy_id WHERE b.taxonomy='item_location'"); $html = "<div class='select_transcharity_locations' style='padding:10px'><b><u>Select Location</u></b><br>"; foreach ($locations as $location) { if (!in_array($location->term_id, getUserLocations())) { $html .= "<input type='radio' required='required' name='select_transcharity_location[]' value='{$location->term_id}'> {$location->name} <br>"; } } $html .= "</div>"; return $html; }