示例#1
0
 /**
  * Function that try to load from the SSO server the user information...
  *
  * @since version 0.84
  **/
 function getFromSSO()
 {
     global $DB, $CFG_GLPI;
     $a_field = array();
     foreach ($CFG_GLPI as $key => $value) {
         if (!is_array($value) && !empty($value) && strstr($key, "_ssofield")) {
             $key = str_replace('_ssofield', '', $key);
             $a_field[$key] = $value;
         }
     }
     if (count($a_field) == 0) {
         return true;
     }
     $this->fields['_ruleright_process'] = true;
     foreach ($a_field as $field => $value) {
         if (!isset($_SERVER[$value]) || empty($_SERVER[$value])) {
             switch ($field) {
                 case "title":
                     $this->fields['usertitles_id'] = 0;
                     break;
                 case "category":
                     $this->fields['usercategories_id'] = 0;
                     break;
                 default:
                     $this->fields[$field] = "";
             }
         } else {
             switch ($field) {
                 case "email1":
                 case "email2":
                 case "email3":
                 case "email4":
                     // Manage multivaluable fields
                     if (!preg_match('/count/', $_SERVER[$value])) {
                         $this->fields["_emails"][] = addslashes($_SERVER[$value]);
                     }
                     // Only get them once if duplicated
                     $this->fields["_emails"] = array_unique($this->fields["_emails"]);
                     break;
                 case "language":
                     $language = Config::getLanguage($_SERVER[$value]);
                     if ($language != '') {
                         $this->fields[$field] = $language;
                     }
                     break;
                 case "title":
                     $this->fields['usertitles_id'] = Dropdown::importExternal('UserTitle', addslashes($_SERVER[$value]));
                     break;
                 case "category":
                     $this->fields['usercategories_id'] = Dropdown::importExternal('UserCategory', addslashes($_SERVER[$value]));
                     break;
                 default:
                     $this->fields[$field] = $_SERVER[$value];
                     break;
             }
         }
     }
     ///Only process rules if working on the master database
     if (!$DB->isSlave()) {
         //Instanciate the affectation's rule
         $rule = new RuleRightCollection();
         $this->fields = $rule->processAllRules(array(), Toolbox::stripslashes_deep($this->fields), array('type' => 'SSO', 'email' => $this->fields["_emails"], 'login' => $this->fields["name"]));
         //If rule  action is ignore import
         if (isset($this->fields["_stop_import"])) {
             return false;
         }
     }
     return true;
 }
示例#2
0
 /**
  * Display content of Tab
  *
  * @param $ID of the item
  * @param $tab number of the tab
  *
  * @return true if handled (for class stack)
  */
 function showTabContent($ID, $tab)
 {
     global $CFG_GLPI;
     if (!$this->isNewID($ID)) {
         switch ($tab) {
             case -1:
                 // All
                 $this->showChildren($ID);
                 EntityData::showStandardOptions($this);
                 Profile_User::showForEntity($this);
                 $collection = new RuleRightCollection();
                 if ($collection->canList()) {
                     $ldaprule = new RuleRight();
                     $ldaprule->showAndAddRuleForm($this);
                 }
                 $collection = new RuleOcsCollection();
                 if ($collection->canList()) {
                     $ocsrule = new RuleOcs();
                     $ocsrule->showAndAddRuleForm($this);
                 }
                 $collection = new RuleMailCollectorCollection();
                 if ($collection->canList()) {
                     $mailcollector = new RuleMailCollector();
                     $mailcollector->showAndAddRuleForm($this);
                 }
                 Document::showAssociated($this);
                 EntityData::showNotificationOptions($this);
                 EntityData::showHelpdeskOptions($this);
                 EntityData::showInventoryOptions($this);
                 Plugin::displayAction($this, $tab);
                 break;
             case 2:
                 EntityData::showStandardOptions($this);
                 break;
             case 3:
                 Profile_User::showForEntity($this);
                 break;
             case 4:
                 $collection = new RuleRightCollection();
                 if ($collection->canList()) {
                     $ldaprule = new RuleRight();
                     $ldaprule->showAndAddRuleForm($this);
                 }
                 $collection = new RuleOcsCollection();
                 if ($collection->canList()) {
                     $ocsrule = new RuleOcs();
                     $ocsrule->showAndAddRuleForm($this);
                 }
                 $collection = new RuleMailCollectorCollection();
                 if ($collection->canList()) {
                     $mailcollector = new RuleMailCollector();
                     $mailcollector->showAndAddRuleForm($this);
                 }
                 break;
             case 5:
                 EntityData::showAdvancedOptions($this);
                 break;
             case 6:
                 Document::showAssociated($this);
                 break;
             case 7:
                 EntityData::showNotificationOptions($this);
                 break;
             case 8:
                 EntityData::showHelpdeskOptions($this);
                 break;
             case 9:
                 EntityData::showInventoryOptions($this);
                 break;
             case 10:
                 showNotesForm(getItemTypeFormURL('EntityData'), 'EntityData', $_POST["id"]);
                 break;
             default:
                 if (!Plugin::displayAction($this, $tab)) {
                     $this->showChildren($ID);
                 }
                 return false;
         }
     }
     return false;
 }
