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


PHP Document::add方法代码示例

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


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

示例1: parse

 /**
  * This method starts the parsing process.
  *
  * If the input was not supplied during construction, it's possible to pass
  * it here instead.
  *
  * If either input or options are not supplied, the defaults will be used.
  *
  * @param resource|string|array|null $input
  * @param int|null $options
  * @return array
  */
 public function parse($input = null, $options = null)
 {
     if (!is_null($input)) {
         $this->setInput($input);
     }
     if (is_null($this->input)) {
         throw new EofException('End of input stream, or no input supplied');
     }
     if (!is_null($options)) {
         $this->options = $options;
     }
     switch ($this->input[0]) {
         case 'vcalendar':
             $this->root = new VCalendar(array(), false);
             break;
         case 'vcard':
             $this->root = new VCard(array(), false);
             break;
         default:
             throw new ParseException('The root component must either be a vcalendar, or a vcard');
     }
     foreach ($this->input[1] as $prop) {
         $this->root->add($this->parseProperty($prop));
     }
     if (isset($this->input[2])) {
         foreach ($this->input[2] as $comp) {
             $this->root->add($this->parseComponent($comp));
         }
     }
     // Resetting the input so we can throw an feof exception the next time.
     $this->input = null;
     return $this->root;
 }
开发者ID:vernonlacerda,项目名称:jorani,代码行数:45,代码来源:Json.php

示例2: testDocumentForFree

 function testDocumentForFree()
 {
     $d = new Document(false);
     $set = array('mediatype' => 'flac', 'url' => 'freesong.flac', 'description' => 'free song');
     $new_id = $d->add($set);
     $d = new Document($new_id);
     $this->assertEquals($set['description'], $d->description());
     $m = $d->price_in('AUD');
     $this->assertEquals('$0.00 AUD', $m->show_with_code());
 }
开发者ID:songwork,项目名称:songwork,代码行数:10,代码来源:testDocument.php

