/** * Outputs the feed of the specified photo * * @param Zend_Http_Client $client The authenticated client object * @param string $user The user's account name * @param integer $albumId The album's id * @param integer $photoId The photo's id * @return void */ function outputPhotoFeed($client, $user, $albumId, $photoId) { $photos = new Zend_Gdata_Photos($client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($user); $query->setAlbumId($albumId); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag"; $photoFeed = $photos->getPhotoFeed($query); echo "<h2>Photo Feed for: " . $photoFeed->getTitle() . "</h2>"; $thumbs = $photoFeed->getMediaGroup()->getThumbnail(); echo "<img src='" . $thumbs[2]->url . "' />"; echo "<h3 class='nopad'>Comments:</h3>"; echo "<ul>\n"; foreach ($photoFeed as $entry) { if ($entry instanceof Zend_Gdata_Photos_CommentEntry) { echo "\t<li>" . $entry->getContent(); echo "<form action='" . getCurrentScript() . "' method='post' class='deleteForm'>"; echo "<input type='hidden' name='user' value='" . $user . "' />"; echo "<input type='hidden' name='album' value='" . $albumId . "' />"; echo "<input type='hidden' name='photo' value='" . $photoId . "' />"; echo "<input type='hidden' name='comment' value='" . $entry->getGphotoId(); echo "' />"; echo "<input type='hidden' name='command' value='deleteComment' />"; echo "<input type='submit' value='Delete' /></form>"; echo "</li>\n"; } } echo "</ul>\n"; echo "<h4>Add a Comment</h4>"; ?> <form method="POST" action="<?php echo getCurrentScript(); ?> "> <input type="hidden" name="command" value="addComment" /> <input type="hidden" name="user" value="<?php echo $user; ?> " /> <input type="hidden" name="album" value="<?php echo $albumId; ?> " /> <input type="hidden" name="photo" value="<?php echo $photoId; ?> " /> <input type="text" name="comment" /> <input type="submit" name="Comment" value="Comment" /> </form> <?php echo "<br />"; echo "<h3 class='nopad'>Tags:</h3>"; echo "<ul>\n"; foreach ($photoFeed as $entry) { if ($entry instanceof Zend_Gdata_Photos_TagEntry) { echo "\t<li>" . $entry->getTitle(); echo "<form action='" . getCurrentScript() . "' method='post' class='deleteForm'>"; echo "<input type='hidden' name='user' value='" . $user . "' />"; echo "<input type='hidden' name='album' value='" . $albumId . "' />"; echo "<input type='hidden' name='photo' value='" . $photoId . "' />"; echo "<input type='hidden' name='tag' value='" . $entry->getContent(); echo "' />"; echo "<input type='hidden' name='command' value='deleteTag' />"; echo "<input type='submit' value='Delete' /></form>"; echo "</li>\n"; } } echo "</ul>\n"; echo "<h4>Add a Tag</h4>"; ?> <form method="POST" action="<?php echo getCurrentScript(); ?> "> <input type="hidden" name="command" value="addTag" /> <input type="hidden" name="user" value="<?php echo $user; ?> " /> <input type="hidden" name="album" value="<?php echo $albumId; ?> " /> <input type="hidden" name="photo" value="<?php echo $photoId; ?> " /> <input type="text" name="tag" /> <input type="submit" name="Tag" value="Tag" /> </form> <?php displayBackLink(); }
/** * Show reservation calendar * * @param $ID ID of the reservation item (if empty display all) **/ static function showCalendar($ID = "") { global $LANG, $CFG_GLPI; if (!haveRight("reservation_helpdesk", "1")) { return false; } if (!isset($_GET["mois_courant"])) { $mois_courant = strftime("%m"); } else { $mois_courant = $_GET["mois_courant"]; } if (!isset($_GET["annee_courante"])) { $annee_courante = strftime("%Y"); } else { $annee_courante = $_GET["annee_courante"]; } $mois_suivant = $mois_courant + 1; $mois_precedent = $mois_courant - 1; $annee_suivante = $annee_courante; $annee_precedente = $annee_courante; if ($mois_precedent == 0) { $mois_precedent = 12; $annee_precedente--; } if ($mois_suivant == 13) { $mois_suivant = 1; $annee_suivante++; } $str_suivant = "?reservationitems_id={$ID}&mois_courant={$mois_suivant}&" . "annee_courante={$annee_suivante}"; $str_precedent = "?reservationitems_id={$ID}&mois_courant={$mois_precedent}&" . "annee_courante={$annee_precedente}"; if (!empty($ID)) { $m = new ReservationItem(); $m->getFromDB($ID); if (!isset($m->fields['is_active']) || !$m->fields['is_active']) { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; echo "<td class='center b'>" . $LANG['reservation'][2] . "</td></tr>"; echo "<tr class='tab_bg_1'><td class='center b'>"; displayBackLink(); echo "</td></tr>"; echo "</table>"; echo "</div>"; return false; } $type = $m->fields["itemtype"]; $name = NOT_AVAILABLE; if (class_exists($m->fields["itemtype"])) { $item = new $m->fields["itemtype"](); $type = $item->getTypeName(); if ($item->getFromDB($m->fields["items_id"])) { $name = $item->getName(); } $name = $type . " - " . $name; } $all = "<a href='reservation.php?reservationitems_id=&mois_courant=" . "{$mois_courant}&annee_courante={$annee_courante}'>" . $LANG['buttons'][40] . "</a>"; } else { $type = ""; $name = $LANG['reservation'][25]; $all = " "; } echo "<div class='center'><table class='tab_glpi'><tr><td>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation.png' alt='' title=''></td>"; echo "<td class ='b'><span class='icon_consol'>" . $name . "</span></td></tr>"; echo "<tr><td colspan='2' class ='center'>{$all}</td></tr></table></div>\n"; // Check bisextile years if ($annee_courante % 4 == 0) { $fev = 29; } else { $fev = 28; } $nb_jour = array(31, $fev, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // Datas used to put right informations in columns $jour_debut_mois = strftime("%w", mktime(0, 0, 0, $mois_courant, 1, $annee_courante)); if ($jour_debut_mois == 0) { $jour_debut_mois = 7; } $jour_fin_mois = strftime("%w", mktime(0, 0, 0, $mois_courant, $nb_jour[$mois_courant - 1], $annee_courante)); echo "<div class='center'>"; echo "<table class='tab_glpi'><tr><td><a href='reservation.php" . $str_precedent . "'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . $LANG['buttons'][12] . "\" title=\"" . $LANG['buttons'][12] . "\"></a></td>"; echo "<td class='b'>" . $LANG['calendarM'][$mois_courant - 1] . " " . $annee_courante . "</td>"; echo "<td><a href='reservation.php" . $str_suivant . "'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . $LANG['buttons'][11] . "\" title=\"" . $LANG['buttons'][11] . "\"></a></td></tr></table>\n"; // test echo "<table width='90%' class='tab_glpi'><tr><td class='top' width='100px'>"; echo "<table><tr><td width='100px' class='top'>"; // today date $today = getdate(time()); $mois = $today["mon"]; $annee = $today["year"]; $annee_avant = $annee_courante - 1; $annee_apres = $annee_courante + 1; echo "<div class='calendrier_mois'>"; echo "<div class='center b'>{$annee_avant}</div>"; for ($i = $mois_courant; $i < 13; $i++) { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_avant}'>" . $LANG['calendarM'][$i - 1] . "</a></div>"; } echo "<div class='center b'>{$annee_courante}</div>"; for ($i = 1; $i < 13; $i++) { if ($i == $mois_courant) { echo "<div class='calendrier_case1 b'>" . $LANG['calendarM'][$i - 1] . "</div>\n"; } else { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_courante}'>" . $LANG['calendarM'][$i - 1] . "</a></div>\n"; } } echo "<div class='center'><strong>{$annee_apres}</strong></div>\n"; for ($i = 1; $i < $mois_courant + 1; $i++) { echo "<div class='calendrier_case2'>"; echo "<a href='reservation.php?reservationitems_id={$ID}&mois_courant={$i}&" . "annee_courante={$annee_apres}'>" . $LANG['calendarM'][$i - 1] . "</a></div>\n"; } echo "</div>"; echo "</td></tr></table>"; echo "</td><td class='top' width='100%'>"; // test echo "<table width='100%' class='tab_cadre'><tr>"; echo "<th width='14%'>" . $LANG['calendarD'][1] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][2] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][3] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][4] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][5] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][6] . "</th>"; echo "<th width='14%'>" . $LANG['calendarD'][0] . "</th>"; echo "</tr>\n"; echo "<tr class='tab_bg_3' >"; // Insert blank cell before the first day of the month for ($i = 1; $i < $jour_debut_mois; $i++) { echo "<td class='calendrier_case_white'> </td>"; } // voici le remplissage proprement dit if ($mois_courant < 10 && strlen($mois_courant) == 1) { $mois_courant = "0" . $mois_courant; } for ($i = 1; $i < $nb_jour[$mois_courant - 1] + 1; $i++) { if ($i < 10) { $ii = "0" . $i; } else { $ii = $i; } echo "<td class='top' height='100px'>"; echo "<table class='center' width='100%'><tr><td class='center'>"; echo "<span class='calendrier_jour'>" . $i . "</span></td></tr>\n"; if (!empty($ID)) { echo "<tr><td class='center'>"; echo "<a href='reservation.form.php?id=&item[{$ID}]={$ID}&" . "date=" . $annee_courante . "-" . $mois_courant . "-" . $ii . "'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/addresa.png' alt=\"" . $LANG['reservation'][8] . "\" title=\"" . $LANG['reservation'][8] . "\"></a></td></tr>\n"; } echo "<tr><td>"; self::displayReservationDay($ID, $annee_courante . "-" . $mois_courant . "-" . $ii); echo "</td></tr></table>\n"; echo "</td>"; // il ne faut pas oublie d'aller a la ligne suivante en fin de semaine if (($i + $jour_debut_mois) % 7 == 1) { echo "</tr>\n"; if ($i != $nb_jour[$mois_courant - 1]) { echo "<tr class='tab_bg_3'>"; } } } // on recommence pour finir le tableau proprement pour les m�es raisons if ($jour_fin_mois != 0) { for ($i = 0; $i < 7 - $jour_fin_mois; $i++) { echo "<td class='calendrier_case_white'> </td>"; } } echo "</tr></table>\n"; echo "</td></tr></table></div>\n"; }
} else { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 1, $_POST['entities_id']); } } break; default: // Plugin specific actions $split = explode('_', $_POST["action"]); if ($split[0] == 'plugin' && isset($split[1])) { // Normalized name plugin_name_action // Allow hook from any plugin on any (core or plugin) type doOneHook($split[1], 'MassiveActionsProcess', $_POST); } else { if ($plug = isPluginItemType($_POST["itemtype"])) { // non-normalized name // hook from the plugin defining the type doOneHook($plug['plugin'], 'MassiveActionsProcess', $_POST); } } } addMessageAfterRedirect($LANG['common'][23]); glpi_header($REDIRECT); } else { //action, itemtype or item not defined echo "<div class='center'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='warning'><br><br>"; echo "<b>" . $LANG['common'][24] . "</b></div>"; displayBackLink(); } commonFooter(); } // itemtype defined
/** * Displays a list of computers that can be cleaned. * * @param $ocsservers_id int : id of ocs server in GLPI * @param $check string : parameter for HTML input checkbox * @param $start int : parameter for printPager method * * @return nothing **/ static function showComputersToClean($ocsservers_id, $check, $start) { global $DB, $DBocs, $LANG, $CFG_GLPI; self::checkOCSconnection($ocsservers_id); if (!haveRight("clean_ocsng", "r")) { return false; } $canedit = haveRight("clean_ocsng", "w"); // Select unexisting OCS hardware $query_ocs = "SELECT *\n FROM `hardware`"; $result_ocs = $DBocs->query($query_ocs); $hardware = array(); if ($DBocs->numrows($result_ocs) > 0) { while ($data = $DBocs->fetch_array($result_ocs)) { $data = clean_cross_side_scripting_deep(addslashes_deep($data)); $hardware[$data["ID"]] = $data["DEVICEID"]; } } $query = "SELECT *\n FROM `glpi_ocslinks`\n WHERE `ocsservers_id` = '{$ocsservers_id}'"; $result = $DB->query($query); $ocs_missing = array(); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { $data = clean_cross_side_scripting_deep(addslashes_deep($data)); if (!isset($hardware[$data["ocsid"]])) { $ocs_missing[$data["ocsid"]] = $data["ocsid"]; } } } $sql_ocs_missing = ""; if (count($ocs_missing)) { $sql_ocs_missing = " OR `ocsid` IN ('" . implode("','", $ocs_missing) . "')"; } //Select unexisting computers $query_glpi = "SELECT `glpi_ocslinks`.`entities_id` AS entities_id,\n `glpi_ocslinks`.`ocs_deviceid` AS ocs_deviceid,\n `glpi_ocslinks`.`last_update` AS last_update,\n `glpi_ocslinks`.`ocsid` AS ocsid,\n `glpi_ocslinks`.`id`,\n `glpi_computers`.`name` AS name\n FROM `glpi_ocslinks`\n LEFT JOIN `glpi_computers`\n ON `glpi_computers`.`id` = `glpi_ocslinks`.`computers_id`\n WHERE ((`glpi_computers`.`id` IS NULL\n AND `glpi_ocslinks`.`ocsservers_id` = '{$ocsservers_id}')" . $sql_ocs_missing . ")" . getEntitiesRestrictRequest(" AND", "glpi_ocslinks"); $result_glpi = $DB->query($query_glpi); // fetch all links missing between glpi and OCS $already_linked = array(); if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_assoc($result_glpi)) { $data = clean_cross_side_scripting_deep(addslashes_deep($data)); $already_linked[$data["ocsid"]]["entities_id"] = $data["entities_id"]; if (utf8_strlen($data["ocs_deviceid"]) > 20) { // Strip datetime tag $already_linked[$data["ocsid"]]["ocs_deviceid"] = substr($data["ocs_deviceid"], 0, -20); } else { $already_linked[$data["ocsid"]]["ocs_deviceid"] = $data["ocs_deviceid"]; } $already_linked[$data["ocsid"]]["date"] = $data["last_update"]; $already_linked[$data["ocsid"]]["id"] = $data["id"]; $already_linked[$data["ocsid"]]["in_ocs"] = isset($hardware[$data["ocsid"]]); if ($data["name"] == null) { $already_linked[$data["ocsid"]]["in_glpi"] = 0; } else { $already_linked[$data["ocsid"]]["in_glpi"] = 1; } } } echo "<div class='center'>"; echo "<h2>" . $LANG['ocsng'][3] . "</h2>"; $target = $CFG_GLPI['root_doc'] . '/front/ocsng.clean.php'; if (($numrows = count($already_linked)) > 0) { $parameters = "check={$check}"; printPager($start, $numrows, $target, $parameters); // delete end array_splice($already_linked, $start + $_SESSION['glpilist_limit']); // delete begin if ($start > 0) { array_splice($already_linked, 0, $start); } echo "<form method='post' id='ocsng_form' name='ocsng_form' action='" . $target . "'>"; if ($canedit) { echo "<a href='" . $target . "?check=all' " . "onclick= \"if (markCheckboxes('ocsng_form')) return false;\">" . $LANG['buttons'][18] . "</a> / \n"; echo "<a href='" . $target . "?check=none' " . "onclick= \"if ( unMarkCheckboxes('ocsng_form') ) return false;\">" . $LANG['buttons'][19] . "</a>\n"; } echo "<table class='tab_cadre'>"; echo "<tr><th>" . $LANG['common'][1] . "</th><th>" . $LANG['ocsng'][13] . "</th>"; echo "<th>" . $LANG['ocsng'][59] . "</th><th>" . $LANG['ocsng'][60] . "</th>"; if (isMultiEntitiesMode()) { echo "<th>" . $LANG['entity'][0] . "</th>"; } if ($canedit) { echo "<th> </th>"; } echo "</tr>\n"; echo "<tr class='tab_bg_1'><td colspan='6' class='center'>"; if ($canedit) { echo "<input class='submit' type='submit' name='clean_ok' value=\"" . $LANG['buttons'][53] . "\">"; } echo "</td></tr>\n"; foreach ($already_linked as $ID => $tab) { echo "<tr class='tab_bg_2 center'>"; echo "<td>" . $tab["ocs_deviceid"] . "</td>\n"; echo "<td>" . convDateTime($tab["date"]) . "</td>\n"; echo "<td>" . $LANG['choice'][$tab["in_glpi"]] . "</td>\n"; echo "<td>" . $LANG['choice'][$tab["in_ocs"]] . "</td>\n"; if (isMultiEntitiesMode()) { echo "<td>" . Dropdown::getDropdownName('glpi_entities', $tab['entities_id']) . "</td>\n"; } if ($canedit) { echo "<td><input type='checkbox' name='toclean[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . "></td>"; } echo "</tr>\n"; } echo "<tr class='tab_bg_1'><td colspan='6' class='center'>"; if ($canedit) { echo "<input class='submit' type='submit' name='clean_ok' value=\"" . $LANG['buttons'][53] . "\">"; } echo "</td></tr>"; echo "</table></form>\n"; printPager($start, $numrows, $target, $parameters); } else { echo "<div class='center'><strong>" . $LANG['ocsng'][61] . "</strong></div>"; displayBackLink(); } echo "</div>"; }