/** * Remove mreporting notifications from GLPI. * * @return array 'success' => true on success */ static function uninstall() { global $DB; $queries = array(); // Remove NotificationTargets and Notifications $notification = new Notification(); $result = $notification->find("itemtype = 'PluginMreportingNotification'"); foreach ($result as $row) { $notification_id = $row['id']; $queries[] = "DELETE FROM glpi_notificationtargets \n WHERE notifications_id = " . $notification_id; $queries[] = "DELETE FROM glpi_notifications \n WHERE id = " . $notification_id; } // Remove NotificationTemplateTranslations and NotificationTemplates $template = new NotificationTemplate(); $result = $template->find("itemtype = 'PluginMreportingNotification'"); foreach ($result as $row) { $template_id = $row['id']; $queries[] = "DELETE FROM glpi_notificationtemplatetranslations \n WHERE notificationtemplates_id = " . $template_id; $queries[] = "DELETE FROM glpi_notificationtemplates \n WHERE id = " . $template_id; } foreach ($queries as $query) { $DB->query($query); } return array('success' => true); }
/** * Raise a notification event event * * @param $event the event raised for the itemtype * @param $item the object which raised the event * @param $options array options used * @param $label used for debugEvent() **/ static function raiseEvent($event, $item, $options = array(), $label = '') { global $CFG_GLPI; //If notifications are enabled in GLPI's configuration if ($CFG_GLPI["use_mailing"]) { $email_processed = array(); $email_notprocessed = array(); //Get template's informations $template = new NotificationTemplate(); $notificationtarget = NotificationTarget::getInstance($item, $event, $options); $entity = $notificationtarget->getEntity(); //Foreach notification foreach (Notification::getNotificationsByEventAndType($event, $item->getType(), $entity) as $data) { $targets = getAllDatasFromTable('glpi_notificationtargets', 'notifications_id = ' . $data['id']); $notificationtarget->clearAddressesList(); //Process more infos (for example for tickets) $notificationtarget->addAdditionnalInfosForTarget(); $template->getFromDB($data['notificationtemplates_id']); $template->resetComputedTemplates(); //Set notification's signature (the one which corresponds to the entity) $template->setSignature(Notification::getMailingSignature($entity)); //Foreach notification targets foreach ($targets as $target) { //Get all users affected by this notification $notificationtarget->getAddressesByTarget($target, $options); foreach ($notificationtarget->getTargets() as $user_email => $users_infos) { if ($label || $notificationtarget->validateSendTo($users_infos)) { //If the user have not yet been notified if (!isset($email_processed[$users_infos['language']][$users_infos['email']])) { //If ther user's language is the same as the template's one if (isset($email_notprocessed[$users_infos['language']][$users_infos['email']])) { unset($email_notprocessed[$users_infos['language']][$users_infos['email']]); } if ($template->getTemplateByLanguage($notificationtarget, $users_infos, $event, $options)) { //Send notification to the user if ($label == '') { Notification::send($template->getDataToSend($notificationtarget, $users_infos, $options)); } else { $notificationtarget->getFromDB($target['id']); echo "<tr class='tab_bg_2'><td>" . $label . "</td>"; echo "<td>" . $notificationtarget->getNameID() . "</td>"; echo "<td>" . $template->getName() . " (" . $users_infos['language'] . ")</td>"; echo "<td>" . $users_infos['email'] . "</td>"; echo "</tr>"; } $email_processed[$users_infos['language']][$users_infos['email']] = $users_infos; } else { $email_notprocessed[$users_infos['language']][$users_infos['email']] = $users_infos; } } } } } } } unset($email_processed); unset($email_notprocessed); $template = null; return true; }
static function postClone(NotificationTemplate $clone, $oldid) { global $DB; $trad = new NotificationTemplateTranslation(); $fkey = getForeignKeyFieldForTable($clone->getTable()); $crit = array($fkey => $oldid); foreach ($DB->request($trad->getTable(), $crit) as $data) { unset($data['id']); $data[$fkey] = $clone->getID(); $trad->add(Toolbox::addslashes_deep($data)); } }
function plugin_consumables_uninstall() { global $DB; include_once GLPI_ROOT . "/plugins/consumables/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/consumables/inc/menu.class.php"; $tables = array("glpi_plugin_consumables_profiles", "glpi_plugin_consumables_requests"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $options = array('itemtype' => 'PluginConsumablesRequest', 'event' => 'ConsumableRequest', 'FIELDS' => 'id'); $notif = new Notification(); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginConsumablesRequest', 'event' => 'ConsumableResponse', 'FIELDS' => 'id'); $notif = new Notification(); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginConsumablesRequest', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } // Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginConsumablesProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginConsumablesMenu::removeRightsFromSession(); PluginConsumablesProfile::removeRightsFromSession(); return true; }
public static function install() { $notifications = array('plugin_formcreator_form_created' => array('name' => __('A form has been created', 'formcreator'), 'subject' => __('Your request have been saved', 'formcreator'), 'content' => __('Hi,\\nYour request from GLPI have been successfully saved with number ##formcreator.request_id## and transmetted to the helpdesk team.\\nYou can see your answers onto the following link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_need_validation' => array('name' => __('A form need to be validate', 'formcreator'), 'subject' => __('A form from GLPI need to be validate', 'formcreator'), 'content' => __('Hi,\\nA form from GLPI need to be validate and you have been choosen as the validator.\\nYou can access it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::APPROVER), 'plugin_formcreator_refused' => array('name' => __('The form is refused', 'formcreator'), 'subject' => __('Your form have been refused by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your form have been refused by the validator for the reason below:\\n##formcreator.validation_comment##\\n\\nYou can still modify and resubmit it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_accepted' => array('name' => __('The form is accepted', 'formcreator'), 'subject' => __('Your form have been accepted by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are pleased to inform you that your form have been accepted by the validator.\\nYour request will be considered soon.', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_deleted' => array('name' => __('The form is deleted', 'formcreator'), 'subject' => __('Your form have been deleted by an administrator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your request cannot be considered and have been deleted by an administrator.', 'formcreator'), 'notified' => self::AUTHOR)); // Create the notification template $notification = new Notification(); $notification_target = new NotificationTarget(); $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); foreach ($notifications as $event => $datas) { // Check if notification allready exists $exists = $notification->find("itemtype = 'PluginFormcreatorFormanswer' AND event = '{$event}'"); // If it doesn't exists, create it if (count($exists) == 0) { $template_id = $template->add(array('name' => addslashes($datas['name']), 'comment' => '', 'itemtype' => 'PluginFormcreatorFormanswer')); // Add a default translation for the template $translation->add(array('notificationtemplates_id' => $template_id, 'language' => '', 'subject' => addslashes($datas['subject']), 'content_text' => addslashes($datas['content']), 'content_html' => '<p>' . str_replace('\\n', '<br />', $datas['content']) . '</p>')); // Create the notification $notification_id = $notification->add(array('name' => addslashes($datas['name']), 'comment' => '', 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'itemtype' => 'PluginFormcreatorFormanswer', 'notificationtemplates_id' => $template_id, 'event' => $event, 'mode' => 'mail')); // Add default notification targets $notification_target->add(array("items_id" => $datas['notified'], "type" => Notification::USER_TYPE, "notifications_id" => $notification_id)); } } }
function plugin_accounts_uninstall() { global $DB; include_once GLPI_ROOT . "/plugins/accounts/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/accounts/inc/menu.class.php"; $tables = array("glpi_plugin_accounts_accounts", "glpi_plugin_accounts_accounts_items", "glpi_plugin_accounts_accounttypes", "glpi_plugin_accounts_accountstates", "glpi_plugin_accounts_configs", "glpi_plugin_accounts_hashs", "glpi_plugin_accounts_hashes", "glpi_plugin_accounts_aeskeys", "glpi_plugin_accounts_notificationstates"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_comptes", "glpi_plugin_compte_device", "glpi_dropdown_plugin_compte_type", "glpi_dropdown_plugin_compte_status", "glpi_plugin_compte_profiles", "glpi_plugin_compte_config", "glpi_plugin_compte_default", "glpi_plugin_compte_mailing", "glpi_plugin_compte", "glpi_plugin_compte_hash", "glpi_plugin_compte_aeskey", "glpi_plugin_accounts_profiles"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'new', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'ExpiredAccounts', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'AccountsWhichExpire', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAccountsAccount', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_dropdowntranslations"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}`\n WHERE `itemtype` = 'PluginAccountsAccount'\n OR `itemtype` = 'PluginAccountsHelpdesk'\n OR `itemtype` = 'PluginAccountsGroup'\n OR `itemtype` = 'PluginAccountsAccountState'\n OR `itemtype` = 'PluginAccountsAccountType' ;"); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginAccountsAccount')); } //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginAccountsProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginAccountsProfile::removeRightsFromSession(); PluginAccountsMenu::removeRightsFromSession(); return true; }
$language = new NotificationTemplateTranslation(); if (isset($_POST["add"])) { $language->check(-1, CREATE, $_POST); $newID = $language->add($_POST); Event::log($newID, "notificationtemplatetranslations", 4, "notification", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["language"])); Html::back(); } else { if (isset($_POST["purge"])) { $language->check($_POST["id"], PURGE); $language->delete($_POST, 1); Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $language->redirectToList(); } else { if (isset($_POST["update"])) { $language->check($_POST["id"], UPDATE); $language->update($_POST); Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header(NotificationTemplate::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "notification", "notificationtemplate"); if ($_GET["id"] == '') { $options = array("notificationtemplates_id" => $_GET["notificationtemplates_id"]); } else { $options = array(); } $options['id'] = $_GET["id"]; $language->display($options); Html::footer(); } } }
function plugin_certificates_uninstall() { global $DB; include_once (GLPI_ROOT."/plugins/certificates/inc/profile.class.php"); include_once (GLPI_ROOT."/plugins/certificates/inc/menu.class.php"); $tables = array("glpi_plugin_certificates_certificates", "glpi_plugin_certificates_certificates_items", "glpi_plugin_certificates_certificatetypes", "glpi_plugin_certificates_certificatestates", "glpi_plugin_certificates_configs", "glpi_plugin_certificates_notificationstates"); foreach($tables as $table) $DB->query("DROP TABLE IF EXISTS `$table`;"); //old versions $tables = array("glpi_plugin_certificates", "glpi_plugin_certificates_profiles", "glpi_plugin_certificates_device", "glpi_dropdown_plugin_certificates_type", "glpi_dropdown_plugin_certificates_status", "glpi_plugin_certificates_config", "glpi_plugin_certificates_mailing", "glpi_plugin_certificates_default"); foreach($tables as $table) $DB->query("DROP TABLE IF EXISTS `$table`;"); $notif = new Notification(); $options = array('itemtype' => 'PluginCertificatesCertificate', 'event' => 'ExpiredCertificates', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginCertificatesCertificate', 'event' => 'CertificatesWhichExpire', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginCertificatesCertificate', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets", "glpi_contracts_items", "glpi_notepads"); foreach($tables_glpi as $table_glpi) $DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` = 'PluginCertificatesCertificate';"); //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginCertificatesProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginCertificatesMenu::removeRightsFromSession(); PluginCertificatesProfile::removeRightsFromSession(); return true; }
function plugin_badges_uninstall() { global $DB; include_once GLPI_ROOT . "/plugins/badges/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/badges/inc/menu.class.php"; $tables = array("glpi_plugin_badges_badges", "glpi_plugin_badges_badgetypes", "glpi_plugin_badges_configs", "glpi_plugin_badges_notificationstates", "glpi_plugin_badges_requests"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_badges", "glpi_dropdown_plugin_badges_type", "glpi_plugin_badges_users", "glpi_plugin_badges_profiles", "glpi_plugin_badges_config", "glpi_plugin_badges_mailing", "glpi_plugin_badges_default"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'ExpiredBadges', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'BadgesWhichExpire', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'BadgesReturn', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'AccessBadgeRequest', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginBadgesBadge', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_notepads", "glpi_dropdowntranslations"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` LIKE 'PluginBadges%';"); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginBadgesBadge')); } CronTask::Unregister('PluginBadgesReturn'); //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginBadgesProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginBadgesMenu::removeRightsFromSession(); PluginBadgesProfile::removeRightsFromSession(); return true; }
function showForm($ID, $options = array()) { global $LANG, $CFG_GLPI; if (!haveRight("notification", "r")) { return false; } if ($ID > 0) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . " :</td>"; echo "<td>"; autocompletionTextField($this, "name"); echo "</td>"; echo "<td rowspan='6' class='middle right'>" . $LANG['common'][25] . " :</td>"; echo "<td class='center middle' rowspan='6'><textarea cols='45' rows='9' name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['common'][60] . " :</td>"; echo "<td>"; Dropdown::showYesNo('is_active', $this->fields['is_active']); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['common'][17] . " :</td>"; echo "<td>"; if (haveRight('config', 'w') && $this->getEntityID() == 0) { $rand = Dropdown::dropdownTypes("itemtype", $this->fields['itemtype'], $CFG_GLPI["notificationtemplates_types"]); } else { $rand = Dropdown::dropdownTypes("itemtype", $this->fields['itemtype'], array_diff($CFG_GLPI["notificationtemplates_types"], array('Crontask', 'DBConnection'))); } $params = array('itemtype' => '__VALUE__'); ajaxUpdateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_events", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationEvent.php", $params); ajaxUpdateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_templates", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationTemplate.php", $params); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][120] . " :</td>"; echo "<td>"; self::dropdownMode($this->fields['mode']); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][119] . " :</td>"; echo "<td><span id='show_events'>"; NotificationEvent::dropdownEvents($this->fields['itemtype'], $this->fields['event']); echo "</span></td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][113] . " :</td>"; echo "<td><span id='show_templates'>"; NotificationTemplate::dropdownTemplates('notificationtemplates_id', $this->fields['itemtype'], $this->fields['notificationtemplates_id']); echo "</span></td></tr>"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
public static function uninstall() { global $DB; $notif = new Notification(); foreach (array('ask', 'validation', 'cancel', 'undovalidation', 'duedate', 'delivered') as $event) { $options = array('itemtype' => 'PluginOrderOrder', 'event' => $event, 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginOrderOrder', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } }
function plugin_projet_uninstall() { global $DB; $tables = array("glpi_plugin_projet_projets", "glpi_plugin_projet_projetstates", "glpi_plugin_projet_projets_items", "glpi_plugin_projet_projets_projets", "glpi_plugin_projet_tasks", "glpi_plugin_projet_tasks_items", "glpi_plugin_projet_taskstates", "glpi_plugin_projet_tasktypes", "glpi_plugin_projet_taskplannings", "glpi_plugin_projet_tasks_tasks", "glpi_plugin_projet_profiles", "glpi_plugin_projet_followups"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $oldtables = array("glpi_plugin_projet", "glpi_plugin_projet_items", "glpi_plugin_projet_tasks", "glpi_plugin_projet_tasks_items", "glpi_dropdown_plugin_projet_tasks_type", "glpi_plugin_projet_mailing", "glpi_dropdown_plugin_projet_status", "glpi_dropdown_plugin_projet_task_status", "glpi_plugin_project", "glpi_plugin_project_items", "glpi_plugin_project_tasks", "glpi_plugin_project_tasks_items", "glpi_dropdown_plugin_project_status", "glpi_dropdown_plugin_project_tasks_type", "glpi_dropdown_plugin_project_task_status", "glpi_plugin_project_mailing", "glpi_plugin_project_profiles", "glpi_plugin_project_users", "glpi_plugin_project_setup", "glpi_plugin_project_groups", "glpi_plugin_project_items", "glpi_plugin_project_enterprises", "glpi_plugin_project_contracts", "glpi_plugin_project_documents", "glpi_dropdown_project_tasks_type", "glpi_project", "glpi_project_tasks", "glpi_project_user", "glpi_project_items", "glpi_plugin_projet_projetitems", "glpi_plugin_projet_mailings", "glpi_plugin_projet_taskitems"); foreach ($oldtables as $oldtable) { $DB->query("DROP TABLE IF EXISTS `{$oldtable}`;"); } $rep_files_projet = GLPI_PLUGIN_DOC_DIR . "/projet"; Toolbox::deleteDir($rep_files_projet); $in = "IN (" . implode(',', array("'PluginProjetProjet'", "'PluginProjetTask'")) . ")"; $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_contracts_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables as $table) { $query = "DELETE FROM `{$table}` WHERE (`itemtype` " . $in . " ) "; $DB->query($query); } $notif = new Notification(); $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'new', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'update', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'delete', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'newtask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'updatetask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginProjetProjet', 'event' => 'deletetask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginProjetProjet', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } return true; }
function plugin_accounts_uninstall() { global $DB; $tables = array("glpi_plugin_accounts_accounts", "glpi_plugin_accounts_accounts_items", "glpi_plugin_accounts_accounttypes", "glpi_plugin_accounts_accountstates", "glpi_plugin_accounts_profiles", "glpi_plugin_accounts_configs", "glpi_plugin_accounts_hashs", "glpi_plugin_accounts_hashes", "glpi_plugin_accounts_aeskeys", "glpi_plugin_accounts_notificationstates"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_comptes", "glpi_plugin_compte_device", "glpi_dropdown_plugin_compte_type", "glpi_dropdown_plugin_compte_status", "glpi_plugin_compte_profiles", "glpi_plugin_compte_config", "glpi_plugin_compte_default", "glpi_plugin_compte_mailing", "glpi_plugin_compte", "glpi_plugin_compte_hash", "glpi_plugin_compte_aeskey"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'new', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'ExpiredAccounts', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'AccountsWhichExpire', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAccountsAccount', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}`\n WHERE `itemtype` = 'PluginAccountsAccount'\n OR `itemtype` = 'PluginAccountsHelpdesk'\n OR `itemtype` = 'PluginAccountsGroup' ;"); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginAccountsAccount')); } return true; }
function plugin_additionalalerts_uninstall() { global $DB; $tables = array("glpi_plugin_additionalalerts_ocsalerts", "glpi_plugin_additionalalerts_infocomalerts", "glpi_plugin_additionalalerts_notificationstates", "glpi_plugin_additionalalerts_notificationtypes", "glpi_plugin_additionalalerts_profiles", "glpi_plugin_additionalalerts_configs"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_additionalalerts_reminderalerts", "glpi_plugin_alerting_config", "glpi_plugin_alerting_state", "glpi_plugin_alerting_profiles", "glpi_plugin_alerting_mailing", "glpi_plugin_alerting_type"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'event' => 'ocs', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'event' => 'newocs', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAdditionalalertsInfocomAlert', 'event' => 'notinfocom', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAdditionalalertsInfocomAlert', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } return true; }
/** * Display notification registered for a group * * @since version 0.83 * * @param $group Group object * * @return nothing **/ static function showForGroup(Group $group) { global $DB; if (!Notification::canView()) { return false; } $sql = "SELECT `glpi_notifications`.`id`\n FROM `glpi_notificationtargets`\n INNER JOIN `glpi_notifications`\n ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)\n WHERE `items_id` = '" . $group->getID() . "'\n AND (`type` = '" . Notification::SUPERVISOR_GROUP_TYPE . "'\n OR `type` = '" . Notification::GROUP_TYPE . "') " . getEntitiesRestrictRequest('AND', 'glpi_notifications', '', '', true); $req = $DB->request($sql); echo "<table class='tab_cadre_fixe'>"; if ($req->numrows()) { echo "<tr><th>" . __('Name') . "</th>"; echo "<th>" . Entity::getTypeName(1) . "</th>"; echo "<th>" . __('Active') . "</th>"; echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Notification method') . "</th>"; echo "<th>" . NotificationEvent::getTypeName(1) . "</th>"; echo "<th>" . NotificationTemplate::getTypeName(1) . "</th></tr>"; $notif = new Notification(); Session::initNavigateListItems('Notification', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName())); foreach ($req as $data) { Session::addToNavigateListItems('Notification', $data['id']); if ($notif->getFromDB($data['id'])) { echo "<tr class='tab_bg_2'><td>" . $notif->getLink(); echo "</td><td>" . Dropdown::getDropdownName('glpi_entities', $notif->getEntityID()); echo "</td><td>" . Dropdown::getYesNo($notif->getField('is_active')) . "</td><td>"; $itemtype = $notif->getField('itemtype'); if ($tmp = getItemForItemtype($itemtype)) { echo $tmp->getTypeName(1); } else { echo " "; } echo "</td><td>" . Notification::getMode($notif->getField('mode')); echo "</td><td>" . NotificationEvent::getEventName($itemtype, $notif->getField('event')); echo "</td>" . "<td>" . Dropdown::getDropdownName('glpi_notificationtemplates', $notif->getField('notificationtemplates_id')); echo "</td></tr>"; } } } else { echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>"; } echo "</table>"; }
/** * @return bool */ function plugin_ocsinventoryng_uninstall() { global $DB; include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/ocsinventoryng/inc/menu.class.php"; $tables = array("glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_threads", "glpi_plugin_ocsinventoryng_snmpocslinks", "glpi_plugin_ocsinventoryng_ipdiscoverocslinks", "glpi_plugin_ocsinventoryng_servers", "glpi_plugin_ocsinventoryng_configs", "glpi_plugin_ocsinventoryng_notimportedcomputers", "glpi_plugin_ocsinventoryng_details", "glpi_plugin_ocsinventoryng_registrykeys", "glpi_plugin_ocsinventoryng_networkports", "glpi_plugin_ocsinventoryng_networkporttypes", "glpi_plugin_ocsinventoryng_ocsservers_profiles", "glpi_plugin_ocsinventoryng_devicebiosdatas", "glpi_plugin_ocsinventoryng_items_devicebiosdatas"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $tables_glpi = array("glpi_bookmarks", "glpi_displaypreferences", "glpi_logs"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE\r\n FROM `" . $table_glpi . "`\r\n WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n 'PluginMassocsimportDetail',\r\n 'PluginOcsinventoryngOcsServer',\r\n 'PluginOcsinventoryngNotimportedcomputer',\r\n 'PluginOcsinventoryngDetail')"); } $tables_ocs = array("ocs_glpi_crontasks", "ocs_glpi_displaypreferences", "ocs_glpi_ocsadmininfoslinks", "ocs_glpi_ocslinks", "ocs_glpi_ocsservers", "ocs_glpi_registrykeys", "ocs_glpi_profiles"); foreach ($tables_ocs as $table_ocs) { $DB->query("DROP TABLE IF EXISTS `{$table_ocs}`;"); } $tables_mass = array("backup_glpi_plugin_massocsimport_configs", "backup_glpi_plugin_massocsimport_details", "backup_glpi_plugin_massocsimport_notimported", "backup_glpi_plugin_massocsimport_servers", "backup_glpi_plugin_massocsimport_threads"); foreach ($tables_mass as $table_mass) { $DB->query("DROP TABLE IF EXISTS `{$table_mass}`;"); } $query = "DELETE\r\n FROM `glpi_alerts`\r\n WHERE `itemtype` IN ('PluginMassocsimportNotimported',\r\n 'PluginOcsinventoryngNotimportedcomputer')"; $DB->queryOrDie($query, $DB->error()); // clean rules $rule = new RuleImportEntity(); foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity')) as $data) { $rule->delete($data); } $rule = new RuleImportComputer(); foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportComputer')) as $data) { $rule->delete($data); } $notification = new Notification(); foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n 'PluginOcsinventoryngNotimportedcomputer')") as $data) { $notification->delete($data); } $template = new NotificationTemplate(); foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\r\n 'PluginOcsinventoryngNotimportedcomputer')") as $data) { $template->delete($data); } $cron = new CronTask(); if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) { CronTask::Unregister('massocsimport'); CronTask::Unregister('CleanOldThreads'); } if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'ocsng')) { CronTask::Unregister('ocsinventoryng'); CronTask::Unregister('ocsng'); } if ($cron->getFromDBbyName('PluginOcsinventoryngNotimportedcomputer', 'SendAlerts')) { CronTask::Unregister('SendAlerts'); } if ($cron->getFromDBbyName('PluginOcsinventoryngOcsServer', 'CleanOldAgents')) { CronTask::Unregister('CleanOldAgents'); } //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginOcsinventoryngProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginOcsinventoryngMenu::removeRightsFromSession(); PluginOcsinventoryngProfile::removeRightsFromSession(); return true; }
function plugin_ideabox_uninstall() { global $DB; $tables = array("glpi_plugin_ideabox_ideaboxs", "glpi_plugin_ideabox_ideaboxes", "glpi_plugin_ideabox_comments", "glpi_plugin_ideabox_profiles"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old tables $tables = array("glpi_plugin_ideabox", "glpi_plugin_ideabox_mailing"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'new', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'update', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'delete', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'newcomment', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'updatecomment', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'deletecomment', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginIdeaboxIdeabox' OR `itemtype` = 'PluginIdeaboxComment';"); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginIdeaboxIdeabox')); } return true; }
function showSummary(NotificationTemplate $template, $options = array()) { global $DB, $LANG, $CFG_GLPI; $nID = $template->getField('id'); $canedit = haveRight("config", "w"); if ($canedit) { echo "<div class='center'>" . "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . $LANG['mailing'][124] . "</a></div><br>"; } echo "<div class='center' id='tabsbody'>"; initNavigateListItems('NotificationTemplateTranslation', $template->getTypeName() . " = " . $template->fields["name"]); echo "<form name='form_language' id='form_language' method='post'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th></th><th>" . $LANG['setup'][41] . "</th></tr>"; foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) { if ($this->getFromDB($data['id'])) { addToNavigateListItems('NotificationTemplateTranslation', $data['id']); echo "<tr class='tab_bg_1'><td class='center'>"; echo "<input type='checkbox' name=\"languages[" . $data['id'] . "]\"></td>"; echo "<td class='center'>"; echo "<a href='" . getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "¬ificationtemplates_id=" . $nID . "'>"; if ($data['language'] != '') { echo $CFG_GLPI['languages'][$data['language']][0]; } else { echo $LANG['mailing'][125]; } echo "</a></td></tr>"; } } echo "</table>"; if ($canedit) { openArrowMassive("form_language", true); closeArrowMassive("delete_languages", $LANG["buttons"][6]); } }
function IGtNotificationTemplateDemo() { $template = new NotificationTemplate(); $template->set_appId(APPID); //应用appid $template->set_appkey(APPKEY); //应用appkey $template->set_transmissionType(1); //透传消息类型 $template->set_transmissionContent("测试离线"); //透传内容 $template->set_title("个推"); //通知栏标题 $template->set_text("个推最新版点击下载"); //通知栏内容 $template->set_logo("http://wwww.igetui.com/logo.png"); //通知栏logo $template->set_isRing(true); //是否响铃 $template->set_isVibrate(true); //是否震动 $template->set_isClearable(true); //通知栏是否可清除 // iOS推送需要设置的pushInfo字段 //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage); //$template ->set_pushInfo("test",1,"message","","","","",""); return $template; }
function plugin_ocsinventoryng_uninstall() { global $DB; $tables = array("glpi_plugin_ocsinventoryng_ocsservers", "glpi_plugin_ocsinventoryng_ocslinks", "glpi_plugin_ocsinventoryng_ocsadmininfoslinks", "glpi_plugin_ocsinventoryng_profiles", "glpi_plugin_ocsinventoryng_threads", "glpi_plugin_ocsinventoryng_servers", "glpi_plugin_ocsinventoryng_configs", "glpi_plugin_ocsinventoryng_notimportedcomputers", "glpi_plugin_ocsinventoryng_details", "glpi_plugin_ocsinventoryng_registrykeys", "glpi_plugin_ocsinventoryng_networkports", "glpi_plugin_ocsinventoryng_networkporttypes"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $tables_glpi = array("glpi_bookmarks", "glpi_displaypreferences", "glpi_documents_items", "glpi_logs", "glpi_tickets"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE\n FROM `" . $table_glpi . "`\n WHERE `itemtype` IN ('PluginMassocsimportNotimported',\n 'PluginMassocsimportDetail',\n 'PluginOcsinventoryngOcsServer',\n 'PluginOcsinventoryngNotimportedcomputer',\n 'PluginOcsinventoryngDetail')"); } $query = "DELETE\n FROM `glpi_alerts`\n WHERE `itemtype` IN ('PluginMassocsimportNotimported',\n 'PluginOcsinventoryngNotimportedcomputer')"; $DB->queryOrDie($query, $DB->error()); // clean rules $rule = new RuleImportEntity(); foreach ($DB->request("glpi_rules", array('sub_type' => 'RuleImportEntity', 'name' => 'RootOcs')) as $data) { $rule->delete($data); } $notification = new Notification(); foreach (getAllDatasFromTable($notification->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\n 'PluginOcsinventoryngNotimportedcomputer')") as $data) { $notification->delete($data); } $template = new NotificationTemplate(); foreach (getAllDatasFromTable($template->getTable(), "`itemtype` IN ('PluginMassocsimportNotimported',\n 'PluginOcsinventoryngNotimportedcomputer')") as $data) { $template->delete($data); } $cron = new CronTask(); if ($cron->getFromDBbyName('PluginMassocsimportThread', 'CleanOldThreads')) { // creation du cron - param = duree de conservation CronTask::Unregister('massocsimport'); } if ($cron->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) { // creation du cron - param = duree de conservation CronTask::Unregister('ocsinventoryng'); } return true; }
function plugin_additionalalerts_uninstall() { global $DB; $tables = array("glpi_plugin_additionalalerts_ocsalerts", "glpi_plugin_additionalalerts_infocomalerts", "glpi_plugin_additionalalerts_notificationstates", "glpi_plugin_additionalalerts_notificationtypes", "glpi_plugin_additionalalerts_configs"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_additionalalerts_reminderalerts", "glpi_plugin_alerting_config", "glpi_plugin_alerting_state", "glpi_plugin_alerting_profiles", "glpi_plugin_alerting_mailing", "glpi_plugin_alerting_type", "glpi_plugin_additionalalerts_profiles"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'event' => 'ocs', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'event' => 'newocs', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginAdditionalalertsInfocomAlert', 'event' => 'notinfocom', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAdditionalalertsOcsAlert', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginAdditionalalertsInfocomAlert', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } //Delete rights associated with the plugin $profileRight = new ProfileRight(); foreach (PluginAdditionalalertsProfile::getAllRights() as $right) { $profileRight->deleteByCriteria(array('name' => $right['field'])); } PluginAdditionalalertsProfile::removeRightsFromSession(); PluginAdditionalalertsMenu::removeRightsFromSession(); return true; }
function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "<td rowspan='6' class='middle right'>" . __('Comments') . "</td>"; echo "<td class='center middle' rowspan='6'><textarea cols='45' rows='9' class='form-control' name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Active') . "</td>"; echo "<td>"; Dropdown::showYesNo('is_active', $this->fields['is_active']); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Type') . "</td>"; echo "<td>"; if (!Session::haveRight(static::$rightname, UPDATE)) { $itemtype = $this->fields['itemtype']; echo $itemtype::getTypeName(1); $rand = ''; } else { if (Config::canUpdate() && $this->getEntityID() == 0) { $rand = Dropdown::showItemTypes('itemtype', $CFG_GLPI["notificationtemplates_types"], array('value' => $this->fields['itemtype'])); } else { $rand = Dropdown::showItemTypes('itemtype', array_diff($CFG_GLPI["notificationtemplates_types"], array('Crontask', 'DBConnection', 'User')), array('value' => $this->fields['itemtype'])); } } $params = array('itemtype' => '__VALUE__'); Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_events", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationEvent.php", $params); Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_templates", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationTemplate.php", $params); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Notification method') . "</td>"; echo "<td>"; self::dropdownMode(array('value' => $this->fields['mode'])); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . NotificationEvent::getTypeName(1) . "</td>"; echo "<td><span id='show_events'>"; NotificationEvent::dropdownEvents($this->fields['itemtype'], array('value' => $this->fields['event'])); echo "</span></td></tr>"; echo "<tr class='tab_bg_1'><td>" . NotificationTemplate::getTypeName(1) . "</td>"; echo "<td><span id='show_templates'>"; NotificationTemplate::dropdownTemplates('notificationtemplates_id', $this->fields['itemtype'], $this->fields['notificationtemplates_id']); echo "</span></td></tr>"; $this->showFormButtons($options); return true; }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkCentralAccess(); if (!isset($_GET["id"])) { $_GET["id"] = ""; } $notificationtemplate = new NotificationTemplate(); if (isset($_POST["add"])) { $notificationtemplate->check(-1, CREATE, $_POST); $newID = $notificationtemplate->add($_POST); Event::log($newID, "notificationtemplates", 4, "notification", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); $language = new NotificationTemplateTranslation(); $url = Toolbox::getItemTypeFormURL('NotificationTemplateTranslation', true); $url .= "?notificationtemplates_id={$newID}"; Html::redirect($url); } else { if (isset($_POST["purge"])) { $notificationtemplate->check($_POST["id"], PURGE); $notificationtemplate->delete($_POST, 1); Event::log($_POST["id"], "notificationtemplates", 4, "notification", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $notificationtemplate->redirectToList(); } else {
You should have received a copy of the GNU General Public License along with GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (!isset($_GET["id"])) { $_GET["id"] = ""; } $notificationtemplate = new NotificationTemplate(); if (isset($_POST["add"])) { $notificationtemplate->check(-1, 'w', $_POST); $newID = $notificationtemplate->add($_POST); Event::log($newID, "notificationtemplates", 4, "notification", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " : " . $_POST["name"] . "."); $language = new NotificationTemplateTranslation(); $url = getItemTypeFormURL('NotificationTemplateTranslation', true); $url .= "?notificationtemplates_id={$newID}"; glpi_header($url); } else { if (isset($_POST["delete"])) { $notificationtemplate->check($_POST["id"], 'd'); $notificationtemplate->delete($_POST); Event::log($_POST["id"], "notificationtemplates", 4, "notification", $_SESSION["glpiname"] . " " . $LANG['log'][22]); $notificationtemplate->redirectToList(); } else {
/** * Display debug information for current object * NotificationTemplateTranslation => translation preview * * @since version 0.84 **/ function showDebug() { $template = new NotificationTemplate(); if (!$template->getFromDB($this->fields['notificationtemplates_id'])) { return; } $itemtype = $template->getField('itemtype'); if (!($item = getItemForItemtype($itemtype))) { return; } echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . __('Preview') . "</th></tr>"; $oktypes = array('CartridgeItem', 'Change', 'ConsumableItem', 'Contract', 'Crontask', 'Problem', 'Project', 'Ticket', 'User'); if (!in_array($itemtype, $oktypes)) { // this itemtype doesn't work, need to be fixed echo "<tr class='tab_bg_2 center'><td>" . NOT_AVAILABLE . "</td>"; echo "</table></div>"; return; } // Criteria Form $key = getForeignKeyFieldForItemType($item->getType()); $id = Session::getSavedOption(__CLASS__, $key, 0); $event = Session::getSavedOption(__CLASS__, $key . '_event', ''); echo "<tr class='tab_bg_2'><td>" . $item->getTypeName(1) . " "; $item->dropdown(array('value' => $id, 'on_change' => 'reloadTab("' . $key . '="+this.value)')); echo "</td><td>" . NotificationEvent::getTypeName(1) . " "; NotificationEvent::dropdownEvents($item->getType(), array('value' => $event, 'on_change' => 'reloadTab("' . $key . '_event="+this.value)')); echo "</td>"; // Preview if ($event && $item->getFromDB($id)) { $options = array('_debug' => true); // TODO Awfull Hack waiting for https://forge.indepnet.net/issues/3439 $multi = array('alert', 'alertnotclosed', 'end', 'notice', 'periodicity', 'periodicitynotice'); if (in_array($event, $multi)) { // Won't work for Cardridge and Consumable $options['entities_id'] = $item->getEntityID(); $options['items'] = array($item->getID() => $item->fields); } $target = NotificationTarget::getInstance($item, $event, $options); $infos = array('language' => $_SESSION['glpilanguage'], 'additionnaloption' => array('usertype' => NotificationTarget::GLPI_USER)); $template->resetComputedTemplates(); $template->setSignature(Notification::getMailingSignature($_SESSION['glpiactive_entity'])); if ($tid = $template->getTemplateByLanguage($target, $infos, $event, $options)) { $data = $template->templates_by_languages[$tid]; echo "<tr><th colspan='2'>" . __('Subject') . "</th></tr>"; echo "<tr class='tab_bg_2 b'><td colspan='2'>" . $data['subject'] . "</td></tr>"; echo "<tr><th>" . __('Email text body') . "</th>"; echo "<th>" . __('Email HTML body') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . nl2br($data['content_text']) . "</td>"; echo "<td>" . $data['content_html'] . "</td></tr>"; } } echo "</table></div>"; }
public static function uninstallOrderItemNotification() { global $DB; $notif = new Notification(); $options = array('itemtype' => 'PluginOrderOrder_Item', 'event' => 'delivered', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); //templates $options = array('itemtype' => 'PluginOrderOrder_Item', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } }
Copyright (C) 2003-2014 by the INDEPNET Development Team. http://indepnet.net/ http://glpi-project.org ------------------------------------------------------------------------- LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("config", "r"); Html::header(NotificationTemplate::getTypeName(2), $_SERVER['PHP_SELF'], "config", "mailing", "notificationtemplate"); Search::show('NotificationTemplate'); Html::footer();
function plugin_domains_uninstall() { global $DB; $tables = array("glpi_plugin_domains_domains", "glpi_plugin_domains_domains_items", "glpi_plugin_domains_domaintypes", "glpi_plugin_domains_profiles", "glpi_plugin_domains_configs", "glpi_plugin_domains_notificationstates"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_domain", "glpi_plugin_domain_device", "glpi_dropdown_plugin_domain_type", "glpi_plugin_domain_profiles", "glpi_plugin_domain_mailing"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $notif = new Notification(); $options = array('itemtype' => 'PluginDomainsDomain', 'event' => 'ExpiredDomains', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginDomainsDomain', 'event' => 'DomainsWhichExpire', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginDomainsDomain', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets", "glpi_contracts_items"); foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginDomainsDomain';"); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginDomainsDomain')); } return true; }
------------------------------------------------------------------------- LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ if (strpos($_SERVER['PHP_SELF'], "dropdownNotificationTemplate.php")) { include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } Session::checkRight("notification", UPDATE); NotificationTemplate::dropdownTemplates('notificationtemplates_id', $_POST['itemtype']);
function plugin_resources_uninstall() { global $DB; $tables = array("glpi_plugin_resources_resources", "glpi_plugin_resources_resources_items", "glpi_plugin_resources_employees", "glpi_plugin_resources_employers", "glpi_plugin_resources_clients", "glpi_plugin_resources_choices", "glpi_plugin_resources_choiceitems", "glpi_plugin_resources_departments", "glpi_plugin_resources_contracttypes", "glpi_plugin_resources_resourcestates", "glpi_plugin_resources_tasktypes", "glpi_plugin_resources_profiles", "glpi_plugin_resources_tasks", "glpi_plugin_resources_taskplannings", "glpi_plugin_resources_tasks_items", "glpi_plugin_resources_checklists", "glpi_plugin_resources_checklistconfigs", "glpi_plugin_resources_reportconfigs", "glpi_plugin_resources_resourcerestings", "glpi_plugin_resources_resourceholidays", "glpi_plugin_resources_ticketcategories", "glpi_plugin_resources_resourcesituations", "glpi_plugin_resources_contractnatures", "glpi_plugin_resources_ranks", "glpi_plugin_resources_resourcespecialities", "glpi_plugin_resources_leavingreasons", "glpi_plugin_resources_professions", "glpi_plugin_resources_professionlines", "glpi_plugin_resources_professioncategories", "glpi_plugin_resources_employments", "glpi_plugin_resources_employmentstates", "glpi_plugin_resources_budgets", "glpi_plugin_resources_costs", "glpi_plugin_resources_budgettypes", "glpi_plugin_resources_budgetvolumes"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } //old versions $tables = array("glpi_plugin_resources", "glpi_plugin_resources_device", "glpi_plugin_resources_needs", "glpi_plugin_resources_employee", "glpi_dropdown_plugin_resources_employer", "glpi_dropdown_plugin_resources_client", "glpi_dropdown_plugin_resources_type", "glpi_dropdown_plugin_resources_department", "glpi_dropdown_plugin_resources_tasks_type", "glpi_plugin_resources_mailingsettings", "glpi_plugin_resources_mailing"); foreach ($tables as $table) { $DB->query("DROP TABLE IF EXISTS `{$table}`;"); } $in = "IN (" . implode(',', array("'PluginResourcesResource'", "'PluginResourcesTask'", "'PluginResourcesHelpdesk'", "'PluginResourcesDirectory'", "'PluginResourcesChecklistconfig'", "'PluginResourcesResourceResting'", "'PluginResourcesResourceHoliday'", "'PluginResourcesBudget'", "'PluginResourcesEmployment'", "'PluginResourcesRecap'")) . ")"; $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables as $table) { $query = "DELETE FROM `{$table}` WHERE (`itemtype` " . $in . " ) "; $DB->query($query); } //drop rules $Rule = new Rule(); $a_rules = $Rule->find("`sub_type`='PluginResourcesRuleChecklist'\n OR `sub_type`='PluginResourcesRuleContracttype'"); foreach ($a_rules as $data) { $Rule->delete($data); } $notif = new Notification(); $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'new', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'update', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'delete', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newtask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updatetask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deletetask', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertExpiredTasks', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingResources', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertArrivalChecklists', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingChecklists', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'LeavingResource', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'report', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newresting', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateresting', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteresting', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newholiday', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateholiday', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteholiday', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notifications', $options) as $data) { $notif->delete($data); } //templates $template = new NotificationTemplate(); $translation = new NotificationTemplateTranslation(); $options = array('itemtype' => 'PluginResourcesResource', 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplates', $options) as $data) { $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id'); foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) { $translation->delete($data_template); } $template->delete($data); } if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(array('itemtype' => 'PluginResourcesResource')); PluginDatainjectionModel::clean(array('itemtype' => 'PluginResourcesClient')); } $rep_files_resources = GLPI_PLUGIN_DOC_DIR . "/resources"; Toolbox::deleteDir($rep_files_resources); return true; }