• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getTableNameForForeignKeyField函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getTableNameForForeignKeyField函数的典型用法代码示例。如果您正苦于以下问题:PHP getTableNameForForeignKeyField函数的具体用法?PHP getTableNameForForeignKeyField怎么用?PHP getTableNameForForeignKeyField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getTableNameForForeignKeyField函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: executeActions

 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "assign":
                     $output[$action->fields["field"]] = $action->fields["value"];
                     break;
                 case "regex_result":
                     //Regex result : assign value from the regex
                     $res = "";
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     if ($res != '' && ($action->fields["field"] != 'user' && $action->fields["field"] != 'otherserial' && $action->fields["field"] != 'software' && $action->fields["field"] != 'softwareversion')) {
                         $res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res);
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
                 default:
                     //plugins actions
                     $executeaction = clone $this;
                     $ouput = $executeaction->executePluginsActions($action, $output, $params);
                     break;
             }
         }
     }
     return $output;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:collectrule.class.php


示例2: __construct

 /**
  * @param $report
  * @param $name
  * @param $tableortype  (default '')
  * @param $label        (default '')
  * @param $condition    (default '')
  **/
 function __construct($report, $name, $tableortype = '', $label = '', $condition = '')
 {
     parent::__construct($report, $name, $name, $label);
     $this->condition = $condition;
     if (empty($tableortype)) {
         $this->table = getTableNameForForeignKeyField($name);
     } else {
         if (preg_match("/^glpi_/", $tableortype)) {
             $this->table = $tableortype;
         } else {
             if ($tableortype == NOT_AVAILABLE) {
                 $this->table = NOT_AVAILABLE;
             } else {
                 $this->table = getTableForItemType($tableortype);
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:25,代码来源:dropdowncriteria.class.php


示例3: selectValues

 function selectValues($field = '')
 {
     global $DB, $CFG_GLPI;
     if ($field == '') {
         $field = $this->fields['field'];
     }
     echo "<span id='span_values' name='span_values'>";
     if ($this->fields['itemtype'] != '') {
         $item = new $this->fields['itemtype']();
         $searchOption = $item->getSearchOptionByField('field', $field);
         if (isset($searchOption['linkfield'])) {
             $linkfield = $searchOption['linkfield'];
         } else {
             $linkfield = $searchOption['field'];
         }
         if ($linkfield == $this->fields['field']) {
             $value = $this->fields['value'];
         } else {
             $value = '';
         }
         //If field is a foreign key on another table or not
         $table = getTableNameForForeignKeyField($linkfield);
         if ($table == '') {
             if (isset($searchOption['datatype'])) {
                 $datatype = $searchOption['datatype'];
             } else {
                 $datatype = 'text';
             }
             switch ($datatype) {
                 case 'text':
                 case 'string':
                 default:
                     autocompletionTextField($this, 'value', array('value' => $value));
                     break;
                 case 'bool':
                     Dropdown::showYesNo('value', $value);
                     break;
             }
         } else {
             $itemtype = getItemTypeForTable($table);
             Dropdown::show($itemtype, array('name' => 'value', 'value' => $value));
         }
     }
     echo "</span>";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:45,代码来源:fieldblacklist.class.php


示例4: showFormForNetworkPort

 /**
  * @param $networkPortID
  **/
 static function showFormForNetworkPort($networkPortID)
 {
     global $DB, $CFG_GLPI;
     $name = new self();
     $number_names = 0;
     if ($networkPortID > 0) {
         $query = "SELECT `id`\n                   FROM `" . $name->getTable() . "`\n                   WHERE `itemtype` = 'NetworkPort'\n                   AND `items_id` = '{$networkPortID}'\n                   AND `is_deleted` = '0'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 1) {
             echo "<tr class='tab_bg_1'><th colspan='4'>" . __("Several network names available! Go to the tab 'Network Name' to manage them.") . "</th></tr>\n";
             return;
         }
         switch ($DB->numrows($result)) {
             case 1:
                 $nameID = $DB->fetch_assoc($result);
                 $name->getFromDB($nameID['id']);
                 break;
             case 0:
                 $name->getEmpty();
                 break;
         }
     } else {
         $name->getEmpty();
     }
     echo "<tr class='tab_bg_1'><th colspan='4'>";
     // If the networkname is defined, we must be able to edit it. So we make a link
     if ($name->getID() > 0) {
         echo "<a href='" . $name->getLinkURL() . "'>" . self::getTypeName(1) . "</a>";
         echo "<input type='hidden' name='NetworkName_id' value='" . $name->getID() . "'>&nbsp;\n";
         Html::showSimpleForm($name->getFormURL(), 'unaffect', _sx('button', 'Dissociate'), array('id' => $name->getID()), $CFG_GLPI["root_doc"] . '/pics/sub_dropdown.png');
     } else {
         echo self::getTypeName(1);
     }
     echo "</th>\n";
     echo "</tr><tr class='tab_bg_1'>";
     echo "<td>" . self::getTypeName(1) . "</td><td>\n";
     Html::autocompletionTextField($name, "name", array('name' => 'NetworkName_name'));
     echo "</td>\n";
     echo "<td>" . FQDN::getTypeName(1) . "</td><td>";
     Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField("fqdns_id")), array('value' => $name->fields["fqdns_id"], 'name' => 'NetworkName_fqdns_id', 'entity' => $name->getEntityID(), 'displaywith' => array('view')));
     echo "</td>\n";
     echo "</tr><tr class='tab_bg_1'>\n";
     echo "<td>" . IPAddress::getTypeName(Session::getPluralNumber());
     IPAddress::showAddChildButtonForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     echo "<td>";
     IPAddress::showChildsForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     // MoYo : really need to display it here ?
     // make confure because not updatable
     //       echo "<td>".IPNetwork::getTypeName(Session::getPluralNumber())."&nbsp;";
     //       Html::showToolTip(__('IP network is not included in the database. However, you can see current available networks.'));
     //       echo "</td><td>";
     //       IPNetwork::showIPNetworkProperties($name->getEntityID());
     //       echo "</td>\n";
     echo "<td colspan='2'>&nbsp;</td>";
     echo "</tr>\n";
 }
开发者ID:kipman,项目名称:glpi,代码行数:61,代码来源:networkname.class.php


示例5: sprintf

         if ($tmpitem->getFromDB($data['items_id'])) {
             $outputval = sprintf(__('%1$s - %2$s'), $tmpitem->getTypeName(), $tmpitem->getName());
         } else {
             $outputval = $tmpitem->getTypeName();
         }
     } else {
         $outputval = $data[$field];
     }
 }
 $outputval = Toolbox::unclean_cross_side_scripting_deep($outputval);
 if ($displaywith) {
     foreach ($_POST['displaywith'] as $key) {
         if (isset($data[$key])) {
             $withoutput = $data[$key];
             if (isForeignKeyField($key)) {
                 $withoutput = Dropdown::getDropdownName(getTableNameForForeignKeyField($key), $data[$key]);
             }
             if (strlen($withoutput) > 0 && $withoutput != '&nbsp;') {
                 $outputval = sprintf(__('%1$s - %2$s'), $outputval, $withoutput);
             }
         }
     }
 }
 $ID = $data['id'];
 $addcomment = "";
 $title = $outputval;
 if (isset($data["comment"])) {
     if (isset($data['transcomment']) && !empty($data['transcomment'])) {
         $addcomment .= $data['transcomment'];
     } else {
         $addcomment .= $data["comment"];
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:getDropdownValue.php


示例6: match

 /**
  * Try to match a definied rule
  *
  * @param &$criterion         RuleCriteria object
  * @param $field              the field to match
  * @param &$criterias_results
  * @param &$regex_result
  *
  * @return true if the field match the rule, false if it doesn't match
  **/
 static function match(RuleCriteria &$criterion, $field, &$criterias_results, &$regex_result)
 {
     $condition = $criterion->fields['condition'];
     $pattern = $criterion->fields['pattern'];
     $criteria = $criterion->fields['criteria'];
     //If pattern is wildcard, don't check the rule and return true
     //or if the condition is "already present in GLPI" : will be processed later
     if ($pattern == Rule::RULE_WILDCARD || $condition == Rule::PATTERN_FIND) {
         return true;
     }
     $pattern = trim($pattern);
     switch ($condition) {
         case Rule::PATTERN_EXISTS:
             return !empty($field);
         case Rule::PATTERN_DOES_NOT_EXISTS:
             return empty($field);
         case Rule::PATTERN_IS:
             if (is_array($field)) {
                 // Special case (used only by UNIQUE_PROFILE, for now)
                 // $pattern is an ID
                 if (in_array($pattern, $field)) {
                     $criterias_results[$criteria] = $pattern;
                     return true;
                 }
             } else {
                 //Perform comparison with fields in lower case
                 $field = Toolbox::strtolower($field);
                 $pattern = Toolbox::strtolower($pattern);
                 if ($field == $pattern) {
                     $criterias_results[$criteria] = $pattern;
                     return true;
                 }
             }
             return false;
         case Rule::PATTERN_IS_NOT:
             //Perform comparison with fields in lower case
             $field = Toolbox::strtolower($field);
             $pattern = Toolbox::strtolower($pattern);
             if ($field != $pattern) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_UNDER:
             $table = getTableNameForForeignKeyField($criteria);
             $values = getSonsOf($table, $pattern);
             if (isset($values[$field])) {
                 return true;
             }
             return false;
         case Rule::PATTERN_NOT_UNDER:
             $table = getTableNameForForeignKeyField($criteria);
             $values = getSonsOf($table, $pattern);
             if (isset($values[$field])) {
                 return false;
             }
             return true;
         case Rule::PATTERN_END:
             $value = "/" . $pattern . "\$/i";
             if (preg_match($value, $field) > 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_BEGIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value !== false && $value == 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_CONTAIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value !== false && $value >= 0) {
                 $criterias_results[$criteria] = $pattern;
                 return true;
             }
             return false;
         case Rule::PATTERN_NOT_CONTAIN:
             if (empty($pattern)) {
                 return false;
             }
             $value = mb_stripos($field, $pattern, 0, 'UTF-8');
             if ($value === false) {
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:rulecriteria.class.php


示例7: displaySpecificTypeField

 /**
  * @see CommonDropdown::displaySpecificTypeField()
  */
 function displaySpecificTypeField($ID, $field = array())
 {
     switch ($field['type']) {
         case "plugin_customfields_dropdowns_id":
             // We have a dropdown.
             if (isset($_REQUEST['plugin_customfields_dropdowns_id'])) {
                 $ID = $_REQUEST['plugin_customfields_dropdowns_id'];
             } elseif (isset($this->fields[$field['name']])) {
                 $ID = $this->fields[$field['name']];
             } else {
                 $ID = -1;
             }
             Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), array('value' => $ID, 'name' => $field['name'], 'entity' => $this->getEntityID(), 'auto_submit' => true));
             break;
         case "plugin_customfields_dropdownsitems_id":
             // We have a dropdown item
             $condition = "plugin_customfields_dropdowns_id = -1";
             if (isset($_REQUEST['plugin_customfields_dropdowns_id'])) {
                 $condition = "plugin_customfields_dropdowns_id = '" . $_REQUEST['plugin_customfields_dropdowns_id'] . "'";
             }
             if ($field['name'] == 'entities_id') {
                 $restrict = -1;
             } else {
                 $restrict = $this->getEntityID();
             }
             Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'comments' => false, 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array(), 'condition' => $condition));
             break;
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:32,代码来源:dropdownsitem.class.php


示例8: parseDropdowns

 /**
  * transform array of fields passed in parameter :
  * change value from  integer id to string name of foreign key
  * You can pass an array of array, this method is recursive.
  *
  * @param $fields     array    to check and transform
  * @param $expand     bool     array of option to enable, could be :
  *                                 - expand_dropdowns (default false)
  *                                 - get_hateoas      (default true)
  *
  * @return     array  altered $fields
  **/
 protected static function parseDropdowns($fields, $params = array())
 {
     // default params
     $default = array('expand_dropdowns' => false, 'get_hateoas' => true);
     $params = array_merge($default, $params);
     // parse fields recursively
     foreach ($fields as $key => &$value) {
         if (is_array($value)) {
             $value = self::parseDropdowns($value);
         }
         if (is_integer($key)) {
             continue;
         }
         if (isForeignKeyField($key)) {
             // specific key transformations
             if ($key == "items_id" && isset($fields['itemtype'])) {
                 $key = getForeignKeyFieldForItemType($fields['itemtype']);
             }
             if ($key == "auths_id" && isset($fields['authtype']) && $fields['authtype'] == Auth::LDAP) {
                 $key = "authldaps_id";
             }
             if ($key == "default_requesttypes_id") {
                 $key = "requesttypes_id";
             }
             if (!empty($value) || $key == 'entities_id' && $value >= 0) {
                 $tablename = getTableNameForForeignKeyField($key);
                 $itemtype = getItemTypeForTable($tablename);
                 // get hateoas
                 if ($params['get_hateoas']) {
                     $fields['links'][] = array('rel' => $itemtype, 'href' => self::$api_url . "/{$itemtype}/" . $value);
                 }
                 // expand dropdown
                 if ($params['expand_dropdowns']) {
                     $value = Dropdown::getDropdownName($tablename, $value);
                     // fix value for inexistent items
                     if ($value == "&nbsp;") {
                         $value = "";
                     }
                 }
             }
         }
     }
     return $fields;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:56,代码来源:api.class.php


示例9: checkUnicity

 /**
  * Check field unicity before insert or update
  *
  * @param add true for insert, false for update
  * @param $options array
  *
  * @return true if item can be written in DB, false if not
  **/
 function checkUnicity($add = false, $options = array())
 {
     global $LANG, $DB, $CFG_GLPI;
     $p['unicity_error_message'] = true;
     $p['add_event_on_duplicate'] = true;
     $p['disable_unicity_check'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $value) {
             $p[$key] = $value;
         }
     }
     $result = true;
     //Do not check unicity when creating infocoms or if checking is expliclty disabled
     if ($p['disable_unicity_check']) {
         return $result;
     }
     //Get all checks for this itemtype and this entity
     if (in_array(get_class($this), $CFG_GLPI["unicity_types"])) {
         // Get input entities if set / else get object one
         if (isset($this->input['entities_id'])) {
             $entities_id = $this->input['entities_id'];
         } else {
             $entities_id = $this->fields['entities_id'];
         }
         $all_fields = FieldUnicity::getUnicityFieldsConfig(get_class($this), $entities_id);
         foreach ($all_fields as $key => $fields) {
             //If there's fields to check
             if (!empty($fields) && !empty($fields['fields'])) {
                 $where = "";
                 $continue = true;
                 foreach (explode(',', $fields['fields']) as $field) {
                     if (isset($this->input[$field]) && (getTableNameForForeignKeyField($field) == '' && $this->input[$field] != '' || getTableNameForForeignKeyField($field) != '' && $this->input[$field] > 0) && !Fieldblacklist::isFieldBlacklisted(get_class($this), $entities_id, $field, $this->input[$field])) {
                         $where .= " AND `" . $this->getTable() . "`.`{$field}` = '" . $this->input[$field] . "'";
                     } else {
                         $continue = false;
                     }
                 }
                 if ($continue && $where != '') {
                     $entities = $fields['entities_id'];
                     if ($fields['is_recursive']) {
                         $entities = getSonsOf('glpi_entities', $fields['entities_id']);
                     }
                     $where_global = getEntitiesRestrictRequest(" AND", $this->getTable(), '', $entities);
                     //If update, exclude ID of the current object
                     if (!$add) {
                         $where .= " AND `" . $this->getTable() . "`.`id` NOT IN (" . $this->input['id'] . ") ";
                     }
                     if (countElementsInTable($this->table, "1 {$where} {$where_global}") > 0) {
                         if ($p['unicity_error_message'] || $p['add_event_on_duplicate']) {
                             $message = array();
                             foreach (explode(',', $fields['fields']) as $field) {
                                 $table = getTableNameForForeignKeyField($field);
                                 if ($table != '') {
                                     $searchOption = $this->getSearchOptionByField('field', 'name', $table);
                                 } else {
                                     $searchOption = $this->getSearchOptionByField('field', $field);
                                 }
                                 $message[] = $searchOption['name'] . '=' . $this->input[$field];
                             }
                             $doubles = getAllDatasFromTable($this->table, "1 {$where} {$where_global}");
                             $message_text = $this->getUncityErrorMessage($message, $fields, $doubles);
                             if ($p['unicity_error_message']) {
                                 if (!$fields['action_refuse']) {
                                     $show_other_messages = $fields['action_refuse'] ? true : false;
                                 } else {
                                     $show_other_messages = true;
                                 }
                                 addMessageAfterRedirect($message_text, true, $show_other_messages, $show_other_messages);
                             }
                             if ($p['add_event_on_duplicate']) {
                                 Event::log(!$add ? $this->fields['id'] : 0, get_class($this), 4, 'inventory', $_SESSION["glpiname"] . " " . $LANG['log'][123] . ' : ' . $message_text);
                             }
                         }
                         if ($fields['action_refuse']) {
                             $result = false;
                         }
                         if ($fields['action_notify']) {
                             $params = array('message' => html_clean($message_text), 'action_type' => $add, 'action_user' => getUserName(getLoginUserID()), 'entities_id' => $entities_id, 'itemtype' => get_class($this), 'date' => $_SESSION['glpi_currenttime'], 'refuse' => $fields['action_refuse']);
                             NotificationEvent::raiseEvent('refuse', new FieldUnicity(), $params);
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:95,代码来源:commondbtm.class.php


示例10: deleteField

 /**
  * Delete a field in DB
  * @param table the table
  * @param field the field to delete
  * @return nothing
  */
 static function deleteField($table, $field)
 {
     global $DB;
     //Remove field from displaypreferences
     self::deleteDisplayPreferences($table, $field);
     //If field exists, drop it !
     if (FieldExists($table, $field)) {
         $DB->query("ALTER TABLE `{$table}` DROP `{$field}`");
     }
     $table = getTableNameForForeignKeyField($field);
     //If dropdown is managed by the plugin
     if ($table != '' && preg_match('/plugin_genericobject_(.*)/', $table, $results)) {
         //Delete dropdown table
         $query = "DROP TABLE `{$table}`";
         $DB->query($query);
         //Delete dropdown files & class
         $name = getSingular($results[1]);
         PluginGenericobjectType::deleteClassFile($name);
         PluginGenericobjectType::deleteFormFile($name);
         PluginGenericobjectType::deletesearchFile($name);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:28,代码来源:field.class.php


示例11: showForm

 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE);
     }
     $this->showFormHeader($options);
     $fields = $this->getAdditionalFields();
     $nb = count($fields);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     if ($this instanceof CommonDevice) {
         // Awfull hack for CommonDevice where name is designation
         Html::autocompletionTextField($this, "designation");
     } else {
         Html::autocompletionTextField($this, "name");
     }
     echo "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>\n            <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     foreach ($fields as $field) {
         if ($field['name'] == 'entities_id' && $ID == 0 && !$this->isNewID($ID)) {
             // No display for root entity
             echo "<tr class='tab_bg_1'><td colspan='2'>&nbsp;</td></tr>";
             break;
         }
         if (!isset($field['type'])) {
             $field['type'] = '';
         }
         if ($field['name'] == 'header') {
             echo "<tr class='tab_bg_1'><th colspan='2'>" . $field['label'] . "</th></tr>";
             continue;
         }
         echo "<tr class='tab_bg_1'><td>" . $field['label'];
         if (isset($field['comment']) && !empty($field['comment'])) {
             echo "&nbsp;";
             Html::showToolTip($field['comment']);
         }
         echo "</td><td>";
         switch ($field['type']) {
             case 'UserDropdown':
                 $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]);
                 if (isset($field['right'])) {
                     $params['right'] = $field['right'];
                 }
                 User::dropdown($param);
                 break;
             case 'dropdownValue':
                 $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID());
                 if (isset($field['condition'])) {
                     $params['condition'] = $field['condition'];
                 }
                 Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params);
                 break;
             case 'text':
                 Html::autocompletionTextField($this, $field['name']);
                 break;
             case 'textarea':
                 $cols = 40;
                 $rows = 3;
                 if (isset($field['rows'])) {
                     $rows = $field['rows'];
                 }
                 if (isset($field['cols'])) {
                     $cols = $field['cols'];
                 }
                 echo "<textarea name='" . $field['name'] . "' cols='{$cols}' rows='{$rows}'>" . $this->fields[$field['name']] . "</textarea >";
                 break;
             case 'integer':
                 Dropdown::showNumber($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'timestamp':
                 $param = array('value' => $this->fields[$field['name']]);
                 if (isset($field['min'])) {
                     $param['min'] = $field['min'];
                 }
                 if (isset($field['max'])) {
                     $param['max'] = $field['max'];
                 }
                 if (isset($field['step'])) {
                     $param['step'] = $field['step'];
                 }
                 Dropdown::showTimeStamp($field['name'], $param);
                 break;
             case 'parent':
                 if ($field['name'] == 'entities_id') {
                     $restrict = -1;
                 } else {
                     $restrict = $this->getEntityID();
                 }
                 Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array()));
                 break;
             case 'icon':
                 Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones");
                 if (!empty($this->fields[$field['name']])) {
                     echo "&nbsp;<img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>";
//.........这里部分代码省略.........
开发者ID:pvasener,项目名称:glpi,代码行数:101,代码来源:commondropdown.class.php


示例12: executeActions

 function executeActions($output, $params)
 {
     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-locationrules", "execute action\n");
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "assign":
                     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-locationrules", "value " . $action->fields["value"] . "\n");
                     $output[$action->fields["field"]] = $action->fields["value"];
                     break;
                 case "regex_result":
                     $res = '';
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     if ($res != '') {
                         $entities_id = 0;
                         if (isset($_SESSION["plugin_fusioninventory_entity"]) && $_SESSION["plugin_fusioninventory_entity"] > 0) {
                             $entities_id = $_SESSION["plugin_fusioninventory_entity"];
                         }
                         $res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res, $entities_id);
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
             }
         }
     }
     return $output;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:inventoryrulelocation.class.php


示例13: getSearchOptions

 function getSearchOptions()
 {
     $tab = array();
     $tab[1]['table'] = $this->getTable();
     $tab[1]['field'] = 'name';
     $tab[1]['linkfield'] = 'name';
     $tab[1]['name'] = __('Name');
     $tab[1]['datatype'] = 'itemlink';
     $tab[1]['itemlink_type'] = $this->getType();
     $tab[19]['table'] = $this->getTable();
     $tab[19]['field'] = 'date_mod';
     $tab[19]['linkfield'] = '';
     $tab[19]['name'] = __('Last update');
     $tab[19]['datatype'] = 'datetime';
     $tab[2]['table'] = $this->getTable();
     $tab[2]['field'] = 'url';
     $tab[2]['linkfield'] = 'url';
     $tab[2]['name'] = __('Mirror server address', 'fusioninventory');
     $tab[2]['datatype'] = 'string';
     $tab[16]['table'] = $this->getTable();
     $tab[16]['field'] = 'comment';
     $tab[16]['linkfield'] = 'comment';
     $tab[16]['name'] = __('Comments');
     $tab[16]['datatype'] = 'text';
     $tab[80]['table'] = 'glpi_entities';
     $tab[80]['field'] = 'completename';
     $tab[80]['name'] = __('Entity');
     $tab[81]['table'] = getTableNameForForeignKeyField('locations_id');
     $tab[81]['field'] = 'completename';
     $tab[81]['linkfield'] = 'locations_id';
     $tab[81]['name'] = Location::getTypeName();
     $tab[81]['datatype'] = 'itemlink';
     $tab[86]['table'] = $this->getTable();
     $tab[86]['field'] = 'is_recursive';
     $tab[86]['linkfield'] = 'is_recursive';
     $tab[86]['name'] = __('Child entities');
     $tab[86]['datatype'] = 'bool';
     return $tab;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:39,代码来源:deploymirror.class.php


示例14: showChildren

 /**
  * Print the HTML array children of a TreeDropdown
  *
  *@param $ID of the dropdown
  *
  *@return Nothing (display)
  **/
 function showChildren($ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     $this->check($ID, 'r');
     $fields = $this->getAdditionalFields();
     $nb = count($fields);
     $entity_assign = $this->isEntityAssign();
     // Minimal form for quick input.
     if ($this->canCreate()) {
         $link = $this->getFormURL();
         echo "<div class='firstbloc'>";
         echo "<form action='" . $link . "' method='post'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . $LANG['common'][93] . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . "&nbsp;: ";
         autocompletionTextField($this, "name", array('value' => ''));
         if ($entity_assign && $this->getForeignKeyField() != 'entities_id') {
             echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>";
         }
         if ($entity_assign && $this->isRecursive()) {
             echo "<input type='hidden' name='is_recursive' value='1'>";
         }
         echo "<input type='hidden' name='" . $this->getForeignKeyField() . "' value='{$ID}'></td>";
         echo "<td><input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table></form></div>\n";
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='" . ($nb + 3) . "'>" . $LANG['setup'][76] . " " . $this->getTreeLink();
     echo "</th></tr>";
     echo "<tr><th>" . $LANG['common'][16] . "</th>";
     // Name
     if ($entity_assign) {
         echo "<th>" . $LANG['entity'][0] . "</th>";
         // Entity
     }
     foreach ($fields as $field) {
         if ($field['list']) {
             echo "<th>" . $field['label'] . "</th>";
         }
     }
     echo "<th>" . $LANG['common'][25] . "</th>";
     echo "</tr>\n";
     $fk = $this->getForeignKeyField();
     $crit = array($fk => $ID, 'ORDER' => 'name');
     if ($entity_assign) {
         if ($fk == 'entities_id') {
             $crit['id'] = $_SESSION['glpiactiveentities'];
             $crit['id'] += $_SESSION['glpiparententities'];
         } else {
             $crit['entities_id'] = $_SESSION['glpiactiveentities'];
         }
     }
     foreach ($DB->request($this->getTable(), $crit) as $data) {
         echo "<tr class='tab_bg_1'>";
         echo "<td><a href='" . $this->getFormURL();
         echo '?id=' . $data['id'] . "'>" . $data['name'] . "</a></td>";
         if ($entity_assign) {
             echo "<td>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>";
         }
         foreach ($fields as $field) {
             if ($field['list']) {
                 echo "<td>";
                 switch ($field['type']) {
                     case 'UserDropdown':
                         echo getUserName($data[$field['name']]);
                         break;
                     case 'bool':
                         echo Dropdown::getYesNo($data[$field['name']]);
                         break;
                     case 'dropdownValue':
                         echo Dropdown::getDropdownName(getTableNameForForeignKeyField($field['name']), $data[$field['name']]);
                         break;
                     default:
                         echo $data[$field['name']];
                 }
                 echo "</td>";
             }
         }
         echo "<td>" . $data['comment'] . "</td>";
         echo "</tr>\n";
     }
     echo "</table></div>\n";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:92,代码来源:commontreedropdown.class.php


示例15: selectCriterias

 /**
  * Display a list of available fields for unicity checks
  *
  * @param $unicity an instance of CommonDBTM class
  *
  * @return nothing
  **/
 static function selectCriterias(CommonDBTM $unicity)
 {
     global $DB;
     //Do not check unicity on fields in DB with theses types
     $blacklisted_types = array('longtext', 'text');
     echo "<span id='span_fields' name='span_fields'>";
     if (!isset($unicity->fields['itemtype']) || !$unicity->fields['itemtype']) {
         echo "</span>";
         return;
     }
     if (!isset($unicity->fields['entities_id'])) {
         $unicity->fields['entities_id'] = $_SESSION['glpiactive_entity'];
     }
     $unicity_fields = explode(',', $unicity->fields['fields']);
     //Search option for this type
     $target = new $unicity->fields['itemtype']();
     //Construct list
     echo "<span id='span_fields' name='span_fields'>";
     echo "<select name='_fields[]' multiple size='15' style='width:400px'>";
     foreach ($DB->list_fields(getTableForItemType($unicity->fields['itemtype'])) as $field) {
         $searchOption = $target->getSearchOptionByField('field', $field['Field']);
         if (empty($searchOption)) {
             if ($table = getTableNameForForeignKeyField($field['Field'])) {
                 $searchOption = $target->getSearchOptionByField('field', 'name', $table);
             }
         }
         if (!empty($searchOption) && !in_array($field['Type'], $blacklisted_types) && !in_array($field['Field'], $target->getUnallowedFieldsForUnicity())) {
             echo "<option value='" . $field['Field'] . "'";
             if (isset($unicity_fields) && in_array($field['Field'], $unicity_fields)) {
                 echo " selected ";
             }
             echo ">" . $searchOption['name'] . "</option>";
         }
     }
     echo "</select></span>";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:43,代码来源:fieldunicity.class.php


示例16: transfer

 function transfer($new_entity)
 {
     global $DB;
     if ($this->fields['id'] > 0 && $this->fields['entities_id'] != $new_entity) {
         //Update entity for this object
         $tmp['id'] = $this->fields['id'];
         $tmp['entities_id'] = $new_entity;
         $this->update($tmp);
         $toupdate = array('id' => $this->fields['id']);
         foreach (PluginGenericobjectSingletonObjectField::getInstance(get_called_class()) as $field => $data) {
             $table = getTableNameForForeignKeyField($field);
             //It is a dropdown table !
             if ($field != 'entities_id' && $table != '' && isset($this->fields[$field]) && $this->fields[$field] > 0) {
                 //Instanciate a new dropdown object
                 $dropdown_itemtype = getItemTypeForTable($table);
                 $dropdown = new $dropdown_itemtype();
                 $dropdown->getFromDB($this->fields[$field]);
                 //If dropdown is only accessible in the other entity
                 //do not go further
                 if (!$dropdown->isEntityAssign() || in_array($new_entity, getAncestorsOf('glpi_entities', $dropdown->getEntityID()))) {
                     continue;
                 } else {
                     $tmp = array();
                     $where = "";
                     if ($dropdown instanceof CommonTreeDropdown) {
                         $tmp['completename'] = $dropdown->fields['completename'];
                         $where = "`completename`='" . addslashes_deep($tmp['completename']) . "'";
                     } else {
                         $tmp['name'] = $dropdown->fields['name'];
                         $where = "`name`='" . addslashes_deep($tmp['name']) . "'";
                     }
                     $tmp['entities_id'] = $new_entity;
                     $where .= " AND `entities_id`='" . $tmp['entities_id'] . "'";
                     //There's a dropdown value in the target entity
                     if ($found = $this->find($where)) {
                         $myfound = array_pop($found);
                         if ($myfound['id'] != $this->fields[$field]) {
                             $toupdate[$field] = $myfound['id'];
                         }
                     } else {
                         $clone = $dropdown->fields;
                         if ($dropdown instanceof CommonTreeDropdown) {
                             unset($clone['completename']);
                         }
                         unset($clone['id']);
                         $clone['entities_id'] = $new_entity;
                         $new_id = $dropdown->impo 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getTablePermissions函数代码示例发布时间:2022-05-15
下一篇:
PHP getTableNameForField函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap