Initial version of the tracking plugin

This commit is contained in:
Christoph Haas 2015-04-13 16:11:52 +00:00
commit accc3e5904
24 changed files with 2609 additions and 0 deletions

View File

@ -0,0 +1 @@
emailtracking

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/emailtracking.iml" filepath="$PROJECT_DIR$/.idea/emailtracking.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="svn" />
</component>
</project>

View File

@ -0,0 +1,619 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BookmarkManager">
<bookmark url="file://$PROJECT_DIR$/js/ui/TrackingInfoPanel.js" line="37" />
</component>
<component name="ChangeListManager">
<list default="true" readonly="true" id="fc09c1ca-c63e-4437-a07f-a7bcd272417f" name="Default" comment="" />
<ignored path="emailtracking.iws" />
<ignored path=".idea/workspace.xml" />
<ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="emailtracking" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="EmailTrackingPlugin.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/EmailTrackingPlugin.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="510" max-vertical-offset="3120">
<caret line="34" column="33" selection-start-line="34" selection-start-column="33" selection-end-line="34" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="plugin.emailtracking.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/plugin.emailtracking.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1710" max-vertical-offset="2355">
<caret line="142" column="38" selection-start-line="142" selection-start-column="29" selection-end-line="142" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TrackingInfoPanel.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/ui/TrackingInfoPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="434" max-vertical-offset="1815">
<caret line="45" column="11" selection-start-line="45" selection-start-column="11" selection-end-line="45" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="emailtracking-styles.css" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/resources/css/emailtracking-styles.css">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.25541794" vertical-offset="0" max-vertical-offset="646">
<caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="60" max-vertical-offset="285">
<caret line="4" column="47" selection-start-line="4" selection-start-column="8" selection-end-line="4" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="database_structure.sql" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/lib/database_structure.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="465" max-vertical-offset="795">
<caret line="31" column="9" selection-start-line="31" selection-start-column="9" selection-end-line="31" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="class.plugintrackingmodule.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/class.plugintrackingmodule.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="398" max-vertical-offset="1020">
<caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="class.EmailTracker.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/lib/class.EmailTracker.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="503" max-vertical-offset="1890">
<caret line="92" column="7" selection-start-line="92" selection-start-column="7" selection-end-line="92" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/js/ui/TrackingInfoContentPanel.js" />
<option value="$PROJECT_DIR$/js/data/ResponseHandler.js" />
<option value="$PROJECT_DIR$/manifest.xml" />
<option value="$PROJECT_DIR$/php/class.plugintrackingmodule.php" />
<option value="$PROJECT_DIR$/php/lib/database_structure.sql" />
<option value="$PROJECT_DIR$/php/lib/class.EmailTracker.php" />
<option value="$PROJECT_DIR$/php/track.php" />
<option value="$PROJECT_DIR$/js/EmailTrackingPlugin.js" />
<option value="$PROJECT_DIR$/config.php" />
<option value="$PROJECT_DIR$/php/plugin.emailtracking.php" />
<option value="$PROJECT_DIR$/js/ui/TrackingInfoPanel.js" />
</list>
</option>
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="65" />
<option name="y" value="24" />
<option name="width" value="1855" />
<option name="height" value="1056" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="php" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="php" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="ui" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="emailtracking" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="data" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="FullScreen" value="false" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/php/lib" />
</key>
</component>
<component name="RunManager">
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="PhpUnitRemoteRunConfigurationType" factoryName="PHPUnit on Server">
<method />
</configuration>
<configuration default="true" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
<TestRunner />
<method />
</configuration>
<configuration default="true" type="PhpLocalRunConfigurationType" factoryName="PHP Console">
<method />
</configuration>
<configuration default="true" type="PhpBehatConfigurationType" factoryName="Behat">
<BehatRunner />
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<node-options />
<gulpfile />
<tasks />
<pass-parent-envs>true</pass-parent-envs>
<envs />
<method />
</configuration>
<list size="0" />
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="SvnConfiguration" cleanupOnStartRun="true">
<configuration>$USER_HOME$/.subversion</configuration>
<supportedVersion>125</supportedVersion>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="fc09c1ca-c63e-4437-a07f-a7bcd272417f" name="Default" comment="" />
<created>1425490373578</created>
<option name="number" value="Default" />
<updated>1425490373578</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="65" y="24" width="1855" height="1056" extended-state="6" />
<editor active="false" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.26091763" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.29583332" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<option name="myTodoPanelSettings">
<TodoPanelSettings />
</option>
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/js/EmailTrackingPlugin.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="510" max-vertical-offset="3120">
<caret line="34" column="33" selection-start-line="34" selection-start-column="33" selection-end-line="34" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.emailtracking.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1710" max-vertical-offset="2355">
<caret line="142" column="38" selection-start-line="142" selection-start-column="29" selection-end-line="142" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/TrackingInfoPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1815">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="60" max-vertical-offset="285">
<caret line="4" column="47" selection-start-line="4" selection-start-column="8" selection-end-line="4" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/database_structure.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="465" max-vertical-offset="795">
<caret line="31" column="9" selection-start-line="31" selection-start-column="9" selection-end-line="31" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/class.plugintrackingmodule.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="398" max-vertical-offset="1020">
<caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/class.EmailTracker.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="503" max-vertical-offset="1890">
<caret line="92" column="7" selection-start-line="92" selection-start-column="7" selection-end-line="92" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/EmailTrackingPlugin.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="510" max-vertical-offset="3120">
<caret line="34" column="33" selection-start-line="34" selection-start-column="33" selection-end-line="34" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.emailtracking.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1710" max-vertical-offset="2355">
<caret line="142" column="38" selection-start-line="142" selection-start-column="29" selection-end-line="142" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/TrackingInfoPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1815">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="60" max-vertical-offset="285">
<caret line="4" column="47" selection-start-line="4" selection-start-column="8" selection-end-line="4" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/database_structure.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="465" max-vertical-offset="795">
<caret line="31" column="9" selection-start-line="31" selection-start-column="9" selection-end-line="31" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/class.plugintrackingmodule.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="398" max-vertical-offset="1020">
<caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/class.EmailTracker.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="503" max-vertical-offset="1890">
<caret line="92" column="7" selection-start-line="92" selection-start-column="7" selection-end-line="92" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.emailtracking.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2280">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/EmailTrackingPlugin.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1155" max-vertical-offset="1890">
<caret line="105" column="52" selection-start-line="105" selection-start-column="52" selection-end-line="105" selection-end-column="52" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/track.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="90" max-vertical-offset="555">
<caret line="6" column="30" selection-start-line="6" selection-start-column="30" selection-end-line="6" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="120" max-vertical-offset="240">
<caret line="8" column="46" selection-start-line="8" selection-start-column="8" selection-end-line="8" selection-end-column="46" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/class.plugintrackingmodule.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="555" max-vertical-offset="675">
<caret line="37" column="5" selection-start-line="37" selection-start-column="5" selection-end-line="37" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/class.EmailTracker.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="90" max-vertical-offset="1455">
<caret line="6" column="11" selection-start-line="6" selection-start-column="11" selection-end-line="6" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/medoo.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="14115">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/data/ResponseHandler.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.44117647" vertical-offset="0" max-vertical-offset="646">
<caret line="19" column="7" selection-start-line="19" selection-start-column="7" selection-end-line="19" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/manifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="645">
<caret line="26" column="69" selection-start-line="26" selection-start-column="69" selection-end-line="26" selection-end-column="69" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/class.plugintrackingmodule.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="398" max-vertical-offset="1020">
<caret line="8" column="24" selection-start-line="8" selection-start-column="24" selection-end-line="8" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/class.EmailTracker.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="503" max-vertical-offset="1890">
<caret line="92" column="7" selection-start-line="92" selection-start-column="7" selection-end-line="92" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/track.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.50643086" vertical-offset="0" max-vertical-offset="622">
<caret line="21" column="50" selection-start-line="21" selection-start-column="38" selection-end-line="21" selection-end-column="50" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/lib/database_structure.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="465" max-vertical-offset="795">
<caret line="31" column="9" selection-start-line="31" selection-start-column="9" selection-end-line="31" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/EmailTrackingPlugin.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="3120">
<caret line="34" column="33" selection-start-line="34" selection-start-column="33" selection-end-line="34" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="60" max-vertical-offset="285">
<caret line="4" column="47" selection-start-line="4" selection-start-column="8" selection-end-line="4" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.emailtracking.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1710" max-vertical-offset="2355">
<caret line="142" column="38" selection-start-line="142" selection-start-column="29" selection-end-line="142" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/TrackingInfoPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="434" max-vertical-offset="1815">
<caret line="45" column="11" selection-start-line="45" selection-start-column="11" selection-end-line="45" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/resources/css/emailtracking-styles.css">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.25541794" vertical-offset="0" max-vertical-offset="646">
<caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

