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


PHP Plugin::doHookFunction方法代码示例

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


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

示例1: getFromLDAP

 /**
  * Function that try to load from LDAP the user information...
  *
  * @param $ldap_connection          ldap connection descriptor
  * @param $ldap_method              LDAP method
  * @param $userdn                   Basedn of the user
  * @param $login                    User Login
  * @param $import          boolean  true for import, false for update (true by default)
  *
  * @return boolean : true if found / false if not founded
  **/
 function getFromLDAP($ldap_connection, $ldap_method, $userdn, $login, $import = true)
 {
     global $DB, $CFG_GLPI;
     // we prevent some delay...
     if (empty($ldap_method["host"])) {
         return false;
     }
     if ($ldap_connection) {
         //Set all the search fields
         $this->fields['password'] = "";
         $fields = AuthLDAP::getSyncFields($ldap_method);
         //Hook to allow plugin to request more attributes from ldap
         $fields = Plugin::doHookFunction("retrieve_more_field_from_ldap", $fields);
         $fields = array_filter($fields);
         $f = array_values($fields);
         $sr = @ldap_read($ldap_connection, $userdn, "objectClass=*", $f);
         $v = AuthLDAP::get_entries_clean($ldap_connection, $sr);
         if (!is_array($v) || count($v) == 0 || empty($v[0][$fields['name']][0])) {
             return false;
         }
         //Store user's dn
         $this->fields['user_dn'] = addslashes($userdn);
         //Store date_sync
         $this->fields['date_sync'] = $_SESSION['glpi_currenttime'];
         // Empty array to ensure than syncDynamicEmails will be done
         $this->fields["_emails"] = array();
         foreach ($fields as $k => $e) {
             if (empty($v[0][$e][0])) {
                 switch ($k) {
                     case "language":
                         // Not set value : managed but user class
                         break;
                     case "usertitles_id":
                     case "usercategories_id":
                         $this->fields[$k] = 0;
                         break;
                     default:
                         $this->fields[$k] = "";
                 }
             } else {
                 switch ($k) {
                     case "email1":
                     case "email2":
                     case "email3":
                     case "email4":
                         // Manage multivaluable fields
                         if (!empty($v[0][$e])) {
                             foreach ($v[0][$e] as $km => $m) {
                                 if (!preg_match('/count/', $km)) {
                                     $this->fields["_emails"][] = addslashes($m);
                                 }
                             }
                             // Only get them once if duplicated
                             $this->fields["_emails"] = array_unique($this->fields["_emails"]);
                         }
                         break;
                     case "language":
                         $language = Config::getLanguage($v[0][$e][0]);
                         if ($language != '') {
                             $this->fields[$k] = $language;
                         }
                         break;
                     case "usertitles_id":
                         $this->fields[$k] = Dropdown::importExternal('UserTitle', addslashes($v[0][$e][0]));
                         break;
                     case "usercategories_id":
                         $this->fields[$k] = Dropdown::importExternal('UserCategory', addslashes($v[0][$e][0]));
                         break;
                     default:
                         if (!empty($v[0][$e][0])) {
                             $this->fields[$k] = addslashes($v[0][$e][0]);
                         } else {
                             $this->fields[$k] = "";
                         }
                 }
             }
         }
         // Empty array to ensure than syncLdapGroups will be done
         $this->fields["_groups"] = array();
         ///The groups are retrieved by looking into an ldap user object
         if ($ldap_method["group_search_type"] == 0 || $ldap_method["group_search_type"] == 2) {
             $this->getFromLDAPGroupVirtual($ldap_connection, $ldap_method, $userdn, $login);
         }
         ///The groups are retrived by looking into an ldap group object
         if ($ldap_method["group_search_type"] == 1 || $ldap_method["group_search_type"] == 2) {
             $this->getFromLDAPGroupDiscret($ldap_connection, $ldap_method, $userdn, $login);
         }
         ///Only process rules if working on the master database
         if (!$DB->isSlave()) {
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:user.class.php

示例2: showForItem

 /**
  * Display form to unlock fields and links
  *
  * @param CommonDBTM $item the source item
  **/
 static function showForItem(CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getID();
     $itemtype = $item->getType();
     $header = false;
     //If user doesn't have write right on the item, lock form must not be displayed
     if (!$item->canCreate()) {
         return false;
     }
     echo "<div width='50%'>";
     echo "<form method='post' id='lock_form'\n             name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<input type='hidden' name='id' value='{$ID}'>\n";
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
     //Use a hook to allow external inventory tools to manage per field lock
     $results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
     $header |= $results['header'];
     //Special locks for computers only
     if ($itemtype == 'Computer') {
         //Locks for items recorded in glpi_computers_items table
         $types = array('Monitor', 'Peripheral', 'Printer');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
             $params['FIELDS'] = array('id', 'items_id');
             $first = true;
             foreach ($DB->request('glpi_computers_items', $params) as $line) {
                 $tmp = new $type();
                 $tmp->getFromDB($line['items_id']);
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
                 echo "</tr>\n";
             }
         }
         $types = array('ComputerDisk', 'ComputerVirtualMachine');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
             $params['FIELDS'] = array('id', 'name');
             $first = true;
             foreach ($DB->request(getTableForItemType($type), $params) as $line) {
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
                 echo "</tr>\n";
             }
         }
         //Software versions
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwareversions` AS csv\n                    LEFT JOIN `glpi_softwareversions` AS sv\n                       ON (`csv`.`softwareversions_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . Software::getTypeName(2) . "</th></tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
         //Software licenses
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwarelicenses` AS csv\n                    LEFT JOIN `glpi_softwarelicenses` AS sv\n                       ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
     }
     $first = true;
     $item = new NetworkPort();
     $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
     $params['FIELDS'] = array('id');
     foreach ($DB->request('glpi_networkports', $params) as $line) {
         $item->getFromDB($line['id']);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:lock.class.php

示例3: connection_ldap

 /**
  * Find a user in a LDAP and return is BaseDN
  * Based on GRR auth system
  *
  * @param $ldap_method  ldap_method array to use
  * @param $login        User Login
  * @param $password     User Password
  *
  * @return String : basedn of the user / false if not founded
  **/
 function connection_ldap($ldap_method, $login, $password)
 {
     // we prevent some delay...
     if (empty($ldap_method['host'])) {
         return false;
     }
     $this->ldap_connection = AuthLdap::tryToConnectToServer($ldap_method, $login, $password);
     $this->user_deleted_ldap = false;
     if ($this->ldap_connection) {
         $params['method'] = AuthLDAP::IDENTIFIER_LOGIN;
         $params['fields'][AuthLDAP::IDENTIFIER_LOGIN] = $ldap_method['login_field'];
         $infos = AuthLdap::searchUserDn($this->ldap_connection, array('basedn' => $ldap_method['basedn'], 'login_field' => $ldap_method['login_field'], 'search_parameters' => $params, 'user_params' => array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $login), 'condition' => $ldap_method['condition'], 'user_dn' => $this->user_dn));
         $dn = $infos['dn'];
         if (!empty($dn) && @ldap_bind($this->ldap_connection, $dn, $password)) {
             //Hook to implement to restrict access by checking the ldap directory
             if (Plugin::doHookFunction("restrict_ldap_auth", $dn)) {
                 return $dn;
             }
             $this->addToError(__('User not authorized to connect in GLPI'));
             //Use is present by has no right to connect because of a plugin
             return false;
         } else {
             // Incorrect login
             $this->addToError(__('Incorrect username or password'));
             //Use is not present anymore in the directory!
             if ($dn == '') {
                 $this->user_deleted_ldap = true;
             }
             return false;
         }
     } else {
         $this->addToError(__('Unable to connect to the LDAP directory'));
         //Directory is not available
         return false;
     }
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:46,代码来源:auth.class.php

示例4: unsetUndisclosedFields

 public static function unsetUndisclosedFields(&$fields)
 {
     if (isset($fields['context']) && isset($fields['name'])) {
         if ($fields['context'] == 'core' && in_array($fields['name'], self::$undisclosedFields)) {
             unset($fields['value']);
         } else {
             $fields = Plugin::doHookFunction('undiscloseConfigValue', $fields);
         }
     }
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:10,代码来源:config.class.php

示例5: array

 You should have received a copy of the GNU General Public License
 along with GLPI. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
/** @file
 * @brief
 * @since version 0.84
*/
include '../inc/includes.php';
if (isset($_POST['itemtype']) && isset($_POST["unlock"])) {
    $itemtype = $_POST['itemtype'];
    $source_item = new $itemtype();
    if ($source_item->canCreate()) {
        $source_item->check($_POST['id'], UPDATE);
        $actions = array("Computer_Item", "Computer_SoftwareLicense", "Computer_SoftwareVersion", "ComputerDisk", "ComputerVirtualMachine", "NetworkPort", "NetworkName", "IPAddress");
        $devices = Item_Devices::getDeviceTypes();
        $actions = array_merge($actions, array_values($devices));
        foreach ($actions as $type) {
            if (isset($_POST[$type]) && count($_POST[$type])) {
                $item = new $type();
                foreach ($_POST[$type] as $key => $val) {
                    //Force unlock
                    $item->restore(array('id' => $key));
                }
            }
        }
    }
}
//Execute hook to unlock fields managed by a plugin, if needed
Plugin::doHookFunction('unlock_fields', $_POST);
Html::back();
开发者ID:btry,项目名称:glpi,代码行数:31,代码来源:lock.form.php

示例6: getNodesFromDb


//.........这里部分代码省略.........
                                 if ($r['comment'] != "") {
                                     $l_name .= ' (' . $r['comment'] . ')';
                                 }
                             }
                         }
                     }
                 }
                 // Is this location requested by the user to be opened
                 if (in_array($r['id'], $nodes)) {
                     echo "d.add(" . $r['id'] . ", " . $r['locations_id'] . ", \"" . strtr($l_name, $trans) . "\", true, -1,'');\n";
                     $dontLoad = 'true';
                     // Then add aloso its items
                     foreach (self::$types as $type) {
                         $item = new $type();
                         $itemtable = getTableForItemType($type);
                         $query = "SELECT *\n                               FROM `{$itemtable}`\n                               WHERE `locations_id` = '" . $r['id'] . "'";
                         if ($item->maybeTemplate()) {
                             $query .= " AND `{$itemtable}`.`is_template` = '0'";
                         }
                         if ($item->maybeDeleted()) {
                             $query .= " AND `{$itemtable}`.`is_deleted` = '0'";
                         }
                         if ($this->isEntityAssign()) {
                             $query .= " AND `{$itemtable}`.`entities_id` = '" . $_SESSION["glpiactive_entity"] . "'";
                         }
                         $query .= " ORDER BY `{$itemtable}`.`name`";
                         $result_1 = $DB->query($query);
                         if ($DB->numrows($result_1)) {
                             $pid = $tv_id;
                             $field_num = 3;
                             $query_location = "SELECT `completename`\n                                           FROM `glpi_locations`\n                                           WHERE `id` = '" . $r['id'] . "'";
                             $result_location = $DB->query($query_location);
                             while ($row = $DB->fetch_assoc($result_location)) {
                                 $name_location = $row['completename'];
                             }
                             $getParam = '?is_deleted=0' . '&criteria[0][field]=' . $field_num . '&criteria[0][searchtype]=equals&criteria[0][value]=' . $r['id'] . '&itemtype=' . $type;
                             // Add items parent node
                             echo "d.add({$tv_id}," . $r['id'] . ",\"" . strtr($item::getTypeName(2), $trans) . "\", {$dontLoad}, '" . $type . "', '" . Toolbox::getItemTypeSearchURL($type) . $getParam . "', '', '', '" . self::getPicbyType($type) . "', '" . self::getPicbyType($type) . "');\n";
                             if ($openedType == $type && $nodes[count($nodes) - 1] == $tv_id) {
                                 $openedType = $tv_id;
                             }
                             $tv_id++;
                         }
                         while ($r_1 = $DB->fetch_assoc($result_1)) {
                             // Item's name schema
                             if ($itemName == 0 || $type == 'Software') {
                                 $i_name = $r_1['name'];
                             } else {
                                 if ($itemName == 1) {
                                     if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                         $i_name = $r_1['otherserial'];
                                     } else {
                                         $i_name = $r_1['name'];
                                     }
                                 } else {
                                     if ($itemName == 2) {
                                         $i_name = $r_1['name'] != "" ? $r_1['name'] : "";
                                         if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                             $i_name .= $r_1['otherserial'] != "" ? $r_1['name'] != "" ? ' / ' . $r_1['otherserial'] : $r_1['otherserial'] : "";
                                         } else {
                                             $i_name .= '';
                                         }
                                     } else {
                                         if ($itemName == 3) {
                                             if (isset($r_1['otherserial']) && !empty($r_1['otherserial'])) {
                                                 $i_name = $r_1['otherserial'] != "" ? $r_1['otherserial'] : "";
                                                 $i_name .= $r_1['name'] != "" ? $r_1['otherserial'] != "" ? ' / ' . $r_1['name'] : $r_1['name'] : "";
                                             } else {
                                                 $i_name = $r_1['name'];
                                             }
                                         }
                                     }
                                 }
                             }
                             $url = Toolbox::getItemTypeFormURL($type) . "?id=" . $r_1['id'];
                             $pic = "pics/node.gif";
                             $name = strtr($i_name, $trans);
                             $opt = array('url' => $url, 'pic' => $pic, 'name' => $name);
                             $params = array('itemtype' => $type, 'id' => $r_1['id'], 'url' => $url, 'pic' => $pic, 'name' => $name);
                             $opt = Plugin::doHookFunction('treeview_params', $params);
                             // Add the item
                             echo "d.add(" . $tv_id++ . ", {$pid}, \"" . $opt['name'] . "\", true, -1, '" . $opt['url'] . "', '', '', '" . $opt['pic'] . "','" . $opt['pic'] . "');\n";
                         }
                     }
                     // Add only the location without its items
                 } else {
                     echo "d.add(" . $r['id'] . "," . $r['locations_id'] . ",\"" . strtr($l_name, $trans) . "\", false, -1,'', '', '', '', '', false, true);\n";
                 }
             }
         }
     }
     // Print the node from JavaScript
     echo "document.write(d);\n";
     // Open the tree to the desired node
     if ($openedType != -1) {
         echo "d.openTo(" . $openedType . ");\n";
     } else {
         echo "d.openTo(" . $nodes[count($nodes) - 1] . ");\n";
     }
 }
开发者ID:Blank-Vcf,项目名称:Treeview,代码行数:101,代码来源:config.class.php

示例7: addPluginInfos

 static function addPluginInfos(CommonDBTM $item)
 {
     Plugin::doHookFunction("infocom", $item);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:4,代码来源:infocom.class.php


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