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


PHP Rule::find方法代码示例

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


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

示例1: plugin_typology_uninstall

function plugin_typology_uninstall()
{
    global $DB;
    // Plugin tables deletion
    $tables = array("glpi_plugin_typology_profiles", "glpi_plugin_typology_typologies", "glpi_plugin_typology_typologycriterias", "glpi_plugin_typology_typologycriteriadefinitions", "glpi_plugin_typology_typologies_items");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    // Plugin adding information on general table deletion
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginTypologyTypology';");
    }
    //drop rules
    $Rule = new Rule();
    $a_rules = $Rule->find("`sub_type`='PluginTypologyRuleTypology'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginTypologyTypology', 'event' => 'AlertNotValidatedTypology', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:26,代码来源:hook.php

示例2: doExecute

 protected function doExecute()
 {
     $params = array('url' => $this->url);
     if ($this->group !== '') {
         $params['group'] = $this->group;
     } else {
         $params['group'] = null;
     }
     $rules = Rule::find(array($params));
     if ($rules) {
         $contextMap = array(RuleConditionExpressionOperand::CONTEXT_TYPE_REQUEST => $_REQUEST, RuleConditionExpressionOperand::CONTEXT_TYPE_GET => $_GET, RuleConditionExpressionOperand::CONTEXT_TYPE_POST => $_POST, RuleConditionExpressionOperand::CONTEXT_TYPE_HEADER => HttpUtils::getHttpHeaders(), RuleConditionExpressionOperand::CONTEXT_TYPE_COOKIE => $_COOKIE);
         $matcher = new RuleResponseMatcher();
         foreach ($rules as $rule) {
             $res = $matcher->match($rule, $contextMap);
             if (isset($res)) {
                 if (is_array($res) || is_object($res)) {
                     $this->setReturnType(self::RETURN_TYPE_JSON);
                     return $this->success($rule->res);
                 } else {
                     return $res;
                 }
             }
         }
     }
     $this->setReturnType(self::RETURN_TYPE_JSON);
     return $this->error(1, 'can\'t match any url for [' . $this->url . ']');
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:27,代码来源:IndexPageService.php

示例3: doExecute

 protected function doExecute()
 {
     $params = array();
     foreach ($this->get() as $key => $val) {
         if (!empty($val) && in_array($key, array('url', '_id', 'tag', 'group', 'page', 'pageSize'))) {
             $params[$key] = $val;
         }
     }
     if (!empty($params['_id'])) {
         $id = new MongoId($params['_id']);
         $params['_id'] = (object) $id;
     }
     $pageSize = $params['pageSize'];
     $page = $params['page'];
     if (isset($pageSize)) {
         unset($params['pageSize']);
         $page += 0;
         if ($pageSize < self::MIN_PAGE_SIZE) {
             $pageSize = 1;
         } else {
             if ($pageSize > self::MAX_PAGE_SIZE) {
                 $pageSize = self::MAX_PAGE_SIZE;
             }
         }
     }
     if (isset($page)) {
         if (!isset($pageSize)) {
             $pageSize = self::DEFAULT_PAGE_SIZE;
         }
         unset($params['page']);
         $page += 0;
         if ($page <= 0) {
             $page = 1;
         }
         $queryParams = array('conditions' => $params, 'sort' => array('url' => 1), 'limit' => $pageSize, 'skip' => $pageSize * ($page - 1));
     } else {
         $queryParams = array('conditions' => $params, 'sort' => array('url' => 1));
     }
     $result = array('count' => Rule::count(array('conditions' => $params)), 'list' => Rule::find($queryParams));
     if (isset($page)) {
         $result['page'] = $page;
         $result['pageSize'] = $pageSize;
         if ($result['count'] > 0) {
             $result['totalPage'] = ceil($result['count'] / $pageSize);
         } else {
             $result['totalPage'] = 0;
         }
     }
     return $this->success($result);
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:50,代码来源:ListRulePageService.php

示例4: beforeSave

 public function beforeSave($rule)
 {
     if (empty($rule->url)) {
         throw new MockApiException('url is not set', ErrorInfo::ERROR_NO_INVALID_PARAM);
     }
     if (empty($rule->res)) {
         throw new MockApiException('res is not set', ErrorInfo::ERROR_NO_INVALID_PARAM);
     }
     $condition = array('url' => $rule->url);
     if ($rule->group !== '') {
         $condition['group'] = $rule->group;
     } else {
         $condition['group'] = $rule->null;
     }
     $list = Rule::find(array($condition));
     if (!empty($list)) {
         throw new MockApiException('rule has been existed' . ($rule->group ? ' in group [' . $rule->group . ']' : ''), ErrorInfo::ERROR_NO_INVALID_PARAM);
     }
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:19,代码来源:AddRulePageService.php

示例5: pluginFusioninventoryInstall

function pluginFusioninventoryInstall($version, $migrationname = 'Migration')
{
    global $DB;
    ini_set("memory_limit", "-1");
    ini_set("max_execution_time", "0");
    $migration = new $migrationname($version);
    /*
     * Load classes
     */
    foreach (glob(GLPI_ROOT . '/plugins/fusioninventory/inc/*.php') as $file) {
        require_once $file;
    }
    $migration->displayMessage("Installation of plugin FusionInventory");
    // Get informations of plugin
    /*
     * Clean if Fusion / Tracker has been installed and uninstalled (not clean correctly)
     */
    $migration->displayMessage("Clean data from old installation of the plugin");
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5150'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5151'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5152'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5153'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5156'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5157'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5158'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5159'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5161'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5165'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5166'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5167'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype`='5168'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype` LIKE 'PluginFusioninventory%'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype` LIKE 'PluginFusinvinventory%'";
    $DB->query($sql);
    $sql = "DELETE FROM `glpi_displaypreferences`\n         WHERE `itemtype` LIKE 'PluginFusinvsnmp%'";
    $DB->query($sql);
    // Purge network ports have itemtype tp 5153
    $networkPort = new NetworkPort();
    $sql = "SELECT * FROM `glpi_networkports`\n            WHERE `itemtype`='5153'";
    $result = $DB->query($sql);
    while ($data = $DB->fetch_array($result)) {
        $networkPort->delete(array('id' => $data['id']), 1);
    }
    /*
     * Remove old rules
     */
    $migration->displayMessage("Clean rules from old installation of the plugin");
    $Rule = new Rule();
    $a_rules = $Rule->find("`sub_type`='PluginFusioninventoryInventoryRuleImport'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    $a_rules = $Rule->find("`sub_type`='PluginFusinvinventoryRuleEntity'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    $a_rules = $Rule->find("`sub_type`='PluginFusinvinventoryRuleLocation'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    /*
     * Create DB structure
     */
    $migration->displayMessage("Creation tables in database");
    $DB_file = GLPI_ROOT . "/plugins/fusioninventory/install/mysql/plugin_fusioninventory-empty.sql";
    if (!$DB->runFile($DB_file)) {
        $migration->displayMessage("Error on creation tables in database");
    }
    if (!$DB->runFile(GLPI_ROOT . "/plugins/fusioninventory/install/mysql/usbid.sql")) {
        $migration->displayMessage("Error on creation table usbid in database");
    }
    if (!$DB->runFile(GLPI_ROOT . "/plugins/fusioninventory/install/mysql/pciid.sql")) {
        $migration->displayMessage("Error on creation table pciid in database");
    }
    if (!$DB->runFile(GLPI_ROOT . "/plugins/fusioninventory/install/mysql/oui.sql")) {
        $migration->displayMessage("Error on creation table oui in database");
    }
    /*
     * Creation of folders
     */
    $migration->displayMessage("Creation of folders");
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory');
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory/tmp')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory/tmp');
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:install.php

示例6: initRules

 /**
  * Create rules (initialisation)
  */
 function initRules($reset = 0)
 {
     if ($reset == 1) {
         $grule = new Rule();
         $a_rules = $grule->find("`sub_type`='PluginFusioninventoryInventoryRuleImport'");
         foreach ($a_rules as $data) {
             $grule->delete($data);
         }
     }
     $rules = array();
     $rules[] = array('name' => 'Computer constraint (name)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'name', 'condition' => 9, 'pattern' => 1)), 'action' => '_fusion2');
     $rules[] = array('name' => 'Computer update (by serial + uuid)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'uuid', 'condition' => 10, 'pattern' => 1), array('criteria' => 'uuid', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer update (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer update (by uuid)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'uuid', 'condition' => 10, 'pattern' => 1), array('criteria' => 'uuid', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer update (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'mac', 'condition' => 10, 'pattern' => 1), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer update (by name)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'name', 'condition' => 10, 'pattern' => 1), array('criteria' => 'name', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import (by serial + uuid)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'uuid', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import (by uuid)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'uuid', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import (by name)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer'), array('criteria' => 'name', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Computer import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Computer')), 'action' => '_fusion2');
     $rules[] = array('name' => 'Printer constraint (name)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer'), array('criteria' => 'name', 'condition' => 9, 'pattern' => 1)), 'action' => '_fusion2');
     $rules[] = array('name' => 'Printer update (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Printer update (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1), array('criteria' => 'mac', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Printer import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Printer import (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Printer import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Printer')), 'action' => '_fusion2');
     $rules[] = array('name' => 'NetworkEquipment constraint (name)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment'), array('criteria' => 'name', 'condition' => 9, 'pattern' => 1)), 'action' => '_fusion2');
     $rules[] = array('name' => 'NetworkEquipment import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'NetworkEquipment update (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1), array('criteria' => 'mac', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'NetworkEquipment import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'NetworkEquipment import (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'NetworkEquipment import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'NetworkEquipment')), 'action' => '_fusion2');
     $rules[] = array('name' => 'Peripheral update (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Peripheral'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Peripheral import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Peripheral'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Peripheral import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Peripheral')), 'action' => '_fusion2');
     $rules[] = array('name' => 'Monitor update (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Monitor'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Monitor import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Monitor'), array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Monitor import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Monitor')), 'action' => '_fusion2');
     $rules[] = array('name' => 'Phone constraint (name)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Phone'), array('criteria' => 'name', 'condition' => 9, 'pattern' => 1)), 'action' => '_fusion2');
     $rules[] = array('name' => 'Phone update (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Phone'), array('criteria' => 'mac', 'condition' => 10, 'pattern' => 1), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Phone import (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Phone'), array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Phone import denied', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => 'Phone')), 'action' => '_fusion2');
     $rules[] = array('name' => 'Global constraint (name)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'name', 'condition' => 9, 'pattern' => 1)), 'action' => '_fusion2');
     $rules[] = array('name' => 'Global update (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1), array('criteria' => 'serial', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Global update (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1), array('criteria' => 'mac', 'condition' => 10, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Global import (by serial)', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'serial', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Global import (by mac)', 'match' => 'AND', 'is_active' => 0, 'criteria' => array(array('criteria' => 'mac', 'condition' => 8, 'pattern' => 1)), 'action' => '_fusion1');
     $rules[] = array('name' => 'Global import denied', 'match' => 'AND', 'is_active' => 1, 'criteria' => array(array('criteria' => 'itemtype', 'condition' => 0, 'pattern' => '')), 'action' => '_fusion2');
     $ranking = 0;
     foreach ($rules as $rule) {
         $rulecollection = new PluginFusioninventoryInventoryRuleImportCollection();
         $input = array();
         $input['is_active'] = $rule['is_active'];
         $input['name'] = $rule['name'];
         $input['match'] = $rule['match'];
         $input['sub_type'] = 'PluginFusioninventoryInventoryRuleImport';
         $input['ranking'] = $ranking;
         $rule_id = $rulecollection->add($input);
         // Add criteria
         $rulefi = $rulecollection->getRuleClass();
         foreach ($rule['criteria'] as $criteria) {
             $rulecriteria = new RuleCriteria(get_class($rulefi));
             $criteria['rules_id'] = $rule_id;
             $rulecriteria->add($criteria);
         }
         // Add action
         $ruleaction = new RuleAction(get_class($rulefi));
         $input = array();
         $input['rules_id'] = $rule_id;
         $input['action_type'] = 'assign';
         if ($rule['action'] == '_fusion1') {
             $input['field'] = '_fusion';
             $input['value'] = '1';
         } else {
             if ($rule['action'] == '_fusion2') {
                 $input['field'] = '_fusion';
                 $input['value'] = '2';
             } else {
                 if ($rule['action'] == '_ignore_import') {
                     $input['field'] = '_ignore_import';
                     $input['value'] = '1';
                 }
             }
         }
         $ruleaction->add($input);
         $ranking++;
     }
     return true;
     // Old rules
     $ranking = 0;
     // Create rule for : Peripheral + serial
     $rulecollection = new PluginFusioninventoryInventoryRuleImportCollection();
     $input = array();
     $input['is_active'] = 1;
     $input['name'] = 'Peripheral serial';
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:setup.class.php

示例7: Rule

switch ($action) {
    case "preview_import":
        $rulecollection->checkGlobal(CREATE);
        if (RuleCollection::previewImportRules()) {
            break;
        }
    case "import":
        $rulecollection->checkGlobal(CREATE);
        RuleCollection::displayImportRulesForm();
        break;
    case "export":
        $rule = new Rule();
        if (isset($_SESSION['exportitems'])) {
            $rules_key = array_keys($_SESSION['exportitems']);
        } else {
            $rules_key = array_keys($rule->find());
        }
        $rulecollection->exportRulesToXML($rules_key);
        unset($_SESSION['exportitems']);
        break;
    case "download":
        echo "<div class='center'>";
        echo "<a href='" . Toolbox::getItemTypeSearchURL($_REQUEST['itemtype']) . "'>" . __('Back') . "</a>";
        echo "</div>";
        Html::redirect("rule.backup.php?action=export&itemtype=" . $_REQUEST['itemtype']);
        break;
    case "process_import":
        $rulecollection->checkGlobal(CREATE);
        RuleCollection::processImportRules();
        Html::back();
        break;
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:rule.backup.php

示例8: delete_base_rules

 /**
  * Delete rule, also remove and update groups.
  *
  * @param null $id
  * @return bool
  * @throws Sentry\SentryException
  */
 public function delete_base_rules($id = null)
 {
     try {
         if (!empty($id)) {
             $rules = array(Rule::find($id));
         } else {
             $rules = Rule::all();
         }
         $groups = $this->get_base_groups();
         foreach ($groups as $group) {
             $permissions = array();
             if (!empty($group['permissions'])) {
                 $permissions = json_decode($group['permissions'], true);
                 foreach ($rules as $rule) {
                     if (!isset($permissions[$rule->rule])) {
                         continue;
                     }
                     $permissions[$rule->rule] = 0;
                 }
                 $this->update_base_group_rules($group['id'], $permissions);
             }
         }
         foreach ($rules as $rule) {
             $rule->delete();
         }
         return true;
     } catch (Sentry\SentryException $e) {
         throw new Sentry\SentryException($e->getMessage());
     }
 }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:37,代码来源:GroupAccess.php

示例9: plugin_resources_uninstall

function plugin_resources_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_resources_resources", "glpi_plugin_resources_resources_items", "glpi_plugin_resources_employees", "glpi_plugin_resources_employers", "glpi_plugin_resources_clients", "glpi_plugin_resources_choices", "glpi_plugin_resources_choiceitems", "glpi_plugin_resources_departments", "glpi_plugin_resources_contracttypes", "glpi_plugin_resources_resourcestates", "glpi_plugin_resources_tasktypes", "glpi_plugin_resources_profiles", "glpi_plugin_resources_tasks", "glpi_plugin_resources_taskplannings", "glpi_plugin_resources_tasks_items", "glpi_plugin_resources_checklists", "glpi_plugin_resources_checklistconfigs", "glpi_plugin_resources_reportconfigs", "glpi_plugin_resources_resourcerestings", "glpi_plugin_resources_resourceholidays", "glpi_plugin_resources_ticketcategories", "glpi_plugin_resources_resourcesituations", "glpi_plugin_resources_contractnatures", "glpi_plugin_resources_ranks", "glpi_plugin_resources_resourcespecialities", "glpi_plugin_resources_leavingreasons", "glpi_plugin_resources_professions", "glpi_plugin_resources_professionlines", "glpi_plugin_resources_professioncategories", "glpi_plugin_resources_employments", "glpi_plugin_resources_employmentstates", "glpi_plugin_resources_budgets", "glpi_plugin_resources_costs", "glpi_plugin_resources_budgettypes", "glpi_plugin_resources_budgetvolumes");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_resources", "glpi_plugin_resources_device", "glpi_plugin_resources_needs", "glpi_plugin_resources_employee", "glpi_dropdown_plugin_resources_employer", "glpi_dropdown_plugin_resources_client", "glpi_dropdown_plugin_resources_type", "glpi_dropdown_plugin_resources_department", "glpi_dropdown_plugin_resources_tasks_type", "glpi_plugin_resources_mailingsettings", "glpi_plugin_resources_mailing");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $in = "IN (" . implode(',', array("'PluginResourcesResource'", "'PluginResourcesTask'", "'PluginResourcesHelpdesk'", "'PluginResourcesDirectory'", "'PluginResourcesChecklistconfig'", "'PluginResourcesResourceResting'", "'PluginResourcesResourceHoliday'", "'PluginResourcesBudget'", "'PluginResourcesEmployment'", "'PluginResourcesRecap'")) . ")";
    $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables as $table) {
        $query = "DELETE FROM `{$table}` WHERE (`itemtype` " . $in . " ) ";
        $DB->query($query);
    }
    //drop rules
    $Rule = new Rule();
    $a_rules = $Rule->find("`sub_type`='PluginResourcesRuleChecklist'\n                              OR `sub_type`='PluginResourcesRuleContracttype'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'new', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'update', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'delete', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newtask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updatetask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deletetask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertExpiredTasks', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingResources', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertArrivalChecklists', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingChecklists', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'LeavingResource', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'report', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:hook.php


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