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


PHP Search::getCleanedOptions方法代码示例

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


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

示例1: showMinimalList

 function showMinimalList($params)
 {
     global $DB, $CFG_GLPI;
     // Instanciate an object to access method
     $item = NULL;
     $itemtype = $this->getType();
     $itemtable = $this->getTable();
     if (class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     if ($p['export_all']) {
         $p['start'] = 0;
     }
     // Manage defautlt seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     //$target = Toolbox::getItemTypeSearchURL($itemtype);
     $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/resourceresting.php";
     $limitsearchopt = Search::getCleanedOptions("PluginResourcesResourceResting");
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == Search::GLOBAL_SEARCH) {
             $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT;
         }
     }
     $PluginResourcesResource = new PluginResourcesResource();
     $entity_restrict = $PluginResourcesResource->isEntityAssign();
     // Get the items to display
     $toview = Search::addDefaultToView($itemtype);
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser("PluginResourcesResourceResting", Session::getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
     if (!in_array($p['sort'], $toview)) {
         array_push($toview, $p['sort']);
     }
     // Clean toview array
     $toview = array_unique($toview);
     foreach ($toview as $key => $val) {
         if (!isset($limitsearchopt[$val])) {
             unset($toview[$key]);
         }
     }
     $toview_count = count($toview);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:resourceresting.class.php

示例2: constructSQL

 function constructSQL($itemtype, $params, $items_id_check = 0)
 {
     global $CFG_GLPI;
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Default values of parameters
     $p = array();
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     if ($p['export_all']) {
         $p['start'] = 0;
     }
     // Manage defautll seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     //      $target = Toolbox::getItemTypeSearchURL($itemtype);
     $limitsearchopt = Search::getCleanedOptions($itemtype);
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $itemtable = $CFG_GLPI['union_search_type'][$itemtype];
     } else {
         $itemtable = getTableForItemType($itemtype);
     }
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == GLOBAL_SEARCH) {
             $LIST_LIMIT = GLOBAL_SEARCH_DISPLAY_COUNT;
         }
     }
     // hack for States
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $entity_restrict = true;
     } else {
         $entity_restrict = $item->isEntityAssign();
     }
     //      $metanames = array();
     // Get the items to display
     //      $toview = Search::addDefaultToView($itemtype);
     //      // Add items to display depending of personal prefs
     //      $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID());
     //      if (count($displaypref)) {
     //         foreach ($displaypref as $val) {
     //            array_push($toview,$val);
     //         }
     //      }
     /* =========== Add for plugin Monitoring ============ */
     $toview = array();
     array_push($toview, 1);
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:search.class.php

