Welcome to mirror list, hosted at ThFree Co, Russian Federation.

openads_piwik_plugin.php « openads_integration « misc - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bd956c5db48c57f72da2f56e6781eec27b7884f6 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php

class Piwik_Openads_Plugin
{
	/**
	 * Returns an array associating the hook name to the method to call
	 * 
	 * @return array array("hookToListenTo" => "methodNameToTrigger")
	 */
	function getListHooksRegistered()
	{
		return array(
			// publishers
			"openAds.insertPublisher" => "insertWebsite",
			"openAds.deletePublisher" => "deleteWebsite",
			"openAds.updatePublisher" => "updateWebsite",
			
			// users
			"openAds.insertPublisher" => "insertUser",
			"openAds.insertPublisher" => "deleteUser",
			"openAds.updatePublisher" => "updateUser",

		);
	}
	
	/**
	 * Methods triggered on the Openads DLL events
	 */
	 
	 /**
	  * Website methods
	  * 
	  * Information necessary:
	  * - publisher name
	  * - publisher ID
	  * - publisher main URL 
	  */
//	function insertWebsite( $parameters )
//	function deleteWebsite( $parameters )
//	function updateWebsite( $parameters )


	 /**
	  * User methods
	  * 
	  * Information necessary:
	  * - user login
	  * - user email
	  * 
	  * Information optional
	  * - user real name
	  */
//	function insertUser( $parameters )
//	function deleteUser( $parameters )
//	function updateUser( $parameters )
	
	
	/**
	 * Function called statically within Piwik at the end of the installation process
	 * 
	 * Returns a value from the Openads config file.
	 * This function is called either from openads or it can be called from piwik directly, 
	 * without the Openads initialization process.
	 * So this function must load the config file if it is not already loaded.
	 * 
	 * @param string Name of the config variable to return
	 * @param string Optional category name containing the config variable to return
	 * 
	 * @return string
	 * 
	 * -------------------------
	 * Example:
	 *  
	 * #config file
	 * [adminPlugins]
	 * piwik = piwik/example.php
	 * 
	 * Piwik_Openads_Plugin::getOpenadsConfigurationValue('piwik', 'adminPlugins') returns 'piwik/example.php'
	 * 
	 */
	function getOpenadsConfigurationValue($valueName, $valueCategory = null)
	{
		
	}
	
	
	/**
	 * 
	 * Function called statically within Piwik at the end of the installation process
	 * 
	 * Set a value from the Openads config file.
	 * This function is called either from openads or it can be called from piwik directly, 
	 * without the Openads initialization process.
	 * So this function must load the config file if it is not already loaded.
	 * 
	 * @param string Name of the value to set
	 * @param string Optional category name containing the config var to return
	 * 
	 * @return string
	 * 
	 * -------------------------
	 * Example:
	 * Piwik_Openads_Plugin::setOpenadsConfigurationValue('adminPlugins', 'piwik', 'piwik/example.php') 
	 * add the following lines in the configuration file (or modify the existing value for this variable)
	 *  
	 * [adminPlugins]
	 * piwik = piwik/example.php
	 * 
	 * 
	 */
	function setOpenadsConfigurationValue($variableCategory, $variableName, $value)
	{
		
	}
	
	/**
	 * Function called statically within Piwik at the end of the installation process
	 * 
	 * Returns the openads database information
	 * - host
	 * - login
	 * - password
	 * - Database name
	 * 
	 * @return array The array of values array( 
	 * 				'host' => "localhost",
	 *  			'login' => "mysqlUser",
	 * 				'password' => "passwordUser",
	 * 				'database_name' => "openads_db",
	 * );
	 */
	function getOpenadsDatabaseInformation()
	{
		
	}
	
	/**
	 * Function called statically within Piwik at the end of the installation process
	 * Returns the login of the OpenAds super user
	 * 
	 * @return string
	 */
	function getOpenadsSuperUserLogin()
	{
		
	}
	
