当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::getField方法代码示例

本文整理汇总了PHP中Entity::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getField方法的具体用法?PHP Entity::getField怎么用?PHP Entity::getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::getField方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: syncEntity

/**
 * @param $pid
 * @param $data
 * @param $server
 * @param $prof
 * @param $verb
 * @param $mail
**/
function syncEntity($pid, $data, $server, $prof, $verb, $mail)
{
    global $DB, $LANG, $CFG_GLPI;
    // Re-establish DB connexion - mandatory in each forked process
    if (!DBConnection::switchToMaster()) {
        echo " {$pid}: lost DB connection\n";
        return 0;
    }
    // Server from entity (if not given from option)
    if ($data['authldaps_id'] > 0) {
        $server = $data['authldaps_id'];
    }
    $entity = new Entity();
    if ($entity->getFromDB($id = $data['id'])) {
        $tps = microtime(true);
        if ($verb) {
            echo "  {$pid}: Synchonizing entity '" . $entity->getField('completename') . "' ({$id}, mail={$mail})\n";
        }
        $sql = "SELECT DISTINCT glpi_users.*\n              FROM glpi_users\n              INNER JOIN glpi_profiles_users\n                  ON (glpi_profiles_users.users_id = glpi_users.id\n                      AND glpi_profiles_users.entities_id = {$id}";
        if ($prof > 0) {
            $sql .= "    AND glpi_profiles_users.profiles_id = {$prof}";
        }
        $sql .= ")\n               WHERE glpi_users.authtype = " . Auth::LDAP;
        if ($server > 0) {
            $sql .= " AND glpi_users.auths_id = {$server}";
        }
        $users = array();
        $results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0);
        $req = $DB->request($sql);
        $i = 0;
        $nb = $req->numrows();
        foreach ($req as $row) {
            $i++;
            $result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $row['name']), AuthLDAP::ACTION_SYNCHRONIZE, $row['auths_id']);
            if ($result) {
                $results[$result['action']] += 1;
                $users[$row['id']] = $row['name'];
                if ($result['action'] == AuthLDAP::USER_SYNCHRONIZED) {
                    if ($verb) {
                        echo "  {$pid}: User '" . $row['name'] . "' synchronized ({$i}/{$nb})\n";
                    }
                } else {
                    if ($verb) {
                        echo "  {$pid}: User '" . $row['name'] . "' deleted\n";
                    }
                }
            } else {
                if ($verb) {
                    echo "  {$pid}: Problem with LDAP for user '" . $row['name'] . "'\n";
                }
            }
        }
        $tps = microtime(true) - $tps;
        printf("  %d: Entity '%s' - Synchronized: %d, Deleted from LDAP: %d, Time: %.2f\"\n", $pid, $entity->getField('completename'), $results[AuthLDAP::USER_SYNCHRONIZED], $results[AuthLDAP::USER_DELETED_LDAP], $tps);
        if ($mail) {
            $report = '';
            $user = new User();
            foreach ($users as $id => $name) {
                if ($user->getFromDB($id)) {
                    $logs = Log::getHistoryData($user, 0, $_SESSION['glpilist_limit'], "`date_mod`='" . $_SESSION['glpi_currenttime'] . "'");
                    if (count($logs)) {
                        $report .= "\n{$name} (" . $user->getName() . ")\n";
                        foreach ($logs as $log) {
                            $report .= "\t";
                            if ($log['field']) {
                                $report .= $log['field'] . ": ";
                            }
                            $report .= Html::clean($log['change']) . "\n";
                        }
                    }
                } else {
                    $report .= "\n" . $name . "\n\t deleted\n";
                }
            }
            if ($report) {
                $report = "Synchronization of already imported users\n " . "Entité: " . $entity->getField('completename') . "\n " . "Date: " . Html::convDateTime($_SESSION['glpi_currenttime']) . "\n " . $report;
                $entdata = new Entity();
                $mmail = new NotificationMail();
                $mmail->AddCustomHeader("Auto-Submitted: auto-generated");
                $mmail->From = $CFG_GLPI["admin_email"];
                $mmail->FromName = "GLPI";
                $mmail->Subject = "[GLPI] LDAP directory link";
                $mmail->Body = $report . "\n--\n" . $CFG_GLPI["mailing_signature"];
                if ($mail & 1 && $entdata->getFromDB($entity->getField('id')) && $entdata->fields['admin_email']) {
                    $mmail->AddAddress($entdata->fields['admin_email']);
                } else {
                    if ($mail & 1 && $verb) {
                        echo "  {$pid}: No address found for email entity\n";
                    }
                    $mail = $mail & 2;
                }
                if ($mail & 2 && $CFG_GLPI['admin_email']) {
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:ldapsync.php

示例2: generateHostgroupsCfg

   function generateHostgroupsCfg($file=0, $tag='') {
      global $DB;

      PluginMonitoringToolbox::logIfExtradebug(
         'pm-shinken',
         "Starting generateHostgroupsCfg ($tag) ...\n"
      );
      $pmEntity      = new PluginMonitoringEntity();

      $a_hostgroups = array();
      $i=0;

      $a_entities_allowed = $pmEntity->getEntitiesByTag($tag);
      $a_entities_list = array();
      foreach ($a_entities_allowed as $entity) {
         $a_entities_list = getSonsOf("glpi_entities", $entity);
      }
      $where = '';
      if (! isset($a_entities_allowed['-1'])) {
         $where = getEntitiesRestrictRequest("WHERE", "glpi_entities", '', $a_entities_list);
      }

      $query = "SELECT
         `glpi_entities`.`id` AS entityId, `glpi_entities`.`name` AS entityName, `glpi_entities`.`level` AS entityLevel
         FROM `glpi_entities` $where";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
/*
Nagios configuration file :
   define hostgroup{
      hostgroup_name	hostgroup_name
      alias	alias
      members	hosts
      hostgroup_members	hostgroups
      notes	note_string
      notes_url	url
      action_url	url
   }
*/
         // Hostgroup name
         $hostgroup_name = strtolower(preg_replace("/[^A-Za-z0-9\-_ ]/","",$data['entityName']));
         $hostgroup_name = preg_replace("/[ ]/","_",$hostgroup_name);

         PluginMonitoringToolbox::logIfExtradebug(
            'pm-shinken',
            " - add group $hostgroup_name ...\n"
         );

         $a_hostgroups[$i]['hostgroup_name'] = $hostgroup_name;
         $a_hostgroups[$i]['alias'] = $data['entityName'];

         // Custom variable are ignored for hostgroups ... simple information for debug purpose !
         $a_hostgroups[$i]['_GROUP_LEVEL'] = $data['entityLevel'];

         $a_sons_list = getSonsOf("glpi_entities", $data['entityId']);
         if (count($a_sons_list) > 1) {
            $a_hostgroups[$i]['hostgroup_members'] = '';
            $first_member = true;
            foreach ($a_sons_list as $son_entity) {
               if ($son_entity == $data['entityId']) continue;
               if (! in_array ($son_entity, $a_entities_list)) continue;

               $pmEntity = new Entity();
               $pmEntity->getFromDB($son_entity);
			   // Only immediate sub level are considered as hostgroup members
               if ($data['entityLevel']+1 != $pmEntity->fields['level']) continue;

               $hostgroup_name = strtolower(preg_replace("/[^A-Za-z0-9\-_ ]/","",$pmEntity->getField('name')));
               $hostgroup_name = preg_replace("/[ ]/","_",$hostgroup_name);

               $a_hostgroups[$i]['hostgroup_members'] .= (! $first_member) ? ", $hostgroup_name" : "$hostgroup_name";
               if ($first_member) $first_member = false;
            }
         }

         $i++;
      }

      // Add an hostgroup for fake hosts
      if (self::$shinkenParameters['shinken']['fake_hosts']['build']) {
         $a_hostgroups[$i]['hostgroup_name'] = self::$shinkenParameters['shinken']['fake_hosts']['hostgroup_name'];
         $a_hostgroups[$i]['alias'] = self::$shinkenParameters['shinken']['fake_hosts']['hostgroup_alias'];
      }

      PluginMonitoringToolbox::logIfExtradebug(
         'pm-shinken',
         "End generateHostgroupsCfg\n"
      );

      if ($file == "1") {
         $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n";

         foreach ($a_hostgroups as $data) {
            $config .= $this->writeFile("hostgroup", $data);
         }
         return array('hostgroups.cfg', $config);

      } else {
         return $a_hostgroups;
      }
//.........这里部分代码省略.........
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:101,代码来源:shinken.class.php

示例3: showForEntity

 /**
  * Show users of an entity
  *
  * @param $entity Entity object
  **/
 static function showForEntity(Entity $entity)
 {
     global $DB;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ)) {
         return false;
     }
     $canedit = $entity->canEdit($ID);
     $canshowuser = User::canView();
     $nb_per_line = 3;
     $rand = mt_rand();
     if ($canedit) {
         $headerspan = $nb_per_line * 2;
     } else {
         $headerspan = $nb_per_line;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
         echo "<tr class='tab_bg_1'><td class='tab_bg_2 center'>" . __('User') . "&nbsp;";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         User::dropdown(array('right' => 'all'));
         echo "</td><td class='tab_bg_2 center'>" . self::getTypeName(1) . "</td><td>";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td class='tab_bg_2 center'>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     $query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                     AND `glpi_users`.`is_deleted` = '0'";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<thead><tr>";
     echo "<th class='noHover' colspan='{$headerspan}'>";
     printf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive'));
     echo "</th></tr></thead>";
     if ($nb) {
         Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Entity::getTypeName(1), $entity->getName()));
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tbody><tr class='noHover'>";
             $reduce_header = 0;
             if ($canedit && $nb) {
                 echo "<th width='10'>";
                 echo Html::checkAllAsCheckbox("profile" . $data['id'] . "_{$rand}");
                 echo "</th>";
                 $reduce_header++;
             }
             echo "<th colspan='" . ($headerspan - $reduce_header) . "'>";
             printf(__('%1$s: %2$s'), __('Profile'), $data["name"]);
             echo "</th></tr></tbody>";
             echo "<tbody id='profile" . $data['id'] . "_{$rand}'>";
             $query = "SELECT `glpi_users`.*,\n                             `glpi_profiles_users`.`id` AS linkID,\n                             `glpi_profiles_users`.`is_recursive`,\n                             `glpi_profiles_users`.`is_dynamic`\n                      FROM `glpi_profiles_users`\n                      LEFT JOIN `glpi_users`\n                           ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                      WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                            AND `glpi_users`.`is_deleted` = '0'\n                            AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n                      ORDER BY `glpi_profiles_users`.`profiles_id`,\n                               `glpi_users`.`name`,\n                               `glpi_users`.`realname`,\n                               `glpi_users`.`firstname`";
             $result2 = $DB->query($query);
             if ($DB->numrows($result2) > 0) {
                 $i = 0;
                 while ($data2 = $DB->fetch_assoc($result2)) {
                     Session::addToNavigateListItems('User', $data2["id"]);
                     if ($i % $nb_per_line == 0) {
                         if ($i != 0) {
                             echo "</tr>";
                         }
                         echo "<tr class='tab_bg_1'>";
                     }
                     if ($canedit) {
                         echo "<td width='10'>";
                         Html::showMassiveActionCheckBox(__CLASS__, $data2["linkID"]);
                         echo "</td>";
                     }
                     $username = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
                     if ($data2["is_dynamic"] || $data2["is_recursive"]) {
                         $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                         if ($data2["is_dynamic"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                         }
                         if ($data2["is_dynamic"] && $data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, ", ");
                         }
                         if ($data2["is_recursive"]) {
                             $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                         }
                         $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
//.........这里部分代码省略.........
开发者ID:Ixertec,项目名称:glpi,代码行数:101,代码来源:profile_user.class.php

示例4: manageValuesInSession

 /**
  * @param $options   array
  * @param $delete          (false by default)
  **/
 static function manageValuesInSession($options = array(), $delete = false)
 {
     $fields = array('action', 'authldaps_id', 'basedn', 'begin_date', 'criterias', 'end_date', 'entities_id', 'interface', 'ldap_filter', 'mode');
     //If form accessed via modal, do not show expert mode link
     // Manage new value is set : entity or mode
     if (isset($options['entity']) || isset($options['mode'])) {
         if (isset($options['_in_modal']) && $options['_in_modal']) {
             //If coming form the helpdesk form : reset all criterias
             $_SESSION['ldap_import']['_in_modal'] = 1;
             $_SESSION['ldap_import']['no_expert_mode'] = 1;
             $_SESSION['ldap_import']['action'] = 'show';
             $_SESSION['ldap_import']['interface'] = self::SIMPLE_INTERFACE;
             $_SESSION['ldap_import']['mode'] = self::ACTION_IMPORT;
         } else {
             $_SESSION['ldap_import']['_in_modal'] = 0;
         }
     }
     if (!$delete) {
         if (!isset($_SESSION['ldap_import']['entities_id'])) {
             $options['entities_id'] = $_SESSION['glpiactive_entity'];
         }
         if (isset($options['toprocess'])) {
             $_SESSION['ldap_import']['action'] = 'process';
         }
         if (isset($options['change_directory'])) {
             $options['ldap_filter'] = '';
         }
         if (!isset($_SESSION['ldap_import']['authldaps_id'])) {
             $_SESSION['ldap_import']['authldaps_id'] = NOT_AVAILABLE;
         }
         if (!Config::canUpdate() && !Entity::canUpdate() || !isset($_SESSION['ldap_import']['interface']) && !isset($options['interface'])) {
             $options['interface'] = self::SIMPLE_INTERFACE;
         }
         foreach ($fields as $field) {
             if (isset($options[$field])) {
                 $_SESSION['ldap_import'][$field] = $options[$field];
             }
         }
         if (isset($_SESSION['ldap_import']['begin_date']) && $_SESSION['ldap_import']['begin_date'] == 'NULL') {
             $_SESSION['ldap_import']['begin_date'] = '';
         }
         if (isset($_SESSION['ldap_import']['end_date']) && $_SESSION['ldap_import']['end_date'] == 'NULL') {
             $_SESSION['ldap_import']['end_date'] = '';
         }
         if (!isset($_SESSION['ldap_import']['criterias'])) {
             $_SESSION['ldap_import']['criterias'] = array();
         }
         $authldap = new self();
         //Filter computation
         if ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE) {
             $entity = new Entity();
             if ($entity->getFromDB($_SESSION['ldap_import']['entities_id']) && $entity->getField('authldaps_id') > 0) {
                 $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                 $_SESSION['ldap_import']['authldaps_id'] = $entity->getField('authldaps_id');
                 $_SESSION['ldap_import']['basedn'] = $entity->getField('ldap_dn');
                 // No dn specified in entity : use standard one
                 if (empty($_SESSION['ldap_import']['basedn'])) {
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
                 if ($entity->getField('entity_ldapfilter') != NOT_AVAILABLE) {
                     $_SESSION['ldap_import']['entity_filter'] = $entity->getField('entity_ldapfilter');
                 }
             } else {
                 $_SESSION['ldap_import']['authldaps_id'] = self::getDefault();
                 if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
             }
             if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                 $_SESSION['ldap_import']['ldap_filter'] = self::buildLdapFilter($authldap);
             }
         } else {
             if ($_SESSION['ldap_import']['authldaps_id'] == NOT_AVAILABLE || !$_SESSION['ldap_import']['authldaps_id']) {
                 $_SESSION['ldap_import']['authldaps_id'] = self::getDefault();
                 if ($_SESSION['ldap_import']['authldaps_id'] > 0) {
                     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                     $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 }
             }
             if (!isset($_SESSION['ldap_import']['ldap_filter']) || $_SESSION['ldap_import']['ldap_filter'] == '') {
                 $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
                 $_SESSION['ldap_import']['basedn'] = $authldap->getField('basedn');
                 $_SESSION['ldap_import']['ldap_filter'] = self::buildLdapFilter($authldap);
             }
         }
         //Unset all values in session
     } else {
         unset($_SESSION['ldap_import']);
     }
 }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:95,代码来源:authldap.class.php

示例5: showNotificationOptions

 static function showNotificationOptions(Entity $entity)
 {
     $con_spotted = false;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID);
     // Get data
     $entitynotification = new PluginAdditionalalertsOcsAlert();
     if (!$entitynotification->getFromDBbyEntity($ID)) {
         $entitynotification->getEmpty();
     }
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td>" . __('New imported computers from OCS-NG', 'additionalalerts') . "</td><td>";
     $default_value = $entitynotification->fields['use_newocs_alert'];
     Alert::dropdownYesNo(array('name' => "use_newocs_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td >" . __('OCS-NG Synchronization alerts', 'additionalalerts') . "</td><td>";
     Alert::dropdownIntegerNever('delay_ocs', $entitynotification->fields["delay_ocs"], array('max' => 99, 'inherit_global' => 1));
     echo "&nbsp;" . _n('Day', 'Days', 2) . "</td>";
     echo "</tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">";
             echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:43,代码来源:ocsalert.class.php

示例6: showHelpdeskOptions

 /**
  * @since version 0.84 (before in entitydata.class)
  *
  * @param $entity Entity object
  **/
 static function showHelpdeskOptions(Entity $entity)
 {
     global $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) {
         return false;
     }
     $canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID);
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     $options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd);
     TicketTemplate::dropdown($options);
     if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $tt = new TicketTemplate();
         $tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0);
         if (!$tid) {
             echo Dropdown::EMPTY_VALUE;
         } else {
             if ($tt->getFromDB($tid)) {
                 echo $tt->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7'));
     if ($ID != 0) {
         $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Calendar::dropdown($options);
     if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $calendar = new Calendar();
         $cid = self::getUsedConfig('calendars_id', $ID, '', 0);
         if (!$cid) {
             _e('24/7');
         } else {
             if ($calendar->getFromDB($cid)) {
                 echo $calendar->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
     if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
     echo "<td colspan='2'>";
     $autoassign = self::getAutoAssignMode();
     if ($ID == 0) {
         unset($autoassign[self::CONFIG_PARENT]);
     }
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
     if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
         $auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
         echo "<font class='green'>&nbsp;&nbsp;";
         echo $autoassign[$auto_assign_mode];
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
     echo "<td colspan='2'>";
     $autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
     if ($ID == 0) {
         unset($autoclose[self::CONFIG_PARENT]);
     }
     Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
     if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
         $autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
         echo "<br><font class='green'>&nbsp;&nbsp;";
         if ($autoclose_mode >= 0) {
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:entity.class.php

示例7: showForEntity

 /**
  * Show users of an entity
  *
  * @param $entity Entity object
  **/
 static function showForEntity(Entity $entity)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, "r")) {
         return false;
     }
     $canedit = $entity->can($ID, "w");
     $canshowuser = haveRight("user", "r");
     $nb_per_line = 3;
     $rand = mt_rand();
     if ($canedit) {
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo getItemTypeFormURL(__CLASS__) . "'>";
         $headerspan = $nb_per_line * 2;
     } else {
         $headerspan = $nb_per_line;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='5'>" . $LANG['setup'][605] . "</tr>";
         echo "<tr><td class='tab_bg_2 center'>" . $LANG['common'][34] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         User::dropdown(array('right' => 'all'));
         echo "</td><td class='tab_bg_2 center'>" . $LANG['profiles'][22] . "&nbsp;:&nbsp;";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td class='tab_bg_2 center'>" . $LANG['profiles'][28] . "&nbsp;:&nbsp;";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='{$headerspan}'>" . $LANG['Menu'][14] . " (D=" . $LANG['profiles'][29] . ", R=" . $LANG['profiles'][28] . ")</th></tr>";
     $query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0'";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         initNavigateListItems('User', $LANG['entity'][0] . " = " . $entity->fields['name']);
         while ($data = $DB->fetch_array($result)) {
             echo "<tr><th colspan='{$headerspan}'>" . $LANG['profiles'][22] . "&nbsp;: " . $data["name"];
             echo "</th></tr>";
             $query = "SELECT `glpi_users`.*,\n                             `glpi_profiles_users`.`id` AS linkID,\n                             `glpi_profiles_users`.`is_recursive`,\n                             `glpi_profiles_users`.`is_dynamic`\n                      FROM `glpi_profiles_users`\n                      LEFT JOIN `glpi_users`\n                           ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                      WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n                            AND `glpi_users`.`is_deleted` = '0'\n                            AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n                      ORDER BY `glpi_profiles_users`.`profiles_id`,\n                               `glpi_users`.`name`,\n                               `glpi_users`.`realname`,\n                               `glpi_users`.`firstname`";
             $result2 = $DB->query($query);
             if ($DB->numrows($result2) > 0) {
                 $i = 0;
                 while ($data2 = $DB->fetch_array($result2)) {
                     addToNavigateListItems('User', $data2["id"]);
                     if ($i % $nb_per_line == 0) {
                         if ($i != 0) {
                             echo "</tr>";
                         }
                         echo "<tr class='tab_bg_1'>";
                     }
                     if ($canedit) {
                         echo "<td width='10'>";
                         echo "<input type='checkbox' name='item[" . $data2["linkID"] . "]' value='1'>";
                         echo "</td>";
                     }
                     echo "<td>";
                     echo formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
                     if ($data2["is_dynamic"] || $data2["is_recursive"]) {
                         echo "<strong>&nbsp;(";
                         if ($data2["is_dynamic"]) {
                             echo "D";
                         }
                         if ($data2["is_dynamic"] && $data2["is_recursive"]) {
                             echo ", ";
                         }
                         if ($data2["is_recursive"]) {
                             echo "R";
                         }
                         echo ")</strong>";
                     }
                     echo "</td>";
                     $i++;
                 }
                 while ($i % $nb_per_line != 0) {
                     echo "<td>&nbsp;</td>";
                     if ($canedit) {
                         echo "<td>&nbsp;</td>";
                     }
                     $i++;
                 }
                 echo "</tr>";
             } else {
                 echo "<tr colspan='{$headerspan}'>" . $LANG['common'][54] . "</tr>";
             }
         }
     }
     echo "</table>";
     if ($canedit) {
         openArrowMassive("entityuser_form{$rand}", true);
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:profile_user.class.php

示例8: getDatasForTemplate

 /**
  * @see NotificationTarget::getDatasForTemplate()
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     //----------- Reservation infos -------------- //
     $events = $this->getAllEvents();
     $item = $this->obj;
     $this->datas['##projecttask.action##'] = $events[$event];
     $this->datas['##projecttask.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ProjectTask_" . $item->getField("id"));
     $this->datas["##projecttask.name##"] = $item->getField('name');
     $this->datas["##projecttask.project##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
     $this->datas["##projecttask.projecturl##"] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("projects_id"));
     $this->datas["##projecttask.description##"] = $item->getField('content');
     $this->datas["##projecttask.comments##"] = $item->getField('comment');
     $this->datas["##projecttask.creationdate##"] = Html::convDateTime($item->getField('date'));
     $this->datas["##projecttask.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
     $this->datas["##projecttask.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
     $this->datas["##projecttask.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
     $this->datas["##projecttask.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
     $this->datas["##projecttask.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
     $this->datas["##projecttask.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
     $this->datas["##projecttask.plannedduration##"] = Html::timestampToString($item->getField('planned_duration'), false);
     $this->datas["##projecttask.effectiveduration##"] = Html::timestampToString($item->getField('effective_duration'), false);
     $ticket_duration = ProjectTask_Ticket::getTicketsTotalActionTime($item->getID());
     $this->datas["##projecttask.ticketsduration##"] = Html::timestampToString($ticket_duration, false);
     $this->datas["##projecttask.totalduration##"] = Html::timestampToString($ticket_duration + $item->getField('effective_duration'), false);
     $entity = new Entity();
     $this->datas["##projecttask.entity##"] = '';
     $this->datas["##projecttask.shortentity##"] = '';
     if ($entity->getFromDB($this->getEntity())) {
         $this->datas["##projecttask.entity##"] = $entity->getField('completename');
         $this->datas["##projecttask.shortentity##"] = $entity->getField('name');
     }
     $this->datas["##projecttask.father##"] = '';
     if ($item->getField('projecttasks_id')) {
         $this->datas["##projecttask.father##"] = Dropdown::getDropdownName('glpi_projecttasks', $item->getField('projecttasks_id'));
     }
     $this->datas["##projecttask.state##"] = '';
     if ($item->getField('projectstates_id')) {
         $this->datas["##projecttask.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
     }
     $this->datas["##projecttask.type##"] = '';
     if ($item->getField('projecttasktypes_id')) {
         $this->datas["##projecttask.type##"] = Dropdown::getDropdownName('glpi_projecttasktypes', $item->getField('projecttasktypes_id'));
     }
     $this->datas["##projecttask.createbyuser##"] = '';
     if ($item->getField('users_id')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id'));
         $this->datas["##projecttask.createbyuser##"] = $user_tmp->getName();
     }
     // Team infos
     $restrict = "`projecttasks_id` = '" . $item->getField('id') . "'";
     $items = getAllDatasFromTable('glpi_projecttaskteams', $restrict);
     $this->datas['teammembers'] = array();
     if (count($items)) {
         foreach ($items as $data) {
             if ($item2 = getItemForItemtype($data['itemtype'])) {
                 if ($item2->getFromDB($data['items_id'])) {
                     $tmp = array();
                     $tmp['##teammember.itemtype##'] = $item2->getTypeName();
                     $tmp['##teammember.name##'] = $item2->getName();
                     $this->datas['teammembers'][] = $tmp;
                 }
             }
         }
     }
     $this->datas['##projecttask.numberofteammembers##'] = count($this->datas['teammembers']);
     // Task infos
     $restrict = "`projecttasks_id`='" . $item->getField('id') . "'";
     $restrict .= " ORDER BY `date` DESC, `id` ASC";
     $tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
     $this->datas['tasks'] = array();
     foreach ($tasks as $task) {
         $tmp = array();
         $tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
         $tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
         $tmp['##task.name##'] = $task['name'];
         $tmp['##task.description##'] = $task['content'];
         $tmp['##task.comments##'] = $task['comment'];
         $tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
         $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
         $tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
         $this->datas["##task.planstartdate##"] = '';
         $this->datas["##task.planenddate##"] = '';
         $this->datas["##task.realstartdate##"] = '';
         $this->datas["##task.realenddate##"] = '';
         if (!is_null($task['plan_start_date'])) {
             $tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
         }
         if (!is_null($task['plan_end_date'])) {
             $tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
         }
         if (!is_null($task['real_start_date'])) {
             $tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
         }
         if (!is_null($task['real_end_date'])) {
             $tmp['##task.realenddate##'] = Html::convDateTime($task['real_end_date']);
//.........这里部分代码省略.........
开发者ID:btry,项目名称:glpi,代码行数:101,代码来源:notificationtargetprojecttask.class.php

示例9: getDatasForTemplate

 /**
  * @see NotificationTarget::getDatasForTemplate()
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     //----------- Reservation infos -------------- //
     $events = $this->getAllEvents();
     $item = $this->obj;
     $this->datas['##project.action##'] = $events[$event];
     $this->datas['##project.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("id"));
     $this->datas["##project.name##"] = $item->getField('name');
     $this->datas["##project.code##"] = $item->getField('code');
     $this->datas["##project.description##"] = $item->getField('content');
     $this->datas["##project.comments##"] = $item->getField('comment');
     $this->datas["##project.creationdate##"] = Html::convDateTime($item->getField('date'));
     $this->datas["##project.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
     $this->datas["##project.priority##"] = CommonITILObject::getPriorityName($item->getField('priority'));
     $this->datas["##project.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
     $this->datas["##project.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
     $this->datas["##project.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
     $this->datas["##project.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
     $this->datas["##project.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
     $this->datas["##project.plannedduration##"] = Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($item->getID()), false);
     $this->datas["##project.effectiveduration##"] = Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($item->getID()), false);
     $entity = new Entity();
     $this->datas["##project.entity##"] = '';
     $this->datas["##project.shortentity##"] = '';
     if ($entity->getFromDB($this->getEntity())) {
         $this->datas["##project.entity##"] = $entity->getField('completename');
         $this->datas["##project.shortentity##"] = $entity->getField('name');
     }
     $this->datas["##project.father##"] = '';
     if ($item->getField('projects_id')) {
         $this->datas["##project.father##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
     }
     $this->datas["##project.state##"] = '';
     if ($item->getField('projectstates_id')) {
         $this->datas["##project.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
     }
     $this->datas["##project.type##"] = '';
     if ($item->getField('projecttypes_id')) {
         $this->datas["##project.type##"] = Dropdown::getDropdownName('glpi_projecttypes', $item->getField('projecttypes_id'));
     }
     $this->datas["##project.manager##"] = '';
     if ($item->getField('users_id')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id'));
         $this->datas["##project.manager##"] = $user_tmp->getName();
     }
     $this->datas["##project.managergroup##"] = '';
     if ($item->getField('groups_id')) {
         $this->datas["##project.managergroup##"] = Dropdown::getDropdownName('glpi_groups', $item->getField('groups_id'));
     }
     // Team infos
     $restrict = "`projects_id` = '" . $item->getField('id') . "'";
     $items = getAllDatasFromTable('glpi_projectteams', $restrict);
     $this->datas['teammembers'] = array();
     if (count($items)) {
         foreach ($items as $data) {
             if ($item2 = getItemForItemtype($data['itemtype'])) {
                 if ($item2->getFromDB($data['items_id'])) {
                     $tmp = array();
                     $tmp['##teammember.itemtype##'] = $item2->getTypeName();
                     $tmp['##teammember.name##'] = $item2->getName();
                     $this->datas['teammembers'][] = $tmp;
                 }
             }
         }
     }
     $this->datas['##project.numberofteammembers##'] = count($this->datas['teammembers']);
     // Task infos
     $restrict = "`projects_id`='" . $item->getField('id') . "'";
     $restrict .= " ORDER BY `date` DESC, `id` ASC";
     $tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
     $this->datas['tasks'] = array();
     foreach ($tasks as $task) {
         $tmp = array();
         $tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
         $tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
         $tmp['##task.name##'] = $task['name'];
         $tmp['##task.description##'] = $task['content'];
         $tmp['##task.comments##'] = $task['comment'];
         $tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
         $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
         $tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
         $this->datas["##task.planstartdate##"] = '';
         $this->datas["##task.planenddate##"] = '';
         $this->datas["##task.realstartdate##"] = '';
         $this->datas["##task.realenddate##"] = '';
         if (!is_null($task['plan_start_date'])) {
             $tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
         }
         if (!is_null($task['plan_end_date'])) {
             $tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
         }
         if (!is_null($task['real_start_date'])) {
             $tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
         }
         if (!is_null($task['real_end_date'])) {
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:glpi,代码行数:101,代码来源:notificationtargetproject.class.php

示例10: showHelpdeskOptions

 static function showHelpdeskOptions(Entity $entity)
 {
     global $LANG, $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r') || !haveRight('entity_helpdesk', 'r')) {
         return false;
     }
     $canedit = haveRight('entity_helpdesk', 'w') && haveAccessToEntity($ID);
     // Get data
     $entdata = new EntityData();
     if (!$entdata->getFromDB($ID)) {
         $entdata->getEmpty();
     }
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['buttons'][15] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entdata->fields["calendars_id"], 'emptylabel' => $LANG['common'][102]);
     if ($ID == 0) {
         $options['emptylabel'] = $LANG['sla'][10];
     }
     Dropdown::show('Calendar', $options);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][28] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(0 => $LANG['common'][102]);
     }
     Ticket::dropdownType('tickettype', $entdata->fields["tickettype"], $toadd);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . $LANG['setup'][52] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $autoassign = array(-1 => $LANG['setup'][731], NO_AUTO_ASSIGN => $LANG['choice'][0], AUTO_ASSIGN_HARDWARE_CATEGORY => $LANG['setup'][51], AUTO_ASSIGN_CATEGORY_HARDWARE => $LANG['setup'][50]);
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entdata->fields["auto_assign_mode"]));
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][17] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][18] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     Dropdown::showInteger('autoclose_delay', $entdata->fields['autoclose_delay'], 0, 99, 1, array(-1 => $LANG['setup'][731], -10 => $LANG['setup'][307]));
     /*
           Alert::dropdownIntegerNever('autoclose_delay', $entdata->fields['autoclose_delay'],
                                       array('max'            => 99,
                                             'inherit_global' => 1,
                                             'never_value'    => -10,));
     */
     echo "&nbsp;" . $LANG['stats'][31] . "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][19] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][19] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     /// no inquest case = rate 0
     $typeinquest = array(0 => $LANG['common'][102], 1 => $LANG['satisfaction'][9], 2 => $LANG['satisfaction'][10]);
     // No inherit from parent for root entity
     if ($entdata->fields['entities_id'] == 0) {
         unset($typeinquest[0]);
         if ($entdata->fields['inquest_config'] == 0) {
             $entdata->fields['inquest_config'] = 1;
         }
     }
     $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entdata->fields['inquest_config']));
     echo "</td></tr>\n";
     // Do not display for root entity in inherit case
     if ($entdata->fields['inquest_config'] == 0 && $entdata->fields['entities_id'] != 0) {
         $inquestconfig = self::getUsedConfig('inquest_config', $entdata->fields['entities_id']);
         $inquestrate = self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_rate');
         echo "<tr><td colspan='4' class='green center'>" . $LANG['common'][102] . "&nbsp;:&nbsp;";
         if ($inquestrate == 0) {
             echo $LANG['crontask'][31];
         } else {
             echo $typeinquest[$inquestconfig];
             echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_delay');
             echo "&nbsp;" . $LANG['stats'][31] . " - ";
             echo $inquestrate . "%";
             if ($inquestconfig == 2) {
                 echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_URL');
             }
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $_REQUEST = array('inquest_config' => $entdata->fields['inquest_config'], 'entities_id' => $ID);
     $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
     echo "<div id='inquestconfig'>";
     include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
     echo "</div>\n";
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:entitydata.class.php

示例11: showNotificationOptions

 static function showNotificationOptions(Entity $entity)
 {
     $con_spotted = false;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = Session::haveRight('notification', 'w') && Session::haveAccessToEntity($ID);
     // Get data
     $entitynotification = new PluginAdditionalalertsInfocomAlert();
     if (!$entitynotification->getFromDBbyEntity($ID)) {
         $entitynotification->getEmpty();
     }
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Alarms options') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td>" . PluginAdditionalalertsInfocomAlert::getTypeName(2) . "</td><td>";
     $default_value = $entitynotification->fields['use_infocom_alert'];
     Alert::dropdownYesNo(array('name' => "use_infocom_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value=\"" . $entitynotification->fields["id"] . "\">";
             echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:40,代码来源:infocomalert.class.php

示例12: getDatasForObject

 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$1');
     } else {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     }
     $tab = '$2';
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $tab = '$1';
     }
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . $tab);
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
                 $tmp = array();
                 $tmp['##author.id##'] = $uid;
                 $tmp['##author.name##'] = $user_tmp->getName();
                 if ($user_tmp->getField('locations_id')) {
                     $tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
                 } else {
                     $tmp['##author.location##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($user_tmp->getFromDB($uid)) {
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:notificationtargetcommonitilobject.class.php

示例13: getDatasForObject

 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$2');
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
                 $tmp = array();
                 $tmp['##author.id##'] = $uid;
                 $tmp['##author.name##'] = $user_tmp->getName();
                 if ($user_tmp->getField('locations_id')) {
                     $tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
                 } else {
                     $tmp['##author.location##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($user_tmp->getFromDB($uid)) {
                 $users[$uid] = $user_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntousers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntosupplier##"] = '';
     if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
         $suppliers = array();
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:notificationtargetcommonitilobject.class.php


注:本文中的Entity::getField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。