当前位置: 首页>>代码示例>>PHP>>正文


PHP Rule::getFromDB方法代码示例

本文整理汇总了PHP中Rule::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::getFromDB方法的具体用法?PHP Rule::getFromDB怎么用?PHP Rule::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule的用法示例。


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

示例1: Rule

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.85
*/
include '../inc/includes.php';
$rule = new Rule();
$rule->getFromDB(intval($_POST['rules_id']));
$criteria = new RuleCriteria($rule->fields['sub_type']);
if (isset($_POST["add"])) {
    $criteria->check(-1, CREATE, $_POST);
    $criteria->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $criteria->check($_POST['id'], UPDATE);
        $criteria->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["purge"])) {
            $criteria->check($_POST['id'], PURGE);
            $criteria->delete($_POST, 1);
            Html::back();
开发者ID:btry,项目名称:glpi,代码行数:31,代码来源:rulecriteria.form.php

示例2: getItemtype

 /**
  * For fixed the issue #1 on Github
  */
 static function getItemtype($itemtype, $id)
 {
     // Specific for a webpage in GLPI
     if ($itemtype == 'rule.generic') {
         $rule = new Rule();
         $rule->getFromDB($id);
         return $rule->fields["sub_type"];
     }
     return $itemtype;
 }
开发者ID:korial29,项目名称:tag,代码行数:13,代码来源:tag.class.php

示例3: moveRule

 /**
  * Move a rule in an ordered collection
  *
  * @param $ID of the rule to move
  * @param $ref_ID of the rule position  (0 means all, so before all or after all)
  * @param $type of move : after or before
  *
  * @return true if all ok
  *
  **/
 function moveRule($ID, $ref_ID, $type = 'after')
 {
     global $DB;
     $ruleDescription = new Rule();
     // Get actual ranking of Rule to move
     $ruleDescription->getFromDB($ID);
     $old_rank = $ruleDescription->fields["ranking"];
     // Compute new ranking
     if ($ref_ID) {
         // Move after/before an existing rule
         $ruleDescription->getFromDB($ref_ID);
         $rank = $ruleDescription->fields["ranking"];
     } else {
         if ($type == "after") {
             // Move after all
             $query = "SELECT MAX(`ranking`) AS maxi\n                   FROM `glpi_rules`\n                   WHERE `sub_type` ='" . $this->getRuleClassName() . "' ";
             $result = $DB->query($query);
             $ligne = $DB->fetch_array($result);
             $rank = $ligne['maxi'];
         } else {
             // Move before all
             $rank = 1;
         }
     }
     $rule = $this->getRuleClass();
     $result = false;
     // Move others rules in the collection
     if ($old_rank < $rank) {
         if ($type == "before") {
             $rank--;
         }
         // Move back all rules between old and new rank
         $query = "SELECT `id`, `ranking`\n                   FROM `glpi_rules`\n                   WHERE `sub_type` ='" . $this->getRuleClassName() . "'\n                         AND `ranking` > '{$old_rank}'\n                         AND `ranking` <= '{$rank}'";
         foreach ($DB->request($query) as $data) {
             $data['ranking']--;
             $result = $rule->update($data);
         }
     } else {
         if ($old_rank > $rank) {
             if ($type == "after") {
                 $rank++;
             }
             // Move forward all rule  between old and new rank
             $query = "SELECT `id`, `ranking`\n                   FROM `glpi_rules`\n                   WHERE `sub_type` ='" . $this->getRuleClassName() . "'\n                         AND `ranking` >= '{$rank}'\n                         AND `ranking` < '{$old_rank}'";
             foreach ($DB->request($query) as $data) {
                 $data['ranking']++;
                 $result = $rule->update($data);
             }
         } else {
             // $old_rank == $rank : nothing to do
             $result = false;
         }
     }
     // Move the rule
     if ($result && $old_rank != $rank) {
         $result = $rule->update(array('id' => $ID, 'ranking' => $rank));
     }
     return $result ? true : false;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:69,代码来源:rulecollection.class.php

示例4: Rule

LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkCentralAccess();
if (isset($_GET["id"])) {
    $generic_rule = new Rule();
    $generic_rule->getFromDB($_GET["id"]);
    $generic_rule->checkGlobal(READ);
    $rulecollection = RuleCollection::getClassByType($generic_rule->fields["sub_type"]);
    include GLPI_ROOT . "/front/rule.common.form.php";
}
开发者ID:glpi-project,项目名称:glpi,代码行数:30,代码来源:rule.generic.form.php

示例5: getSpecificValueToSelect

 /**
  * @since version 0.84
  *
  * @param $field
  * @param $name               (default '')
  * @param $values             (default '')
  * @param $options      array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     global $DB;
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'criteria':
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 if ($rule = getItemForItemtype($generic_rule->fields["sub_type"])) {
                     $options['value'] = $values[$field];
                     $options['name'] = $name;
                     return $rule->dropdownCriteria($options);
                 }
             }
             break;
         case 'condition':
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 if (isset($values['criteria']) && !empty($values['criteria'])) {
                     $options['criterion'] = $values['criteria'];
                 }
                 $options['value'] = $values[$field];
                 $options['name'] = $name;
                 return $rule->dropdownConditions($generic_rule->fields["sub_type"], $options);
             }
             break;
         case 'pattern':
             if (!isset($values["criteria"]) || !isset($values["condition"])) {
                 return NOT_AVAILABLE;
             }
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 if ($rule = getItemForItemtype($generic_rule->fields["sub_type"])) {
                     /// TODO : manage display param to this function : need to send ot to all under functions
                     $rule->displayCriteriaSelectPattern($name, $values["criteria"], $values["condition"], $values[$field]);
                 }
             }
             break;
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
开发者ID:korial29,项目名称:glpi,代码行数:52,代码来源:rulecriteria.class.php

示例6: getSpecificValueToSelect

 /**
  * @since version 0.84
  *
  * @param $field
  * @param $name               (default '')
  * @param $values             (default '')
  * @param $options      array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     global $DB;
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'field':
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 if ($rule = getItemForItemtype($generic_rule->fields["sub_type"])) {
                     $options['value'] = $values[$field];
                     $options['name'] = $name;
                     return $rule->dropdownActions($options);
                 }
             }
             break;
         case 'action_type':
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 return self::dropdownActions(array('subtype' => $generic_rule->fields["sub_type"], 'name' => $name, 'value' => $values[$field], 'alreadyused' => false, 'display' => false));
             }
             break;
         case 'pattern':
             if (!isset($values["field"]) || !isset($values["action_type"])) {
                 return NOT_AVAILABLE;
             }
             $generic_rule = new Rule();
             if (isset($values['rules_id']) && !empty($values['rules_id']) && $generic_rule->getFromDB($values['rules_id'])) {
                 if ($rule = getItemForItemtype($generic_rule->fields["sub_type"])) {
                     /// TODO review it : need to pass display param and others...
                     return $this->displayActionSelectPattern($values);
                 }
             }
             break;
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
开发者ID:stweil,项目名称:glpi,代码行数:47,代码来源:ruleaction.class.php


注:本文中的Rule::getFromDB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。