	/**
	 * Function called statically within Piwik at the end of the installation process.
	 * 
	 * Returns an array containing all the Openads users login & piwik access information
	 * 
	 * This method does the mapping between the openads permission system and piwik permission system
	 * For a given user, we return an array containing, for the list of publishersId, the permission
	 * 
	 * The permission is one of the following value
	 * - view
	 * - admin
	 * 
	 * The mapping between openads and piwik is as follows
	 * - maps to "view" in piwik
	 * - maps to "admin" in piwik
	 * - maps to No Access in piwik (no access set)
	 * 
	 * Example:
	 * The user 'radek' in Openads is a publisher for the publisherId = 4. 
	 * He is also X for the publisherId = 12
	 * 
	 * "radek" => array( 4 => "view", 12 => "admin") 
	 * 
	 * @return array Returns array( 
	 * 		"loginUser1" => array ( openadsPubliserId_1 => piwikAccessForThisPublisher 
	 * 						),
	 * 		"loginUser2" => array ( openadsPubliserId_34 => piwikAccessForThisPublisher,
	 * 								openadsPubliserId_27 => piwikAccessForThisPublisher ) 
	 *						),
	 * 		)
	 */
	function getAllOpenadsUsersInformation()
	{
		
	}
	
	
	/**
	 * Function called statically within Piwik at the end of the installation process
	 * 
	 * Returns an array containing all the Openads websites ID & main Url
	 * 
	 * @return array Returns array( 
	 * 		array('id' => 1, 'url'  => 'http://www.example.com')
	 * 		array('id' => 65, 'url' => 'http://www.example2.com') 
	 * )
	 */
	function getAllOpenadsWebsitesInformation()
	{
		
	}
	
	
	/**
	 * Function called statically within Piwik when trying to authenticate the user
	 * 
	 * Returns the current logged OpenAds user
	 * 
	 * @return string User login of the currently logged user. 
	 * 				  Returns empty string if no user is authenticated.
	 * 
	 */
	function getCurrentlyAuthenticatedUserLogin()
	{
		phpAds_getUserID()
	}
	 
	/**
	 * Redirect the current page to the Piwik/index.php if we find the files
	 * - Piwik/index.php
	 * - Piwik/plugins/OpenadsIntegration.php
	 * 
	 * If we don't find the files we display a nice message explaining what to do to the users
	 * - We tell them where to download the package with the openads plugin
	 * - Once they have uploaded the package on this server, 
	 *   they give us the path to the package.
	 * - We save this path in the openads configuration file 
	 * - We redirect to this same page so it checks if now the files are available
	 */
	function redirectToPiwikIfAvailable()
	{
		print("redirecting...");
	}
	
}
// if we call this script directly then we call the conditional redirect method
if( basename($_SERVER['PHP_SELF']) == basename(__FILE__))
{
	Piwik_Openads_Plugin::redirectToPiwikIfAvailable();
}

/* 
 * Testing script
 * 
 * - Copy the following line in a testOpenadsPiwik.php
 * - add the require "OpenadsPiwikPlugin.php" that loads Piwik_Openads_Plugin class
 * - execute the script
 * 
 */

/*

$currentUserLogin = Piwik_Openads_Plugin::getCurrentlyAuthenticatedUserLogin();
print("Currently logged user login");
var_dump($currentUserLogin);

$allWebsites = Piwik_Openads_Plugin::getAllOpenadsWebsitesInformation();
print("All openads websites");
var_dump($allWebsites);

$allUsers = Piwik_Openads_Plugin::getAllOpenadsUsersInformation();
print("All openads users + access");
var_dump($allUsers);

$superUserLogin = Piwik_Openads_Plugin::getOpenadsSuperUserLogin();
print("Openads super user login");
var_dump($superUserLogin);

$databaseInformation = Piwik_Openads_Plugin::getOpenadsDatabaseInformation();
print("Database information");
var_dump($databaseInformation);

Piwik_Openads_Plugin::setOpenadsConfigurationValue('pluginsToLoad', 'piwik', __FILE__);
$value1 = Piwik_Openads_Plugin::getOpenadsConfigurationValue('piwik', 'pluginsToLoad');
$value2 = Piwik_Openads_Plugin::getOpenadsConfigurationValue('admin', 'webpath');
print("Try to set and get a value");
var_dump($value1);
print("Try get an openads existing value");
var_dump($value2);

*/