Beispiel #1
0
 public function testInstall($verify = 1)
 {
     global $DB;
     // Delete if Table of Monitoring yet in DB
     $query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         if (strstr($data[0], "monitoring")) {
             $DB->query("DROP VIEW " . $data[0]);
         }
     }
     $query = "SHOW TABLES";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         if (strstr($data[0], "monitoring")) {
             $DB->query("DROP TABLE " . $data[0]);
         }
     }
     passthru("cd ../tools && /usr/local/bin/php -f cli_install.php");
     $_SESSION['glpi_use_mode'] = 2;
     $_SESSION["glpiID"] = 2;
     Plugin::load("monitoring");
     loadLanguage("en_GB");
     if ($verify == '1') {
         $MonitoringInstall = new MonitoringInstall();
         $MonitoringInstall->testDB("monitoring");
     }
     $GLPIlog = new GLPIlogs();
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
 }
 /**
  * Carrega o plugin informado
  * 
  * @version 0.1 18/05/2011 Initial
  */
 public function plugin($pluginName)
 {
     if (!class_exists('Plugin')) {
         require OB_DIR . '/lib/core/Plugin.php';
     }
     return Plugin::load($pluginName);
 }
 function load($pluginAPI)
 {
     parent::load($pluginAPI);
     return new Error("LOADING_ERROR");
     $eventM =& $this->_pluginAPI->getEventManager();
     $a = $eventM->subscribeToEvent('viewPage', new Callback('onViewHelloWorld', array($this, 'onViewPage')));
 }
Beispiel #4
0
 protected static function get_images($artist_name)
 {
     $images = array();
     if (AmpConfig::get('echonest_api_key')) {
         $echonest = new EchoNest_Client(new EchoNest_HttpClient_Requests());
         $echonest->authenticate(AmpConfig::get('echonest_api_key'));
         try {
             $images = $echonest->getArtistApi()->setName($artist_name)->getImages();
         } catch (Exception $e) {
             debug_event('echonest', 'EchoNest artist images error: ' . $e->getMessage(), '1');
         }
     }
     foreach (Plugin::get_plugins('get_photos') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($GLOBALS['user'])) {
             $images += $plugin->_plugin->get_photos($artist_name);
         }
     }
     return $images;
 }
Beispiel #5
0
 public function stream()
 {
     $data = null;
     foreach (Plugin::get_plugins('stream_song_preview') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($GLOBALS['user'])) {
             if ($plugin->_plugin->stream_song_preview($this->file)) {
                 break;
             }
         }
     }
     return $data;
 }
Beispiel #6
0
 /**
  * stream_control
  * Check all stream control plugins
  * @param array $media_ids
  * @param User $user
  * @return boolean
  */
 public static function stream_control($media_ids, User $user = null)
 {
     if ($user == null) {
         $user = $GLOBALS['user'];
     }
     foreach (Plugin::get_plugins('stream_control') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($user)) {
             if (!$plugin->_plugin->stream_control($media_ids)) {
                 return false;
             }
         }
     }
     return true;
 }
Beispiel #7
0
You should have received a copy of the GNU Affero General Public License
along with Webservices. If not, see <http://www.gnu.org/licenses/>.

@package   Webservices
@author    Nelly Mahu-Lasson
@copyright Copyright (c) 2009-2015 Webservices plugin team
@license   AGPL License 3.0 or (at your option) any later version
           http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link      https://forge.glpi-project.org/projects/webservices
@link      http://www.glpi-project.org/
@since     2009
--------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Plugin::load('webservices', true);
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
$webservices = new PluginWebservicesClient();
if (isset($_POST["add"])) {
    $webservices->check(-1, CREATE, $_POST);
    $webservices->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $webservices->check($_POST["id"], UPDATE);
        $webservices->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["purge"])) {
Beispiel #8
0
 /**
  * set_rating
  * This function sets the rating for the current object.
  * If no userid is passed in, we use the currently logged in user.
  */
 public function set_rating($rating, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = $GLOBALS['user']->id;
     }
     $user_id = intval($user_id);
     debug_event('Rating', "Setting rating for {$this->type} {$this->id} to {$rating}", 5);
     // If score is -1, then remove rating
     if ($rating == '-1') {
         $sql = "DELETE FROM `rating` WHERE " . "`object_id` = ? AND " . "`object_type` = ? AND " . "`user` = ?";
         $params = array($this->id, $this->type, $user_id);
     } else {
         $sql = "REPLACE INTO `rating` " . "(`object_id`, `object_type`, `rating`, `user`) " . "VALUES (?, ?, ?, ?)";
         $params = array($this->id, $this->type, $rating, $user_id);
     }
     Dba::write($sql, $params);
     parent::add_to_cache('rating_' . $this->type . '_user' . $user_id, $this->id, $rating);
     foreach (Plugin::get_plugins('save_rating') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($GLOBALS['user'])) {
             $plugin->_plugin->save_rating($this, $rating);
         }
     }
     return true;
 }
