aboutsummaryrefslogtreecommitdiff
path: root/mod/translation_editor/lib/hooks.php
blob: 486fb0b7abaa4bc73ff8c5dca4afc4ae10f2dc75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

	function translation_editor_user_hover_menu($hook, $type, $return, $params) {
		$user = $params['entity'];
	
		if (elgg_is_admin_logged_in() && !($user->isAdmin())){
			// TODO: replace with a single toggle editor action?
			if(translation_editor_is_translation_editor($user->getGUID())){
				$url = "action/translation_editor/unmake_translation_editor?user=" . $user->getGUID();
				$title = elgg_echo("translation_editor:action:unmake_translation_editor");
			} else {
				$url = "action/translation_editor/make_translation_editor?user=" . $user->getGUID();
				$title = elgg_echo("translation_editor:action:make_translation_editor");
			}
				
			$item = new ElggMenuItem('translation_editor', $title, $url);
			$item->setSection('admin');
			$item->setConfirmText(elgg_echo("question:areyousure"));
			$return[] = $item;
	
			return $return;
		}
	}

	function translation_editor_actions_hook($hook, $type, $return, $params){
		$allowed_actions = array(
			"admin/plugins/activate",
			"admin/plugins/deactivate",
			"admin/plugins/activate_all",
			"admin/plugins/deactivate_all",
			"admin/plugins/set_priority",
			"upgrading" // not actualy an action but comes from events.php
		);
		
		if(!empty($type) && in_array($type, $allowed_actions)){
			// make sure we have all translations
			translation_editor_reload_all_translations();
			
			if($languages = get_installed_translations()){
				foreach($languages as $key => $desc){
					remove_private_setting(elgg_get_site_entity()->getGUID(), "te_last_update_" . $key);
				}
			}
		}
	}