Exemplo n.º 1
0
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile') {
         return PluginBadgesBadge::getTypeName(2);
     }
     return '';
 }
 public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     global $CFG_GLPI;
     if ($item->getType() == 'CronTask') {
         $target = $CFG_GLPI["root_doc"] . "/plugins/badges/front/notification.state.php";
         PluginBadgesBadge::configCron($target);
     }
     return true;
 }
Exemplo n.º 3
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = "/plugins/badges/front/badge.php";
     $menu['links']['search'] = PluginBadgesBadge::getSearchURL(false);
     if (PluginBadgesBadge::canCreate()) {
         $menu['links']['add'] = PluginBadgesBadge::getFormURL(false);
     }
     return $menu;
 }
Exemplo n.º 4
0
function plugin_init_badges()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['badges'] = true;
    $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'changeProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true;
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true));
        Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask'));
        if (class_exists('PluginResourcesResource')) {
            PluginResourcesResource::registerType('PluginBadgesBadge');
        }
        if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) {
            $_SESSION["glpi_plugin_environment_badges"] = 1;
            if (plugin_badges_haveRight("badges", "r")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['title'] = PluginBadgesBadge::getTypeName(2);
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['page'] = '/plugins/badges/front/badge.php';
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['search'] = '/plugins/badges/front/badge.php';
            }
            if (plugin_badges_haveRight("badges", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['add'] = '/plugins/badges/front/badge.form.php';
            }
        } else {
            if (plugin_badges_haveRight("badges", "r")) {
                $PLUGIN_HOOKS['menu_entry']['badges'] = 'front/badge.php';
                $PLUGIN_HOOKS['submenu_entry']['badges']['search'] = 'front/badge.php';
            }
            if (plugin_badges_haveRight("badges", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['badges']['add'] = 'front/badge.form.php?new=1';
            }
        }
        if (class_exists('PluginBadgesBadge')) {
            // only if plugin activated
            //Clean Plugin on Profile delete
            $PLUGIN_HOOKS['pre_item_purge']['badges'] = array('Profile
                                             ' => array('PluginBadgesProfile', 'purgeProfiles'));
            $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges';
        }
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges';
    }
}
This file is part of badges.

Badges 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.

Badges 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 Badges. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$plugin = new Plugin();
if ($plugin->isActivated("environment")) {
    Html::header(PluginBadgesBadge::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "badges");
} else {
    Html::header(PluginBadgesBadge::getTypeName(2), '', "assets", "pluginbadgesmenu");
}
$badge = new PluginBadgesBadge();
$badge->checkGlobal(READ);
if ($badge->canView()) {
    Search::show("PluginBadgesBadge");
} else {
    Html::displayRightError();
}
Html::footer();
Exemplo n.º 6
0
function plugin_badges_AssignToTicket($types)
{
    if (Session::haveRight("plugin_badges_open_ticket", "1")) {
        $types['PluginBadgesBadge'] = PluginBadgesBadge::getTypeName(2);
    }
    return $types;
}
Exemplo n.º 7
0
		
This file is part of badges.

Badges 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.

Badges 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 Badges. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$plugin = new Plugin();
$badge = new PluginBadgesBadge();
if ($plugin->isActivated("environment")) {
    Html::header(PluginBadgesBadge::getTypeName(), '', "plugins", "environment", "badges");
} else {
    Html::header(PluginBadgesBadge::getTypeName(), '', "plugins", "badges");
}
if ($badge->canView() || Session::haveRight("config", "w")) {
    Search::show("PluginBadgesBadge");
} else {
    Html::displayRightError();
}
Html::footer();
Exemplo n.º 8
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'badges'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginBadgesBadge::getTypeName(2) . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("badges", $this->fields["badges"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginBadgesBadge::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 9
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginBadgesBadge') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $badge = new PluginBadgesBadge();
                         $badge->getFromDB($key);
                         $type = PluginBadgesBadgeType::transfer($badge->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                         if ($type > 0) {
                             $values["id"] = $key;
                             $values["plugin_badges_badgetypes_id"] = $type;
                             if ($badge->update($values)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($badge->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Exemplo n.º 10
0
 /**
  * Show list of items
  * 
  * @param type $fields
  */
 function listItems($requesters_id, $options = array())
 {
     $params['begin_date'] = "NULL";
     $params['end_date'] = "NULL";
     foreach ($options as $key => $val) {
         $params[$key] = $val;
     }
     $data = $this->find('`requesters_id` = ' . $requesters_id . " " . "AND `affectation_date` >= '" . $params['begin_date'] . "' " . "AND (`return_date` <= '" . $params['end_date'] . "' OR `return_date` IS NULL)", "`affectation_date` DESC");
     $message = null;
     if (!empty($data)) {
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Badge usage report', 'badges') . "</th>";
         $message .= "</tr>";
         $message .= "<tr>";
         $message .= "<th>" . _n('Badge', 'Badges', 1, 'badge') . "</th>";
         $message .= "<th>" . __('Visitor realname', 'badges') . "</th>";
         $message .= "<th>" . __('Visitor firstname', 'badges') . "</th>";
         $message .= "<th>" . __('Visitor society', 'badges') . "</th>";
         $message .= "<th>" . __('Arrival date', 'badges') . "</th>";
         $message .= "<th>" . __('Return date', 'badges') . "</th>";
         $message .= "</tr>";
         $badge = new PluginBadgesBadge();
         foreach ($data as $field) {
             $message .= "<tr class='tab_bg_1'>";
             $badge->getFromDB($field['badges_id']);
             $message .= "<td>" . $badge->getLink() . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_realname']) . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_firstname']) . "</td>";
             $message .= "<td>" . stripslashes($field['visitor_society']) . "</td>";
             $message .= "<td>" . Html::convDateTime($field['affectation_date']) . "</td>";
             $message .= "<td>" . Html::convDateTime($field['return_date']) . "</td>";
             $message .= "</tr>";
         }
         $message .= "</table>";
         $message .= "</div>";
     } else {
         $message .= "<div class='center'>";
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Badge usage report', 'badges') . "</th>";
         $message .= "</tr>";
         $message .= "<tr><td class='center'>" . __('No item found') . "</td></tr>";
         $message .= "</table>";
     }
     return array('success' => true, 'message' => $message);
 }
Exemplo n.º 11
0
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 Badges. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$badge = new PluginBadgesBadge();
if (isset($_POST["add"])) {
    $badge->check(-1, 'w', $_POST);
    $newID = $badge->add($_POST);
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $badge->check($_POST['id'], 'w');
        $badge->delete($_POST);
        $badge->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $badge->check($_POST['id'], 'w');
            $badge->restore($_POST);
            $badge->redirectToList();
        } else {
Exemplo n.º 12
0
 /**
  * Show 
  * 
  * @param type $item
  */
 function showForBadge($item)
 {
     if (!$this->canCreate() || !$this->canView()) {
         return false;
     }
     $data = $this->find('`badges_id` = ' . $item->fields['id'], "`affectation_date` DESC");
     $badge = new PluginBadgesBadge();
     $canedit = $badge->can($item->fields['id'], 'w');
     if ($canedit) {
         echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL($this->getType()) . "'>";
         echo "<div align='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th colspan='6'>" . __('Badge return', 'badges') . "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>";
         $return = new PluginBadgesReturn();
         $return->loadBadgeInformation(0, $item->fields['id']);
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='tab_bg_2 center' colspan='6'>";
         echo "<input type='submit' name='force_return' class='submit' value='" . __('Force badge restitution', 'badges') . "' >";
         echo "<input type='hidden' name='return_badges_id' value='" . $item->fields['id'] . "' >";
         echo "<input type='hidden' name='requesters_id' value='0'>";
         echo "</td>";
         echo "</tr>";
         echo "</table></div>";
         Html::closeForm();
     }
     $this->listItems($data);
 }
Exemplo n.º 13
0
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 Badges. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$badge = new PluginBadgesBadge();
if (isset($_POST["add"])) {
    $badge->check(-1, CREATE, $_POST);
    $newID = $badge->add($_POST);
    if ($_SESSION['glpibackcreated']) {
        Html::redirect($badge->getFormURL() . "?id=" . $newID);
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $badge->check($_POST['id'], DELETE);
        $badge->delete($_POST);
        $badge->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $badge->check($_POST['id'], PURGE);