198
emailtracking/build.xml Normal file
View File

@ -0,0 +1,198 @@
<project default="all">
<property environment="env"/>
<property name="root-folder" value="${basedir}/../../"/>
<property name="tools-folder" value="${root-folder}/tools/"/>
<property name="target-folder" value="${root-folder}/deploy/plugins"/>
<import file="${tools-folder}/antutil.xml"/>
<typedef file="${tools-folder}/antlib.xml">
<classpath>
<pathelement location="${tools-folder}/tools.jar"/>
</classpath>
</typedef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${tools-folder}/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- Determine plugin name -->
<var name="plugin" unset="true"/>
<basename file="${basedir}" property="plugin"/>
<!-- The Plugin distribution files -->
<property name="plugin-folder" value="${plugin}"/>
<property name="plugin-debugfile" value="${plugin}-debug.js"/>
<property name="plugin-file" value="${plugin}.js"/>
<!-- The Plugin CSS files -->
<property name="plugin-css-folder" value="resources/css"/>
<property name="plugin-css-file" value="${plugin}.css"/>
<!-- Meta target -->
<target name="all" depends="concat, compress"/>
<!-- Clean -->
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<!-- Delete the Plugin files -->
<fileset dir="${target-folder}/${plugin-folder}/js">
<include name="${plugin-file}"/>
<include name="${plugin-debugfile}"/>
</fileset>
</delete>
</target>
<!-- Concatenates JavaScript files with automatic dependency generation -->
<target name="concat">
<!-- Concatenate plugin JS file -->
<if>
<available file="js" type="dir" />
<then>
<mkdir dir="${target-folder}/${plugin-folder}/js"/>
<echo message="Concatenating: ${plugin-debugfile}"/>
<zConcat outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-debugfile}" prioritize="\w+">
<concatfiles>
<fileset dir="js" includes="**/*.js" />
</concatfiles>
</zConcat>
</then>
</if>
<!-- Concatenate plugin CSS files -->
<if>
<available file="${plugin-css-folder}" type="dir" />
<then>
<mkdir dir="${target-folder}/${plugin-folder}/${plugin-css-folder}"/>
<echo message="Concatenating: ${plugin-css-file}"/>
<zConcat outputFolder="${target-folder}/${plugin-folder}/${plugin-css-folder}" outputFile="${plugin-css-file}">
<concatfiles>
<fileset dir="${plugin-css-folder}" includes="**/*.css" />
</concatfiles>
</zConcat>
</then>
</if>
</target>
<!-- Preformat the Concatenated Javascript files to improve compilation -->
<target name="preformat" depends="concat">
<if>
<available file="${target-folder}/${plugin-folder}/js/${plugin-debugfile}" type="file" />
<then>
<echo message="Preformatting: ${plugin-debugfile}"/>
<replaceregexp byline="true">
<regexp pattern="(^[ ,\t]*\*[ ,\t]@.*)\{(.*)\[\]\}"/>
<substitution expression="\1{\2\|Array}"/>
<fileset dir="${target-folder}/${plugin-folder}/js" includes="${plugin-debugfile}"/>
</replaceregexp>
</then>
</if>
</target>
<!-- Compress JavaScript -->
<target name="compress" depends="preformat">
<if>
<available file="${target-folder}/${plugin-folder}/js/${plugin-debugfile}" type="file" />
<then>
<echo message="Compiling: ${plugin-debugfile}" />
<zCompile inputFolder="${target-folder}/${plugin-folder}/js" inputFile="${plugin-debugfile}" outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-file}">
<externs>
var Ext = {};
var Zarafa = {};
var container = {};
var _ = function(key, domain) {};
var dgettext = function(domain, msgid) {};
var dngettext = function(domain, msgid, msgid_plural, count) {};
var dnpgettext = function(domain, msgctxt, msgid, msgid_plural, count) {};
var dpgettext = function(domain, msgctxt, msgid) {};
var ngettext = function(msgid, msgid_plural, count) {};
var npgettext = function(msgctxt, msgid, msgid_plural, count) {};
var pgettext = function(msgctxt, msgid) {};
</externs>
</zCompile>
</then>
</if>
</target>
<!-- syntax check all PHP files -->
<target name="validate">
<if>
<available file="php" filepath="${env.PATH}" />
<then>
<if>
<available file="config.php" type="file" />
<then>
<antcall target="syntax-check">
<param name="file" value="config.php"/>
</antcall>
</then>
</if>
<if>
<available file="php" type="dir" />
<then>
<foreach target="syntax-check" param="file">
<path>
<fileset dir=".">
<include name="**/*.php"/>
</fileset>
</path>
</foreach>
</then>
</if>
</then>
<else>
<echo message="WARNING: PHP not available, not performing syntax-check on php files"/>
</else>
</if>
</target>
<target name="syntax-check">
<echo message="validating ${file}"/>
<exec executable="php" failonerror="true">
<arg value="-l"/>
<arg value="${file}"/>
</exec>
</target>
<!-- Install all files into the target folder -->
<target name="deploy" depends="compress, validate">
<mkdir dir="${target-folder}/${plugin-folder}"/>
<!-- Copy (and validate) manifest.xml -->
<if>
<available file="xmllint" filepath="${env.PATH}" />
<then>
<exec executable="xmllint" output="${target-folder}/${plugin-folder}/manifest.xml" failonerror="true">
<arg value="--valid"/>
<arg value="--path"/>
<arg value="${root-folder}/server"/>
<arg value="manifest.xml"/>
</exec>
</then>
<else>
<echo message="WARNING: xmllint not available, not performing syntax-check on manifest.xml"/>
<!-- xmllint is not available, so we must copy the file manually -->
<copy todir="${target-folder}/${plugin-folder}">
<fileset dir=".">
<include name="manifest.xml"/>
</fileset>
</copy>
</else>
</if>
<!-- copy files -->
<copy todir="${target-folder}/${plugin-folder}">
<fileset dir=".">
<include name="resources/**/*.*"/>
<include name="php/**/*.php"/>
<include name="config.php"/>
<!-- exclude the ant script -->
<exclude name="build.xml"/>
<!-- CSS is generated during build -->
<exclude name="resources/css/*.*"/>
</fileset>
</copy>
</target>
</project>

