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


PHP CommonDBRelation::prepareInputForAdd方法代码示例

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


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

示例1: prepareInputForAdd

 /**
  * @see CommonDBTM::prepareInputForAdd()
  **/
 function prepareInputForAdd($input)
 {
     // Avoid duplicate entry
     if (countElementsInTable($this->getTable(), ['projects_id' => $input['projects_id'], 'itemtype' => $input['itemtype'], 'items_id' => $input['items_id']]) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:11,代码来源:item_project.class.php

示例2: prepareInputForAdd

 /**
  * @see CommonDBTM::prepareInputForAdd()
  **/
 function prepareInputForAdd($input)
 {
     // Avoid duplicate entry
     $restrict = " `problems_id` = '" . $input['problems_id'] . "'\n                   AND `itemtype` = '" . $input['itemtype'] . "'\n                   AND `items_id` = '" . $input['items_id'] . "'";
     if (countElementsInTable($this->getTable(), $restrict) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:12,代码来源:item_problem.class.php

示例3: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     // TODO: check if the entities should not be inherited from the profile or the user
     if (!isset($input['entities_id']) || $input['entities_id'] < 0) {
         Session::addMessageAfterRedirect(__('No selected element or badly defined operation'), false, ERROR);
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:9,代码来源:profile_user.class.php

示例4: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     // Well, if I remember my PHP: empty(0) == true ...
     if (empty($input['changes_id']) || $input['changes_id'] == 0) {
         return false;
     }
     // Avoid duplicate entry
     if (countElementsInTable($this->getTable(), ['changes_id' => $input['changes_id'], 'itemtype' => $input['itemtype'], 'items_id' => $input['items_id']]) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:12,代码来源:change_item.class.php

示例5: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     // Well, if I remember my PHP: empty(0) == true ...
     if (empty($input['changes_id']) || $input['changes_id'] == 0) {
         return false;
     }
     // Avoid duplicate entry
     $restrict = "`changes_id` = '" . $input['changes_id'] . "'\n                   AND `itemtype` = '" . $input['itemtype'] . "'\n                   AND `items_id` = '" . $input['items_id'] . "'";
     if (countElementsInTable($this->getTable(), $restrict) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:stweil,项目名称:glpi,代码行数:13,代码来源:change_item.class.php

示例6: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     if (!isset($input['is_template_computer']) || !isset($input['is_deleted_computer'])) {
         // Get template and deleted information from computer
         // If computer set update is_template / is_deleted infos to ensure data validity
         if (isset($input['computers_id'])) {
             $computer = new Computer();
             if ($computer->getFromDB($input['computers_id'])) {
                 $input['is_template_computer'] = $computer->getField('is_template');
                 $input['is_deleted_computer'] = $computer->getField('is_deleted');
             }
         }
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:15,代码来源:computer_softwareversion.class.php

示例7: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     if ((empty($input['items_id']) || $input['items_id'] == 0) && $input['itemtype'] != 'Entity') {
         return false;
     }
     // Do not insert circular link for document
     if ($input['itemtype'] == 'Document' && $input['items_id'] == $input['documents_id']) {
         return false;
     }
     // Avoid duplicate entry
     $restrict = "`documents_id` = '" . $input['documents_id'] . "'\n                   AND `itemtype` = '" . $input['itemtype'] . "'\n                   AND `items_id` = '" . $input['items_id'] . "'";
     if (countElementsInTable($this->getTable(), $restrict) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:16,代码来源:document_item.class.php

示例8: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     // Clean values
     $input['tickets_id_1'] = Toolbox::cleanInteger($input['tickets_id_1']);
     $input['tickets_id_2'] = Toolbox::cleanInteger($input['tickets_id_2']);
     // Check of existance of rights on both Ticket(s) is done by the parent
     if ($input['tickets_id_2'] == $input['tickets_id_1']) {
         return false;
     }
     if (!isset($input['link'])) {
         $input['link'] = self::LINK_TO;
     }
     // No multiple links
     $tickets = self::getLinkedTicketsTo($input['tickets_id_1']);
     if (count($tickets)) {
         foreach ($tickets as $key => $t) {
             if ($t['tickets_id'] == $input['tickets_id_2']) {
                 // Delete old simple link
                 if ($input['link'] == self::DUPLICATE_WITH && $t['link'] == self::LINK_TO) {
                     $tt = new Ticket_Ticket();
                     $tt->delete(array("id" => $key));
                 } else {
                     // No duplicate link
                     return false;
                 }
             }
         }
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:stweil,项目名称:glpi,代码行数:30,代码来源:ticket_ticket.class.php

示例9: prepareInputForAdd

 /**
  * @see CommonDBTM::prepareInputForAdd()
  **/
 function prepareInputForAdd($input)
 {
     // Avoid duplicate entry
     $restrict = " `tickets_id` = '" . $input['tickets_id'] . "'\n                   AND `itemtype` = '" . $input['itemtype'] . "'\n                   AND `items_id` = '" . $input['items_id'] . "'";
     if (countElementsInTable($this->getTable(), $restrict) > 0) {
         return false;
     }
     $ticket = new Ticket();
     $ticket->getFromDB($input['tickets_id']);
     // Get item location if location is not already set in ticket
     if (empty($ticket->fields['locations_id'])) {
         if ($input["items_id"] > 0 && !empty($input["itemtype"])) {
             if ($item = getItemForItemtype($input["itemtype"])) {
                 if ($item->getFromDB($input["items_id"])) {
                     if ($item->isField('locations_id')) {
                         $ticket->fields['items_locations'] = $item->fields['locations_id'];
                         // Process Business Rules
                         $rules = new RuleTicketCollection($ticket->fields['entities_id']);
                         $ticket->fields = $rules->processAllRules(Toolbox::stripslashes_deep($ticket->fields), Toolbox::stripslashes_deep($ticket->fields), array('recursive' => true));
                         unset($ticket->fields['items_locations']);
                         $ticket->updateInDB(array('locations_id'));
                     }
                 }
             }
         }
     }
     $group = new Group_Ticket();
     $groups = $group->find("`tickets_id` = " . $input['tickets_id'] . " AND `type` = " . CommonITILActor::REQUESTER);
     if (count($groups) <= 0) {
         if ($input["items_id"] > 0 && !empty($input["itemtype"])) {
             if ($item = getItemForItemtype($input["itemtype"])) {
                 if ($item->getFromDB($input["items_id"])) {
                     if ($item->isField('groups_id')) {
                         $ticket->fields['items_groups'] = $item->fields['groups_id'];
                         // Process Business Rules
                         $rules = new RuleTicketCollection($ticket->fields['entities_id']);
                         $ticket->fields = $rules->processAllRules(Toolbox::stripslashes_deep($ticket->fields), Toolbox::stripslashes_deep($ticket->fields), array('recursive' => true));
                         unset($ticket->fields['items_groups']);
                         $group->add(array('tickets_id' => $input['tickets_id'], 'groups_id' => $item->fields['groups_id'], 'type' => CommonITILActor::REQUESTER));
                     }
                 }
             }
         }
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:korial29,项目名称:glpi,代码行数:49,代码来源:item_ticket.class.php

示例10: prepareInputForAdd

 /**
  * Prepare input datas for adding the relation
  *
  * Overloaded to check is Disconnect needed (during OCS sync)
  * and to manage autoupdate feature
  *
  * @param $input array of datas used to add the item
  *
  * @return the modified $input array
  *
  **/
 function prepareInputForAdd($input)
 {
     global $DB, $CFG_GLPI;
     $item = static::getItemFromArray(static::$itemtype_2, static::$items_id_2, $input);
     if (!$item instanceof CommonDBTM || $item->getField('is_global') == 0 && $this->countForItem($item) > 0) {
         return false;
     }
     $comp = static::getItemFromArray(static::$itemtype_1, static::$items_id_1, $input);
     if (!$item instanceof CommonDBTM || self::countForAll($comp, $item) > 0) {
         // no duplicates
         return false;
     }
     if (!$item->getField('is_global')) {
         // Autoupdate some fields - should be in post_addItem (here to avoid more DB access)
         $updates = array();
         if ($CFG_GLPI["is_location_autoupdate"] && $comp->fields['locations_id'] != $item->getField('locations_id')) {
             $updates['locations_id'] = addslashes($comp->fields['locations_id']);
             Session::addMessageAfterRedirect(__('Location updated. The connected items have been moved in the same location.'), true);
         }
         if ($CFG_GLPI["is_user_autoupdate"] && $comp->fields['users_id'] != $item->getField('users_id') || $CFG_GLPI["is_group_autoupdate"] && $comp->fields['groups_id'] != $item->getField('groups_id')) {
             if ($CFG_GLPI["is_user_autoupdate"]) {
                 $updates['users_id'] = $comp->fields['users_id'];
             }
             if ($CFG_GLPI["is_group_autoupdate"]) {
                 $updates['groups_id'] = $comp->fields['groups_id'];
             }
             Session::addMessageAfterRedirect(__('User or group updated. The connected items have been moved in the same values.'), true);
         }
         if ($CFG_GLPI["is_contact_autoupdate"] && ($comp->fields['contact'] != $item->getField('contact') || $comp->fields['contact_num'] != $item->getField('contact_num'))) {
             $updates['contact'] = addslashes($comp->fields['contact']);
             $updates['contact_num'] = addslashes($comp->fields['contact_num']);
             Session::addMessageAfterRedirect(__('Alternate username updated. The connected items have been updated using this alternate username.'), true);
         }
         if ($CFG_GLPI["state_autoupdate_mode"] < 0 && $comp->fields['states_id'] != $item->getField('states_id')) {
             $updates['states_id'] = $comp->fields['states_id'];
             Session::addMessageAfterRedirect(__('Status updated. The connected items have been updated using this status.'), true);
         }
         if ($CFG_GLPI["state_autoupdate_mode"] > 0 && $item->getField('states_id') != $CFG_GLPI["state_autoupdate_mode"]) {
             $updates['states_id'] = $CFG_GLPI["state_autoupdate_mode"];
         }
         if (count($updates)) {
             $updates['id'] = $input['items_id'];
             $history = true;
             if (isset($input['_no_history']) && $input['_no_history']) {
                 $history = false;
             }
             $item->update($updates, $history);
         }
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:stweil,项目名称:glpi,代码行数:62,代码来源:computer_item.class.php

示例11: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     if ((empty($input['items_id']) || $input['items_id'] == 0) && $input['itemtype'] != 'Entity') {
         return false;
     }
     // Do not insert circular link for document
     if ($input['itemtype'] == 'Document' && $input['items_id'] == $input['documents_id']) {
         return false;
     }
     // Avoid duplicate entry
     if (countElementsInTable($this->getTable(), ['documents_id' => $input['documents_id'], 'itemtype' => $input['itemtype'], 'items_id' => $input['items_id']]) > 0) {
         return false;
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:15,代码来源:document_item.class.php


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