示例3: addFiles

 /**
  * add files (from $_FILES) to a ticket
  * create document if needed
  * create link from document to ticket
  *
  * @param $id of the ticket
  *
  * @return array of doc added name
  **/
 function addFiles($id)
 {
     global $LANG, $CFG_GLPI;
     if (!isset($_FILES)) {
         return array();
     }
     $docadded = array();
     $doc = new Document();
     $docitem = new Document_Item();
     // add Document if exists
     if (isset($_FILES['multiple'])) {
         unset($_FILES['multiple']);
         $TMPFILE = $_FILES;
     } else {
         $TMPFILE = array($_FILES);
     }
     foreach ($TMPFILE as $_FILES) {
         if (isset($_FILES['filename']) && count($_FILES['filename']) > 0 && $_FILES['filename']["size"] > 0) {
             // Check for duplicate
             if ($doc->getFromDBbyContent($this->fields["entities_id"], $_FILES['filename']['tmp_name'])) {
                 $docID = $doc->fields["id"];
             } else {
                 $input2 = array();
                 $input2["name"] = addslashes($LANG['tracking'][24] . " {$id}");
                 $input2["tickets_id"] = $id;
                 $input2["entities_id"] = $this->fields["entities_id"];
                 $input2["documentcategories_id"] = $CFG_GLPI["documentcategories_id_forticket"];
                 $input2["_only_if_upload_succeed"] = 1;
                 $input2["entities_id"] = $this->fields["entities_id"];
                 $docID = $doc->add($input2);
             }
             if ($docID > 0) {
                 if ($docitem->add(array('documents_id' => $docID, 'itemtype' => $this->getType(), 'items_id' => $id))) {
                     $docadded[] = stripslashes($doc->fields["name"] . " - " . $doc->fields["filename"]);
                 }
             }
         } else {
             if (!empty($_FILES['filename']['name']) && isset($_FILES['filename']['error']) && $_FILES['filename']['error']) {
                 addMessageAfterRedirect($LANG['document'][46], false, ERROR);
             }
         }
     }
     unset($_FILES);
     return $docadded;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:54,代码来源:ticket.class.php

示例4: replace

 /**
  * @param $type
  * @param $model_id
  * @param $tab_ids
  * @param $location
  **/
 static function replace($type, $model_id, $tab_ids, $location)
 {
     global $DB, $CFG_GLPI, $PLUGIN_HOOKS;
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     $overwrite = $model->fields["overwrite"];
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'><tr><th>" . __('Replacement', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>";
     $count = 0;
     $tot = count($tab_ids);
     Html::createProgressBar(__('Please wait, replacement is running...', 'uninstall'));
     foreach ($tab_ids as $olditem_id => $newitem_id) {
         $count++;
         $olditem = new $type();
         $olditem->getFromDB($olditem_id);
         $newitem = new $type();
         $newitem->getFromDB($newitem_id);
         //Hook to perform actions before item is being replaced
         $olditem->fields['_newid'] = $newitem_id;
         $olditem->fields['_uninstall_event'] = $model_id;
         $olditem->fields['_action'] = 'replace';
         Plugin::doHook("plugin_uninstall_replace_before", $olditem);
         // Retrieve informations
         //States
         if ($model->fields['states_id'] != 0) {
             $olditem->update(array('id' => $olditem_id, 'states_id' => $model->fields['states_id']), false);
         }
         // METHOD REPLACEMENT 1 : Archive
         if ($model->fields['replace_method'] == self::METHOD_PURGE) {
             $name_out = str_shuffle(Toolbox::getRandomString(5) . time());
             $plugin = new Plugin();
             if ($plugin->isActivated('PDF')) {
                 // USE PDF EXPORT
                 $plugin->load('pdf', true);
                 include_once GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
                 //Get all item's tabs
                 $tab = array_keys($olditem->defineTabs());
                 //Tell PDF to also export item's main tab, and in first position
                 array_unshift($tab, "_main_");
                 $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($olditem);
                 $out = $itempdf->generatePDF(array($olditem_id), $tab, 1, false);
                 $name_out .= ".pdf";
             } else {
                 //TODO Which datas ? Add Defaults...
                 $out = __('Replacement', 'uninstall') . "\r\n";
                 $datas = $olditem->fields;
                 unset($datas['comment']);
                 foreach ($datas as $k => $v) {
                     $out .= $k . ";";
                 }
                 $out .= "\r\n";
                 foreach ($datas as $k => $v) {
                     $out .= $v . ";";
                 }
                 // USE CSV EXPORT
                 $name_out .= ".csv";
             }
             // Write document
             $out_file = GLPI_DOC_DIR . "/_uploads/" . $name_out;
             $open_file = fopen($out_file, 'a');
             fwrite($open_file, $out);
             fclose($open_file);
             // Compute comment text
             $comment = __('This document is the archive of this replaced item', 'uninstall') . " " . self::getCommentsForReplacement($olditem, false, false);
             // Create & Attach new document to current item
             $doc = new Document();
             $input = array('name' => addslashes(__('Archive of old material', 'uninstall')), 'upload_file' => $name_out, 'comment' => addslashes($comment), 'add' => __('Add'), 'entities_id' => $newitem->getEntityID(), 'is_recursive' => $newitem->isRecursive(), 'link' => "", 'documentcategories_id' => 0, 'items_id' => $olditem_id, 'itemtype' => $type);
             //Attached the document to the old item, to generate an accurate name
             $document_added = $doc->add($input);
             //Attach the document to the new item, once the document's name is correct
             $docItem = new Document_Item();
             $docItemId = $docItem->add(array('documents_id' => $document_added, 'itemtype' => $type, 'items_id' => (int) $newitem_id));
         }
         // General Informations - NAME
         if ($model->fields["replace_name"]) {
             if ($overwrite || empty($newitem->fields['name'])) {
                 $newitem->update(array('id' => $newitem_id, 'name' => $olditem->getField('name')), false);
             }
         }
         $data['id'] = $newitem->getID();
         // General Informations - SERIAL
         if ($model->fields["replace_serial"]) {
             if ($overwrite || empty($newitem->fields['serial'])) {
                 $newitem->update(array('id' => $newitem_id, 'serial' => $olditem->getField('serial')), false);
             }
         }
         // General Informations - OTHERSERIAL
         if ($model->fields["replace_otherserial"]) {
             if ($overwrite || empty($newitem->fields['otherserial'])) {
                 $newitem->update(array('id' => $newitem_id, 'otherserial' => $olditem->getField('otherserial')), false);
             }
         }
         // Documents
//.........这里部分代码省略.........
开发者ID:pluginsGLPI,项目名称:uninstall,代码行数:101,代码来源:replace.class.php

示例5: generate_entity

/** Generate bigdump : generate items for an entity
 *
 * @param $ID_entity entity ID
**/
function generate_entity($ID_entity) {
   global $MAX, $DB, $percent, $FIRST, $LAST, $MAX_KBITEMS_BY_CAT, $MAX_DISK,
         $DOCUMENTS, $NET_PORT, $NET_LOC;

   regenerateTreeCompleteName("glpi_entities");

   $current_year = date("Y");


   // DOMAIN
   $items = array("SP2MI", "CAMPUS"," IUT86", "PRESIDENCE", "CEAT", "D'omaine");
   $dp    = new Domain();
   $FIRST["domain"] = getMaxItem("glpi_domains")+1;

   for ($i=0 ; $i<$MAX['domain'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "domain $ID_entity '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                              'entities_id'  => $ID_entity,
                                              'is_recursive' => 1,
                                              'comment'      => "comment $val")));
   }
   $LAST["domain"] = getMaxItem("glpi_domains");


   // STATUS
   $items = array("Reparation", "En stock", "En fonction", "Retour SAV", "En attente d'");
   $dp    = new State();
   $FIRST["state"] = getMaxItem("glpi_states")+1;
   for ($i=0 ; $i<$MAX['state'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "State $ID_entity '$i";
      }
      $state_id = $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                                          'entities_id'  => $ID_entity,
                                                          'is_recursive' => 1,
                                                          'comment'      => "comment $val")));

      // generate sub status
      for ($j=0 ; $j<$MAX['state'] ; $j++) {
         $val2 = "Sub $val $j";

         $dp->add(toolbox::addslashes_deep(array('name'         => $val2,
                                                 'entities_id'  => $ID_entity,
                                                 'is_recursive' => 1,
                                                 'states_id'    => $state_id,
                                                 'comment'      => "comment $val")));
      }

   }
   $LAST["state"]      = getMaxItem("glpi_states");


   // glpi_groups
   $FIRST["groups"] = getMaxItem("glpi_groups")+1;
   $group           = new Group();
   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
      $gID = $group->add(toolbox::addslashes_deep(
                         array('entities_id'  => $ID_entity,
                               'name'         => "group d'$i",
                               'comment'      => "comment group d'$i",
                               'is_assign'    => 0)));

      // Generate sub group
      for ($j=0 ; $j<$MAX['groups'] ; $j++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "subgroup d'$j",
                           'comment'      => "comment subgroup d'$j of group $i",
                           'groups_id'    => $gID,
                           'is_assign'    => 0)));
      }
   }

   $LAST["groups"]      = getMaxItem("glpi_groups");

   $FIRST["techgroups"] = $LAST["groups"]+1;

   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "tech group d'$i",
                           'comment'      => "comment tech group d'$i")));
   }

   $LAST["techgroups"] = getMaxItem("glpi_groups");
   regenerateTreeCompleteName("glpi_groups");


   // glpi_users
   $FIRST["users_sadmin"] = getMaxItem("glpi_users")+1;
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:generate_bigdump.function.php