13
emailtracking/config.php Normal file
View File

@ -0,0 +1,13 @@
<?php
DEFINE('PLUGIN_EMAILTRACKING_USER_DEFAULT_ENABLE_TRACKING', false);
// show logs that were done from within webapp (most probably it was yourself)...
DEFINE('PLUGIN_EMAILTRACKING_SHOW_INTERNAL_LOGS', false);
DEFINE('PLUGIN_EMAILTRACKING_DB_HOST', "localhost");
DEFINE('PLUGIN_EMAILTRACKING_DB_PORT', 3306);
DEFINE('PLUGIN_EMAILTRACKING_DB_USER', "root");
DEFINE('PLUGIN_EMAILTRACKING_DB_PASS', "root");
DEFINE('PLUGIN_EMAILTRACKING_DB_DB', "emailtracking");
DEFINE('PLUGIN_EMAILTRACKING_PUBLIC_WEBAPP_URL', "http://localhost/webapp");
?>

View File

@ -0,0 +1,202 @@
Ext.namespace('Zarafa.plugins.emailtracking');
/**
* @class Zarafa.plugins.emailtracking.EmailTrackingPlugin
* @extends Zarafa.core.Plugin
*/
Zarafa.plugins.emailtracking.EmailTrackingPlugin = Ext.extend(Zarafa.core.Plugin, {
/*
* Called after constructor.
* Registers insertion points.
* @protected
*/
initPlugin : function()
{
Zarafa.plugins.emailtracking.EmailTrackingPlugin.superclass.initPlugin.apply(this, arguments);
// Tracking button in mailcreatecontentpanel
this.registerInsertionPoint('context.mail.mailcreatecontentpanel.toolbar.options', this.showTrackButton, this);
// Insertion point which shows the read status
this.registerInsertionPoint('previewpanel.toolbar.detaillinks', this.showTrackingInfo, this);
Zarafa.core.data.SharedComponentType.addProperty('plugin.emailtracking.ui.trackinginfopanel');
},
/**
* Displays Tracking information in the previewpanel
*
* @return {Object} a box which on record update displays Tracking information
*/
showTrackingInfo : function()
{
return {
xtype: 'button',
style: 'margin-top: 4px; border: 2px solid red;',
plugins : [ 'zarafa.recordcomponentupdaterplugin' ],
autoEl: {
tag: 'div',
ref: 'trackingInfoBox'
},
scope : this,
update : this.onTrackingInfo,
handler : this.onTrackingButton
};
},
/**
* Handler for the button which is displayed when a encrypted / signed message is openend
* When an encrypted message is opened, we will send a request to unlock the certificate.
* When an signed email is openend, we will show a popup with extra information about the signed message
*/
onTrackingButton: function(button, config)
{
var user = container.getUser();
container.getRequest().singleRequest(
'plugintrackingmodule',
'gettrackinglog',
{
'trackingid' : button.record.get("trackingcode"),
'user' : user.getSMTPAddress()
},
new Zarafa.plugins.emailtracking.data.ResponseHandler({
successCallback : this.onTrackingLogLoaded
})
);
},
onTrackingLogLoaded: function(response) {
if(response.status) {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel'], response, {
manager: Ext.WindowMgr
});
} else {
container.getNotifier().notify('info.saved', _('Error'), "No tracking log available!");
}
},
/**
* Function which displays information in the previewpanel.
* In the case of a encrypted message, we either show a button to unlock the certificate
* or shows the message that the message has been decrypted.
* If the message is signed we display information depending on the state of the verification.
*
* @param {Zarafa.core.data.IPMRecord} record record which is displayed
* @param {Boolean} contentReset force the component to perform a full update of the data.
*/
onTrackingInfo : function(record, resetContent) {
// Set button.record for use in onSmimeButton
this.record = record;
var infoBox = this.getEl();
// Set smimeBox to empty value by default, to override previous S/MIME message text
infoBox.update("");
if (this.record.opened) {
// get the tracking code from the body
var body = this.record.getBody(true);
var trackingRegex = /(?:^|.*)track.php\?img=(.*?)(?:\"|\s|$)/g;
var match = trackingRegex.exec(body);
if(match) {
infoBox.update("This message is getting tracked (" + match[1] + ")");
infoBox.show();
this.record.set("trackingcode", match[1]);
}
} else {
infoBox.hide();
}
},
/**
* Create button which adds some tracking specials to the mail content.
*
* @return {Config} creates a button for tracking email
*/
showTrackButton : function()
{
return {
xtype : 'button',
text : _('Track'),
tooltip: {
title: _('Track message'),
text: _('Track this message and get detailed information about the current status.')
},
iconCls : 'icon_tracking_off',
handler : this.onTrackButton,
scope : this
};
},
/**
* Handler for the sign button, when clicked it checks if the private certificate exists.
* If we have signing already set and click it again, we unset it.
* If we already set have encryption set, we set a special message_class for both sign+ecnrypt.
*
*
* @param {Ext.button} button
* @param {Object} config
*/
onTrackButton : function(button, config)
{
var owner = button.ownerCt;
var record = owner.record;
var doTrack = button.iconCls === "icon_tracking_on" ? false : true;
if(record && doTrack) {
button.setIconClass('icon_tracking_on');
record.set('message_class', 'IPM.Note.Tracking');
record.set('entryid', record.entryid);
} else {
record.set('message_class', 'IPM.Note');
button.setIconClass('icon_tracking_off');
}
owner.dialog.saveRecord();
},
/*
* Bid for the type of shared component
* and the given record.
* This will bid on calendar.dialogs.importevents
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Zarafa.mail.dialogs.MailCreateContentPanel} owner Optionally passed panel
* @return {Number} The bid for the shared component
*/
bidSharedComponent : function(type, record) {
var bid = -1;
switch(type) {
case Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel']:
bid = 1;
break;
}
return bid;
},
/**
* Will return the reference to the shared component.
* Based on the type of component requested a component is returned.
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Zarafa.mail.dialogs.MailCreateContentPanel} owner Optionally passed panel
* @return {Ext.Component} Component
*/
getSharedComponent : function(type, record) {
var component;
switch(type) {
case Zarafa.core.data.SharedComponentType['plugin.emailtracking.ui.trackinginfopanel']:
component = Zarafa.plugins.emailtracking.ui.TrackingInfoPanel;
break;
}
return component;
}
});
Zarafa.onReady(function() {
container.registerPlugin(new Zarafa.core.PluginMetaData({
name : 'emailtracking',
displayName : _('Tracking Plugin'),
pluginConstructor : Zarafa.plugins.emailtracking.EmailTrackingPlugin
}));
});

