本文整理汇总了PHP中Plugin::loadLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::loadLang方法的具体用法?PHP Plugin::loadLang怎么用?PHP Plugin::loadLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::loadLang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addEvents
static function addEvents(NotificationTargetTicket $target)
{
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif')) {
Plugin::loadLang('behaviors');
$target->events['plugin_behaviors_document_itemnew'] = __('Add document to ticket', 'behaviors');
$target->events['plugin_behaviors_document_itemdel'] = __('Delete document to ticket', 'behaviors');
}
}
示例2: addEvents
static function addEvents(NotificationTargetTicket $target)
{
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif')) {
Plugin::loadLang('behaviors');
$target->events['plugin_behaviors_ticketnewtech'] = __('Assign to a technician', 'behaviors');
$target->events['plugin_behaviors_ticketnewgrp'] = __('Assign to a group', 'behaviors');
$target->events['plugin_behaviors_ticketreopen'] = __('Reopen ticket', 'behaviors');
$target->events['plugin_behaviors_replysurvey'] = __('Reply to satisfaction survey', 'behaviors');
}
}
示例3: showSelector
/**
* Display entities of the loaded profile
*
* @param $myname select name
* @param $target target for entity change action
*/
public static function showSelector($target)
{
global $CFG_GLPI;
$rand = mt_rand();
Plugin::loadLang('order');
echo "<div class='center' ><span class='b'>" . __("Select the wanted item type", "order") . "</span><br>";
echo "<a style='font-size:14px;' href='" . $target . "?reset=reset' title=\"" . __("Show all") . "\">" . str_replace(" ", " ", __("Show all")) . "</a></div>";
echo "<div class='left' style='width:100%'>";
echo "<script type='javascript'>";
echo "var Tree_Category_Loader{$rand} = new Ext.tree.TreeLoader({\n dataUrl:'" . $CFG_GLPI["root_doc"] . "/plugins/order/ajax/referencetreetypes.php'\n });";
echo "var Tree_Category{$rand} = new Ext.tree.TreePanel({\n collapsible : false,\n animCollapse : false,\n border : false,\n id : 'tree_projectcategory{$rand}',\n el : 'tree_projectcategory{$rand}',\n autoScroll : true,\n animate : false,\n enableDD : true,\n containerScroll : true,\n height : 320,\n width : 770,\n loader : Tree_Category_Loader{$rand},\n rootVisible : false\n });";
// SET the root node.
echo "var Tree_Category_Root{$rand} = new Ext.tree.AsyncTreeNode({\n text : '',\n draggable : false,\n id : '-1' // this IS the id of the startnode\n });\n Tree_Category{$rand}.setRootNode(Tree_Category_Root{$rand});";
// Render the tree.
echo "Tree_Category{$rand}.render();\n Tree_Category_Root{$rand}.expand();";
echo "</script>";
echo "<div id='tree_projectcategory{$rand}' ></div>";
echo "</div>";
}
示例4: getTemplateByLanguage
/**
* @param $target NotificationTarget object
* @param $user_infos array
* @param $event
* @param $options array
*
* @return id of the template in templates_by_languages / false if computation failed
**/
function getTemplateByLanguage(NotificationTarget $target, $user_infos = array(), $event, $options = array())
{
$lang = array();
$language = $user_infos['language'];
if (isset($user_infos['additionnaloption'])) {
$additionnaloption = $user_infos['additionnaloption'];
} else {
$additionnaloption = array();
}
$tid = $language;
$tid .= serialize($additionnaloption);
$tid = sha1($tid);
if (!isset($this->templates_by_languages[$tid])) {
//Switch to the desired language
$bak_dropdowntranslations = $_SESSION['glpi_dropdowntranslations'];
$_SESSION['glpi_dropdowntranslations'] = DropdownTranslation::getAvailableTranslations($language);
Session::loadLanguage($language);
$bak_language = $_SESSION["glpilanguage"];
$_SESSION["glpilanguage"] = $language;
//If event is raised by a plugin, load it in order to get the language file available
if ($plug = isPluginItemType(get_class($target->obj))) {
Plugin::loadLang(strtolower($plug['plugin']), $language);
}
//Get template's language data for in this language
$options['additionnaloption'] = $additionnaloption;
$data =& $target->getForTemplate($event, $options);
$footer_string = Html::entity_decode_deep(sprintf(__('Automatically generated by GLPI %s'), GLPI_VERSION));
$add_header = Html::entity_decode_deep($target->getContentHeader());
$add_footer = Html::entity_decode_deep($target->getContentFooter());
//Restore default language
$_SESSION["glpilanguage"] = $bak_language;
Session::loadLanguage();
$_SESSION['glpi_dropdowntranslations'] = $bak_dropdowntranslations;
if ($plug = isPluginItemType(get_class($target->obj))) {
Plugin::loadLang(strtolower($plug['plugin']));
}
if ($template_datas = $this->getByLanguage($language)) {
//Template processing
// Decode html chars to have clean text
$template_datas['content_text'] = Html::entity_decode_deep($template_datas['content_text']);
$save_data = $data;
$data = Html::entity_decode_deep($data);
$template_datas['subject'] = Html::entity_decode_deep($template_datas['subject']);
$this->signature = Html::entity_decode_deep($this->signature);
$lang['subject'] = $target->getSubjectPrefix($event) . self::process($template_datas['subject'], $data);
$lang['content_html'] = '';
//If no html content, then send only in text
if (!empty($template_datas['content_html'])) {
// Encode in HTML all chars
$data_html = Html::entities_deep($data);
$data_html = Html::nl2br_deep($data_html);
// Restore HTML tags
if (count($target->html_tags)) {
foreach ($target->html_tags as $tag) {
if (isset($save_data[$tag])) {
$data_html[$tag] = $save_data[$tag];
}
}
}
$signature_html = Html::entities_deep($this->signature);
$signature_html = Html::nl2br_deep($signature_html);
$template_datas['content_html'] = self::process($template_datas['content_html'], $data_html);
$lang['content_html'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" . "<html>\n <head>\n <META http-equiv='Content-Type' content='text/html; charset=utf-8'>\n <title>" . Html::entities_deep($lang['subject']) . "</title>\n <style type='text/css'>\n " . $this->fields['css'] . "\n </style>\n </head>\n <body>\n" . (!empty($add_header) ? $add_header . "\n<br><br>" : '') . $template_datas['content_html'] . "<br><br>-- \n<br>" . $signature_html . "<br>{$footer_string}" . "<br><br>\n" . (!empty($add_footer) ? $add_footer . "\n<br><br>" : '') . "\n</body></html>";
}
$lang['content_text'] = (!empty($add_header) ? $add_header . "\n\n" : '') . Html::clean(self::process($template_datas['content_text'], $data) . "\n\n-- \n" . $this->signature . "\n" . Html::entity_decode_deep(sprintf(__('Automatically generated by GLPI %s'), GLPI_VERSION))) . "\n\n" . $add_footer;
$this->templates_by_languages[$tid] = $lang;
}
}
if (isset($this->templates_by_languages[$tid])) {
return $tid;
}
return false;
}
示例5: cronCertificatesAlert
/**
* Cron action on certificates : ExpiredCertificates or CertificatesWhichExpire
*
* @param $task for log, if NULL display
*
**/
static function cronCertificatesAlert($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$cron_status = 0;
$Certificate = new self();
$query_expired = self::queryExpiredCertificates();
$query_whichexpire = self::queryCertificatesWhichExpire();
$querys = array(Alert::NOTICE => $query_whichexpire, Alert::END => $query_expired);
$certificate_infos = array();
$certificate_messages = array();
foreach ($querys as $type => $query) {
$certificate_infos[$type] = array();
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = $data["name"] . ": " . Html::convdate($data["date_expiration"]) . "<br>\n";
$certificate_infos[$type][$entity][] = $data;
if (!isset($certificates_infos[$type][$entity])) {
$certificate_messages[$type][$entity] = __('Certificates expired since more', 'certificates') . "<br />";
}
$certificate_messages[$type][$entity] .= $message;
}
}
foreach ($querys as $type => $query) {
foreach ($certificate_infos[$type] as $entity => $certificates) {
Plugin::loadLang('certificates');
if (NotificationEvent::raiseEvent($type == Alert::NOTICE ? "CertificatesWhichExpire" : "ExpiredCertificates", new PluginCertificatesCertificate(), array('entities_id' => $entity, 'certificates' => $certificates))) {
$message = $certificate_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send certificates alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send certificates alert failed", false, ERROR);
}
}
}
}
return $cron_status;
}
示例6: showSelector
/**
* Display types of used accounts
*
* @param $target target for type change action
*
* @return nothing
*/
public static function showSelector($target)
{
global $CFG_GLPI;
$rand = mt_rand();
Plugin::loadLang('accounts');
echo "<div class='center' ><span class='b'>" . __('Select the wanted account type', 'accounts') . "</span><br>";
echo "<a style='font-size:14px;' href='" . $target . "?reset=reset' title=\"" . __s('Show all') . "\">" . str_replace(" ", " ", __('Show all')) . "</a></div>";
$js = "\$('#tree_projectcategory{$rand}').jstree({\n 'plugins' : ['themes', 'json_data', 'search'],\n 'core' : {'load_open': true,\n 'html_titles': true,\n 'animation' : 0},\n 'themes' : {\n 'theme' : 'classic',\n 'url' : '" . $CFG_GLPI["root_doc"] . "/css/jstree/style.css'\n },\n 'search' : {\n 'case_insensitive' : true,\n 'show_only_matches' : true,\n 'ajax' : {\n 'type': 'POST',\n 'url' : '" . $CFG_GLPI["root_doc"] . "/plugins/accounts/ajax/accounttreetypes.php'\n }\n },\n 'json_data' : {\n 'ajax' : {\n 'type': 'POST',\n 'url': function (node) {\n var nodeId = '';\n var url = '';\n if (node == -1) {\n url = '" . $CFG_GLPI["root_doc"] . "/plugins/accounts/ajax/accounttreetypes.php?node=-1';\n } else {\n nodeId = node.attr('id');\n url = '" . $CFG_GLPI["root_doc"] . "/plugins/accounts/ajax/accounttreetypes.php?node='+nodeId;\n }\n return url;\n },\n 'success': function (new_data) {\n return new_data;\n },\n 'progressive_render' : true\n }\n }\n });";
echo Html::scriptBlock($js);
echo "<div class='left' style='width:100%'>";
echo "<div id='tree_projectcategory{$rand}'></div>";
echo "</div>";
}
示例7: plugin_init_monitoring
function plugin_init_monitoring()
{
global $PLUGIN_HOOKS, $LANG;
$PLUGIN_HOOKS['change_profile']['monitoring'] = array('PluginMonitoringProfile', 'changeprofile');
$Plugin = new Plugin();
if ($Plugin->isActivated('monitoring')) {
if (isset($_SESSION["glpiID"])) {
Plugin::loadLang("monitoring");
$PLUGIN_HOOKS['use_massive_action']['monitoring'] = 1;
$PLUGIN_HOOKS['add_css']['monitoring'] = "css/views.css";
$plugin = new Plugin();
if ($plugin->isActivated('monitoring') and isset($_SESSION['glpi_plugin_monitoring_profile'])) {
$PLUGIN_HOOKS['menu_entry']['monitoring'] = true;
}
$PLUGIN_HOOKS['config_page']['monitoring'] = 'front/config.form.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['config'] = 'front/config.form.php';
// Tabs for each type
$PLUGIN_HOOKS['headings']['monitoring'] = 'plugin_get_headings_monitoring';
$PLUGIN_HOOKS['headings_action']['monitoring'] = 'plugin_headings_actions_monitoring';
// Icons add, search...
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['commands'] = 'front/command.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['commands'] = 'front/command.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['checks'] = 'front/check.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['checks'] = 'front/check.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['componentscatalog'] = 'front/componentscatalog.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['componentscatalog'] = 'front/componentscatalog.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['servicescatalog'] = 'front/servicescatalog.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['servicescatalog'] = 'front/servicescatalog.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['components'] = 'front/component.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['components'] = 'front/component.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['contacttemplates'] = 'front/contacttemplate.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['contacttemplates'] = 'front/contacttemplate.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['displayview'] = 'front/displayview.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['displayview'] = 'front/displayview.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['rrdtemplates'] = 'front/rrdtemplate.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['rrdtemplates'] = 'front/rrdtemplate.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['PluginMonitoringRealm'] = 'front/realm.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['PluginMonitoringRealm'] = 'front/realm.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['add']['weathermap'] = 'front/weathermap.form.php?add=1';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['weathermap'] = 'front/weathermap.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['search']['service'] = 'front/display.php';
// Fil ariane
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['check']['title'] = $LANG['plugin_monitoring']['check'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['check']['page'] = '/plugins/monitoring/front/check.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['command']['title'] = $LANG['plugin_monitoring']['command'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['command']['page'] = '/plugins/monitoring/front/command.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['components']['title'] = $LANG['plugin_monitoring']['component'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['components']['page'] = '/plugins/monitoring/front/component.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['componentscatalog']['title'] = $LANG['plugin_monitoring']['componentscatalog'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['componentscatalog']['page'] = '/plugins/monitoring/front/componentscatalog.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['contacttemplates']['title'] = $LANG['plugin_monitoring']['contacttemplate'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['contacttemplates']['page'] = '/plugins/monitoring/front/contacttemplate.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['display']['title'] = $LANG['plugin_monitoring']['display'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['display']['page'] = '/plugins/monitoring/front/display.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['displayview']['title'] = $LANG['plugin_monitoring']['displayview'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['displayview']['page'] = '/plugins/monitoring/front/displayview.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['PluginMonitoringRealm']['title'] = $LANG['plugin_monitoring']['realms'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['PluginMonitoringRealm']['page'] = '/plugins/monitoring/front/realm.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['servicescatalog']['title'] = $LANG['plugin_monitoring']['servicescatalog'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['servicescatalog']['page'] = '/plugins/monitoring/front/servicescatalog.php';
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['weathermap']['title'] = $LANG['plugin_monitoring']['weathermap'][0];
$PLUGIN_HOOKS['submenu_entry']['monitoring']['options']['weathermap']['page'] = '/plugins/monitoring/front/weathermap.php';
// Define hook item
$rule_check = array('PluginMonitoringComponentscatalog_rule', 'isThisItemCheckRule');
$rule_check_networkport = array('PluginMonitoringComponentscatalog_rule', 'isThisItemCheckRuleNetworkport');
$PLUGIN_HOOKS['item_add']['monitoring'] = array('Computer' => $rule_check, 'NetworkEquipment' => $rule_check, 'Printer' => $rule_check, 'Peripheral' => $rule_check, 'Phone' => $rule_check, 'PluginMonitoringNetworkport' => $rule_check_networkport, 'PluginMonitoringComponentscatalog_rule' => array('PluginMonitoringComponentscatalog_rule', 'getItemsDynamicly'), 'PluginMonitoringComponentscatalog_Host' => array('PluginMonitoringHost', 'addHost'));
$PLUGIN_HOOKS['item_update']['monitoring'] = array('Computer' => $rule_check, 'NetworkEquipment' => $rule_check, 'Printer' => $rule_check, 'Peripheral' => $rule_check, 'Phone' => $rule_check, 'PluginMonitoringComponentscatalog' => array('PluginMonitoringComponentscatalog', 'replayRulesCatalog'), 'PluginMonitoringComponentscatalog_rule' => array('PluginMonitoringComponentscatalog_rule', 'getItemsDynamicly'));
$PLUGIN_HOOKS['item_purge']['monitoring'] = array('Computer' => $rule_check, 'NetworkEquipment' => $rule_check, 'Printer' => $rule_check, 'Peripheral' => $rule_check, 'Phone' => $rule_check, 'PluginMonitoringNetworkport' => $rule_check_networkport, 'PluginMonitoringComponentscatalog_rule' => array('PluginMonitoringComponentscatalog_rule', 'getItemsDynamicly'), 'PluginMonitoringComponentscatalog_Host' => array('PluginMonitoringComponentscatalog_Host', 'unlinkComponentsToItem'), 'PluginMonitoringComponentscatalog' => array('PluginMonitoringComponentscatalog', 'removeCatalog'), 'PluginMonitoringBusinessrulegroup' => array('PluginMonitoringBusinessrule', 'removeBusinessruleonDeletegroup'));
if (!isset($_SESSION['glpi_plugin_monitoring']['_refresh'])) {
$_SESSION['glpi_plugin_monitoring']['_refresh'] = '60';
}
}
$PLUGIN_HOOKS['webservices']['monitoring'] = 'plugin_monitoring_registerMethods';
}
return $PLUGIN_HOOKS;
}
示例8: cronAdditionalalertsNewOcs
static function cronAdditionalalertsNewOcs($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$CronTask = new CronTask();
if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsNewOcs")) {
if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
return 0;
}
} else {
return 0;
}
$message = array();
$cron_status = 0;
foreach (self::getEntitiesToNotify('use_newocs_alert') as $entity => $repeat) {
foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) {
$query_newocsmachine = self::queryNew($config, $entity);
$newocsmachine_infos = array();
$newocsmachine_messages = array();
$type = Alert::END;
$newocsmachine_infos[$type] = array();
foreach ($DB->request($query_newocsmachine) as $data) {
$entity = $data['entities_id'];
$message = $data["name"];
$newocsmachine_infos[$type][$entity][] = $data;
if (!isset($newocsmachines_infos[$type][$entity])) {
$newocsmachine_messages[$type][$entity] = __('New imported computers from OCS-NG', 'additionalalerts') . "<br />";
}
$newocsmachine_messages[$type][$entity] .= $message;
}
$delay_ocs = 0;
foreach ($newocsmachine_infos[$type] as $entity => $newocsmachines) {
Plugin::loadLang('additionalalerts');
if (NotificationEvent::raiseEvent("newocs", new PluginAdditionalalertsOcsAlert(), array('entities_id' => $entity, 'ocsmachines' => $newocsmachines, 'delay_ocs' => $delay_ocs))) {
$message = $newocsmachine_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send newocsmachines alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send newocsmachines alert failed", false, ERROR);
}
}
}
}
}
return $cron_status;
}
示例9: cronBadgesAlert
/**
* Cron action on badges : ExpiredBadges or BadgesWhichExpire
*
* @param $task for log, if NULL display
*
**/
static function cronBadgesAlert($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$cron_status = 0;
$query_expired = self::queryExpiredBadges();
$query_whichexpire = self::queryBadgesWhichExpire();
$querys = array(PluginBadgesNotificationTargetBadge::BadgesWhichExpire => $query_whichexpire, PluginBadgesNotificationTargetBadge::ExpiredBadges => $query_expired);
$badge_infos = array();
$badge_messages = array();
foreach ($querys as $type => $query) {
$badge_infos[$type] = array();
if (!empty($query)) {
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = $data["name"] . ": " . Html::convdate($data["date_expiration"]) . "<br>\n";
$badge_infos[$type][$entity][] = $data;
if (!isset($badges_infos[$type][$entity])) {
$badge_messages[$type][$entity] = __('Badges at the end of the validity', 'badges') . "<br />";
}
$badge_messages[$type][$entity] .= $message;
}
}
}
foreach ($querys as $type => $query) {
foreach ($badge_infos[$type] as $entity => $badges) {
Plugin::loadLang('badges');
if (NotificationEvent::raiseEvent($type, new PluginBadgesBadge(), array('entities_id' => $entity, 'badges' => $badges))) {
$message = $badge_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send badges alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send badges alert failed", false, ERROR);
}
}
}
}
return $cron_status;
}
示例10: cronAdditionalalertsNotInfocom
/**
* Cron action
*
* @param $task for log, if NULL display
*
**/
static function cronAdditionalalertsNotInfocom($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$CronTask = new CronTask();
if ($CronTask->getFromDBbyName("PluginAdditionalalertsInfocomAlert", "AdditionalalertsNotInfocom")) {
if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
return 0;
}
} else {
return 0;
}
$message = array();
$cron_status = 0;
foreach (self::getEntitiesToNotify('use_infocom_alert') as $entity => $repeat) {
$query_notinfocom = self::query($entity);
$notinfocom_infos = array();
$notinfocom_messages = array();
$type = Alert::END;
$notinfocom_infos[$type] = array();
foreach ($DB->request($query_notinfocom) as $data) {
$entity = $data['entities_id'];
$message = $data["name"];
$notinfocom_infos[$type][$entity][] = $data;
if (!isset($notinfocoms_infos[$type][$entity])) {
$notinfocom_messages[$type][$entity] = PluginAdditionalalertsInfocomAlert::getTypeName(2) . "<br />";
}
$notinfocom_messages[$type][$entity] .= $message;
}
foreach ($notinfocom_infos[$type] as $entity => $notinfocoms) {
Plugin::loadLang('additionalalerts');
if (NotificationEvent::raiseEvent("notinfocom", new PluginAdditionalalertsInfocomAlert(), array('entities_id' => $entity, 'notinfocoms' => $notinfocoms))) {
$message = $notinfocom_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send infocoms alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send infocoms alert failed", false, ERROR);
}
}
}
}
return $cron_status;
}
示例11: cronNotValidated
/**
* Cron action on tasks : UpdateTypology
*
* @param $task for log, if NULL display
*
**/
static function cronNotValidated($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$cron_status = 0;
$message = array();
$typo = new self();
$query_items = $typo->queryNotValidated();
$querys = array(Alert::END => $query_items);
$task_infos = array();
$task_messages = array();
foreach ($querys as $type => $query) {
$task_infos[$type] = array();
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = $data["name"] . ": " . $data["error"] . "<br>\n";
$task_infos[$type][$entity][] = $data;
if (!isset($tasks_infos[$type][$entity])) {
$task_messages[$type][$entity] = __('Elements not match with the typology', 'typology') . "<br />";
}
$task_messages[$type][$entity] .= $message;
}
}
foreach ($querys as $type => $query) {
foreach ($task_infos[$type] as $entity => $items) {
Plugin::loadLang('typology');
$message = $task_messages[$type][$entity];
$cron_status = 1;
if (NotificationEvent::raiseEvent("AlertNotValidatedTypology", new PluginTypologyTypology(), array('entities_id' => $entity, 'items' => $items))) {
$message = $task_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(count($items));
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
}
}
}
return $cron_status;
}
示例12: cronResourcesChecklist
/**
* Cron action on checklists
*
* @param $task for log, if NULL display
*
**/
static function cronResourcesChecklist($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$cron_status = 0;
$query_arrival = self::queryChecklists(false);
$query_leaving = self::queryChecklists(false, 1);
$querys = array(Alert::NOTICE => $query_arrival, Alert::END => $query_leaving);
$checklist_infos = array();
$checklist_messages = array();
foreach ($querys as $type => $query) {
$checklist_infos[$type] = array();
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = "checklists" . ": " . $data["resource_name"] . " " . $data["resource_firstname"] . "<br>\n";
$checklist_infos[$type][$entity][] = $data;
if (!isset($checklists_infos[$type][$entity])) {
$checklist_messages[$type][$entity] = __('Checklists Verification', 'resources') . "<br />";
}
$checklist_messages[$type][$entity] .= $message;
}
}
foreach ($querys as $type => $query) {
foreach ($checklist_infos[$type] as $entity => $checklists) {
Plugin::loadLang('resources');
if (NotificationEvent::raiseEvent($type == Alert::NOTICE ? "AlertArrivalChecklists" : "AlertLeavingChecklists", new PluginResourcesResource(), array('entities_id' => $entity, 'checklists' => $checklists, 'tasklists' => $checklists))) {
$message = $checklist_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send checklists resources alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send checklists resources alert failed", false, ERROR);
}
}
}
}
return $cron_status;
}
示例13: cronBadgesReturnAlert
/**
* Cron action on badges : ExpiredBadges or BadgesWhichExpire
*
* @param $task for log, if NULL display
*
* */
static function cronBadgesReturnAlert($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$cron_status = 0;
$query_returnexpire = self::queryBadgesReturnExpire();
$querys = array(PluginBadgesNotificationTargetBadge::BadgesReturn => $query_returnexpire);
$badge_infos = array();
$badge_messages = array();
foreach ($querys as $type => $query) {
$badge_infos[$type] = array();
if (!empty($query)) {
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = $data["name"] . "<br>" . __("Arrival date", "badges") . " : " . Html::convdate($data["affectation_date"]) . "<br>\n";
$badge_infos[$type][$entity][] = $data;
if (!isset($badges_infos[$type][$entity])) {
$badge_messages[$type][$entity] = __('Badges at the end of the validity', 'badges') . "<br />";
}
$badge_messages[$type][$entity] .= $message;
}
}
}
foreach ($querys as $type => $query) {
foreach ($badge_infos[$type] as $entity => $badges) {
Plugin::loadLang('badges');
// Set badge request fields
foreach ($badges as $badge) {
$badgerequest[] = array('visitor_realname' => $badge['visitor_realname'], 'visitor_firstname' => $badge['visitor_firstname'], 'visitor_society' => $badge['visitor_society'], 'affectation_date' => $badge['affectation_date'], 'requesters_id' => $badge['requesters_id']);
}
if (NotificationEvent::raiseEvent($type, new PluginBadgesBadge(), array('entities_id' => $entity, 'badges' => $badges, 'badgerequest' => $badgerequest))) {
$message = $badge_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send badges alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send badges alert failed", false, ERROR);
}
}
}
}
return $cron_status;
}
示例14: suite
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('FusionInventory');
if (file_exists("save.sql")) {
unlink("save.sql");
}
$suite->addTest(GLPIInstall_AllTests::suite());
$suite->addTest(FusinvInstall_AllTests::suite());
Plugin::loadLang('fusioninventory');
if (isset($_SERVER['argv']) && isset($_SERVER['argv'][2]) && !isset($_SERVER['argv'][3])) {
$class = $_SERVER['argv'][2] . "_AllTests";
$suite->addTest($class::suite());
} else {
$suite->addTest(FormatConvertData_AllTests::suite());
$suite->addTest(SoftwareUpdate_AllTests::suite());
$suite->addTest(AgentChangeDeviceid_AllTests::suite());
$suite->addTest(ComputerTransformation_AllTests::suite());
$suite->addTest(ComputerUpdate_AllTests::suite());
$suite->addTest(PrinterTransformation_AllTests::suite());
$suite->addTest(PrinterUpdate_AllTests::suite());
$suite->addTest(NetworkEquipmentTransformation_AllTests::suite());
$suite->addTest(NetworkEquipmentUpdate_AllTests::suite());
$suite->addTest(NetworkEquipmentUpdateDiscovery_AllTests::suite());
$suite->addTest(ComputerLog_AllTests::suite());
$suite->addTest(ComputerEntity_AllTests::suite());
$suite->addTest(RuleIgnoredImport_AllTests::suite());
$suite->addTest(RuleImport_AllTests::suite());
$suite->addTest(SoftwareEntityCreation_AllTests::suite());
$suite->addTest(SoftwareVersionAdd_AllTests::suite());
$suite->addTest(ComputerDynamic_AllTests::suite());
$suite->addTest(UnmanagedManaged_AllTests::suite());
$suite->addTest(UnmanagedImport_AllTests::suite());
//$suite->addTest(TaskDeployDynamicGroup_AllTests::suite());
$suite->addTest(ComputerPrinter_AllTests::suite());
$suite->addTest(ComputerLicense_AllTests::suite());
$suite->addTest(NetworkEquipmentLLDP_AllTests::suite());
$suite->addTest(ComputerMonitor_AllTests::suite());
$suite->addTest(ComputerPeripheral_AllTests::suite());
}
# For travis-CI
file_put_contents("result.stamp", "test ok");
return $suite;
}
示例15: loadLanguage
/**
* Include the good language dict.
*
* Get the default language from current user in $_SESSION["glpilanguage"].
* And load the dict that correspond.
*
* @param $forcelang Force to load a specific lang (default '')
*
* @return nothing (make an include)
**/
static function loadLanguage($forcelang = '')
{
global $LANG, $CFG_GLPI, $TRANSLATE;
$file = "";
if (!isset($_SESSION["glpilanguage"])) {
if (isset($CFG_GLPI["language"])) {
// Default config in GLPI >= 0.72
$_SESSION["glpilanguage"] = $CFG_GLPI["language"];
} else {
if (isset($CFG_GLPI["default_language"])) {
// Default config in GLPI < 0.72 : keep it for upgrade process
$_SESSION["glpilanguage"] = $CFG_GLPI["default_language"];
} else {
$_SESSION["glpilanguage"] = "en_GB";
}
}
}
$trytoload = $_SESSION["glpilanguage"];
// Force to load a specific lang
if (!empty($forcelang)) {
$trytoload = $forcelang;
}
// If not set try default lang file
if (empty($trytoload)) {
$trytoload = $CFG_GLPI["language"];
}
if (isset($CFG_GLPI["languages"][$trytoload])) {
$newfile = "/locales/" . $CFG_GLPI["languages"][$trytoload][1];
}
if (empty($newfile) || !is_file(GLPI_ROOT . $newfile)) {
$newfile = "/locales/en_GB.mo";
}
$TRANSLATE = new Zend\I18n\Translator\Translator();
try {
$cache = Zend\Cache\StorageFactory::factory(array('adapter' => 'apc'));
$TRANSLATE->setCache($cache);
} catch (Zend\Cache\Exception\ExtensionNotLoadedException $e) {
// ignore when APC not available
// toolbox::logDebug($e->getMessage());
}
$TRANSLATE->addTranslationFile('gettext', GLPI_ROOT . $newfile, 'glpi', $trytoload);
// Test APC version, if is enable with special check for cli
// if (version_compare(phpversion('apc'), '3.1.6') >= 0
// && ini_get('apc.enabled')
// && (!isCommandLine() || ini_get('apc.enable_cli'))) { // Try from APC cache
//// $key = "glpi".sha1_file(GLPI_ROOT.$newfile); // Use content to detect changes
// $cache = Zend\Cache\StorageFactory::factory(array('adapter' => 'apc',
// 'plugins' => array('exception_handler'
// => array('throw_exceptions'
// => false))));
// $TRANSLATE->setCache($cache);
// $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
//
// } else if (function_exists('xcache_get') && !isCommandLine()) { // Try from XCache
// // TODO : use xcache adapter of Zend when available (2.1)
// // see http://framework.zend.com/issues/browse/ZF2-543
// $key = "glpi".sha1_file(GLPI_ROOT.$newfile); // Use content to detect changes
// if (@xcache_isset($key)) {
// $TRANSLATE = unserialize(xcache_get($key));
// }
// if (!$TRANSLATE) {
// $TRANSLATE = new Zend\I18n\Translator\Translator;
// $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
// }
// $tmp = xcache_set($key, serialize($TRANSLATE));
// } else {
// $TRANSLATE = new Zend\I18n\Translator\Translator;
// $TRANSLATE->addTranslationFile('gettext', GLPI_ROOT.$newfile, 'glpi', $trytoload);
// }
// Load plugin dicts
if (isset($_SESSION['glpi_plugins']) && is_array($_SESSION['glpi_plugins'])) {
if (count($_SESSION['glpi_plugins'])) {
foreach ($_SESSION['glpi_plugins'] as $plug) {
Plugin::loadLang($plug, $forcelang, $trytoload);
}
}
}
// TRANSLATION_MODE deleted : maybe find another solution ?
// Debug display lang element with item
// if ($_SESSION['glpi_use_mode'] == Session::TRANSLATION_MODE && $CFG_GLPI["debug_lang"]) {
// foreach ($LANG as $module => $tab) {
// foreach ($tab as $num => $val) {
// $LANG[$module][$num] = "".$LANG[$module][$num].
// "/<span style='font-size:12px; color:red;'>$module/$num</span>";
// }
// }
// }
$TRANSLATE->setLocale($trytoload);
return $trytoload;
}