コード例 #1
0
ファイル: setup.php プロジェクト: geldarr/hack-space
function plugin_init_typology()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['add_css']['typology'] = 'typology.css';
    $PLUGIN_HOOKS['csrf_compliant']['typology'] = true;
    $PLUGIN_HOOKS['change_profile']['typology'] = array('PluginTypologyProfile', 'changeProfile');
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginTypologyProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginTypologyTypology', array('notificationtemplates_types' => true));
        // Display a menu entry ?
        if (plugin_typology_haveRight("typology", "r")) {
            // menu entry
            $PLUGIN_HOOKS['menu_entry']['typology'] = 'front/typology.php';
            // search link
            $PLUGIN_HOOKS['submenu_entry']['typology']['search'] = 'front/typology.php';
            $PLUGIN_HOOKS['redirect_page']['typology'] = 'front/typology.form.php';
        }
        if (plugin_typology_haveRight("typology", "w")) {
            //add link
            $PLUGIN_HOOKS['submenu_entry']['typology']['add'] = 'front/typology.form.php';
            //use massiveaction in the plugin
            $PLUGIN_HOOKS['use_massive_action']['typology'] = 1;
            $PLUGIN_HOOKS['redirect_page']['typology'] = 'front/typology.form.php';
        }
        Plugin::registerClass('PluginTypologyRuleTypologyCollection', array('rulecollections_types' => true));
        if (class_exists('PluginBehaviorsCommon')) {
            PluginBehaviorsCommon::addCloneType('PluginTypologyRuleTypology', 'PluginBehaviorsRule');
        }
        $PLUGIN_HOOKS['post_init']['typology'] = 'plugin_typology_postinit';
    }
}
コード例 #2
0
ファイル: profile.class.php プロジェクト: geldarr/hack-space
 /**
  * Check if I have the right $right to module $module 
  *
  * @param $module Module to check (typology)
  * @param $right Right to check
  *
  * @return Nothing : display error if not permit
  **/
 static function checkRight($module, $right)
 {
     global $CFG_GLPI;
     if (!plugin_typology_haveRight($module, $right)) {
         // Gestion timeout session
         if (!Session::getLoginUserID()) {
             Html::redirect($CFG_GLPI["root_doc"] . "/index.php");
             exit;
         }
         Html::displayRightError();
     }
 }
コード例 #3
0
 static function canView()
 {
     return plugin_typology_haveRight('typology', 'w');
 }