示例3: showFormGlobal

 /**
  * Print the search config form
  *
  * @param $target    form target
  * @param $itemtype  item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $global_write = Session::haveRight(self::$rightname, self::GENERAL);
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixehov'><tr><th colspan='4'>";
     echo __('Select default items to show') . "</th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         $group = '';
         $values = array();
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 $group = $val;
             } else {
                 if ($key != 1 && !in_array($key, $already_added) && (!isset($val['nodisplay']) || !$val['nodisplay'])) {
                     $values[$group][$key] = $val["name"];
                 }
             }
         }
         if ($values) {
             Dropdown::showFromArray('num', $values);
             echo "<span class='small_space'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</span>";
         }
         Html::closeForm();
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (Session::isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . __s('Bring up') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png' alt=\"" . __s('Bring up') . "\"  title=\"" . __s('Bring up') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . __s('Bring down') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png' alt=\"" . __s('Bring down') . "\" title=\"" . __s('Bring down') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:glpi,代码行数:101,代码来源:displaypreference.class.php

示例4: showMinimalList

 static function showMinimalList($params = array())
 {
     global $DB, $CFG_GLPI;
     $item = new self();
     $itemtype = $item->getType();
     $itemtable = $item->getTable();
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['id'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     $p['withtemplate'] = 0;
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $PluginResourcesResource = new PluginResourcesResource();
     $PluginResourcesResource->getFromDB($p['id']);
     $canedit = $PluginResourcesResource->can($p['id'], 'w');
     if (isset($_POST["start"])) {
         $p['start'] = $_POST["start"];
     } else {
         $p['start'] = 0;
     }
     if (isset($_POST["sort"])) {
         $p['sort'] = $_POST["sort"];
     } else {
         $p['sort'] = 1;
     }
     if (isset($_POST["order"]) && $_POST["order"] == "DESC") {
         $p['order'] = "DESC";
     } else {
         $p['order'] = "ASC";
     }
     // Manage defautll seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     $target = Toolbox::getItemTypeSearchURL($itemtype);
     $limitsearchopt = Search::getCleanedOptions($itemtype);
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == Search::GLOBAL_SEARCH) {
             $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT;
         }
     }
     $entity_restrict = $item->isEntityAssign();
     // Get the items to display
     $toview = Search::addDefaultToView($itemtype);
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:task.class.php

示例5: showMinimalList

 function showMinimalList($params)
 {
     global $DB, $CFG_GLPI;
     $itemtype = "PluginResourcesDirectory";
     $itemtable = $this->table;
     if (class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['id'] = 0;
     $p['withtemplate'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     if ($p['export_all']) {
         $p['start'] = 0;
     }
     $PluginResourcesResource = new PluginResourcesResource();
     $canedit = $PluginResourcesResource->can($p['id'], 'w');
     // Manage defautlt seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/directory.php";
     $limitsearchopt = Search::getCleanedOptions("PluginResourcesDirectory");
     $LIST_LIMIT = $_SESSION['glpilist_limit'];
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == Search::GLOBAL_SEARCH) {
             $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT;
         }
     }
     $entity_restrict = $PluginResourcesResource->isEntityAssign();
     // Get the items to display
     $toview = Search::addDefaultToView("User");
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser("PluginResourcesDirectory", Session::getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
     // Add order item
     if (!in_array($p['sort'], $toview)) {
         array_push($toview, $p['sort']);
     }
     // Clean toview array
     $toview = array_unique($toview);
     foreach ($toview as $key => $val) {
         if (!isset($limitsearchopt[$val])) {
             unset($toview[$key]);
         }
     }
     $toview_count = count($toview);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:directory.class.php

示例6: header

along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (!($item = getItemForItemtype($_POST['itemtype']))) {
    exit;
}
$item->checkGlobal(READ);
$group = "";
$values = array();
$searchopt = Search::getCleanedOptions($_POST["itemtype"], READ, false);
echo "<table width='100%'><tr><td width='40%'>";
foreach ($searchopt as $key => $val) {
    // print groups
    $str_limit = 28;
    if (!is_array($val)) {
        $group = $val;
    } else {
        // No search on plugins
        if (!isPluginItemType($key) && !isset($val["nometa"])) {
            $values[$group][$key] = $val["name"];
        }
    }
}
$rand = Dropdown::showFromArray("metacriteria[" . $_POST["num"] . "][field]", $values, array('value' => $_POST["field"]));
$field_id = Html::cleanId("dropdown_metacriteria[" . $_POST["num"] . "][field]" . $rand);
开发者ID:jose-martins,项目名称:glpi,代码行数:31,代码来源:updateMetaSearch.php

示例7: header

*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "searchmetarow.php")) {
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkLoginUser();
// Non define case
if (isset($_POST["itemtype"]) && isset($_POST["num"])) {
    $metacriteria = array();
    if (isset($_SESSION['glpisearch'][$_POST["itemtype"]]['metacriteria'][$_POST["num"]]) && is_array($_SESSION['glpisearch'][$_POST["itemtype"]]['metacriteria'][$_POST["num"]])) {
        $metacriteria = $_SESSION['glpisearch'][$_POST["itemtype"]]['metacriteria'][$_POST["num"]];
    } else {
        // Set default field
        $options = Search::getCleanedOptions($_POST["itemtype"]);
        foreach ($options as $key => $val) {
            if (is_array($val)) {
                $metacriteria['field'] = $key;
                break;
            }
        }
    }
    $linked = Search::getMetaItemtypeAvailable($_POST["itemtype"]);
    $rand = mt_rand();
    $rowid = 'metasearchrow' . $_POST['itemtype'] . $rand;
    echo "<tr class='metacriteria' id='{$rowid}'><td class='left' colspan='2'>";
    echo "<table class='tab_format'><tr class='left'>";
    echo "<td width='30%'>";
    echo "<img class='pointer' src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . __s('Delete a global search criterion') . "\" onclick=\"" . Html::jsGetElementbyID($rowid) . ".remove();\">";
    echo "&nbsp;&nbsp;";
开发者ID:kipman,项目名称:glpi,代码行数:31,代码来源:searchmetarow.php

示例8: prepareQueryToUse

 /**
  * Prepare query to use depending of the type
  *
  * @param $type         bookmark type
  * @param $query_tab    parameters array
  *
  * @return prepared query array
  **/
 function prepareQueryToUse($type, $query_tab)
 {
     switch ($type) {
         case self::SEARCH:
             // Check if all datas are valid
             $opt = Search::getCleanedOptions($this->fields['itemtype']);
             $query_tab_save = $query_tab;
             $partial_load = false;
             // Standard search
             if (isset($query_tab_save['criteria']) && count($query_tab_save['criteria'])) {
                 unset($query_tab['criteria']);
                 $new_key = 0;
                 foreach ($query_tab_save['criteria'] as $key => $val) {
                     if ($val['field'] != 'view' && $val['field'] != 'all' && (!isset($opt[$val['field']]) || isset($opt[$val['field']]['nosearch']) && $opt[$val['field']]['nosearch'])) {
                         $partial_load = true;
                     } else {
                         $query_tab['criteria'][$new_key] = $val;
                         $new_key++;
                     }
                 }
             }
             // Meta search
             if (isset($query_tab_save['metacriteria']) && count($query_tab_save['metacriteria'])) {
                 $meta_ok = Search::getMetaItemtypeAvailable($query_tab['itemtype']);
                 unset($query_tab['metacriteria']);
                 $new_key = 0;
                 foreach ($query_tab_save['metacriteria'] as $key => $val) {
                     $opt = Search::getCleanedOptions($val['itemtype']);
                     // Use if meta type is valid and option available
                     if (!in_array($val['itemtype'], $meta_ok) || !isset($opt[$val['field']])) {
                         $partial_load = true;
                     } else {
                         $query_tab['metacriteria'][$new_key] = $val;
                         $new_key++;
                     }
                 }
             }
             // Display message
             if ($partial_load) {
                 Session::addMessageAfterRedirect(__('Partial load of the bookmark.'), false, ERROR);
             }
             // add reset value
             $query_tab['reset'] = 'reset';
             break;
     }
     return $query_tab;
 }
