本文整理汇总了PHP中getSingular函数 的典型用法代码示例。如果您正苦于以下问题:PHP getSingular函数的具体用法?PHP getSingular怎么用?PHP getSingular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSingular函数 的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: deleteDropdownsForItemtype
static function deleteDropdownsForItemtype($itemtype)
{
global $DB;
//Foreach dropdown : drop table & remove files !
foreach (self::getDropdownForItemtype($itemtype) as $table) {
$results = array();
if (preg_match("/glpi_plugin_genericobject_(.*)/i", getSingular($table), $results) && isset($results[1])) {
$name = $results[1];
$DB->query("DROP TABLE IF EXISTS `{$table}`");
self::deleteFormFile($name);
self::deleteSearchFile($name);
self::deleteClassFile($name);
}
}
}
开发者ID:geldarr, 项目名称:hack-space, 代码行数:15, 代码来源:type.class.php
示例2: showList
/**
* Print a nice tab for last event
*
* Print a great tab to present lasts events occured on glpi
*
* @param $target where to go when complete
* @param $order order by clause occurences (eg: )
* @param $sort order by clause occurences (eg: date)
* @param $start
**/
static function showList($target, $order = 'DESC', $sort = 'date', $start = 0)
{
global $DB, $CFG_GLPI, $LANG;
// Show events from $result in table form
list($logItemtype, $logService) = self::logArray();
// Columns of the Table
$items = array("items_id" => array($LANG['event'][0], "colspan='2'"), "date" => array($LANG['common'][27], ""), "service" => array($LANG['event'][2], "width='8%'"), "level" => array($LANG['event'][3], "width='8%'"), "message" => array($LANG['event'][4], "width='50%'"));
// define default sorting
if (!isset($items[$sort])) {
$sort = "date";
}
if ($order != "ASC") {
$order = "DESC";
}
// Query Database
$query_limit = "SELECT *\n FROM `glpi_events`\n ORDER BY `{$sort}` {$order}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
// Number of results
$numrows = countElementsInTable("glpi_events");
// Get results
$result = $DB->query($query_limit);
$number = $DB->numrows($result);
// No Events in database
if ($number < 1) {
echo "<div class='center b'>" . $LANG['central'][4] . "</div>";
return;
}
// Output events
$i = 0;
echo "<div class='center'>";
$parameters = "sort={$sort}&order={$order}";
printPager($start, $numrows, $target, $parameters);
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
foreach ($items as $field => $args) {
echo "<th " . $args[1] . ">";
if ($sort == $field) {
if ($order == "DESC") {
echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png\" alt='' title=''>";
} else {
echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png\" alt='' title=''>";
}
}
echo "<a href='{$target}?sort={$field}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "'>" . $args[0] . "</a></th>";
}
echo "</tr>";
while ($i < $number) {
$ID = $DB->result($result, $i, "id");
$items_id = $DB->result($result, $i, "items_id");
$type = $DB->result($result, $i, "type");
$date = $DB->result($result, $i, "date");
$service = $DB->result($result, $i, "service");
$level = $DB->result($result, $i, "level");
$message = $DB->result($result, $i, "message");
$itemtype = " ";
if (isset($logItemtype[$type])) {
$itemtype = $logItemtype[$type];
} else {
$type = getSingular($type);
if (class_exists($type)) {
$item = new $type();
$itemtype = $item->getTypeName();
}
}
echo "<tr class='tab_bg_2'>";
echo "<td>{$itemtype} :</td>";
echo "<td class='center b'>";
self::displayItemLogID($type, $items_id);
echo "</td><td>" . convDateTime($date) . "</td>";
echo "<td class='center'>" . (isset($logService[$service]) ? $logService[$service] : $service);
echo "</td><td class='center'>{$level}</td><td>{$message}</td></tr>";
$i++;
}
echo "</table></div><br>";
}
开发者ID:ryukansent, 项目名称:Thesis-SideB, 代码行数:84, 代码来源:event.class.php
示例3: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
$datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
$datas['##ticket.content##'] = $datas['##ticket.description##'];
// Specific datas
$datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
$datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
$datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
$datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
$autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
$datas['##ticket.autoclose##'] = __('Never');
$datas['##lang.ticket.autoclosewarning##'] = "";
if ($autoclose_value > 0) {
$datas['##ticket.autoclose##'] = $autoclose_value;
$datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
}
$datas['##ticket.sla##'] = '';
if ($item->getField('slas_id')) {
$datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
}
$datas['##ticket.location##'] = '';
if ($item->getField('locations_id')) {
$datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
}
// is ticket deleted
$datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
//Tags associated with the object linked to the ticket
$datas['##ticket.itemtype##'] = '';
$datas['##ticket.item.name##'] = '';
$datas['##ticket.item.serial##'] = '';
$datas['##ticket.item.otherserial##'] = '';
$datas['##ticket.item.location##'] = '';
$datas['##ticket.item.contact##'] = '';
$datas['##ticket.item.contactnumber##'] = '';
$datas['##ticket.item.user##'] = '';
$datas['##ticket.item.group##'] = '';
$datas['##ticket.item.model##'] = '';
$item_ticket = new Item_Ticket();
$items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
$datas['items'] = array();
if (count($items)) {
foreach ($items as $val) {
if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
$tmp = array();
//Object type
$tmp['##ticket.itemtype##'] = $hardware->getTypeName();
//Object name
$tmp['##ticket.item.name##'] = $hardware->getField('name');
//Object serial
if ($hardware->isField('serial')) {
$tmp['##ticket.item.serial##'] = $hardware->getField('serial');
}
//Object contact
if ($hardware->isField('contact')) {
$tmp['##ticket.item.contact##'] = $hardware->getField('contact');
}
//Object contact num
if ($hardware->isField('contact_num')) {
$tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
}
//Object otherserial
if ($hardware->isField('otherserial')) {
$tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
}
//Object location
if ($hardware->isField('locations_id')) {
$tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
}
//Object user
if ($hardware->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($hardware->getField('users_id'))) {
$tmp['##ticket.item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($hardware->getField('groups_id')) {
$tmp['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $hardware->getField('groups_id'));
}
$modeltable = getSingular($hardware->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($hardware->isField($modelfield)) {
$tmp['##ticket.item.model##'] = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield));
}
$datas['items'][] = $tmp;
}
}
}
$datas['##ticket.numberofitems##'] = count($datas['items']);
// Get followups, log, validation, satisfaction, linked tickets
if (!$simple) {
// Linked tickets
$linked_tickets = Ticket_Ticket::getLinkedTicketsTo($item->getField('id'));
//.........这里部分代码省略.........
开发者ID:jose-martins, 项目名称:glpi, 代码行数:101, 代码来源:notificationtargetticket.class.php
示例4: deleteDropdownsForItemtype
static function deleteDropdownsForItemtype($itemtype)
{
global $DB;
//Foreach dropdown : drop table & remove files !
foreach (self::getDropdownForItemtype($itemtype) as $table) {
$results = array();
if (preg_match("/glpi_plugin_genericobject_(.*)/i", getSingular($table), $results) && isset($results[1])) {
$name = $results[1];
$DB->query("DROP TABLE IF EXISTS `{$table}`");
self::deleteFormFile($name);
self::deleteSearchFile($name);
self::deleteClassFile($name);
}
}
// Invalidate submenu data in current session for minor cleanup
unset($_SESSION['glpimenu']);
}
开发者ID:btry, 项目名称:genericobject, 代码行数:17, 代码来源:type.class.php
示例5: testGetSingular
/**
* @covers ::getSingular
* @dataProvider dataPlural
**/
public function testGetSingular($singular, $plural)
{
$this->assertEquals($singular, getSingular($plural));
$this->assertEquals($singular, getSingular(getSingular($plural)));
}
开发者ID:glpi-project, 项目名称:glpi, 代码行数:9, 代码来源:DbFunctionTest.php
示例6: showList
/**
* Print a nice tab for last event
*
* Print a great tab to present lasts events occured on glpi
*
* @param $target where to go when complete
* @param $order order by clause occurences (eg: ) (default 'DESC')
* @param $sort order by clause occurences (eg: date) (defaut 'date')
* @param $start (default 0)
**/
static function showList($target, $order = 'DESC', $sort = 'date', $start = 0)
{
global $DB, $CFG_GLPI;
// Show events from $result in table form
list($logItemtype, $logService) = self::logArray();
// Columns of the Table
$items = array("type" => array(__('Source'), ""), "items_id" => array(__('ID'), ""), "date" => array(__('Date'), ""), "service" => array(__('Service'), "width='8%'"), "level" => array(__('Level'), "width='8%'"), "message" => array(__('Message'), "width='50%'"));
// define default sorting
if (!isset($items[$sort])) {
$sort = "date";
}
if ($order != "ASC") {
$order = "DESC";
}
// Query Database
$query_limit = "SELECT *\n FROM `glpi_events`\n ORDER BY `{$sort}` {$order}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
// Number of results
$numrows = countElementsInTable("glpi_events");
// Get results
$result = $DB->query($query_limit);
$number = $DB->numrows($result);
// No Events in database
if ($number < 1) {
echo "<div class='center b'>" . __('No Event') . "</div>";
return;
}
// Output events
$i = 0;
echo "<div class='center'>";
$parameters = "sort={$sort}&order={$order}";
Html::printPager($start, $numrows, $target, $parameters);
echo "<table class='tab_cadre_fixehov'>";
echo "<tr>";
foreach ($items as $field => $args) {
echo "<th " . $args[1] . "";
if ($sort == $field) {
echo " class='order_{$order}' ";
}
echo "><a href='{$target}?sort={$field}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "'>" . $args[0] . "</a></th>";
}
echo "</tr>";
while ($i < $number) {
$ID = $DB->result($result, $i, "id");
$items_id = $DB->result($result, $i, "items_id");
$type = $DB->result($result, $i, "type");
$date = $DB->result($result, $i, "date");
$service = $DB->result($result, $i, "service");
$level = $DB->result($result, $i, "level");
$message = $DB->result($result, $i, "message");
$itemtype = " ";
if (isset($logItemtype[$type])) {
$itemtype = $logItemtype[$type];
} else {
$type = getSingular($type);
if ($item = getItemForItemtype($type)) {
$itemtype = $item->getTypeName(1);
}
}
echo "<tr class='tab_bg_2'>";
echo "<td>{$itemtype}</td>";
echo "<td class='center b'>";
self::displayItemLogID($type, $items_id);
echo "</td><td>" . Html::convDateTime($date) . "</td>";
echo "<td class='center'>" . (isset($logService[$service]) ? $logService[$service] : $service);
echo "</td><td class='center'>" . $level . "</td><td>" . $message . "</td></tr>";
$i++;
}
echo "</table></div><br>";
}
开发者ID:stweil, 项目名称:glpi, 代码行数:79, 代码来源:event.class.php
示例7: getMenuIcon
static function getMenuIcon($itemtype) {
global $CFG_GLPI;
$default_icon = "/plugins/genericobject/pics/default-icon.png";
_log("get called class", get_called_class());
_log("itemtype", $itemtype);
$itemtype_table = getTableForItemType($itemtype);
$itemtype_shortname = preg_replace("/^glpi_plugin_genericobject_/", "", $itemtype_table);
_log("itemtype short name", $itemtype_shortname);
_log("itemtype short name (singular)", getSingular($itemtype_shortname));
$itemtype_icons = glob(
GENERICOBJECT_PICS_PATH . '/' . getSingular($itemtype_shortname) . ".*"
);
_log("itemtype_icons\n", $itemtype_icons);
$finfo = new finfo(FILEINFO_MIME);
$icon_found = null;
foreach($itemtype_icons as $icon) {
if ( preg_match("|^image/|", $finfo->file($icon)) ) {
$icon_found = preg_replace("|^".GLPI_ROOT."|", "", $icon);
}
}
_log("itemtype icon found", $icon_found);
if ( !is_null($icon_found)) {
$icon_path = $CFG_GLPI['root_doc'] . "/" . $icon_found;
} else {
$icon_path = $CFG_GLPI['root_doc'] . "/" . $default_icon;
}
return "".
"<img ".
" class='genericobject_menu_icon' ".
"src='".$icon_path."'".
"/>";
}
开发者ID:euqip, 项目名称:glpi-smartcities, 代码行数:32, 代码来源:object.class.php
示例8: deleteField
/**
* Delete a field in DB
* @param table the table
* @param field the field to delete
* @return nothing
*/
static function deleteField($table, $field)
{
global $DB;
//Remove field from displaypreferences
self::deleteDisplayPreferences($table, $field);
//If field exists, drop it !
if (FieldExists($table, $field)) {
$DB->query("ALTER TABLE `{$table}` DROP `{$field}`");
}
$table = getTableNameForForeignKeyField($field);
//If dropdown is managed by the plugin
if ($table != '' && preg_match('/plugin_genericobject_(.*)/', $table, $results)) {
//Delete dropdown table
$query = "DROP TABLE `{$table}`";
$DB->query($query);
//Delete dropdown files & class
$name = getSingular($results[1]);
PluginGenericobjectType::deleteClassFile($name);
PluginGenericobjectType::deleteFormFile($name);
PluginGenericobjectType::deletesearchFile($name);
}
}
开发者ID:paisdelconocimiento, 项目名称:glpi-smartcities, 代码行数:28, 代码来源:field.class.php
示例9: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
// Specific datas
$datas['##change.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $item->getField("id") . "_ChangeValidation\$1");
$datas['##change.globalvalidation##'] = ChangeValidation::getStatus($item->getField('global_validation'));
// $datas["##problem.impacts##"] = $item->getField('impactcontent');
// $datas["##problem.causes##"] = $item->getField('causecontent');
// $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode
if (!$simple) {
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_changes_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##change.numberoftickets##'] = count($datas['tickets']);
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$problems = getAllDatasFromTable('glpi_changes_problems', $restrict);
$datas['problems'] = array();
if (count($problems)) {
$problem = new Problem();
foreach ($problems as $data) {
if ($problem->getFromDB($data['problems_id'])) {
$tmp = array();
$tmp['##problem.id##'] = $data['problems_id'];
$tmp['##problem.date##'] = $problem->getField('date');
$tmp['##problem.title##'] = $problem->getField('name');
$tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Problem_" . $data['problems_id']);
$tmp['##problem.content##'] = $problem->getField('content');
$datas['problems'][] = $tmp;
}
}
}
$datas['##change.numberofproblems##'] = count($datas['problems']);
$restrict = "`changes_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_changes_items', $restrict);
$datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
}
}
$datas['##change.numberofitems##'] = count($datas['items']);
//Validation infos
$restrict = "`changes_id`='" . $item->getField('id') . "'";
if (isset($options['validation_id']) && $options['validation_id']) {
$restrict .= " AND `glpi_changevalidations`.`id` = '" . $options['validation_id'] . "'";
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento, 项目名称:glpi-smartcities, 代码行数:101, 代码来源:notificationtargetchange.class.php
示例10: getTableForItemType
/**
* Return ItemType for a table
*
* @param $itemtype string itemtype
*
* @return string table name corresponding to the itemtype parameter
**/
function getTableForItemType($itemtype)
{
global $CFG_GLPI;
// Force singular for itemtype : States case
$itemtype = getSingular($itemtype);
if (isset($CFG_GLPI['glpitablesitemtype'][$itemtype])) {
return $CFG_GLPI['glpitablesitemtype'][$itemtype];
} else {
$prefix = "glpi_";
if ($plug = isPluginItemType($itemtype)) {
$prefix .= "plugin_" . strtolower($plug['plugin']) . "_";
$table = strtolower($plug['class']);
} else {
$table = strtolower($itemtype);
}
if (strstr($table, '_')) {
$split = explode('_', $table);
foreach ($split as $key => $part) {
$split[$key] = getPlural($part);
}
$table = implode('_', $split);
} else {
$table = getPlural($table);
}
$CFG_GLPI['glpitablesitemtype'][$itemtype] = $prefix . $table;
$CFG_GLPI['glpiitemtypetables'][$prefix . $table] = $itemtype;
return $prefix . $table;
}
}
开发者ID:paisdelconocimiento, 项目名称:glpi-smartcities, 代码行数:36, 代码来源:db.function.php
示例11: getDatasForTemplate
//.........这里部分代码省略.........
// Use list_limit_max or load the full history ?
foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
$tmp = array();
$tmp["##project.log.date##"] = $data['date_mod'];
$tmp["##project.log.user##"] = $data['user_name'];
$tmp["##project.log.field##"] = $data['field'];
$tmp["##project.log.content##"] = $data['change'];
$this->datas['log'][] = $tmp;
}
$this->datas["##project.numberoflogs##"] = count($this->datas['log']);
// Changes infos
$restrict = "`projects_id`='" . $item->getField('id') . "'";
$changes = getAllDatasFromTable('glpi_changes_projects', $restrict);
$this->datas['changes'] = array();
if (count($changes)) {
$change = new Change();
foreach ($changes as $data) {
if ($change->getFromDB($data['changes_id'])) {
$tmp = array();
$tmp['##change.id##'] = $data['changes_id'];
$tmp['##change.date##'] = $change->getField('date');
$tmp['##change.title##'] = $change->getField('name');
$tmp['##change.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $data['changes_id']);
$tmp['##change.content##'] = $change->getField('content');
$this->datas['changes'][] = $tmp;
}
}
}
$this->datas['##project.numberofchanges##'] = count($this->datas['changes']);
// Document
$query = "SELECT `glpi_documents`.*\n FROM `glpi_documents`\n LEFT JOIN `glpi_documents_items`\n ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'Project'\n AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
$this->datas["documents"] = array();
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$tmp = array();
$tmp['##document.id##'] = $data['id'];
$tmp['##document.name##'] = $data['name'];
$tmp['##document.weblink##'] = $data['link'];
$tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']);
$downloadurl = "/front/document.send.php?docid=" . $data['id'];
$tmp['##document.downloadurl##'] = $this->formatURL($options['additionnaloption']['usertype'], $downloadurl);
$tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']);
$tmp['##document.filename##'] = $data['filename'];
$this->datas['documents'][] = $tmp;
}
}
$this->datas["##project.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("id") . '_Document_Item$1');
$this->datas["##project.numberofdocuments##"] = count($this->datas['documents']);
// Items infos
$restrict = "`projects_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_items_projects', $restrict);
$this->datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$this->datas['items'][] = $tmp;
}
}
}
}
$this->datas['##project.numberofitems##'] = count($this->datas['items']);
$this->getTags();
foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
if (!isset($this->datas[$tag])) {
$this->datas[$tag] = $values['label'];
}
}
}
开发者ID:stweil, 项目名称:glpi, 代码行数:101, 代码来源:notificationtargetproject.class.php
示例12: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas["##problem.impacts##"] = $item->getField('impactcontent');
$datas["##problem.causes##"] = $item->getField('causecontent');
$datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode
if (!$simple) {
$restrict = "`problems_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_problems_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##problem.numberoftickets##'] = count($datas['tickets']);
$restrict = "`problems_id`='" . $item->getField('id') . "'";
$changes = getAllDatasFromTable('glpi_changes_problems', $restrict);
$datas['changes'] = array();
if (count($changes)) {
$change = new Change();
foreach ($changes as $data) {
if ($change->getFromDB($data['changes_id'])) {
$tmp = array();
$tmp['##change.id##'] = $data['changes_id'];
$tmp['##change.date##'] = $change->getField('date');
$tmp['##change.title##'] = $change->getField('name');
$tmp['##change.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Change_" . $data['changes_id']);
$tmp['##change.content##'] = $change->getField('content');
$datas['changes'][] = $tmp;
}
}
}
$datas['##problem.numberofchanges##'] = count($datas['changes']);
$restrict = "`problems_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_items_problems', $restrict);
$datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
}
}
$datas['##problem.numberofitems##'] = count($datas['items']);
}
return $datas;
}
开发者ID:stweil, 项目名称:glpi, 代码行数:96, 代码来源:notificationtargetproblem.class.php
示例13: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas["##problem.impacts##"] = $item->getField('impactcontent');
$datas["##problem.causes##"] = $item->getField('causecontent');
$datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode : get tasks
if (!$simple) {
$restrict = "`problems_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_problems_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php" . "?redirect=ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##problem.numberoftickets##'] = 0;
if (!empty($datas['tickets'])) {
$datas['##problem.numberoftickets##'] = count($datas['tickets']);
}
$restrict = "`problems_id` = '" . $item->getField('id') . "'\n ORDER BY `date` DESC,\n `id` ASC";
//Task infos
$tasks = getAllDatasFromTable('glpi_problemtasks', $restrict);
foreach ($tasks as $task) {
$tmp = array();
$tmp['##task.author##'] = Html::clean(getUserName($task['users_id']));
$tmp['##task.category##'] = Dropdown::getDropdownName('glpi_taskcategories', $task['taskcategories_id']);
$tmp['##task.date##'] = Html::convDateTime($task['date']);
$tmp['##task.description##'] = $task['content'];
$tmp['##task.time##'] = Problem::getActionTime($task['actiontime']);
$tmp['##task.status##'] = Planning::getState($task['state']);
$tmp['##task.user##'] = "";
$tmp['##task.begin##'] = "";
$tmp['##task.end##'] = "";
if (!is_null($task['begin'])) {
$tmp['##task.user##'] = Html::clean(getUserName($task['users_id_tech']));
$tmp['##task.begin##'] = Html::convDateTime($task['begin']);
$tmp['##task.end##'] = Html::convDateTime($task['end']);
}
$datas['tasks'][] = $tmp;
}
$datas['##problem.numberoftasks##'] = 0;
if (!empty($datas['tasks'])) {
$datas['##problem.numberoftasks##'] = count($datas['tasks']);
}
$restrict = "`problems_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_items_problems', $restrict);
$datas['items'] = array();
if (count($tickets)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
//.........这里部分代码省略.........
开发者ID:gaforeror, 项目名称:glpi, 代码行数:101, 代码来源:notificationtargetproblem.class.php
示例14: deleteField
/**
* Delete a field in DB
* @param table the table
* @param field the field to delete
* @return nothing
*/
static function deleteField($table, $field) {
global $DB;
//If field exists, drop it !
if (FieldExists($table, $field)) {
_log("delete", $field, "from", $table);
$DB->query("ALTER TABLE `$table` DROP `$field`");
}
$table = getTableNameForForeignKeyField($field);
//If dropdown is managed by the plugin
if ($table != '' && preg_match('/plugin_genericobject_(.*)/', $table, $results)) {
//Delete dropdown table
$query = "DROP TABLE `$table`";
$DB->query($query);
//Delete dropdown files & class
$name = getSingular($results[1]);
PluginGenericobjectType::deleteClassFile($name);
PluginGenericobjectType::deleteFormFile($name);
PluginGenericobjectType::deletesearchFile($name);
}
}
开发者ID:euqip, 项目名称:glpi-smartcities, 代码行数:27, 代码来源:field.class.php
示例15: getDatasForTemplate
请发表评论