View File

@ -0,0 +1,25 @@
Ext.namespace('Zarafa.plugins.emailtracking.data');
/**
* @class Zarafa.plugins.emailtracking.data.ResponseHandler
* @extends Zarafa.core.data.AbstractResponseHandler
*
* Emailtracking specific response handler.
*/
Zarafa.plugins.emailtracking.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
/**
* @cfg {Function} successCallback The function which
* will be called after success request.
*/
successCallback : null,
/**
* @param {Object} response Object contained the response data.
*/
doGettrackinglog : function(response) {
this.successCallback(response);
}
});
Ext.reg('emailtracking.responsehandler', Zarafa.plugins.emailtracking.data.ResponseHandler);

View File

@ -0,0 +1,116 @@
Ext.namespace('Zarafa.plugins.emailtracking.ui');
/**
* @class Zarafa.plugins.emailtracking.ui.TrackingInfoPanel
* @extends Zarafa.core.ui.ContentPanel
*
* Show the tracking table.
* @xtype emailtracking.trackinginfopanel
*/
Zarafa.plugins.emailtracking.ui.TrackingInfoPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/**
* @var object The server response
*/
record : null,
store: null,
/**
* @constructor
* @param config Configuration structure
*/
constructor : function(config) {
config = config || {};
// fill the store
// create the data store
this.store = new Ext.data.ArrayStore({
fields: [
{name: 'ip'},
{name: 'timestamp', type: 'date'},
{name: 'referrer'},
{name: 'client'},
{name: 'tracking_type'}
]
});
var data = [];
var internals = container.getSettingsModel().get('zarafa/v1/plugins/emailtracking/internals');
Ext.each(config.record.log, function(rec) {
// hide entries from the own system (only external tracking will be possible!)
if(internals || (rec.referrer != window.location.href)) {
data.push([rec.ip_addr, rec.timestamp, rec.referrer, rec.client, rec.tracking_type]);
}
});
this.store.loadData(data);
Ext.applyIf(config, {
layout : 'fit',
title : _('Tracking information'),
closeOnSave : true,
width : 340,
height : 300,
//Add panel
items : [{
xtype: "grid",
style: 'margin-top:20px;',
store: this.store,
columns: [
{
header : 'IP Address',
width : 75,
sortable : true,
dataIndex: 'ip'
},
{
id : "timestamp",
header : 'Date',
width : 75,
sortable : true,
renderer : Ext.util.Format.dateRenderer('m/d/Y H:m:s'),
dataIndex: 'timestamp'
},
{
header : 'Referrer',
width : 150,
hidden : true,
sortable : true,
dataIndex: 'referrer'
},
{
header : 'Client',
width : 150,
hidden : true,
sortable : true,
dataIndex: 'client'
},
{
header : 'Type',
width : 60,
hidden : true,
sortable : true,
dataIndex: 'tracking_type'
}
],
viewConfig: {
forceFit: true
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
frame: true
},{
xtype: 'button',
text: _('Close'),
handler: this.close,
scope: this
}]
});
Zarafa.plugins.emailtracking.ui.TrackingInfoPanel.superclass.constructor.call(this, config);
}
});
Ext.reg('emailtracking.trackinginfopanel' ,Zarafa.plugins.emailtracking.ui.TrackingInfoPanel);

View File

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2">
<info>
<version>0.1</version>
<name>Tracking Plugin</name>
<title>Tracking Plugin</title>
<author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL>
<description>Enables Email Tracking in Webapp</description>
</info>
<config>
<configfile>config.php</configfile>
</config>
<components>
<component>
<files>
<server>
<serverfile>php/plugin.emailtracking.php</serverfile>
<serverfile type="module" module="plugintrackingmodule">php/class.plugintrackingmodule.php</serverfile>
</server>
<client>
<clientfile load="release">js/emailtracking.js</clientfile>
<clientfile load="debug">js/emailtracking-debug.js</clientfile>
<clientfile load="source">js/EmailTrackingPlugin.js</clientfile>
<clientfile load="source">js/ui/TrackingInfoPanel.js</clientfile>
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
</client>
<resources>
<resourcefile load="release">resources/css/emailtracking.css</resourcefile>
<resourcefile load="debug">resources/css/emailtracking.css</resourcefile>
<resourcefile load="source">resources/css/emailtracking-styles.css</resourcefile>
</resources>
</files>
</component>
</components>
</plugin>

View File

@ -0,0 +1,62 @@
<?php
require_once __DIR__ . "/lib/class.EmailTracker.php";
class PluginTrackingModule extends Module
{
/**
* @var EmailTracker
*/
private $emailTracker;
/**
* Constructor
* @param int $id unique id.
* @param string $folderentryid Entryid of the folder. Data will be selected from this folder.
* @param array $data list of all actions.
*/
function PluginEmailtrackingModule($id, $data)
{
$this->store = $GLOBALS['mapisession']->getDefaultMessageStore();
parent::Module($id, $data);
}
/**
* Executes all the actions in the $data variable.
* @return boolean true on success of false on fialure.
*/
function execute()
{
$this->emailTracker = new EmailTracker();
foreach($this->data as $actionType => $actionData)
{
if(isset($actionType)) {
try {
switch($actionType)
{
case "gettrackinglog" :
$data = $this->getTrackingLog($actionData);
$this->addActionData('gettrackinglog', $data);
$GLOBALS['bus']->addData($this->getResponseData());
break;
default:
$this->handleUnknownActionType($actionType);
}
} catch (Exception $e) {
$this->sendFeedback(false, parent::errorDetailsFromException($e));
}
}
}
}
function getTrackingLog($actionData) {
$data = array();
$data["trackingid"] = $actionData["trackingid"];
$data["log"] = $this->emailTracker->getAllLogs($data["trackingid"]);
$data["status"] = true;
return $data;
}
}

View File