コード例 #4
0
 /**
  * Display a link to add directly an item to a typo.
  *
  * @param $itemtype of item class
  * @param $ID : id item
  *
  * @return Nothing (displays)
  **/
 public static function showPluginFromItems($itemtype, $ID, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $typo = new PluginTypologyTypology();
     $typo_item = new PluginTypologyTypology_Item();
     $table_typo_item = $typo_item->getTable();
     $item = new $itemtype();
     if (!plugin_typology_haveRight('typology', 'r')) {
         return false;
     }
     if (!$item->can($ID, 'r')) {
         return false;
     }
     $canread = $item->can($ID, 'r');
     $canedit = $item->can($ID, 'w');
     $restrict = "`items_id` = '" . $ID . "'\n              AND `itemtype` = '" . $itemtype . "'";
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     $used = array();
     if ($withtemplate != 2) {
         echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/typology/front/typology.form.php\">";
     }
     echo "<div align='center'><table class='tab_cadre_fixe'>";
     //typologie attribuée
     if (countElementsInTable($table_typo_item, $restrict) > 0) {
         $typos = getAllDatasFromTable($table_typo_item, $restrict);
         if (!empty($typos)) {
             foreach ($typos as $typo) {
                 $typo_ID = $typo["plugin_typology_typologies_id"];
             }
         }
         $query = "SELECT `" . $table_typo_item . "`.`id` AS typo_items_id,\n                           `" . $table_typo_item . "`.`is_validated`,\n                           `" . $table_typo_item . "`.`error`,\n                             `glpi_plugin_typology_typologies`.*" . " FROM `" . $table_typo_item . "`,`glpi_plugin_typology_typologies` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_typology_typologies`.`entities_id`) " . " WHERE `" . $table_typo_item . "`.`plugin_typology_typologies_id` = '" . $typo_ID . "' " . " AND `" . $table_typo_item . "`.`items_id` = '" . $ID . "' " . " AND `" . $table_typo_item . "`.`itemtype` = '" . $itemtype . "'\n                    AND `" . $table_typo_item . "`.`plugin_typology_typologies_id`=`glpi_plugin_typology_typologies`.`id`" . getEntitiesRestrictRequest(" AND ", "glpi_plugin_typology_typologies", '', '', true);
         $result = $DB->query($query);
         echo "<tr><th>" . __('Typology assigned to this material', 'typology') . "</th>";
         if (Session::isMultiEntitiesMode()) {
             echo "<th>" . __('Entity') . "</th>";
         }
         echo "<th>" . __('Responding to typology\'s criteria', 'typology') . "</th>";
         echo "<th>" . __('Actions', 'typology') . "</th>";
         echo "</tr>";
         while ($data = $DB->fetch_array($result)) {
             $typo_ID = $data["id"];
             $used[] = $typo_ID;
             echo "<tr class='tab_bg_1'>";
             if ($withtemplate != 3 && $canread && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["is_recursive"])) {
                 echo "<td class='center'><a href='" . $CFG_GLPI["root_doc"] . "/plugins/typology/front/typology.form.php?id=" . $data["id"] . "'>" . $data["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     echo " (" . $data["id"] . ")";
                 }
                 echo "</a></td>";
             } else {
                 echo "<td class='center'>" . $data["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     echo " (" . $data["id"] . ")";
                 }
                 echo "</td>";
             }
             if (Session::isMultiEntitiesMode()) {
                 echo "<td  class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             if ($data["is_validated"] > 0) {
                 $critTypOK = __('Yes');
             } else {
                 $critTypOK = "<font color='red'>" . __('No') . " " . __('for the criteria', 'typology') . " ";
                 $i = 0;
                 $critTypOK .= self::displayErrors($data["error"]);
                 $critTypOK .= "</font>";
             }
             echo "<td class ='center'><b>" . $critTypOK . "</b></td>";
             echo "<td class='center'  width = '25%'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
             echo "<input type='hidden' name='id' value='" . $data["typo_items_id"] . "'>";
             echo "<input type='hidden' name='plugin_typology_typologies_id' value='" . $data["id"] . "'>";
             //actualiser la typologie
             echo "<input type='submit' name='update_item' value=\"" . _sx('button', 'Upgrade') . "\" class='submit'>";
             //retirer la typologie
             if ($canedit) {
                 echo "&nbsp;&nbsp;<input type='submit' name='delete_item' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>";
             }
             echo "</td>";
             echo "</tr>";
         }
         self::showManagementConsole($ID, $typo_ID);
         //typologie non attribuée
     } else {
         echo "<tr><th colspan='" . (5 + $colsup) . "'>" . __('Assign a typology to this material', 'typology') . "</th></tr>";
         //Affecter une typologie
         if ($canedit) {
             if ($withtemplate < 2) {
                 if ($typo_item->canCreate()) {
                     $typo_item->showAdd($itemtype, $ID);
                 }
             }
         }
     }
     echo "</table></div>";
     if ($withtemplate != 2) {
         Html::closeForm();
     }
 }
