本文整理汇总了PHP中Rule::getUuid方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::getUuid方法的具体用法?PHP Rule::getUuid怎么用?PHP Rule::getUuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule::getUuid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRecursiveAttached
/**
* Private function : Recursivly get attached documents
*
* @param $mid message id
* @param $path temporary path
* @param $maxsize of document to be retrieved
* @param $structure of the message or part
* @param $part part for recursive
*
* Result is stored in $this->files
**/
function getRecursiveAttached($mid, $path, $maxsize, $structure, $part = "")
{
if ($structure->type == 1) {
// multipart
reset($structure->parts);
while (list($index, $sub) = each($structure->parts)) {
$this->getRecursiveAttached($mid, $path, $maxsize, $sub, $part ? $part . "." . ($index + 1) : $index + 1);
}
} else {
$filename = '';
if ($structure->ifdparameters) {
// get filename of attachment if present
// if there are any dparameters present in this part
if (count($structure->dparameters) > 0) {
foreach ($structure->dparameters as $dparam) {
if (Toolbox::strtoupper($dparam->attribute) == 'NAME' || Toolbox::strtoupper($dparam->attribute) == 'FILENAME') {
$filename = $dparam->value;
}
}
}
}
//if no filename found
if (empty($filename) && $structure->ifparameters) {
// if there are any parameters present in this part
if (count($structure->parameters) > 0) {
foreach ($structure->parameters as $param) {
if (Toolbox::strtoupper($param->attribute) == 'NAME' || Toolbox::strtoupper($param->attribute) == 'FILENAME') {
$filename = $param->value;
}
}
}
}
if (empty($filename) && $structure->type == 5 && $structure->subtype) {
// Embeded image come without filename - generate trivial one
$filename = "image_{$part}." . $structure->subtype;
}
// if no filename found, ignore this part
if (empty($filename)) {
return false;
}
//try to avoid conflict between inline image and attachment
$i = 2;
while (in_array($filename, $this->files)) {
//replace filename with name_(num).EXT by name_(num+1).EXT
$new_filename = preg_replace("/(.*)_([0-9])*(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$3", $filename);
if ($new_filename !== $filename) {
$filename = $new_filename;
} else {
//the previous regex didn't found _num pattern, so add it with this one
$filename = preg_replace("/(.*)(\\.[a-zA-Z0-9]*)\$/", "\$1_" . $i . "\$2", $filename);
}
$i++;
}
$filename = $this->decodeMimeString($filename);
if ($structure->bytes > $maxsize) {
$this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Too large attached file'), sprintf(__('%1$s (%2$s)'), $filename, Toolbox::getSize($structure->bytes)));
return false;
}
if (!Document::isValidDoc($filename)) {
//TRANS: %1$s is the filename and %2$s its mime type
$this->addtobody .= "\n\n" . sprintf(__('%1$s: %2$s'), __('Invalid attached file'), sprintf(__('%1$s (%2$s)'), $filename, $this->get_mime_type($structure)));
return false;
}
if ($message = imap_fetchbody($this->marubox, $mid, $part)) {
switch ($structure->encoding) {
case 1:
$message = imap_8bit($message);
break;
case 2:
$message = imap_binary($message);
break;
case 3:
$message = imap_base64($message);
break;
case 4:
$message = quoted_printable_decode($message);
break;
}
if (file_put_contents($path . $filename, $message)) {
$this->files[$filename] = $filename;
// If embeded image, we add a tag
if ($structure->type == 5 && $structure->subtype) {
end($this->files);
$tag = Rule::getUuid();
$this->tags[$filename] = $tag;
// Link file based on id
if (isset($structure->id)) {
$clean = array('<' => '', '>' => '');
$this->altfiles[strtr($structure->id, $clean)] = $filename;
//.........这里部分代码省略.........
示例2: update084to085
//.........这里部分代码省略.........
$migration->dropTable('glpi_rulecacheprinters');
$migration->dropTable('glpi_rulecacheprintertypes');
$migration->dropTable('glpi_rulecachesoftwares');
$migration->displayMessage(sprintf(__('Data migration - %s'), 'glpi_rules'));
$migration->addField("glpi_rules", 'uuid', "string");
$migration->addField("glpi_slalevels", 'uuid', "string");
$migration->migrationOneTable('glpi_rules');
$migration->migrationOneTable('glpi_slalevels');
// Dropdown translations
$migration->displayMessage(sprintf(__('Data migration - %s'), 'glpi_knowbaseitemtranslations'));
Config::setConfigurationValues('core', array('translate_kb' => 0));
if (!TableExists("glpi_knowbaseitemtranslations")) {
$query = "CREATE TABLE IF NOT EXISTS `glpi_knowbaseitemtranslations` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `knowbaseitems_id` int(11) NOT NULL DEFAULT '0',\n `language` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,\n `name` text COLLATE utf8_unicode_ci,\n `answer` longtext COLLATE utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `item` (`knowbaseitems_id`, `language`),\n FULLTEXT KEY `fulltext` (`name`,`answer`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->queryOrDie($query, "0.85 add table glpi_knowbaseitemtranslations");
}
// kb translations
$migration->displayMessage(sprintf(__('Data migration - %s'), 'glpi_dropdowntranslations'));
Config::setConfigurationValues('core', array('translate_dropdowns' => 0));
if (!TableExists("glpi_dropdowntranslations")) {
$query = "CREATE TABLE IF NOT EXISTS `glpi_dropdowntranslations` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `items_id` int(11) NOT NULL DEFAULT '0',\n `itemtype` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,\n `language` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,\n `field` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,\n `value` text COLLATE utf8_unicode_ci,\n PRIMARY KEY (`id`),\n UNIQUE KEY `unicity` (`itemtype`,`items_id`,`language`,`field`),\n KEY `typeid` (`itemtype`,`items_id`),\n KEY `language` (`language`),\n KEY `field` (`field`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->queryOrDie($query, "0.85 add table glpi_dropdowntranslations");
}
//generate uuid for the basic rules of glpi
// we use a complete sql where for cover all migration case (0.78 -> 0.85)
$rules = array(array('sub_type' => 'RuleImportEntity', 'name' => 'Root', 'match' => 'AND', 'description' => ''), array('sub_type' => 'RuleRight', 'name' => 'Root', 'match' => 'AND', 'description' => ''), array('sub_type' => 'RuleMailCollector', 'name' => 'Root', 'match' => 'AND', 'description' => ''), array('sub_type' => 'RuleMailCollector', 'name' => 'Auto-Reply X-Auto-Response-Suppress', 'match' => 'AND', 'description' => 'Exclude Auto-Reply emails using X-Auto-Response-Suppress header'), array('sub_type' => 'RuleMailCollector', 'name' => 'Auto-Reply Auto-Submitted', 'match' => 'AND', 'description' => 'Exclude Auto-Reply emails using Auto-Submitted header'), array('sub_type' => 'RuleTicket', 'name' => 'Ticket location from item', 'match' => 'AND', 'description' => ''), array('sub_type' => 'RuleTicket', 'name' => 'Ticket location from user', 'match' => 'AND', 'description' => ''));
$i = 0;
foreach ($rules as $rule) {
$query = "UPDATE `glpi_rules`\n SET `uuid` = 'STATIC-UUID-{$i}'\n WHERE `entities_id` = 0\n AND `is_recursive` = 0\n AND `sub_type` = '" . $rule['sub_type'] . "'\n AND `name` = '" . $rule['name'] . "'\n AND `description` = '" . $rule['description'] . "'\n AND `match` = '" . $rule['match'] . "'\n ORDER BY id ASC\n LIMIT 1";
$DB->queryOrDie($query, "0.85 add uuid to basic rules (STATIC-UUID-{$i})");
$i++;
}
//generate uuid for the rules of user
foreach ($DB->request('glpi_rules', array('uuid' => NULL)) as $data) {
$uuid = Rule::getUuid();
$query = "UPDATE `glpi_rules`\n SET `uuid` = '{$uuid}'\n WHERE `id` = '" . $data['id'] . "'";
$DB->queryOrDie($query, "0.85 add uuid to existing rules");
}
foreach ($DB->request('glpi_slalevels', array('uuid' => NULL)) as $data) {
$uuid = Rule::getUuid();
$query = "UPDATE `glpi_slalevels`\n SET `uuid` = '{$uuid}'\n WHERE `id` = '" . $data['id'] . "'";
$DB->queryOrDie($query, "0.85 add uuid to existing slalevels");
}
$migration->addField('glpi_users', 'is_deleted_ldap', 'bool');
$migration->addKey('glpi_users', 'is_deleted_ldap');
Config::deleteConfigurationValues('core', array('use_ajax'));
Config::deleteConfigurationValues('core', array('ajax_min_textsearch_load'));
Config::deleteConfigurationValues('core', array('ajax_buffertime_load'));
Config::deleteConfigurationValues('core', array('is_categorized_soft_expanded'));
Config::deleteConfigurationValues('core', array('is_not_categorized_soft_expanded'));
$migration->dropField("glpi_users", 'is_categorized_soft_expanded');
$migration->dropField("glpi_users", 'is_not_categorized_soft_expanded');
// Config::setConfigurationValues('core', array('use_unicodefont' => 0));
// $migration->addField("glpi_users", 'use_unicodefont', "int(11) DEFAULT NULL");
Config::deleteConfigurationValues('core', array('use_unicodefont'));
$migration->dropField("glpi_users", 'use_unicodefont');
Config::setConfigurationValues('core', array('pdffont' => 'helvetica'));
$migration->addField("glpi_users", 'pdffont', "string");
$migration->addField("glpi_users", 'picture', "string");
$migration->addField("glpi_authldaps", 'picture_field', 'string');
$migration->addField('glpi_links', 'open_window', 'bool', array('value' => 1));
$migration->displayMessage(sprintf(__('Data migration - %s'), 'glpi_states'));
foreach (array('is_visible_computer', 'is_visible_monitor', 'is_visible_networkequipment', 'is_visible_peripheral', 'is_visible_phone', 'is_visible_printer', 'is_visible_softwareversion') as $field) {
$migration->addField('glpi_states', $field, 'bool', array('value' => '1'));
$migration->addKey('glpi_states', $field);
}
// glpi_domains by entity
示例3: exportPackage
/**
* Used to export package
*
*/
function exportPackage($packages_id)
{
$this->getFromDB($packages_id);
if (empty($this->fields['uuid'])) {
$input = array('id' => $this->fields['id'], 'uuid' => Rule::getUuid());
$this->update($input);
}
$pfDeployOrder = new PluginFusioninventoryDeployOrder();
$pfDeployFile = new PluginFusioninventoryDeployFile();
// Generate JSON
$a_xml = array();
$input = $this->fields;
unset($input['id']);
$a_xml['package'] = $input;
$a_xml['orders'] = array();
$a_xml['files'] = array();
$a_xml['manifests'] = array();
$a_xml['repository'] = array();
$a_files = array();
$a_data = $pfDeployOrder->find("`plugin_fusioninventory_deploypackages_id`='" . $this->fields['id'] . "'");
foreach ($a_data as $data) {
unset($data['id']);
unset($data['plugin_fusioninventory_deploypackages_id']);
$a_xml['orders'][] = $data;
$json = json_decode($data['json'], true);
$a_files = array_merge($a_files, $json['associatedFiles']);
}
// Add files
foreach ($a_files as $files_id => $data) {
$a_pkgfiles = current($pfDeployFile->find("`sha512`='" . $files_id . "'", '', 1));
if (count($a_pkgfiles) > 0) {
unset($a_pkgfiles['id']);
$a_xml['files'][] = $a_pkgfiles;
}
}
// Create zip with JSON and files
$name = preg_replace("/[^a-zA-Z0-9]/", '', $this->fields['name']);
$filename = GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/export/" . $this->fields['uuid'] . "." . $name . ".zip";
if (file_exists($filename)) {
unlink($filename);
}
$zip = new ZipArchive();
if ($zip->open($filename) == TRUE) {
if ($zip->open($filename, ZipArchive::CREATE) == TRUE) {
$zip->addEmptyDir('files');
$zip->addEmptyDir('files/manifests');
$zip->addEmptyDir('files/repository');
foreach ($a_files as $hash => $data) {
$sha512 = file_get_contents(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/manifests/" . $hash);
$sha512 = trim($sha512);
$zip->addFile(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/manifests/" . $hash, "files/manifests/" . $hash);
$a_xml['manifests'][] = $hash;
$file = PluginFusioninventoryDeployFile::getDirBySha512($sha512) . "/" . $sha512;
$zip->addFile(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/repository/" . $file, "files/repository/" . $file);
$a_xml['repository'][] = $file;
}
$json_string = json_encode($a_xml);
$zip->addFromString('information.json', $json_string);
}
$zip->close();
Session::addMessageAfterRedirect(__("Package exported in", "fusioninventory") . " " . GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/export/" . $this->fields['uuid'] . "." . $name . ".zip");
}
}
示例4: prepareInputForAdd
/**
* @see CommonDBTM::prepareInputForAdd()
**/
function prepareInputForAdd($input)
{
global $CFG_GLPI, $DB;
// security (don't accept filename from $_POST)
unset($input['filename']);
if ($uid = Session::getLoginUserID()) {
$input["users_id"] = Session::getLoginUserID();
}
// Create a doc only selecting a file from a item form
$create_from_item = false;
if (isset($input["items_id"]) && isset($input["itemtype"]) && ($item = getItemForItemtype($input["itemtype"])) && $input["items_id"] > 0) {
$typename = $item->getTypeName(1);
$name = NOT_AVAILABLE;
if ($item->getFromDB($input["items_id"])) {
$name = $item->getNameID();
}
//TRANS: %1$s is Document, %2$s is item type, %3$s is item name
$input["name"] = addslashes(Html::resume_text(sprintf(__('%1$s: %2$s'), __('Document'), sprintf(__('%1$s - %2$s'), $typename, $name)), 200));
$create_from_item = true;
}
$upload_ok = false;
if (isset($input["_filename"]) && !empty($input["_filename"]) == 1) {
$upload_ok = $this->moveDocument($input, stripslashes(array_shift($input["_filename"])));
} else {
if (isset($input["upload_file"]) && !empty($input["upload_file"])) {
// Move doc from upload dir
$upload_ok = $this->moveUploadedDocument($input, $input["upload_file"]);
}
}
// Tag
if (isset($input["_tag_filename"]) && !empty($input["_tag_filename"]) == 1) {
$input['tag'] = array_shift($input["_tag_filename"]);
}
if (!isset($input["tag"]) || empty($input["tag"])) {
$input['tag'] = Rule::getUuid();
}
// Upload failed : do not create document
if ($create_from_item && !$upload_ok) {
return false;
}
// Default document name
if ((!isset($input['name']) || empty($input['name'])) && isset($input['filename'])) {
$input['name'] = $input['filename'];
}
unset($input["upload_file"]);
// Don't add if no file
if (isset($input["_only_if_upload_succeed"]) && $input["_only_if_upload_succeed"] && (!isset($input['filename']) || empty($input['filename']))) {
return false;
}
// Set default category for document linked to tickets
if (isset($input['itemtype']) && $input['itemtype'] == 'Ticket' && (!isset($input['documentcategories_id']) || $input['documentcategories_id'] == 0)) {
$input['documentcategories_id'] = $CFG_GLPI["documentcategories_id_forticket"];
}
/* Unicity check
if (isset($input['sha1sum'])) {
// Check if already upload in the current entity
$crit = array('sha1sum'=>$input['sha1sum'],
'entities_id'=>$input['entities_id']);
foreach ($DB->request($this->getTable(), $crit) as $data) {
$link=$this->getFormURL();
Session::addMessageAfterRedirect(__('"A document with that filename has already been attached to another record.').
" : <a href=\"".$link."?id=".
$data['id']."\">".$data['name']."</a>",
false, ERROR, true);
return false;
}
} */
return $input;
}
示例5: duplicateRule
/**
* Duplicate a rule
*
* @param $ID of the rule to duplicate
*
* @since version 0.85
*
* @return true if all ok
**/
function duplicateRule($ID)
{
//duplicate rule
$rulecollection = new self();
$rulecollection->getFromDB($ID);
//get ranking
$ruletype = $rulecollection->fields['sub_type'];
$rule = new $ruletype();
$nextRanking = $rule->getNextRanking();
//Update fields of the new duplicate
$rulecollection->fields['name'] = sprintf(__('Copy of %s'), $rulecollection->fields['name']);
$rulecollection->fields['is_active'] = 0;
$rulecollection->fields['ranking'] = $nextRanking;
$rulecollection->fields['uuid'] = Rule::getUuid();
unset($rulecollection->fields['id']);
//add new duplicate
$newID = $rulecollection->add($rulecollection->fields);
$rule = $rulecollection->getRuleClass();
if (!$newID) {
return false;
}
//find and duplicate actions
$ruleaction = new RuleAction(get_class($rule));
$actions = $ruleaction->find("`rules_id` = '{$ID}'");
foreach ($actions as $action) {
$action['rules_id'] = $newID;
unset($action['id']);
if (!$ruleaction->add($action)) {
return false;
}
}
//find and duplicate criterias
$rulecritera = new RuleCriteria(get_class($rule));
$criteria = $rulecritera->find("`rules_id` = '{$ID}'");
foreach ($criteria as $criterion) {
$criterion['rules_id'] = $newID;
unset($criterion['id']);
if (!$rulecritera->add($criterion)) {
return false;
}
}
return true;
}
示例6: header
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
* @since version 0.85
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header('Content-type: application/json');
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['data'])) {
foreach ($_POST['data'] as $key => $values) {
$unique_name = Rule::getUuid();
$response[$key] = array('tag' => Document::getImageTag($unique_name), 'name' => $unique_name);
}
echo json_encode($response);
}