@ -0,0 +1,120 @@
<?php
require __DIR__ . '/medoo.php';
require_once __DIR__ . '/../../config.php';
class EmailTracker {
/**
* @var Database connector object. A medoo object.
*/
private $dbObj;
/**
* Contructor
*/
function __construct() {
$dbOptions = array(
'database_type' => 'mysql',
'database_name' => PLUGIN_EMAILTRACKING_DB_DB,
'server' => PLUGIN_EMAILTRACKING_DB_HOST,
'username' => PLUGIN_EMAILTRACKING_DB_USER,
'password' => PLUGIN_EMAILTRACKING_DB_PASS,
'port' => PLUGIN_EMAILTRACKING_DB_PORT,
'charset' => 'utf8',
);
$this->dbObj = new medoo($dbOptions);
}
/**
* Generates a new ID out of some values
*
* @param $emailId
* @param $destAddr
* @param $srcAddr
* @param $subject
* @return string
*/
public function getNewTrackingCode ($emailId, $destAddr, $srcAddr, $subject) {
$currentTimeStamp = time();
$trackingHash = md5($emailId . $destAddr . $subject . $currentTimeStamp);
$data = array(
"email_id" => $emailId,
"destination_addr" => $destAddr,
"source_addr" => $srcAddr,
"subject" => $subject,
"current_time" => date('Y-m-d H:i:s',$currentTimeStamp),
"generated_id" => $trackingHash
);
$this->dbObj->insert("trackingid", $data);
return $trackingHash;
}
/**
* Get the database ID for the given hash
*
* @param $trackingHash
* @return int
*/
private function getTrackingIDbyCode ($trackingHash) {
$filter = array(
"generated_id" => $trackingHash,
);
$data = $this->dbObj->select("trackingid", "id", $filter);
if (is_array($data) && count($data) > 0) {
return $data[0];
} else {
return -1;
}
}
/**
* Stores a new log entry to db
*
* @param $trackingHash
* @param $data
*/
public function addLog($trackingHash, $data) {
// first get the id - to add it to our new entry
$dbID = $this->getTrackingIDbyCode($trackingHash);
// check if trackingHash was valid
if($dbID != -1) {
// build our tracking entry
$data["trackingid_id"] = $dbID;
$this->dbObj->insert("trackinglog", $data);
}
}
/**
* Get all Tracking logs for the specified hash.
*
* @param $trackingHash
* @return array|bool
*/
public function getAllLogs($trackingHash) {
// first get the id - to add it to our new entry
$dbID = $this->getTrackingIDbyCode($trackingHash);
// check if trackingHash was valid
if($dbID != -1) {
$data = $this->dbObj->select("trackinglog", [
"ip_addr",
"timestamp",
"referrer",
"client",
"tracking_type"
], [
"trackingid_id" => $dbID
]);
return $data;
}
return false;
}
}

View File