コード例 #5
0
ファイル: hook.php プロジェクト: geldarr/hack-space
function plugin_typology_getAddSearchOptions($itemtype)
{
    $plugin = new Plugin();
    $sopt = array();
    if ($plugin->isActivated('typology') && plugin_typology_haveRight("typology", "r")) {
        if (in_array($itemtype, PluginTypologyTypology::getTypes(true))) {
            $sopt[4650]['table'] = 'glpi_plugin_typology_typologies';
            $sopt[4650]['field'] = 'name';
            $sopt[4650]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Typology\'s name', 'typology');
            $sopt[4650]['forcegroupby'] = true;
            $sopt[4650]['datatype'] = 'itemlink';
            $sopt[4650]['massiveaction'] = false;
            $sopt[4650]['itemlink_type'] = 'PluginTypologyTypology';
            $sopt[4650]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_typology_typologies_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $sopt[4651]['table'] = 'glpi_plugin_typology_typologies_items';
            $sopt[4651]['field'] = 'is_validated';
            $sopt[4651]['datatype'] = 'bool';
            $sopt[4651]['massiveaction'] = false;
            $sopt[4651]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Responding to typology\'s criteria', 'typology');
            $sopt[4651]['forcegroupby'] = true;
            $sopt[4651]['joinparams'] = array('jointype' => 'itemtype_item');
            $sopt[4652]['table'] = 'glpi_plugin_typology_typologies_items';
            $sopt[4652]['field'] = 'error';
            $sopt[4652]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Result details');
            $sopt[4652]['forcegroupby'] = true;
            $sopt[4652]['massiveaction'] = false;
            $sopt[4652]['joinparams'] = array('jointype' => 'itemtype_item');
        }
    }
    return $sopt;
}
コード例 #6
0
 function showChildrensTab()
 {
     return plugin_typology_haveRight('typology', 'w') && count($_SESSION['glpiactiveentities']) > 1;
 }
コード例 #7
0
 /**
  * Display the add Definition form
  *
  * @param $typocrit_id typocrit ID
  **/
 static function showForCriteria(PluginTypologyTypologyCriteria $typocrit)
 {
     global $DB;
     $typocrit_id = $typocrit->getField('id');
     $query = "SELECT `glpi_plugin_typology_typologycriteriadefinitions`.`id`,\n                        `glpi_plugin_typology_typologycriterias`.`itemtype`,\n                        `glpi_plugin_typology_typologycriterias`.`link`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`field`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`action_type`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`value`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`\n                FROM `glpi_plugin_typology_typologycriteriadefinitions`\n                  LEFT JOIN `glpi_plugin_typology_typologycriterias`\n                     ON (`glpi_plugin_typology_typologycriterias`.`id`\n                           = `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`)\n                WHERE `plugin_typology_typologycriterias_id` = '" . $typocrit_id . "'\n                ORDER BY `glpi_plugin_typology_typologycriteriadefinitions`.`id`";
     echo "<div class='firstbloc'>";
     if ($result = $DB->query($query)) {
         echo "<form method='post' action='./typologycriteria.form.php'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='6'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(1) . "</tr>";
         echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>";
         echo "<input type='hidden' name='entities_id' value='" . $typocrit->getField('entities_id') . "'>";
         echo "<input type='hidden' name='is_recursive' value='" . $typocrit->getField('is_recursive') . "'>";
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . _n('Field', 'Fields', 2) . "</td><td>";
         PluginTypologyTypologyCriteriaDefinition::dropdownFields($typocrit_id);
         echo "</td>";
         echo "<td>";
         echo "<span id='span_actions' name='span_actions'></span></td>";
         echo "<td>";
         echo "<span id='span_values' name='span_values'></span></td>";
         echo "<td class='tab_bg_2 left' width='80px'>";
         echo "<input type='submit' name='add_action' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         if ($DB->num_fields($result) > 0) {
             if (plugin_typology_haveRight('typology', 'w')) {
                 echo "<form name='critDef_form' id='critDef_form' method='post' action='./typologycriteria.form.php'>";
             }
             echo "<div class='center'><table class='tab_cadre_fixe'>";
             echo "<tr><th colspan='4'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(2) . "</th></tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<th colspan='2'>" . _n('Field', 'Fields', 2) . "</th>";
             echo "<th class='center b'>" . __('Logical operator') . "</th>";
             echo "<th class='center b'>" . __('Value') . "</th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 echo "<tr class='tab_bg_2'>";
                 if (plugin_typology_haveRight('typology', 'w')) {
                     echo "<td width='10'>";
                     echo "<input type='checkbox' name='item[" . $ligne["id"] . "]' value='1'>";
                     echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>";
                     echo "</td>";
                 }
                 self::showMinimalDefinitionForm($ligne);
                 echo "</tr>";
             }
             if (plugin_typology_haveRight('typology', 'w')) {
                 Html::openArrowMassives("critDef_form", true);
                 Html::closeArrowMassives(array('delete_action' => __('Delete permanently')));
             }
             echo "</table></div>";
             if (plugin_typology_haveRight('typology', 'w')) {
                 Html::closeForm();
             }
         }
     }
 }