Beispiel #9
0
 /**
  * gather
  * This tries to get the art in question
  * @param array $options
  * @param int $limit
  * @return array
  */
 public function gather($options = array(), $limit = 0)
 {
     // Define vars
     $results = array();
     $type = $this->type;
     if (isset($options['type'])) {
         $type = $options['type'];
     }
     if (count($options) == 0) {
         debug_event('Art', 'No options for art search, skipped.', 3);
         return array();
     }
     $config = AmpConfig::get('art_order');
     $methods = get_class_methods('Art');
     /* If it's not set */
     if (empty($config)) {
         // They don't want art!
         debug_event('Art', 'art_order is empty, skipping art gathering', 3);
         return array();
     } elseif (!is_array($config)) {
         $config = array($config);
     }
     debug_event('Art', 'Searching using:' . json_encode($config), 3);
     $plugin_names = Plugin::get_plugins('gather_arts');
     foreach ($config as $method) {
         $method_name = "gather_" . $method;
         $data = array();
         if (in_array($method, $plugin_names)) {
             $plugin = new Plugin($method);
             $installed_version = Plugin::get_plugin_version($plugin->_plugin->name);
             if ($installed_version) {
                 if ($plugin->load($GLOBALS['user'])) {
                     $data = $plugin->_plugin->gather_arts($type, $options, $limit);
                 }
             }
         } else {
             if (in_array($method_name, $methods)) {
                 debug_event('Art', "Method used: {$method_name}", 3);
                 // Some of these take options!
                 switch ($method_name) {
                     case 'gather_lastfm':
                         $data = $this->{$method_name}($limit, $options);
                         break;
                     case 'gather_google':
                         $data = $this->{$method_name}($limit, $options);
                         break;
                     default:
                         $data = $this->{$method_name}($limit);
                         break;
                 }
             } else {
                 debug_event("Art", $method_name . " not defined", 1);
             }
         }
         // Add the results we got to the current set
         $results = array_merge($results, (array) $data);
         if ($limit && count($results) >= $limit) {
             return array_slice($results, 0, $limit);
         }
     }
     // end foreach
     return $results;
 }
http://indepnet.net/   http://glpi-project.org
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Vincent MAZZONI
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
Plugin::load('fusioninventory', true);
$dropdown = new PluginFusioninventoryMib_Label();
include GLPI_ROOT . "/front/dropdown.common.form.php";
Beispiel #11
0
 public function display_map($user = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
 {
     $pts = $this->get_geolocation_pts($user, $object_type, $object_id, $start_date, $end_date, $zoom);
     foreach (Plugin::get_plugins('display_map') as $plugin_name) {
         $plugin = new Plugin($plugin_name);
         if ($plugin->load($GLOBALS['user'])) {
             if ($plugin->_plugin->display_map($pts)) {
                 break;
             }
         }
     }
 }
Beispiel #12
0
 pdf 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.

 pdf 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 pdf. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Plugin::load('pdf', true);
include_once GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
$type = $_SESSION["plugin_pdf"]["type"];
$item = new $type();
$tab_id = unserialize($_SESSION["plugin_pdf"]["tab_id"]);
unset($_SESSION["plugin_pdf"]["tab_id"]);
$query = "SELECT `tabref`\n          FROM `glpi_plugin_pdf_preferences`\n          WHERE `users_ID` = '" . $_SESSION['glpiID'] . "'\n                AND `itemtype` = '{$type}'";
$result = $DB->query($query);
$tab = array();
while ($data = $DB->fetch_array($result)) {
    if ($data["tabref"] == 'landscape') {
        $pag = 1;
    } else {
        $tab[] = $data["tabref"];
    }
}
Beispiel #13
0
         $title = T_('Updated');
         $text = T_('Your Account has been updated');
         $next_url = AmpConfig::get('web_path') . '/preferences.php?tab=account';
     }
     $notification_text = T_('User updated successfully');
     break;
 case 'grant':
     // Make sure we're a user and they came from the form
     if (!Access::check('interface', '25') && $GLOBALS['user']->id > 0) {
         UI::access_denied();
         exit;
     }
     if ($_REQUEST['token'] && in_array($_REQUEST['plugin'], Plugin::get_plugins('save_mediaplay'))) {
         // we receive a token for a valid plugin, have to call getSession and obtain a session key
         if ($plugin = new Plugin($_REQUEST['plugin'])) {
             $plugin->load($GLOBALS['user']);
             if ($plugin->_plugin->get_session($GLOBALS['user']->id, $_REQUEST['token'])) {
                 $title = T_('Updated');
                 $text = T_('Your Account has been updated') . ' : ' . $_REQUEST['plugin'];
                 $next_url = AmpConfig::get('web_path') . '/preferences.php?tab=plugins';
             } else {
                 $title = T_('Error');
                 $text = T_('Your Account has not been updated') . ' : ' . $_REQUEST['plugin'];
                 $next_url = AmpConfig::get('web_path') . '/preferences.php?tab=plugins';
             }
         }
     }
     $fullname = $GLOBALS['user']->fullname;
     $preferences = $GLOBALS['user']->get_preferences($_REQUEST['tab']);
     break;
 default:
Beispiel #14
0
 * @version $Id: HEADER 15930 2012-12-15 11:10:55Z tsmr $
-------------------------------------------------------------------------
Ocsinventoryng plugin for GLPI
Copyright (C) 2012-2013 by the ocsinventoryng plugin Development Team.

https://forge.indepnet.net/projects/ocsinventoryng
-------------------------------------------------------------------------

LICENSE

This file is part of ocsinventoryng.

Ocsinventoryng plugin 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.