@ -0,0 +1,48 @@
--
-- Database: `emailtracking`
--
-- --------------------------------------------------------
--
-- Table structure for table `trackingid`
--
CREATE TABLE IF NOT EXISTS `trackingid` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email_id` varchar(500) NOT NULL,
`destination_addr` varchar(200) NOT NULL,
`source_addr` varchar(200) NOT NULL,
`subject` varchar(1024) NOT NULL,
`current_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`generated_id` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Table structure for table `trackinglog`
--
CREATE TABLE IF NOT EXISTS `trackinglog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`trackingid_id` int(11) NOT NULL,
`ip_addr` varchar(100) NOT NULL,
`referrer` varchar(500) NOT NULL,
`client` varchar(1024) NOT NULL,
`tracking_type` varchar(20) NOT NULL,
`timestamp` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `trackingid_id` (`trackingid_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `trackinglog`
--
ALTER TABLE `trackinglog`
ADD CONSTRAINT `trackinglog_ibfk_1` FOREIGN KEY (`trackingid_id`) REFERENCES `trackingid` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,936 @@
<?php
/*!
* Medoo database framework
* http://medoo.in
* Version 0.9.8
*
* Copyright 2015, Angel Lai
* Released under the MIT license
*/
class medoo
{
// General
protected $database_type;
protected $charset;
protected $database_name;
// For MySQL, MariaDB, MSSQL, Sybase, PostgreSQL, Oracle
protected $server;
protected $username;
protected $password;
// For SQLite
protected $database_file;
// For MySQL or MariaDB with unix_socket
protected $socket;
// Optional
protected $port;
protected $option = array();
// Variable
protected $logs = array();
protected $debug_mode = false;
public function __construct($options = null)
{
try {
$commands = array();
if (is_string($options) && !empty($options))
{
if (strtolower($this->database_type) == 'sqlite')
{
$this->database_file = $options;
}
else
{
$this->database_name = $options;
}
}
elseif (is_array($options))
{
foreach ($options as $option => $value)
{
$this->$option = $value;
}
}
if (
isset($this->port) &&
is_int($this->port * 1)
)
{
$port = $this->port;
}
$type = strtolower($this->database_type);
$is_port = isset($port);
switch ($type)
{
case 'mariadb':
$type = 'mysql';
case 'mysql':
if ($this->socket)
{
$dsn = $type . ':unix_socket=' . $this->socket . ';dbname=' . $this->database_name;
}
else
{
$dsn = $type . ':host=' . $this->server . ($is_port ? ';port=' . $port : '') . ';dbname=' . $this->database_name;
}
// Make MySQL using standard quoted identifier
$commands[] = 'SET SQL_MODE=ANSI_QUOTES';
break;
case 'pgsql':
$dsn = $type . ':host=' . $this->server . ($is_port ? ';port=' . $port : '') . ';dbname=' . $this->database_name;
break;
case 'sybase':
$dsn = 'dblib:host=' . $this->server . ($is_port ? ':' . $port : '') . ';dbname=' . $this->database_name;
break;
case 'oracle':
$dbname = $this->server ?
'//' . $this->server . ($is_port ? ':' . $port : ':1521') . '/' . $this->database_name :
$this->database_name;
$dsn = 'oci:dbname=' . $dbname . ($this->charset ? ';charset=' . $this->charset : '');
break;
case 'mssql':
$dsn = strstr(PHP_OS, 'WIN') ?
'sqlsrv:server=' . $this->server . ($is_port ? ',' . $port : '') . ';database=' . $this->database_name :
'dblib:host=' . $this->server . ($is_port ? ':' . $port : '') . ';dbname=' . $this->database_name;
// Keep MSSQL QUOTED_IDENTIFIER is ON for standard quoting
$commands[] = 'SET QUOTED_IDENTIFIER ON';
break;
case 'sqlite':
$dsn = $type . ':' . $this->database_file;
$this->username = null;
$this->password = null;
break;
}
if (
in_array($type, explode(' ', 'mariadb mysql pgsql sybase mssql')) &&
$this->charset
)
{
$commands[] = "SET NAMES '" . $this->charset . "'";
}
$this->pdo = new PDO(
$dsn,
$this->username,
$this->password,
$this->option
);
foreach ($commands as $value)
{
$this->pdo->exec($value);
}
}
catch (PDOException $e) {
throw new Exception($e->getMessage());
}
}
public function query($query)
{
if ($this->debug_mode)
{
echo $query;
$this->debug_mode = false;
return false;
}
array_push($this->logs, $query);
return $this->pdo->query($query);
}
public function exec($query)
{
if ($this->debug_mode)
{
echo $query;
$this->debug_mode = false;
return false;
}
array_push($this->logs, $query);
return $this->pdo->exec($query);
}
public function quote($string)
{
return $this->pdo->quote($string);
}
protected function column_quote($string)
{
return '"' . str_replace('.', '"."', preg_replace('/(^#|\(JSON\))/', '', $string)) . '"';
}
protected function column_push($columns)
{
if ($columns == '*')
{
return $columns;
}
if (is_string($columns))
{
$columns = array($columns);
}
$stack = array();
foreach ($columns as $key => $value)
{
preg_match('/([a-zA-Z0-9_\-\.]*)\s*\(([a-zA-Z0-9_\-]*)\)/i', $value, $match);
if (isset($match[1], $match[2]))
{
array_push($stack, $this->column_quote( $match[1] ) . ' AS ' . $this->column_quote( $match[2] ));
}
else
{
array_push($stack, $this->column_quote( $value ));
}
}
return implode($stack, ',');
}
protected function array_quote($array)
{
$temp = array();
foreach ($array as $value)
{
$temp[] = is_int($value) ? $value : $this->pdo->quote($value);
}
return implode($temp, ',');
}
protected function inner_conjunct($data, $conjunctor, $outer_conjunctor)
{
$haystack = array();
foreach ($data as $value)
{
$haystack[] = '(' . $this->data_implode($value, $conjunctor) . ')';
}
return implode($outer_conjunctor . ' ', $haystack);
}
protected function fn_quote($column, $string)
{
return (strpos($column, '#') === 0 && preg_match('/^[A-Z0-9\_]*\([^)]*\)$/', $string)) ?
$string :
$this->quote($string);
}
protected function data_implode($data, $conjunctor, $outer_conjunctor = null)
{
$wheres = array();
foreach ($data as $key => $value)
{
$type = gettype($value);
if (
preg_match("/^(AND|OR)\s*#?/i", $key, $relation_match) &&
$type == 'array'
)
{
$wheres[] = 0 !== count(array_diff_key($value, array_keys(array_keys($value)))) ?
'(' . $this->data_implode($value, ' ' . $relation_match[1]) . ')' :
'(' . $this->inner_conjunct($value, ' ' . $relation_match[1], $conjunctor) . ')';
}
else
{
preg_match('/(#?)([\w\.]+)(\[(\>|\>\=|\<|\<\=|\!|\<\>|\>\<|\!?~)\])?/i', $key, $match);
$column = $this->column_quote($match[2]);
if (isset($match[4]))
{
$operator = $match[4];
if ($operator == '!')
{
switch ($type)
{
case 'NULL':
$wheres[] = $column . ' IS NOT NULL';
break;
case 'array':
$wheres[] = $column . ' NOT IN (' . $this->array_quote($value) . ')';
break;
case 'integer':
case 'double':
$wheres[] = $column . ' != ' . $value;
break;
case 'boolean':
$wheres[] = $column . ' != ' . ($value ? '1' : '0');
break;
case 'string':
$wheres[] = $column . ' != ' . $this->fn_quote($key, $value);
break;
}
}
if ($operator == '<>' || $operator == '><')
{
if ($type == 'array')
{
if ($operator == '><')
{
$column .= ' NOT';
}
if (is_numeric($value[0]) && is_numeric($value[1]))
{
$wheres[] = '(' . $column . ' BETWEEN ' . $value[0] . ' AND ' . $value[1] . ')';
}
else
{
$wheres[] = '(' . $column . ' BETWEEN ' . $this->quote($value[0]) . ' AND ' . $this->quote($value[1]) . ')';
}
}
}
if ($operator == '~' || $operator == '!~')
{
if ($type == 'string')
{
$value = array($value);
}
if (!empty($value))
{
$like_clauses = array();
foreach ($value as $item)
{
if ($operator == '!~')
{
$column .= ' NOT';
}
if (preg_match('/^(?!%).+(?<!%)$/', $item))
{
$item = '%' . $item . '%';
}
$like_clauses[] = $column . ' LIKE ' . $this->fn_quote($key, $item);
}
$wheres[] = implode(' OR ', $like_clauses);
}
}
if (in_array($operator, array('>', '>=', '<', '<=')))
{
if (is_numeric($value))
{
$wheres[] = $column . ' ' . $operator . ' ' . $value;
}
elseif (strpos($key, '#') === 0)
{
$wheres[] = $column . ' ' . $operator . ' ' . $this->fn_quote($key, $value);
}
else
{
$wheres[] = $column . ' ' . $operator . ' ' . $this->quote($value);
}
}
}
else
{
switch ($type)
{
case 'NULL':
$wheres[] = $column . ' IS NULL';
break;
case 'array':
$wheres[] = $column . ' IN (' . $this->array_quote($value) . ')';
break;
case 'integer':
case 'double':
$wheres[] = $column . ' = ' . $value;
break;
case 'boolean':
$wheres[] = $column . ' = ' . ($value ? '1' : '0');
break;
case 'string':
$wheres[] = $column . ' = ' . $this->fn_quote($key, $value);
break;
}
}
}
}
return implode($conjunctor . ' ', $wheres);
}
protected function where_clause($where)
{
$where_clause = '';
if (is_array($where))
{
$where_keys = array_keys($where);
$where_AND = preg_grep("/^AND\s*#?$/i", $where_keys);
$where_OR = preg_grep("/^OR\s*#?$/i", $where_keys);
$single_condition = array_diff_key($where, array_flip(
explode(' ', 'AND OR GROUP ORDER HAVING LIMIT LIKE MATCH')
));
if ($single_condition != array())
{
$where_clause = ' WHERE ' . $this->data_implode($single_condition, '');
}
if (!empty($where_AND))
{
$value = array_values($where_AND);
$where_clause = ' WHERE ' . $this->data_implode($where[ $value[0] ], ' AND');
}
if (!empty($where_OR))
{
$value = array_values($where_OR);
$where_clause = ' WHERE ' . $this->data_implode($where[ $value[0] ], ' OR');
}
if (isset($where['MATCH']))
{
$MATCH = $where['MATCH'];
if (is_array($MATCH) && isset($MATCH['columns'], $MATCH['keyword']))
{
$where_clause .= ($where_clause != '' ? ' AND ' : ' WHERE ') . ' MATCH ("' . str_replace('.', '"."', implode($MATCH['columns'], '", "')) . '") AGAINST (' . $this->quote($MATCH['keyword']) . ')';
}
}
if (isset($where['GROUP']))
{
$where_clause .= ' GROUP BY ' . $this->column_quote($where['GROUP']);
if (isset($where['HAVING']))
{
$where_clause .= ' HAVING ' . $this->data_implode($where['HAVING'], ' AND');
}
}
if (isset($where['ORDER']))
{
$rsort = '/(^[a-zA-Z0-9_\-\.]*)(\s*(DESC|ASC))?/';
$ORDER = $where['ORDER'];
if (is_array($ORDER))
{
if (
isset($ORDER[1]) &&
is_array($ORDER[1])
)
{
$where_clause .= ' ORDER BY FIELD(' . $this->column_quote($ORDER[0]) . ', ' . $this->array_quote($ORDER[1]) . ')';
}
else
{
$stack = array();
foreach ($ORDER as $column)
{
preg_match($rsort, $column, $order_match);
array_push($stack, '"' . str_replace('.', '"."', $order_match[1]) . '"' . (isset($order_match[3]) ? ' ' . $order_match[3] : ''));
}
$where_clause .= ' ORDER BY ' . implode($stack, ',');
}
}
else
{
preg_match($rsort, $ORDER, $order_match);
$where_clause .= ' ORDER BY "' . str_replace('.', '"."', $order_match[1]) . '"' . (isset($order_match[3]) ? ' ' . $order_match[3] : '');
}
}
if (isset($where['LIMIT']))
{
$LIMIT = $where['LIMIT'];
if (is_numeric($LIMIT))
{
$where_clause .= ' LIMIT ' . $LIMIT;
}
if (
is_array($LIMIT) &&
is_numeric($LIMIT[0]) &&
is_numeric($LIMIT[1])
)
{
$where_clause .= ' LIMIT ' . $LIMIT[0] . ',' . $LIMIT[1];
}
}
}
else
{
if ($where != null)
{
$where_clause .= ' ' . $where;
}
}
return $where_clause;
}
protected function select_context($table, $join, &$columns = null, $where = null, $column_fn = null)
{
$table = '"' . $table . '"';
$join_key = is_array($join) ? array_keys($join) : null;
if (
isset($join_key[0]) &&
strpos($join_key[0], '[') === 0
)
{
$table_join = array();
$join_array = array(
'>' => 'LEFT',
'<' => 'RIGHT',
'<>' => 'FULL',
'><' => 'INNER'
);
foreach($join as $sub_table => $relation)
{
preg_match('/(\[(\<|\>|\>\<|\<\>)\])?([a-zA-Z0-9_\-]*)\s?(\(([a-zA-Z0-9_\-]*)\))?/', $sub_table, $match);
if ($match[2] != '' && $match[3] != '')
{
if (is_string($relation))
{
$relation = 'USING ("' . $relation . '")';
}
if (is_array($relation))
{
// For ['column1', 'column2']
if (isset($relation[0]))
{
$relation = 'USING ("' . implode($relation, '", "') . '")';
}
// For ['column1' => 'column2']
else
{
$relation = 'ON ' . $table . '."' . key($relation) . '" = "' . (isset($match[5]) ? $match[5] : $match[3]) . '"."' . current($relation) . '"';
}
}
$table_join[] = $join_array[ $match[2] ] . ' JOIN "' . $match[3] . '" ' . (isset($match[5]) ? 'AS "' . $match[5] . '" ' : '') . $relation;
}
}
$table .= ' ' . implode($table_join, ' ');
}
else
{
if (is_null($columns))
{
if (is_null($where))
{
if (
is_array($join) &&
isset($column_fn)
)
{
$where = $join;
$columns = null;
}
else
{
$where = null;
$columns = $join;
}
}
else
{
$where = $join;
$columns = null;
}
}
else
{
$where = $columns;
$columns = $join;
}
}
if (isset($column_fn))
{
if ($column_fn == 1)
{
$column = '1';
if (is_null($where))
{
$where = $columns;
}
}
else
{
if (empty($columns))
{
$columns = '*';
$where = $join;
}
$column = $column_fn . '(' . $this->column_push($columns) . ')';
}
}
else
{
$column = $this->column_push($columns);
}
return 'SELECT ' . $column . ' FROM ' . $table . $this->where_clause($where);
}
public function select($table, $join, $columns = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $columns, $where));
return $query ? $query->fetchAll(
(is_string($columns) && $columns != '*') ? PDO::FETCH_COLUMN : PDO::FETCH_ASSOC
) : false;
}
public function insert($table, $datas)
{
$lastId = array();
// Check indexed or associative array
if (!isset($datas[0]))
{
$datas = array($datas);
}
foreach ($datas as $data)
{
$keys = array_keys($data);
$values = array();
$columns = array();
foreach ($data as $key => $value)
{
array_push($columns, $this->column_quote($key));
switch (gettype($value))
{
case 'NULL':
$values[] = 'NULL';
break;
case 'array':
preg_match("/\(JSON\)\s*([\w]+)/i", $key, $column_match);
$values[] = isset($column_match[0]) ?
$this->quote(json_encode($value)) :
$this->quote(serialize($value));
break;
case 'boolean':
$values[] = ($value ? '1' : '0');
break;
case 'integer':
case 'double':
case 'string':
$values[] = $this->fn_quote($key, $value);
break;
}
}
$this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode($values, ', ') . ')');
$lastId[] = $this->pdo->lastInsertId();
}
return count($lastId) > 1 ? $lastId : $lastId[ 0 ];
}
public function update($table, $data, $where = null)
{
$fields = array();
foreach ($data as $key => $value)
{
preg_match('/([\w]+)(\[(\+|\-|\*|\/)\])?/i', $key, $match);
if (isset($match[3]))
{
if (is_numeric($value))
{
$fields[] = $this->column_quote($match[1]) . ' = ' . $this->column_quote($match[1]) . ' ' . $match[3] . ' ' . $value;
}
}
else
{
$column = $this->column_quote($key);
switch (gettype($value))
{
case 'NULL':
$fields[] = $column . ' = NULL';
break;
case 'array':
preg_match("/\(JSON\)\s*([\w]+)/i", $key, $column_match);
$fields[] = $column . ' = ' . $this->quote(
isset($column_match[0]) ? json_encode($value) : serialize($value)
);
break;
case 'boolean':
$fields[] = $column . ' = ' . ($value ? '1' : '0');
break;
case 'integer':
case 'double':
case 'string':
$fields[] = $column . ' = ' . $this->fn_quote($key, $value);
break;
}
}
}
return $this->exec('UPDATE "' . $table . '" SET ' . implode(', ', $fields) . $this->where_clause($where));
}
public function delete($table, $where)
{
return $this->exec('DELETE FROM "' . $table . '"' . $this->where_clause($where));
}
public function replace($table, $columns, $search = null, $replace = null, $where = null)
{
if (is_array($columns))
{
$replace_query = array();
foreach ($columns as $column => $replacements)
{
foreach ($replacements as $replace_search => $replace_replacement)
{
$replace_query[] = $column . ' = REPLACE(' . $this->column_quote($column) . ', ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
}
}
$replace_query = implode(', ', $replace_query);
$where = $search;
}
else
{
if (is_array($search))
{
$replace_query = array();
foreach ($search as $replace_search => $replace_replacement)
{
$replace_query[] = $columns . ' = REPLACE(' . $this->column_quote($columns) . ', ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
}
$replace_query = implode(', ', $replace_query);
$where = $replace;
}
else
{
$replace_query = $columns . ' = REPLACE(' . $this->column_quote($columns) . ', ' . $this->quote($search) . ', ' . $this->quote($replace) . ')';
}
}
return $this->exec('UPDATE "' . $table . '" SET ' . $replace_query . $this->where_clause($where));
}
public function get($table, $join = null, $column = null, $where = null)
{
if (!isset($where))
{
$where = array();
}
$where['LIMIT'] = 1;
$query = $this->query($this->select_context($table, $join, $column, $where));
if ($query)
{
$data = $query->fetchAll(PDO::FETCH_ASSOC);
if (isset($data[0]))
{
$column = $where == null ? $join : $column;
if (is_string($column) && $column != '*')
{
return $data[ 0 ][ $column ];
}
return $data[ 0 ];
}
else
{
return false;
}
}
else
{
return false;
}
}
public function has($table, $join, $where = null)
{
$column = null;
$query = $this->query('SELECT EXISTS(' . $this->select_context($table, $join, $column, $where, 1) . ')');
return $query ? $query->fetchColumn() === '1' : false;
}
public function count($table, $join = null, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'COUNT'));
return $query ? 0 + $query->fetchColumn() : false;
}
public function max($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'MAX'));
if ($query)
{
$max = $query->fetchColumn();
return is_numeric($max) ? $max + 0 : $max;
}
else
{
return false;
}
}
public function min($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'MIN'));
if ($query)
{
$min = $query->fetchColumn();
return is_numeric($min) ? $min + 0 : $min;
}
else
{
return false;
}
}
public function avg($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'AVG'));
return $query ? 0 + $query->fetchColumn() : false;
}
public function sum($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'SUM'));
return $query ? 0 + $query->fetchColumn() : false;
}
public function debug()
{
$this->debug_mode = true;
return $this;
}
public function error()
{
return $this->pdo->errorInfo();
}
public function last_query()
{
return end($this->logs);
}
public function log()
{
return $this->logs;
}
public function info()
{
$output = array(
'server' => 'SERVER_INFO',
'driver' => 'DRIVER_NAME',
'client' => 'CLIENT_VERSION',
'version' => 'SERVER_VERSION',
'connection' => 'CONNECTION_STATUS'
);
foreach ($output as $key => $value)
{
$output[ $key ] = $this->pdo->getAttribute(constant('PDO::ATTR_' . $value));
}
return $output;
}
}
?>