示例#3
0
 /**
  * @param $item         CommonGLPI object
  * @param $tabnum       (default 1)
  * @param $withtemplate (default 0)
  **/
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($item->getType() == 'Entity') {
         $collection = new RuleRightCollection();
         if ($collection->canList()) {
             $ldaprule = new RuleRight();
             $ldaprule->showAndAddRuleForm($item);
         }
         $collection = new RuleImportEntityCollection();
         if ($collection->canList()) {
             $importrule = new RuleImportEntity();
             $importrule->showAndAddRuleForm($item);
         }
         $collection = new RuleMailCollectorCollection();
         if ($collection->canList()) {
             $mailcollector = new RuleMailCollector();
             $mailcollector->showAndAddRuleForm($item);
         }
     } else {
         if ($item->getType() == 'SLA') {
             $rule = new RuleTicket();
             $rule->showAndAddRuleForm($item);
         } else {
             if ($item instanceof Rule) {
                 $item->getRuleWithCriteriasAndActions($item->getID(), 1, 1);
                 switch ($tabnum) {
                     case 1:
                         $item->showCriteriasList($item->getID());
                         break;
                     case 2:
                         $item->showActionsList($item->getID());
                         break;
                 }
             }
         }
     }
     return true;
 }
示例#4
0
 /**
  * Function that try to load from IMAP the user information...
  *
  * @param $mail_method mail method description array
  * @param $name login of the user
  **/
 function getFromIMAP($mail_method, $name)
 {
     global $DB;
     // we prevent some delay..
     if (empty($mail_method["host"])) {
         return false;
     }
     // some defaults...
     $this->fields['password'] = "";
     if (strpos($name, "@")) {
         $this->fields['email'] = $name;
     } else {
         $this->fields['email'] = $name . "@" . $mail_method["host"];
     }
     $this->fields['name'] = $name;
     //Store date_sync
     $this->fields['date_sync'] = $_SESSION['glpi_currenttime'];
     if (!$DB->isSlave()) {
         //Instanciate the affectation's rule
         $rule = new RuleRightCollection();
         //Process affectation rules :
         //we don't care about the function's return because all the datas are stored in session temporary
         if (isset($this->fields["_groups"])) {
             $groups = $this->fields["_groups"];
         } else {
             $groups = array();
         }
         $this->fields = $rule->processAllRules($groups, $this->fields, array('type' => 'MAIL', 'mail_server' => $mail_method["id"], 'email' => $this->fields["email"]));
         $this->fields['_ruleright_process'] = true;
     }
     return true;
 }