Ocsinventoryng plugin 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 ocsinventoryng. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------------------------------------------------------------------------------- */
include '../../../inc/includes.php';
Plugin::load('ocsinventoryng', true);
plugin_ocsinventoryng_checkRight("ocsng", "r");
Html::header('OCS Inventory NG', '', "plugins", "ocsinventoryng", "ocsserver");
Search::show('PluginOcsinventoryngOcsServer');
Html::footer();
Beispiel #15
0
 public function accept()
 {
     if ($GLOBALS['user']->has_access('75')) {
         $sql = "UPDATE `wanted` SET `accepted` = '1' WHERE `mbid` = ?";
         Dba::write($sql, array($this->mbid));
         $this->accepted = 1;
         foreach (Plugin::get_plugins('process_wanted') as $plugin_name) {
             debug_event('wanted', 'Using Wanted Process plugin: ' . $plugin_name, '5');
             $plugin = new Plugin($plugin_name);
             if ($plugin->load($GLOBALS['user'])) {
                 $plugin->_plugin->process_wanted($this);
             }
         }
     }
 }
Beispiel #16
0
 /**
  * 
  * Note : can separe code of view list
  * @param PluginTagTag $tag
  * @return boolean
  */
 static function showForTag(PluginTagTag $tag)
 {
     global $DB;
     $instID = $tag->fields['id'];
     if (!$tag->can($instID, READ)) {
         return false;
     }
     $canedit = $tag->can($instID, UPDATE);
     $table = getTableForItemType(__CLASS__);
     $result = $DB->query("SELECT DISTINCT `itemtype`\n         FROM `{$table}`\n         WHERE `plugin_tag_tags_id` = '{$instID}'");
     $result2 = $DB->query("SELECT `itemtype`, items_id\n            FROM `{$table}`\n            WHERE `plugin_tag_tags_id` = '{$instID}'");
     $number = $DB->numrows($result);
     $rand = mt_rand();
     if ($canedit) {
         echo "<div class='firstbloc'>";
         //can use standart GLPI function
         $target = Toolbox::getItemTypeFormURL('PluginTagTag');
         echo "<form name='tagitem_form{$rand}' id='tagitem_form{$rand}' method='post' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         //Note : this function is deprecated (and replace by an other)
         $itemtypes_to_show = self::getItemtypes($tag->fields['type_menu']);
         Dropdown::showAllItems("items_id", 0, 0, $tag->fields['is_recursive'] ? -1 : $tag->fields['entities_id'], $itemtypes_to_show, false, true);
         echo "<style>.select2-container { text-align: left; } </style>";
         //minor
         echo "</td><td class='center'>";
         echo "<input type='hidden' name='plugin_tag_tags_id' value='{$instID}'>";
         //Note : can use standart GLPI method
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         Html::showMassiveActions();
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $item_id = $DB->result($result2, $i, "items_id");
         if ($item->canView()) {
             $column = strtolower(substr($itemtype, 0, 6)) == "device" ? "designation" : "name";
             // For rules itemtypes (example : ruledictionnaryphonemodel)
             if (strtolower(substr($itemtype, 0, 4)) == 'rule' || $itemtype == "PluginResourcesRulechecklist") {
                 $itemtable = getTableForItemType('Rule');
             } else {
                 $itemtable = getTableForItemType($itemtype);
             }
             $obj = new $itemtype();
             $obj->getFromDB($item_id);
             $query = "SELECT `{$itemtable}`.*, `glpi_plugin_tag_tagitems`.`id` AS IDD, ";
             switch ($itemtype) {
                 case 'KnowbaseItem':
                     $query .= "-1 AS entity\n                  FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                  " . KnowbaseItem::addVisibilityJoins() . "\n                  WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                  AND ";
                     break;
                 case 'Profile':
                 case 'RSSFeed':
                 case 'Reminder':
                 case 'Entity':
                     //Possible to add (in code) condition to visibility :
                     $query .= "-1 AS entity\n                  FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                  WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                  AND ";
                     break;
                 default:
                     if (isset($obj->fields['entities_id'])) {
                         $query .= "`glpi_entities`.`id` AS entity\n                        FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                        LEFT JOIN `glpi_entities`\n                        ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)\n                        WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                        AND ";
                     } else {
                         $query .= "-1 AS entity\n                        FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                        WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                        AND ";
                     }
                     break;
             }
             $query .= "`glpi_plugin_tag_tagitems`.`itemtype` = '{$itemtype}'\n               AND `glpi_plugin_tag_tagitems`.`plugin_tag_tags_id` = '{$instID}' ";
             $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             switch ($itemtype) {
                 case 'KnowbaseItem':
                 case 'Profile':
                 case 'RSSFeed':
                 case 'Reminder':
                 case 'Entity':
                     $query .= " ORDER BY `{$itemtable}`.`{$column}`";
                     break;
                 default:
                     if (isset($obj->fields['entities_id'])) {
                         $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`";
                     } else {
                         $query .= " ORDER BY `{$itemtable}`.`{$column}`";
                     }
                     break;
             }
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         if ($itemtype == 'Softwarelicense') {
                             $soft = new Software();
                             $soft->getFromDB($data['softwares_id']);
                             $data["name"] .= ' - ' . $soft->getName();
                             //This add name of software
                         } elseif ($itemtype == "PluginResourcesResource") {
                             $data["name"] = formatUserName($data["id"], "", $data["name"], $data["firstname"]);
                         }
                         $linkname = $data[$column];
                         if ($_SESSION["glpiis_ids_visible"] || empty($data[$column])) {
                             $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]);
                         }
                         $name = "<a href=\"" . Toolbox::getItemTypeFormURL($itemtype) . "?id=" . $data["id"] . "\">" . $linkname . "</a>";
                         if ($itemtype == 'PluginProjetProjet' || $itemtype == 'PluginResourcesResource') {
                             $pieces = preg_split('/(?=[A-Z])/', $itemtype);
                             $plugin_name = $pieces[2];
                             $datas = array("entities_id" => $data["entity"], "ITEM_0" => $data["name"], "ITEM_0_2" => $data["id"], "id" => $data["id"], "META_0" => $data["name"]);
                             //for PluginResourcesResource
                             if (isset($data["is_recursive"])) {
                                 $datas["is_recursive"] = $data["is_recursive"];
                             }
                             Plugin::load(strtolower($plugin_name), true);
                             $function_giveitem = 'plugin_' . strtolower($plugin_name) . '_giveItem';
                             if (function_exists($function_giveitem)) {
                                 // For security
                                 $name = call_user_func($function_giveitem, $itemtype, 1, $datas, 0);
                             }
                         }
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             if ($item->canUpdate()) {
                                 Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                             }
                             echo "</td>";
                         }
                         echo "<td class='center'>";
                         // Show plugin name (is to delete remove any ambiguity) :
                         $pieces = preg_split('/(?=[A-Z])/', $itemtype);
                         if ($pieces[1] == 'Plugin') {
                             $plugin_name = $pieces[2];
                             if (function_exists("plugin_version_" . $plugin_name)) {
                                 // For security
                                 $tab = call_user_func("plugin_version_" . $plugin_name);
                                 echo $tab["name"] . " : ";
                             }
                         }
                         echo $item->getTypeName(1) . "</td>";
                         echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         echo "<td class='center'>";
                         $entity = $data['entity'];
                         //for Plugins :
                         if ($data["entity"] == -1) {
                             $item->getFromDB($data['id']);
                             if (isset($item->fields["entities_id"])) {
                                 $entity = $item->fields["entities_id"];
                             }
                         }
                         echo Dropdown::getDropdownName("glpi_entities", $entity);
                         echo "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Beispiel #17
0
 /**
  * @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
         if ($model->fields["replace_documents"] && in_array($type, $CFG_GLPI["document_types"])) {
             $doc_item = new Document_Item();
             foreach (self::getAssociatedDocuments($olditem) as $document) {
                 $doc_item->update(array('id' => $document['assocID'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Contracts
         if ($model->fields["replace_contracts"] && in_array($type, $CFG_GLPI["contract_types"])) {
             $contract_item = new Contract_Item();
             foreach (self::getAssociatedContracts($olditem) as $contract) {
                 $contract_item->update(array('id' => $contract['id'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Infocoms
         if ($model->fields["replace_infocoms"] && in_array($type, $CFG_GLPI["infocom_types"])) {
             $infocom = new Infocom();
             if ($overwrite) {
                 // Delete current Infocoms of new item
                 if ($infocom->getFromDBforDevice($type, $newitem_id)) {
                     //Do not log infocom deletion in the new item's history
                     $infocom->dohistory = false;
                     $infocom->deleteFromDB(1);
                 }
             }
             // Update current Infocoms of old item
             if ($infocom->getFromDBforDevice($type, $olditem_id)) {
                 $infocom->update(array('id' => $infocom->getID(), 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Reservations
         if ($model->fields["replace_reservations"] && in_array($type, $CFG_GLPI["reservation_types"])) {
             $resaitem = new ReservationItem();
             if ($overwrite) {
                 // Delete current reservation of new item
                 $resa_new = new Reservation();
                 $resa_new->getFromDB($newitem_id);
                 if ($resa_new->is_reserved()) {
                     $resa_new = new ReservationItem();
                     $resa_new->getFromDBbyItem($type, $newitem_id);
                     if (count($resa_new->fields)) {
                         $resa_new->deleteFromDB(1);
                     }
                 }
             }
             // Update old reservation for attribute to new item
             $resa_old = new Reservation();
             $resa_old->getFromDB($olditem_id);
             if ($resa_old->is_reserved()) {
                 $resa_old = new ReservationItem();
                 $resa_old->getFromDBbyItem($type, $olditem_id);
                 if (count($resa_old->fields)) {
                     $resa_old->update(array('id' => $resa_old->getID(), 'itemtype' => $type, 'items_id' => $newitem_id), false);
                 }
             }
         }
         // User
         if ($model->fields["replace_users"] && in_array($type, $CFG_GLPI["linkuser_types"])) {
             $data = array();
             $data['id'] = $newitem->getID();
             if ($newitem->isField('users_id') && ($overwrite || empty($data['users_id']))) {
                 $data['users_id'] = $olditem->getField('users_id');
             }
             if ($newitem->isField('contact') && ($overwrite || empty($data['contact']))) {
                 $data['contact'] = $olditem->getField('contact');
             }
             if ($newitem->isField('contact_num') && ($overwrite || empty($data['contact_num']))) {
                 $data['contact_num'] = $olditem->getField('contact_num');
             }
             $newitem->update($data, false);
         }
         // Group
         if ($model->fields["replace_groups"] && in_array($type, $CFG_GLPI["linkgroup_types"])) {
             if ($newitem->isField('groups_id') && ($overwrite || empty($data['groups_id']))) {
                 $newitem->update(array('id' => $newitem_id, 'groups_id' => $olditem->getField('groups_id')), false);
             }
         }
         // Tickets
         if ($model->fields["replace_tickets"] && in_array($type, $CFG_GLPI["ticket_types"])) {
             $ticket_item = new Item_Ticket();
             foreach (self::getAssociatedTickets($type, $olditem_id) as $ticket) {
                 $ticket_item->update(array('id' => $ticket['id'], 'items_id' => $newitem_id), false);
             }
         }
         //Array netport_types renamed in networkport_types in GLPI 0.80
         if (isset($CFG_GLPI["netport_types"])) {
             $netport_types = $CFG_GLPI["netport_types"];
         } else {
             $netport_types = $CFG_GLPI["networkport_types"];
         }
         // NetPorts
         if ($model->fields["replace_netports"] && in_array($type, $netport_types)) {
             $netport_item = new NetworkPort();
             foreach (self::getAssociatedNetports($type, $olditem_id) as $netport) {
                 $netport_item->update(array('id' => $netport['id'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
             }
         }
         // Directs connections
         if ($model->fields["replace_direct_connections"] && in_array($type, array('Computer'))) {
             $comp_item = new Computer_Item();
             foreach (self::getAssociatedItems($olditem) as $itemtype => $connections) {
                 foreach ($connections as $connection) {
                     $comp_item->update(array('id' => $connection['id'], 'computers_id' => $newitem_id, 'itemtype' => $itemtype), false);
                 }
             }
         }
         // Location
         if ($location != 0 && $olditem->isField('locations_id')) {
             $olditem->getFromDB($olditem_id);
             switch ($location) {
                 case -1:
                     break;
                 default:
                     $olditem->update(array('id' => $olditem_id, 'locations_id' => $location), false);
                     break;
             }
         }
         $plug = new Plugin();
         if ($plug->isActivated('ocsinventoryng')) {
             //Delete computer from OCS
             if ($model->fields["remove_from_ocs"] == 1) {
                 PluginUninstallUninstall::deleteComputerInOCSByGlpiID($olditem_id);
             }
             //Delete link in glpi_ocs_link
             if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) {
                 PluginUninstallUninstall::deleteOcsLink($olditem_id);
             }
         }
         if ($plug->isActivated('fusioninventory')) {
             if ($model->fields['raz_fusioninventory']) {
                 PluginUninstallUninstall::deleteFusionInventoryLink(get_class($olditem), $olditem_id);
             }
         }
         // METHOD REPLACEMENT 1 : Purge
         if ($model->fields['replace_method'] == self::METHOD_PURGE) {
             // Retrieve, Compute && Update NEW comment field
             $comment = self::getCommentsForReplacement($olditem, true);
             $comment .= "\n- " . __('See attached document', 'uninstall');
             $newitem->update(array('id' => $newitem_id, 'comment' => addslashes($comment)), false);
             // If old item is attached in PDF/CSV
             // Delete AND Purge it in DB
             if ($document_added) {
                 $olditem->delete(array('id' => $olditem_id), true);
             }
         }
         // METHOD REPLACEMENT 2 : Delete AND Comment
         if ($model->fields['replace_method'] == self::METHOD_DELETE_AND_COMMENT) {
             //Add comment on the new item first
             $comment = self::getCommentsForReplacement($olditem, true);
             $newitem->update(array('id' => $newitem_id, 'comment' => Toolbox::addslashes_deep($comment)), false);
             // Retrieve, Compute && Update OLD comment field
             $comment = self::getCommentsForReplacement($newitem, false);
             $olditem->update(array('id' => $olditem_id, 'comment' => Toolbox::addslashes_deep($comment)), false);
             // Delete OLD item from DB (not PURGE)
             PluginUninstallUninstall::addUninstallLog($type, $olditem_id, 'replaced_by');
             $olditem->delete(array('id' => $olditem_id), 0, false);
         }
         //Plugin hook after replacement
         Plugin::doHook("plugin_uninstall_replace_after", $olditem);
         //Add history
         PluginUninstallUninstall::addUninstallLog($type, $newitem_id, 'replace');
         Html::changeProgressBarPosition($count, $tot + 1);
     }
     Html::changeProgressBarPosition($count, $tot, __('Replacement successful', 'uninstall'));
     echo "</td></tr>";
     echo "</table></div>";
 }
Beispiel #18
0
    $HEADER_LOADED = true;
}
/* On startup, register all plugins configured for use. */
if (!isset($AJAX_INCLUDE) && !isset($PLUGINS_INCLUDED)) {
    // PLugin already included
    $PLUGINS_INCLUDED = 1;
    $LOADED_PLUGINS = array();
    $plugin = new Plugin();
    if (!isset($_SESSION["glpi_plugins"])) {
        $plugin->init();
    }
    if (isset($_SESSION["glpi_plugins"]) && is_array($_SESSION["glpi_plugins"])) {
        //Plugin::doHook("config");
        if (count($_SESSION["glpi_plugins"])) {
            foreach ($_SESSION["glpi_plugins"] as $name) {
                Plugin::load($name);
            }
        }
        // For plugins which require action after all plugin init
        Plugin::doHook("post_init");
    }
}
if (!isset($_SESSION["MESSAGE_AFTER_REDIRECT"])) {
    $_SESSION["MESSAGE_AFTER_REDIRECT"] = "";
}
// Manage force tab
if (isset($_REQUEST['forcetab'])) {
    if (preg_match('/([a-zA-Z]+).form.php/', $_SERVER['PHP_SELF'], $matches)) {
        $itemtype = $matches[1];
        Session::setActiveTab($matches[1], $_REQUEST['forcetab']);
    }
Beispiel #19
0
if ($config->widget_include_css) {
    Weapon::add('shell_before', function () {
        echo Asset::stylesheet(SHIELD . DS . 'widgets.css', "", 'shell/widgets.min.css');
    });
}
if ($config->widget_include_js) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript(SHIELD . DS . 'widgets.js', "", 'sword/widgets.min.js');
    });
}
/**
 * Loading Plugin(s)
 * -----------------
 */
Weapon::fire('plugins_before');
foreach ($plugins = Plugin::load() as $k => $v) {
    $__ = PLUGIN . DS . $k . DS;
    if (!($language = File::exist($__ . 'languages' . DS . $config->language . DS . 'speak.txt'))) {
        $language = $__ . 'languages' . DS . 'en_US' . DS . 'speak.txt';
    }
    if (file_exists($language)) {
        Config::merge('speak', Text::toArray(File::open($language)->read(), S, '  '));
        $speak = Config::speak();
        // refresh ...
    }
    Weapon::fire(array('plugin_before', 'plugin_' . md5($k) . '_before'));
    if ($launch = File::exist($__ . 'launch.php')) {
        if (strpos(File::B($__), '__') === 0) {
            if (Guardian::happy() && $config->page_type === 'manager') {
                include $launch;
                // backend
Beispiel #20
0
  Plugin Barcode 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with Plugin Barcode. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @package   Plugin Barcode
  @author    David Durieux
  @co-author
  @copyright Copyright (c) 2009-2013 Barcode plugin Development team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/barscode
  @since     2009

  ------------------------------------------------------------------------
*/
// Non menu entry case
//header("Location:../../central.php");
include '../../../inc/includes.php';
Session::checkRight("config", "w");
// To be available when plugin is not activated
Plugin::load('barcode');
Html::header(__('Barcode', 'barcode'), $_SERVER['PHP_SELF'], "config", "plugins");
$pbConfig = new PluginBarcodeConfig();
$pbConfig->showForm('');
Html::footer();
Beispiel #21
0
  Plugin Barcode 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with Plugin Barcode. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @package   Plugin Barcode
  @author    David Durieux
  @co-author
  @copyright Copyright (c) 2009-2013 Barcode plugin Development team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/barscode
  @since     2009

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("profile", "r");
// Mainly usefull if not actived
Plugin::load('barcode', true);
$prof = new PluginBarcodeProfile();
if (isset($_POST["update_user_profile"])) {
    Session::checkRight("profile", "w");
    $prof->update($_POST);
    Html::back();
}
Beispiel #22
0
 /**
  * Load wanted release data.
  * @param boolean $track_details
  */
 public function load_all($track_details = true)
 {
     $mb = new MusicBrainz(new RequestsHttpAdapter());
     $this->songs = array();
     try {
         $group = $mb->lookup('release-group', $this->mbid, array('releases'));
         // Set fresh data
         $this->name = $group->title;
         $this->year = date("Y", strtotime($group->{'first-release-date'}));
         // Load from database if already cached
         $this->songs = Song_preview::get_song_previews($this->mbid);
         if (count($group->releases) > 0) {
             $this->release_mbid = $group->releases[0]->id;
             if ($track_details && count($this->songs) == 0) {
                 // Use the first release as reference for track content
                 $release = $mb->lookup('release', $this->release_mbid, array('recordings'));
                 foreach ($release->media as $media) {
                     foreach ($media->tracks as $track) {
                         $song = array();
                         $song['disk'] = $media->position;
                         $song['track'] = $track->number;
                         $song['title'] = $track->title;
                         $song['mbid'] = $track->id;
                         if ($this->artist) {
                             $song['artist'] = $this->artist;
                         }
                         $song['artist_mbid'] = $this->artist_mbid;
                         $song['session'] = session_id();
                         $song['album_mbid'] = $this->mbid;
                         if ($this->artist) {
                             $artist = new Artist($this->artist);
                             $artist_name = $artist->name;
                         } else {
                             $wartist = Wanted::get_missing_artist($this->artist_mbid);
                             $artist_name = $wartist['name'];
                         }
                         $song['file'] = null;
                         foreach (Plugin::get_plugins('get_song_preview') as $plugin_name) {
                             $plugin = new Plugin($plugin_name);
                             if ($plugin->load($GLOBALS['user'])) {
                                 $song['file'] = $plugin->_plugin->get_song_preview($track->id, $artist_name, $track->title);
                                 if ($song['file'] != null) {
                                     break;
                                 }
                             }
                         }
                         if ($song != null) {
                             $this->songs[] = new Song_Preview(Song_preview::insert($song));
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         $this->songs = array();
     }
     foreach ($this->songs as $song) {
         $song->f_album = $this->name;
         $song->format();
     }
 }
<?php

include '../../../inc/includes.php';
Session::checkRight("entity", UPDATE);
Plugin::load('formcreator', true);
$dropdown = new PluginFormcreatorCategory();
if (isset($_POST['add']) && isset($_POST['name'])) {
    $found = $dropdown->find("name LIKE '" . $_POST['name'] . "'");
    if (!empty($found)) {
        Session::addMessageAfterRedirect(__('A category already exists with the same name! Category creation failed.', 'formcreator'), false, ERROR);
        Html::back();
    }
}
include GLPI_ROOT . "/front/dropdown.common.form.php";
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($tabnum == 49) {
         $pmServicescatalog = new PluginMonitoringServicescatalog();
         $pmDisplay = new PluginMonitoringDisplay();
         // $pmDisplay->showCounters("Businessrules");
         $pmServicescatalog->showChecks();
     } else {
         if ($tabnum == 50) {
             $pmContact_Item = new PluginMonitoringContact_Item();
             $pmContact_Item->showContacts("PluginMonitoringServicescatalog", $item->getID());
         } else {
             Plugin::load('monitoring', true);
             Plugin::displayAction($appliance, $_POST['glpi_tab']);
         }
     }
     return true;
 }
Beispiel #25
0
 /**
  * Launch the need cron tasks
  *
  * @param $mode   (internal/external, <0 to force)
  * @param $max    number of task to launch (default 1)
  * @param $name   of task to run (default '')
  *
  * @return the name of last task launched
  **/
 public static function launch($mode, $max = 1, $name = '')
 {
     global $CFG_GLPI;
     // No cron in maintenance mode
     if (isset($CFG_GLPI['maintenance_mode']) && $CFG_GLPI['maintenance_mode']) {
         return false;
     }
     $crontask = new self();
     $taskname = '';
     if (abs($mode) == self::MODE_EXTERNAL) {
         // If cron is launched in command line, and if memory is insufficient,
         // display a warning in the logs
         if (Toolbox::checkMemoryLimit() == 2) {
             Toolbox::logInFile('cron', __('A minimum of 64 Mio is commonly required for GLPI.') . "\n");
         }
         // If no task in CLI mode, call cron.php from command line is not really usefull ;)
         if (!countElementsInTable($crontask->getTable(), ['mode' => abs($mode)])) {
             Toolbox::logInFile('cron', __('No task with Run mode = CLI, fix your tasks configuration') . "\n");
         }
     }
     if (self::get_lock()) {
         for ($i = 1; $i <= $max; $i++) {
             $prefix = abs($mode) == self::MODE_EXTERNAL ? __('External') : __('Internal');
             if ($crontask->getNeedToRun($mode, $name)) {
                 $_SESSION["glpicronuserrunning"] = "cron_" . $crontask->fields['name'];
                 if ($plug = isPluginItemType($crontask->fields['itemtype'])) {
                     Plugin::load($plug['plugin'], true);
                 }
                 $fonction = array($crontask->fields['itemtype'], 'cron' . $crontask->fields['name']);
                 if (is_callable($fonction)) {
                     if ($crontask->start()) {
                         // Lock in DB + log start
                         $taskname = $crontask->fields['name'];
                         //TRANS: %1$s is mode (external or internal), %2$s is an order number,
                         $msgcron = sprintf(__('%1$s #%2$s'), $prefix, $i);
                         $msgcron = sprintf(__('%1$s: %2$s'), $msgcron, sprintf(__('%1$s %2$s') . "\n", __('Launch'), $crontask->fields['name']));
                         Toolbox::logInFile('cron', $msgcron);
                         $retcode = call_user_func($fonction, $crontask);
                         $crontask->end($retcode);
                         // Unlock in DB + log end
                     } else {
                         $msgcron = sprintf(__('%1$s #%2$s'), $prefix, $i);
                         $msgcron = sprintf(__('%1$s: %2$s'), $msgcron, sprintf(__('%1$s %2$s') . "\n", __("Can't start"), $crontask->fields['name']));
                         Toolbox::logInFile('cron', $msgcron);
                     }
                 } else {
                     if (is_array($fonction)) {
                         $fonction = implode('::', $fonction);
                     }
                     Toolbox::logInFile('php-errors', sprintf(__('Undefined function %s (for cron)') . "\n", $fonction));
                     $msgcron = sprintf(__('%1$s #%2$s'), $prefix, $i);
                     $msgcron = sprintf(__('%1$s: %2$s'), $msgcron, sprintf(__('%1$s %2$s') . "\n", __("Can't start"), $crontask->fields['name']));
                     Toolbox::logInFile('cron', $msgcron . "\n" . sprintf(__('Undefined function %s (for cron)') . "\n", $fonction));
                 }
             } else {
                 if ($i == 1) {
                     $msgcron = sprintf(__('%1$s #%2$s'), $prefix, $i);
                     $msgcron = sprintf(__('%1$s: %2$s'), $msgcron, __('Nothing to launch'));
                     Toolbox::logInFile('cron', $msgcron . "\n");
                 }
             }
         }
         // end for
         $_SESSION["glpicronuserrunning"] = '';
         self::release_lock();
     } else {
         Toolbox::logInFile('cron', __("Can't get DB lock") . "\n");
     }
     return $taskname;
 }
Beispiel #26
0
 public static function create_share($object_type, $object_id, $allow_stream = true, $allow_download = true, $expire = 0, $secret = '', $max_counter = 0, $description = '')
 {
     $object_type = self::format_type($object_type);
     if (empty($object_type)) {
         return '';
     }
     if (!$allow_stream && !$allow_download) {
         return '';
     }
     $sql = "INSERT INTO `share` (`user`, `object_type`, `object_id`, `creation_date`, `allow_stream`, `allow_download`, `expire_days`, `secret`, `counter`, `max_counter`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $params = array($GLOBALS['user']->id, $object_type, $object_id, time(), $allow_stream ?: 0, $allow_download ?: 0, $expire, $secret, 0, $max_counter, $description);
     Dba::write($sql, $params);
     $id = Dba::insert_id();
     $url = self::get_url($id, $secret);
     // Get a shortener url if any available
     foreach (Plugin::get_plugins('shortener') as $plugin_name) {
         try {
             $plugin = new Plugin($plugin_name);
             if ($plugin->load($GLOBALS['user'])) {
                 $short_url = $plugin->_plugin->shortener($url);
                 if (!empty($short_url)) {
                     $url = $short_url;
                     break;
                 }
             }
         } catch (Exception $e) {
             debug_event('share', 'Share plugin error: ' . $e->getMessage(), '1');
         }
     }
     $sql = "UPDATE `share` SET `public_url` = ? WHERE `id` = ?";
     Dba::write($sql, array($url, $id));
     return $id;
 }
Beispiel #27
0
This file is part of Webservices plugin for GLPI.

Webservices is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Webservices 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Webservices. If not, see <http://www.gnu.org/licenses/>.

@package   Webservices
@author    Nelly Mahu-Lasson
@copyright Copyright (c) 2009-2015 Webservices plugin team
@license   AGPL License 3.0 or (at your option) any later version
           http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link      https://forge.glpi-project.org/projects/webservices
@link      http://www.glpi-project.org/
@since     2009
--------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Plugin::load('webservices');
Session::checkRight("config", UPDATE);
Html::header(__('Web Services', 'webservices'), $_SERVER['PHP_SELF'], "config", "pluginWebservicesClient");
Search::show('PluginWebservicesClient');
Html::footer();
Beispiel #28
0
UI::show_box_top($client->f_name);
?>
<div class="user_avatar">
<?php 
if ($client->f_avatar) {
    echo $client->f_avatar . "<br /><br />";
}
if (AmpConfig::get('sociable')) {
    echo $client->get_display_follow();
    $plugins = Plugin::get_plugins('display_user_field');
    ?>
    <ul id="plugins_user_field">
<?php 
    foreach ($plugins as $plugin_name) {
        $plugin = new Plugin($plugin_name);
        if ($plugin->load($client)) {
            ?>
        <li><?php 
            $plugin->_plugin->display_user_field();
            ?>
 </li>
<?php 
        }
    }
    ?>
    </ul>
<?php 
}
?>
</div>
<dl class="media_details">
    $migration->displayWarning("***** Install process of plugin TIMELINETICKET *****");
} else {
    $migration->displayWarning("***** Update process of plugin TIMELINETICKET *****");
}
$migration->displayWarning("Current Timelineticket version: {$current_version}");
$migration->displayWarning("Version to update: " . PLUGIN_TIMELINETICKET_VERSION);
// To prevent problem of execution time
ini_set("max_execution_time", "0");
ini_set("memory_limit", "-1");
$mess = '';
if ($current_version != PLUGIN_TIMELINETICKET_VERSION and $current_version != '0') {
    $mess = "Update done.";
} else {
    if ($current_version == PLUGIN_TIMELINETICKET_VERSION) {
        $mess = "No migration needed.";
    } else {
        $mess = "installation done.";
    }
}
$plugin->getFromDBbyDir("timelineticket");
$plugin->install($plugin->fields['id']);
plugin_timelineticket_install();
$migration->displayWarning($mess);
$plugin->load("timelineticket");
$plugin->activate($plugin->fields['id']);
$plugin->load("timelineticket");
if (in_array('--optimize', $_SERVER['argv'])) {
    $migration->displayTitle("Optimizing tables");
    DBmysql::optimize_tables($migration);
    $migration->displayWarning("Optimize done.");
}
You should have received a copy of the GNU Affero General Public License
along with Reports. If not, see <http://www.gnu.org/licenses/>.

@package   reports
@authors    Nelly Mahu-Lasson, Remi Collet
@copyright Copyright (c) 2009-2015 Reports plugin team
@license   AGPL License 3.0 or (at your option) any later version
           http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link      https://forge.indepnet.net/projects/reports
@link      http://www.glpi-project.org/
@since     2009
--------------------------------------------------------------------------
*/
include "../../../../inc/includes.php";
Plugin::load('reports');
Session::checkRight("profile", UPDATE);
Html::header(__('Duplicate computers', 'reports'), $_SERVER['PHP_SELF'], "config", "plugins");
$types = array(1 => __('MAC'), 2 => __('IP'), 3 => __('Serial number'));
if (isset($_POST["delete"]) && isset($_POST['id'])) {
    $query = "DELETE\n             FROM `glpi_plugin_reports_doublons_backlists`\n             WHERE `id` = '" . $_POST['id'] . "'";
    $DB->query($query);
} else {
    if (isset($_POST["add"]) && isset($_POST["type"]) && isset($_POST["addr"]) && strlen($_POST["addr"])) {
        $query = "INSERT INTO `glpi_plugin_reports_doublons_backlists`\n             SET `type` = '" . $_POST["type"] . "',\n                 `addr` = '" . trim($_POST["addr"]) . "',\n                 `comment` = '" . trim($_POST["comment"]) . "'";
        $DB->query($query);
    }
}
// Initial creation
if (TableExists("glpi_plugin_reports_doublons_backlist")) {
    $migration = new Migration(160);