示例6: addFiles

 /**
  * add files (from $_FILES) to an ITIL object
  * create document if needed
  * create link from document to ITIL object
  *
  * @param $id        Integer  ID of the ITIL object
  * @param $donotif   Boolean  if we want to raise notification (default 1)
  *
  * @return array of doc added name
  **/
 function addFiles($id, $donotif = 1)
 {
     global $CFG_GLPI;
     if (!isset($_FILES) || !isset($_FILES['filename'])) {
         return array();
     }
     $docadded = array();
     $doc = new Document();
     $docitem = new Document_Item();
     // if multiple files are uploaded
     $TMPFILE = array();
     if (is_array($_FILES['filename']['name'])) {
         foreach ($_FILES['filename']['name'] as $key => $filename) {
             if (!empty($filename)) {
                 $TMPFILE[$key]['filename']['name'] = $filename;
                 $TMPFILE[$key]['filename']['type'] = $_FILES['filename']['type'][$key];
                 $TMPFILE[$key]['filename']['tmp_name'] = $_FILES['filename']['tmp_name'][$key];
                 $TMPFILE[$key]['filename']['error'] = $_FILES['filename']['error'][$key];
                 $TMPFILE[$key]['filename']['size'] = $_FILES['filename']['size'][$key];
             }
         }
     } else {
         $TMPFILE = array($_FILES);
     }
     foreach ($TMPFILE as $_FILES) {
         if (isset($_FILES['filename']) && count($_FILES['filename']) > 0 && $_FILES['filename']["size"] > 0) {
             // Check for duplicate
             if ($doc->getFromDBbyContent($this->fields["entities_id"], $_FILES['filename']['tmp_name'])) {
                 $docID = $doc->fields["id"];
             } else {
                 $input2 = array();
                 //TRANS: Default document to files attached to tickets : %d is the ticket id
                 $input2["name"] = addslashes(sprintf(__('Document Ticket %d'), $id));
                 if ($this->getType() == 'Ticket') {
                     $input2["tickets_id"] = $id;
                 }
                 $input2["entities_id"] = $this->fields["entities_id"];
                 $input2["documentcategories_id"] = $CFG_GLPI["documentcategories_id_forticket"];
                 $input2["_only_if_upload_succeed"] = 1;
                 $input2["entities_id"] = $this->fields["entities_id"];
                 $docID = $doc->add($input2);
             }
             if ($docID > 0) {
                 if ($docitem->add(array('documents_id' => $docID, '_do_notif' => $donotif, 'itemtype' => $this->getType(), 'items_id' => $id))) {
                     $docadded[] = sprintf(__('%1$s - %2$s'), stripslashes($doc->fields["name"]), stripslashes($doc->fields["filename"]));
                 }
             }
         } else {
             if (!empty($_FILES['filename']['name']) && isset($_FILES['filename']['error']) && $_FILES['filename']['error']) {
                 Session::addMessageAfterRedirect(__('Failed to send the file (probably too large)'), false, ERROR);
             }
         }
         // Only notification for the first New doc
         $donotif = 0;
     }
     unset($_FILES);
     return $docadded;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:68,代码来源:commonitilobject.class.php

示例7: copyDocuments

 /**
  * Copy order documents into the newly generated item
  * @since 1.5.3
  * @param unknown_type $itemtype
  * @param unknown_type $items_id
  * @param unknown_type $orders_id
  * @param unknown_type $entity
  */
 static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
         $document_item = new Document_Item();
         $document = new Document();
         foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder'\n                                           AND `items_id`='{$orders_id}'") as $doc) {
             $document->getFromDB($doc['documents_id']);
             $mime = $document->fields['mime'];
             $newdocument = clone $document;
             $newdocument->fields['entities_id'] = $entity;
             unset($newdocument->fields['id']);
             $newID = $document->add($newdocument->fields);
             $tmp['itemtype'] = $itemtype;
             $tmp['items_id'] = $items_id;
             $tmp['documents_id'] = $newID;
             $document_item->add($tmp);
             //force mimetype
             $document->update(array('id' => $newID, 'mime' => $mime));
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:link.class.php

示例8: saveAnswers

 public function saveAnswers($datas)
 {
     $form = new PluginFormcreatorForm();
     $form->getFromDB($datas['formcreator_form']);
     $query = "SELECT q.`id`, q.`fieldtype`, q.`name`\n                FROM glpi_plugin_formcreator_questions q\n                LEFT JOIN glpi_plugin_formcreator_sections s ON s.`id` = q.`plugin_formcreator_sections_id`\n                WHERE s.`plugin_formcreator_forms_id` = {$datas['formcreator_form']}";
     $result = $GLOBALS['DB']->query($query);
     // Update form answers
     if (isset($_POST['save_formanswer'])) {
         $status = $_POST['status'];
         $this->update(array('id' => (int) $datas['id'], 'status' => $status, 'comment' => isset($_POST['comment']) ? $_POST['comment'] : 'NULL'));
         // Update questions answers
         if ($status == 'waiting') {
             while ($question = $GLOBALS['DB']->fetch_array($result)) {
                 if ($question['fieldtype'] != 'file') {
                     $answer = new PluginFormcreatorAnswer();
                     $found = $answer->find('`plugin_formcreator_formanwers_id` = ' . (int) $datas['id'] . '
                                       AND `plugin_formcreator_question_id` = ' . $question['id']);
                     $found = array_shift($found);
                     $data_value = $datas['formcreator_field_' . $question['id']];
                     if (isset($data_value)) {
                         if (is_array($data_value)) {
                             foreach ($data_value as $key => $value) {
                                 $data_value[$key] = $value;
                             }
                             $answer_value = json_encode($data_value);
                         } else {
                             $answer_value = $data_value;
                         }
                     } else {
                         $answer_value = '';
                     }
                     $answer->update(array('id' => $found['id'], 'answer' => $answer_value));
                 } elseif (isset($_FILES['formcreator_field_' . $question['id']]['tmp_name']) && is_file($_FILES['formcreator_field_' . $question['id']]['tmp_name'])) {
                     $doc = new Document();
                     $answer = new PluginFormcreatorAnswer();
                     $found = $answer->find('`plugin_formcreator_formanwers_id` = ' . (int) $datas['id'] . '
                                       AND `plugin_formcreator_question_id` = ' . $question['id']);
                     $found = array_shift($found);
                     $file_datas = array();
                     $file_datas["name"] = $form->fields['name'] . ' - ' . $question['name'];
                     $file_datas["entities_id"] = isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $form->fields['entities_id'];
                     $file_datas["is_recursive"] = $form->fields['is_recursive'];
                     Document::uploadDocument($file_datas, $_FILES['formcreator_field_' . $question['id']]);
                     if ($docID = $doc->add($file_datas)) {
                         $table = getTableForItemType('Document');
                         $filename = $_FILES['formcreator_field_' . $question['id']]['name'];
                         $query = "UPDATE {$table} SET filename = '" . $filename . "' WHERE id = " . $docID;
                         $GLOBALS['DB']->query($query);
                         $docItem = new Document_Item();
                         $docItemId = $docItem->add(array('documents_id' => $docID, 'itemtype' => __CLASS__, 'items_id' => (int) $datas['id']));
                         $answer->update(array('id' => $found['id'], 'answer' => $docID));
                     }
                 }
             }
         }
         // Create new form answer object
     } else {
         // Does the form need to be validate ?
         if ($form->fields['validation_required']) {
             $status = 'waiting';
         } else {
             $status = 'accepted';
         }
         $id = $this->add(array('entities_id' => isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $form->fields['entities_id'], 'is_recursive' => $form->fields['is_recursive'], 'plugin_formcreator_forms_id' => $datas['formcreator_form'], 'requester_id' => isset($_SESSION['glpiID']) ? $_SESSION['glpiID'] : 0, 'validator_id' => isset($datas['formcreator_validator']) ? $datas['formcreator_validator'] : 0, 'status' => $status, 'request_date' => date('Y-m-d H:i:s')));
         // Save questions answers
         while ($question = $GLOBALS['DB']->fetch_assoc($result)) {
             // If the answer is set, check if it is an array (then implode id).
             if (isset($datas[$question['id']])) {
                 $question_answer = $datas[$question['id']];
                 if (is_array(json_decode($question_answer))) {
                     $question_answer = json_decode($question_answer);
                     foreach ($question_answer as $key => $value) {
                         $question_answer[$key] = $value;
                     }
                     $question_answer = json_encode($question_answer);
                 } else {
                     $question_answer = $question_answer;
                 }
             } else {
                 $question_answer = '';
             }
             $answer = new PluginFormcreatorAnswer();
             $answerID = $answer->add(array('plugin_formcreator_formanwers_id' => $id, 'plugin_formcreator_question_id' => $question['id'], 'answer' => $question_answer));
             // If the question is a file field, save the file as a document
             if ($question['fieldtype'] == 'file' && isset($_FILES['formcreator_field_' . $question['id']]['tmp_name']) && is_file($_FILES['formcreator_field_' . $question['id']]['tmp_name'])) {
                 $doc = new Document();
                 $file_datas = array();
                 $file_datas["name"] = $form->fields['name'] . ' - ' . $question['name'];
                 $file_datas["entities_id"] = isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $form->fields['entities_id'];
                 $file_datas["is_recursive"] = $form->fields['is_recursive'];
                 Document::uploadDocument($file_datas, $_FILES['formcreator_field_' . $question['id']]);
                 if ($docID = $doc->add($file_datas)) {
                     $table = getTableForItemType('Document');
                     $filename = $_FILES['formcreator_field_' . $question['id']]['name'];
                     $query = "UPDATE {$table} SET filename = '" . $filename . "' WHERE id = " . $docID;
                     $GLOBALS['DB']->query($query);
                     $docItem = new Document_Item();
                     $docItemId = $docItem->add(array('documents_id' => $docID, 'itemtype' => __CLASS__, 'items_id' => $id));
                     $answer->update(array('id' => $answerID, 'answer' => $docID));
                 }
//.........这里部分代码省略.........
开发者ID:jcr0ch4,项目名称:formcreator,代码行数:101,代码来源:formanswer.class.php

示例9: showFormResCreateLocation

 /**
  * Résultat de la création du sous-lieu + ajout dans la base de données
  */
 static function showFormResCreateLocation($opt)
 {
     global $CFG_GLPI, $DB;
     $filename = $opt["document_id"] . $opt["name"] . "." . $opt["extension"];
     $filepath = "/_uploads/" . $filename;
     $id = 0;
     if ($opt["test"] == "existLocation") {
         $query = "SELECT `id`,`name`\n                  FROM `glpi_locations`\n                  WHERE `id` = '" . $opt["locations_id"] . "'";
         $result = $DB->query($query);
         while ($data = $DB->fetch_assoc($result)) {
             $name = $data['name'];
             $id = $data['id'];
         }
     } else {
         if ($opt["test"] == "newLocation") {
             $locations_id = $opt["locations_idParent"];
         }
     }
     $params = array("name" => $opt["name"], "document_id" => $opt["document_id"], "filepath" => $filepath, "filename" => $filename, "entities_id" => $opt["entities_id"], "locations_id" => $opt["locations_id"], "id" => $id, "itemtype" => "Location");
     //FONCTION QUI PERMET D'AJOUTER LE LIEU DANS LA BASE DE DONNEES
     $dropdown = new Location();
     //AJOUT DU LIEU
     if ($opt["test"] == 'newLocation') {
         if ($newID = $dropdown->add($params)) {
         } else {
             $locations_found = $dropdown->find("`name` = '" . $params['name'] . "' AND `entities_id` = '" . $params['entities_id'] . "' AND `locations_id` = '" . $params['locations_id'] . "'", '', '1');
             $newID = key($locations_found);
         }
         $opt["locations_id"] = $newID;
     }
     if ($opt["locations_id"] != $opt["locations_idParent"]) {
         //AJOUT DU DOC ASSOCIE AU LIEU
         $doc = new Document();
         $documentitem = new Document_Item();
         $self = new self();
         $input = array();
         $input["entities_id"] = $opt["entities_id"];
         $input["name"] = $opt["name"];
         $input["upload_file"] = $filename;
         //$input["documentcategories_id"]=$options["rubrique"];
         //$input["mime"]="text/html";
         $input["date_mod"] = date("Y-m-d H:i:s");
         $input["users_id"] = Session::getLoginUserID();
         $newdoc = $doc->add($input);
         // Add new location
         if ($opt["test"] == 'newLocation') {
             // We check if the element already exists
             $restrict = "`items_id` = '" . $newID . "' AND `itemtype` = 'Location'";
             if (countElementsInTable("glpi_plugin_positions_positions", $restrict) != 0) {
                 Session::addMessageAfterRedirect(__('This item is already bound to a location', 'positions'), false, ERROR);
                 Html::redirect($CFG_GLPI["root_doc"] . "/plugins/positions/front/map.php?locations_id=" . $opt["locations_idParent"]);
                 // If not we can add its position and picture
             } else {
                 $documentitem->add(array('documents_id' => $newdoc, 'itemtype' => 'Location', 'items_id' => $newID, 'entities_id' => $opt["entities_id"]));
                 $param = array("items_id" => $newID, "entities_id" => $opt["entities_id"], "locations_id" => $opt["locations_idParent"], "itemtype" => "Location", "x_coordinates" => -800, "y_coordinates" => -150);
                 $self->add($param);
                 if ($opt["checked"] == 'on') {
                     self::showMapCreateLocation($opt);
                 } else {
                     if ($opt["checked"] == 'off') {
                         Html::redirect($CFG_GLPI["root_doc"] . "/plugins/positions/front/map.php?locations_id=" . $opt["locations_id"]);
                     }
                 }
             }
             // Add existing location
         } else {
             if ($opt["test"] == 'existLocation') {
                 $documentitem->add(array('documents_id' => $newdoc, 'itemtype' => 'Location', 'items_id' => $id));
                 $param = array("items_id" => $id, "entities_id" => $opt["entities_id"], "locations_id" => $opt["locations_idParent"], "itemtype" => "Location", "x_coordinates" => -800, "y_coordinates" => -150);
                 $self->add($param);
                 if ($opt["checked"] == 'on') {
                     self::showMapCreateLocation($opt);
                 } else {
                     if ($opt["checked"] == 'off') {
                         Html::redirect($CFG_GLPI["root_doc"] . "/plugins/positions/front/map.php?locations_id=" . $opt["locations_id"]);
                     }
                 }
             }
         }
     } else {
         Session::addMessageAfterRedirect(__('This item is already bound to a location', 'positions'), false, ERROR);
         Html::redirect($CFG_GLPI["root_doc"] . "/plugins/positions/front/map.php?locations_id=" . $opt["locations_id"]);
     }
 }
开发者ID:nsautier,项目名称:positions,代码行数:87,代码来源:position.class.php

示例10: copyDocuments

 /**
  * Copy order documents into the newly generated item
  * @since 1.5.3
  * @param unknown_type $itemtype
  * @param unknown_type $items_id
  * @param unknown_type $orders_id
  * @param unknown_type $entity
  */
 public static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
         $document = new Document();
         foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder' AND `items_id`='{$orders_id}'") as $doc) {
             $document->getFromDB($doc['documents_id']);
             $newdocument = clone $document;
             $newdocument->fields['entities_id'] = $entity;
             $newdocument->fields['items_id'] = $items_id;
             $newdocument->fields['itemtype'] = $itemtype;
             unset($newdocument->fields['id']);
             $document->add($newdocument->fields);
         }
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:25,代码来源:link.class.php

示例11: Document

// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
if (!isset($_GET["id"])) {
    $_GET["id"] = -1;
}
$doc = new Document();
$documentitem = new Document_Item();
if (isset($_POST["add"])) {
    $doc->check(-1, 'w', $_POST);
    if (isset($_POST['itemtype']) && isset($_POST['items_id']) && isset($_FILES['filename']['tmp_name']) && $doc->getFromDBbyContent($_POST["entities_id"], $_FILES['filename']['tmp_name'])) {
        $documentitem->add(array('documents_id' => $doc->fields['id'], 'itemtype' => $_POST['itemtype'], 'items_id' => $_POST['items_id']));
    } else {
        $newID = $doc->add($_POST);
        $name = "";
        if (isset($_POST["name"])) {
            $name = $_POST["name"];
        } else {
            if (isset($_FILES['filename']) && isset($_FILES['filename']['name'])) {
                $name = $_FILES['filename']['name'];
            }
        }
        Event::log($newID, "documents", 4, "document", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $name . ".");
    }
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $doc->check($_POST["id"], 'w');
        if ($doc->delete($_POST)) {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:document.form.php

示例12: saveToTargets

 public function saveToTargets($datas)
 {
     $valid = true;
     // Validate form fields
     foreach ($_POST as $key => $value) {
         if (substr($key, 0, 18) == 'formcreator_field_') {
             $question_id = (int) substr($key, 18);
             $question = new PluginFormcreatorQuestion();
             $question->getFromDB($question_id);
             $className = $question->fields['fieldtype'] . 'Field';
             $filePath = dirname(__FILE__) . '/fields/' . $question->fields['fieldtype'] . '-field.class.php';
             if ($question->fields['fieldtype'] == 'float') {
                 $value = str_replace(',', '.', $datas['formcreator_field_' . $question_id]);
                 $datas['formcreator_field_' . $question_id] = $value;
             }
             if (is_file($filePath)) {
                 include_once $filePath;
                 if (class_exists($className)) {
                     if (!$className::isValid($question->fields, $value, $datas)) {
                         $valid = false;
                     }
                 }
             } else {
                 $valid = false;
             }
         }
     }
     // If not valid back to form
     if (!$valid) {
         $_SESSION['formcreator']['datas'] = $datas;
         Html::back();
         // Otherwize  generate targets
     } else {
         $_SESSION['formcreator_documents'] = array();
         // Save files as Documents
         foreach ($_FILES as $question_name => $file) {
             if (isset($file['tmp_name']) && is_file($file['tmp_name'])) {
                 $doc = new Document();
                 $question_id = trim(strrchr($question_name, '_'), '_');
                 $question = new PluginFormcreatorQuestion();
                 $question->getFromDB($question_id);
                 $file_datas = array();
                 $file_datas["name"] = $this->fields['name'] . ' - ' . $question->fields['name'];
                 $file_datas["entities_id"] = isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $this->fields['entities_id'];
                 $file_datas["is_recursive"] = $this->fields['is_recursive'];
                 Document::uploadDocument($file_datas, $file);
                 if ($docID = $doc->add($file_datas)) {
                     $_SESSION['formcreator_documents'][] = $docID;
                     $table = getTableForItemType('Document');
                     $query = "UPDATE {$table} SET filename = '" . addslashes($file['name']) . "' WHERE id = " . $docID;
                     $GLOBALS['DB']->query($query);
                 }
             }
         }
         // Get all targets
         $target_class = new PluginFormcreatorTarget();
         $founded_targets = $target_class->find('plugin_formcreator_forms_id = ' . $this->getID());
         foreach ($founded_targets as $target) {
             $obj = new $target['itemtype']();
             $obj->getFromDB($target['items_id']);
             $obj->save($this, $datas);
         }
         Session::addMessageAfterRedirect(__('The form have been successfully saved!', 'formcreator'), true, INFO);
         unset($_SESSION['formcreator_documents']);
     }
 }
开发者ID:nicholaseduardo,项目名称:formcreator,代码行数:66,代码来源:form.class.php

示例13: Copyright

 Copyright (C) 2013 by the Moreticket Development Team.
 -------------------------------------------------------------------------

 LICENSE

 This file is part of Moreticket.

 Moreticket 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.

 Moreticket 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 Moreticket. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$closeTicket = new PluginMoreticketCloseTicket();
if (isset($_POST["add"])) {
    $closeTicket->check(-1, UPDATE, $_POST);
    $doc = new Document();
    $doc->check(-1, CREATE, $_POST);
    $DocId = $doc->add($_POST);
    $test = $closeTicket->add(array('requesters_id' => $_POST['requesters_id'], 'tickets_id' => $_POST['tickets_id'], 'date' => $_POST['date'], 'comment' => $_POST['comment'], 'documents_id' => $DocId));
    Html::back();
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:closeticket.form.php

示例14: Document

along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkLoginUser();
if (!isset($_GET["id"])) {
    $_GET["id"] = -1;
}
$doc = new Document();
$documentitem = new Document_Item();
if (isset($_POST["add"])) {
    $doc->check(-1, 'w', $_POST);
    if ($newID = $doc->add($_POST)) {
        Event::log($newID, "documents", 4, "login", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $doc->fields["name"]));
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $doc->check($_POST["id"], 'd');
        if ($doc->delete($_POST)) {
            Event::log($_POST["id"], "documents", 4, "document", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        }
        $doc->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $doc->check($_POST["id"], 'd');
            if ($doc->restore($_POST)) {
                Event::log($_POST["id"], "documents", 4, "document", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
开发者ID:gaforeror,项目名称:glpi,代码行数:31,代码来源:document.form.php

示例15: methodAddTicketDocument

 /**
  * Add a document to a existing ticket
  * for an authenticated user
  *
  * @param $params array of options (ticket, uri, name, base64, comment)
  *        only one of uri and base64 must be set
  *        name is mandatory when base64 set, for extension check (filename)
  * @param $protocol     the communication protocol used
  *
  * @return array of hashtable
  **/
 static function methodAddTicketDocument($params, $protocol)
 {
     global $DB, $CFG_GLPI;
     if (isset($params['help'])) {
         return array('ticket' => 'integer,mandatory', 'uri' => 'string,optional', 'base64' => 'string,optional', 'content' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional');
     }
     if (!Session::getLoginUserID()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
     }
     $ticket = new Ticket();
     if (!isset($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
     }
     if (!is_numeric($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket');
     }
     if (!$ticket->can($params['ticket'], 'r')) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
     }
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'closed ticket');
     }
     if (!$ticket->canAddFollowups()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'access denied');
     }
     if (isset($params['name']) && !empty($params['name'])) {
         $document_name = addslashes($params['name']);
     } else {
         $document_name = addslashes(sprintf(__('%1$s %2$s'), _x('phone', 'Number'), $ticket->fields['id']));
     }
     $filename = tempnam(GLPI_DOC_DIR . '/_tmp', 'PWS');
     $response = parent::uploadDocument($params, $protocol, $filename, $document_name);
     //An error occured during document upload
     if (parent::isError($protocol, $response)) {
         return $response;
     }
     $doc = new Document();
     $documentitem = new Document_Item();
     $docid = $doc->getFromDBbyContent($ticket->fields["entities_id"], $filename);
     if ($docid) {
         $input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'documents_id' => $doc->getID());
         if ($DB->request('glpi_documents_items', $input)->numrows()) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'document already associated to this ticket');
         }
         $new = $documentitem->add($input);
     } else {
         $input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'tickets_id' => $ticket->getID(), 'entities_id' => $ticket->getEntityID(), 'is_recursive' => $ticket->isRecursive(), 'documentcategories_id' => $CFG_GLPI["documentcategories_id_forticket"]);
         $new = $doc->add($input);
     }
     // to not add it twice during followup
     unset($_FILES['filename']);
     if (!$new) {
         return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
     }
     if (isset($params['comment']) && !empty($params['comment'])) {
         $params['content'] = $params['comment'];
         unset($params['comment']);
     }
     if (isset($params['content']) && !empty($params['content'])) {
         return self::methodAddTicketFollowup($params, $protocol);
     }
     return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:74,代码来源:methodhelpdesk.class.php


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