开发者ID:pvasener,项目名称:glpi,代码行数:55,代码来源:bookmark.class.php

示例9: processMassiveActionsForOneItemtype

 /**
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     $action = $ma->getAction();
     switch ($action) {
         case 'delete':
             foreach ($ids as $id) {
                 if ($item->can($id, DELETE)) {
                     if ($item->delete(array("id" => $id))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'restore':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     if ($item->restore(array("id" => $id))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'purge_item_but_devices':
         case 'purge_but_item_linked':
         case 'purge':
             foreach ($ids as $id) {
                 if ($item->can($id, PURGE)) {
                     $force = 1;
                     // Only mark deletion for
                     if ($item->maybeDeleted() && $item->useDeletedToLockIfDynamic() && $item->isDynamic()) {
                         $force = 0;
                     }
                     $delete_array = array('id' => $id);
                     if ($action == 'purge_item_but_devices') {
                         $delete_array['keep_devices'] = true;
                     }
                     if ($item instanceof CommonDropdown) {
                         if ($item->haveChildren()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item by massive actions, because it has sub-items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                         if ($item->isUsed()) {
                             if ($action != 'purge_but_item_linked') {
                                 $force = 0;
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage(__("You can't delete that item, because it is used for one or more items"));
                                 $ma->addMessage(__("but you can do it by the form of the item"));
                                 continue;
                             }
                         }
                     }
                     if ($item->delete($delete_array, $force)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'update':
             if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
                 return false;
             }
             $index = $ma->POST['search_options'][$item->getType()];
             $searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
             $input = $ma->POST;
             if (isset($searchopt[$index])) {
                 /// Infocoms case
                 if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$index]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
//.........这里部分代码省略.........
开发者ID:kipman,项目名称:glpi,代码行数:101,代码来源:massiveaction.class.php

示例10: foreach

 case "purge":
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $item->delete(array("id" => $key), 1);
         }
     }
     break;
 case "restore":
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $item->restore(array("id" => $key));
         }
     }
     break;
 case "update":
     $searchopt = Search::getCleanedOptions($_POST["itemtype"], 'w');
     if (isset($searchopt[$_POST["id_field"]])) {
         /// Infocoms case
         if (!isPluginItemType($_POST["itemtype"]) && Search::isInfocomOption($_POST["itemtype"], $_POST["id_field"])) {
             $ic = new Infocom();
             $link_entity_type = -1;
             /// Specific entity item
             if ($searchopt[$_POST["id_field"]]["table"] == "glpi_suppliers") {
                 $ent = new Supplier();
                 if ($ent->getFromDB($_POST[$_POST["field"]])) {
                     $link_entity_type = $ent->fields["entities_id"];
                 }
             }
             foreach ($_POST["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($item->getFromDB($key)) {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php

示例11: showFormGlobal

 /**
  * Print the search config form
  *
  * @param $target form target
  * @param $itemtype item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $LANG, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $global_write = haveRight("search_config_global", "w");
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixe'><tr><th colspan='4'>";
     echo $LANG['setup'][252] . "&nbsp;: </th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         echo "<select name='num'>";
         $first_group = true;
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 if (!$first_group) {
                     echo "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 echo "<optgroup label=\"{$val}\">";
             } else {
                 if ($key != 1 && !in_array($key, $already_added)) {
                     echo "<option value='{$key}'>" . $val["name"] . "</option>";
                 }
             }
         }
         if (!$first_group) {
             echo "</optgroup>\n";
         }
         echo "</select><span class='small_space'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</span></form>";
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_array($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . $LANG['buttons'][24] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up2.png' alt=\"" . $LANG['buttons'][24] . "\"  title=\"" . $LANG['buttons'][24] . "\">";
                         echo "</form>";
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . $LANG['buttons'][25] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down2.png' alt=\"" . $LANG['buttons'][25] . "\" title=\"" . $LANG['buttons'][25] . "\">";
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:displaypreference.class.php

示例12: deleteDisplayPreferences

 static function deleteDisplayPreferences($table, $field)
 {
     $pref = new DisplayPreference();
     $itemtype = getItemTypeForTable($table);
     $searchopt = Search::getCleanedOptions($itemtype);
     foreach ($searchopt as $num => $option) {
         if (isset($option['field']) && $option['field'] == $field || isset($option['field']) && $option['linkfield'] == $field) {
             $criteria = array('itemtype' => $itemtype, 'num' => $num);
             $pref->deleteByCriteria($criteria);
             break;
         }
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:13,代码来源:field.class.php

示例13: showList

 static function showList($itemtype, $params)
 {
     global $DB, $CFG_GLPI, $LANG, $PLUGIN_HOOKS;
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $_SESSION['plugin_mobile']['rows_limit'] = 10;
     // sdb38l
     $_SESSION['plugin_mobile']['cols_limit'] = 5;
     // sdb38l
     $LIST_LIMIT = $_SESSION['plugin_mobile']['rows_limit'];
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     //
     $p['contains'] = array();
     //
     $p['searchtype'] = array();
     //
     $p['sort'] = '1';
     //
     $p['order'] = 'ASC';
     //
     $p['start'] = 0;
     //
     $p['is_deleted'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     //
     $p['field2'] = '';
     //
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     $p['showheader'] = true;
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     if ($p['export_all']) {
         $p['start'] = 0;
     }
     // Manage defautll seachtype value : for bookmark compatibility
     if (count($p['contains'])) {
         foreach ($p['contains'] as $key => $val) {
             if (!isset($p['searchtype'][$key])) {
                 $p['searchtype'][$key] = 'contains';
             }
         }
     }
     if (is_array($p['contains2']) && count($p['contains2'])) {
         foreach ($p['contains2'] as $key => $val) {
             if (!isset($p['searchtype2'][$key])) {
                 $p['searchtype2'][$key] = 'contains';
             }
         }
     }
     $target = Toolbox::getItemTypeSearchURL($itemtype);
     $limitsearchopt = Search::getCleanedOptions($itemtype);
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $itemtable = $CFG_GLPI['union_search_type'][$itemtype];
     } else {
         $itemtable = getTableForItemType($itemtype);
     }
     // Set display type for export if define
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET['display_type'])) {
         $output_type = $_GET['display_type'];
         // Limit to 10 element
         if ($_GET['display_type'] == Search::GLOBAL_SEARCH) {
             $LIST_LIMIT = Search::GLOBAL_SEARCH_DISPLAY_COUNT;
         }
     }
     // hack for States
     if (isset($CFG_GLPI['union_search_type'][$itemtype])) {
         $entity_restrict = true;
     } else {
         $entity_restrict = $item->isEntityAssign();
     }
     $metanames = array();
     // Get the items to display
     $toview = Search::addDefaultToView($itemtype);
     // Add items to display depending of personal prefs
     $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID());
     if (count($displaypref)) {
         foreach ($displaypref as $val) {
             array_push($toview, $val);
         }
     }
     // Add searched items
     if (count($p['field']) > 0) {
         foreach ($p['field'] as $key => $val) {
             if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
                 array_push($toview, $val);
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:search.class.php

示例14: doMassiveActions

 /**
  * Do the standard massive actions
  *
  * @since version 0.84
  *
  * This must not be overloaded in Class
  * @param $input array of input datas
  *
  * @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
  **/
 function doMassiveActions($input = array())
 {
     global $CFG_GLPI;
     if (!isset($input["item"]) || count($input["item"]) == 0) {
         return false;
     }
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'add_document':
         case 'remove_document':
             $doc = new Document();
             return $doc->doSpecificMassiveActions($input);
         case "add_transfer_list":
             if (!isset($_SESSION['glpitransfer_list'])) {
                 $_SESSION['glpitransfer_list'] = array();
             }
             if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
                 $_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
             }
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
                     $res['ok']++;
                 }
             }
             $res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
             break;
         case "delete":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->delete(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "purge":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         $force = 1;
                         // Only mark deletion for
                         if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
                             $force = 0;
                         }
                         if ($this->delete(array("id" => $key), $force)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "restore":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->restore(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "update":
             $searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
             if (isset($searchopt[$input["id_field"]])) {
                 /// Infocoms case
                 if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
                             $link_entity_type = $ent->fields["entities_id"];
                         }
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:commondbtm.class.php

示例15: prepareQueryToUse

 /**
  * Prepare query to use depending of the type
  *
  * @param $type bookmark type
  * @param $query_tab parameters array
  *
  * @return prepared query array
  **/
 function prepareQueryToUse($type, $query_tab)
 {
     global $LANG;
     switch ($type) {
         case BOOKMARK_SEARCH:
             // Check if all datas are valid
             $opt = Search::getCleanedOptions($this->fields['itemtype']);
             $query_tab_save = $query_tab;
             $partial_load = false;
             // Standard search
             if (isset($query_tab_save['field']) && count($query_tab_save['field'])) {
                 unset($query_tab['field']);
                 unset($query_tab['searchtype']);
                 unset($query_tab['contains']);
                 unset($query_tab['link']);
                 $new_key = 0;
                 foreach ($query_tab_save['field'] as $key => $val) {
                     if ($val != 'view' && $val != 'all' && !isset($opt[$val])) {
                         $query_tab['glpisearchcount']--;
                         $partial_load = true;
                     } else {
                         $query_tab['field'][$new_key] = $val;
                         if (isset($query_tab_save['searchtype']) && isset($query_tab_save['searchtype'][$key])) {
                             $query_tab['searchtype'][$new_key] = $query_tab_save['searchtype'][$key];
                         }
                         $query_tab['contains'][$new_key] = $query_tab_save['contains'][$key];
                         if (isset($query_tab_save['link'][$key])) {
                             $query_tab['link'][$new_key] = $query_tab_save['link'][$key];
                         }
                         $new_key++;
                     }
                 }
             }
             if ($query_tab['glpisearchcount'] == 0) {
                 $query_tab['glpisearchcount'] = 1;
             }
             // Meta search
             if (isset($query_tab_save['itemtype2']) && count($query_tab_save['itemtype2'])) {
                 $meta_ok = Search::getMetaItemtypeAvailable($query_tab['itemtype']);
                 unset($query_tab['field2']);
                 unset($query_tab['searchtype2']);
                 unset($query_tab['contains2']);
                 unset($query_tab['link2']);
                 unset($query_tab['itemtype2']);
                 $new_key = 0;
                 foreach ($query_tab_save['field2'] as $key => $val) {
                     $opt = Search::getCleanedOptions($query_tab_save['itemtype2'][$key]);
                     // Use if meta type is valid and option available
                     if (!in_array($query_tab_save['itemtype2'][$key], $meta_ok) || !isset($opt[$val])) {
                         $query_tab['glpisearchcount2']--;
                         $partial_load = true;
                     } else {
                         $query_tab['field2'][$new_key] = $val;
                         if (isset($query_tab_save['searchtype2']) && isset($query_tab_save['searchtype2'][$key])) {
                             $query_tab['searchtype2'][$new_key] = $query_tab_save['searchtype2'][$key];
                         }
                         $query_tab['contains2'][$new_key] = $query_tab_save['contains2'][$key];
                         $query_tab['link2'][$new_key] = $query_tab_save['link2'][$key];
                         $query_tab['itemtype2'][$new_key] = $query_tab_save['itemtype2'][$key];
                         $new_key++;
                     }
                 }
             }
             // Display message
             if ($partial_load) {
                 addMessageAfterRedirect($LANG['bookmark'][2], false, ERROR);
             }
             // add reset value
             $query_tab['reset'] = 'reset';
             break;
     }
     return $query_tab;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:81,代码来源:bookmark.class.php


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