View File

@ -0,0 +1,151 @@
<?php
require_once __DIR__ . "/lib/class.EmailTracker.php";
class Pluginemailtracking extends Plugin {
private $emailTracker;
/**
* Constructor
*/
function Pluginemailtracking(){}
/**
* Called to initialize the plugin and register for hooks.
*/
function init(){
$this->registerHook('server.core.settings.init.before');
$this->registerHook('server.core.operations.submitmessage');
$this->store = $GLOBALS['mapisession']->getDefaultMessageStore();
$this->emailTracker = new EmailTracker();
}
/**
* Process the incoming events that where fired by the client.
*
* @param String $eventID Identifier of the hook
* @param Array $data Reference to the data of the triggered hook
*/
function execute($eventID, &$data) {
switch($eventID){
// Register plugin
case 'server.core.settings.init.before':
$this->onBeforeSettingsInit($data);
break;
// Add tracking stuff before submitting the message
case 'server.core.operations.submitmessage':
$this->onBeforeSubmit($data);
break;
// Add tracking property, which is send to the client
case 'server.module.itemmodule.open.after':
$this->onAfterOpen($data);
break;
}
}
/**
* This function handles the 'beforesend' hook which is triggered before sending the email.
* If the PR_MESSAGE_CLASS is set to a signed email (IPM.Note.SMIME.Multipartsigned), this function
* will convert the mapi message to RFC822, sign the eml and attach the signed email to the mapi message.
*
* @param {mixed} $data from php hook
*/
function onBeforeSubmit(&$data)
{
$message = $data['message'];
// Retrieve message class
$props = mapi_getprops($message, array(PR_MESSAGE_CLASS, PR_SUBJECT, PR_SENDER_EMAIL_ADDRESS));
if (mapi_is_error(mapi_last_hresult())) {
error_log("error loading props!");
}
$recipients = mapi_message_getrecipienttable($message);
$messageClass = $props[PR_MESSAGE_CLASS];
if(isset($messageClass) && (stripos($messageClass, 'IPM.Note.Tracking') !== false)) {
// reset messageClass
mapi_setprops($message, array(PR_MESSAGE_CLASS => 'IPM.Note'));
error_log("Number of recipients: " . mapi_table_getrowcount($recipients));
// get all recipient email addresses
$filters=array(PR_ADDRTYPE, PR_EMAIL_ADDRESS, PR_SMTP_ADDRESS);
$rows = mapi_table_queryrows($recipients,$filters,0,1); // get only the first recipient
$recipient = "";
foreach($rows as $row) {
$recipient = $row[PR_ADDRTYPE] === "SMTP" ? $row[PR_SMTP_ADDRESS] : $row[PR_EMAIL_ADDRESS];
}
// get a new tracking id:
$trackingId = $this->emailTracker->getNewTrackingCode(md5($props[PR_SUBJECT] . time()), $recipient, $props[PR_SENDER_EMAIL_ADDRESS], $props[PR_SUBJECT]);
$trackingURL_Image = PLUGIN_EMAILTRACKING_PUBLIC_WEBAPP_URL . "/plugins/emailtracking/php/track.php?img=" . $trackingId;
$trackingURL_Sound = PLUGIN_EMAILTRACKING_PUBLIC_WEBAPP_URL . "/plugins/emailtracking/php/track.php?bgsound=" . $trackingId;
// add the tracking html tags to the body
$trackingHTML = '<img send="true" alt="" lowsrc="" src="' . $trackingURL_Image . '" border="0" height="1" width="3" />';
$trackingHTML .= '<bgsound volume="-10000" alt="" lowsrc="" src="' . $trackingURL_Sound . '">';
// stream the body and add the tracking changes!
$messageStream = mapi_openproperty($message, PR_HTML, IID_IStream, 0, 0);
$stat = mapi_stream_stat($messageStream);
// create temporary files
$tmpEmail = tempnam(sys_get_temp_dir(),true);
$fhandle = fopen($tmpEmail,'w');
$buffer = null;
for($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) {
// Write stream
$buffer = mapi_stream_read($messageStream, BLOCK_SIZE);
fwrite($fhandle,$buffer,strlen($buffer));
}
// append tracking stuff
fwrite($fhandle, $trackingHTML, strlen($trackingHTML));
fclose($fhandle);
// Save the signed message as attachment of the send email
$outStream = mapi_openproperty($message, PR_HTML, IID_IStream, 0, MAPI_CREATE | MAPI_MODIFY);
$handle = fopen($tmpEmail, 'r');
while (!feof($handle)) {
$contents = fread($handle, BLOCK_SIZE);
mapi_stream_write($outStream, $contents);
}
fclose($handle);
// Save stream
mapi_stream_commit($outStream);
// remove tmp files
unlink($tmpEmail);
// Save changes
mapi_savechanges($message);
}
}
/**
* Called when the core Settings class is initialized and ready to accept sysadmin default
* settings. Registers the sysadmin defaults for the example plugin.
*
* @param {mixed} $data Reference to the data of the triggered hook
*/
function onBeforeSettingsInit(&$data){
$data['settingsObj']->addSysAdminDefaults(Array(
'zarafa' => Array(
'v1' => Array(
'plugins' => Array(
'emailtracking' => Array(
'enable' => PLUGIN_EMAILTRACKING_USER_DEFAULT_ENABLE_TRACKING,
'internals' => PLUGIN_EMAILTRACKING_SHOW_INTERNAL_LOGS
)
)
)
)
));
}
}
?>

View File

@ -0,0 +1,32 @@
<?php
require __DIR__ . "/lib/class.EmailTracker.php";
$trackingID = "";
$type = "none";
// check which type was logged
if(isset($_GET["img"])) {
$trackingID = $_GET["img"];
$type = "img";
} else if(isset($_GET["sound"])) {
$trackingID = $_GET["bgsound"];
$type = "bgsound";
}
if(!empty($trackingID) && $type !== "none") {
$dbObj = new EmailTracker();
// build our tracking entry
$data = array(
"ip_addr" => $_SERVER["REMOTE_ADDR"],
"referrer" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "",
"client" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "",
"tracking_type" => $type,
"timestamp" => date('Y-m-d H:i:s', time()),
);
// log it to db
$dbObj->addLog($trackingID, $data);
} else {
echo "Powerful you have become, the dark side I sense in you.";
}

View File

@ -0,0 +1,11 @@
.icon_tracking_on {
background-image: url(../icons/ico_tracking_on.png);
background-repeat: no-repeat;
background-position: center;
}
.icon_tracking_off {
background-image: url(../icons/ico_tracking_off.png);
background-repeat: no-repeat;
background-position: center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.