Merge branch 'bugfix' into 'master'

Bugfix

See merge request !2
This commit is contained in:
Christoph Haas 2016-11-30 13:33:27 +01:00
commit d658c665d5
11 changed files with 763 additions and 660 deletions

View File

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="osboxes">
<words>
<w>guids</w>
</words>
</dictionary>
</component>

View File

@ -2,8 +2,7 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="aae153d8-808f-4371-b0e9-9ee7ff904cab" name="Default" comment=""> <list default="true" id="aae153d8-808f-4371-b0e9-9ee7ff904cab" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/changelog.txt" afterPath="$PROJECT_DIR$/changelog.txt" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/js/dialogs/ImportPanel.js" afterPath="$PROJECT_DIR$/js/dialogs/ImportPanel.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/manifest.xml" afterPath="$PROJECT_DIR$/manifest.xml" />
</list> </list>
<ignored path="contactimporter.iws" /> <ignored path="contactimporter.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -23,12 +22,12 @@
<favorites_list name="contactimporter" /> <favorites_list name="contactimporter" />
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="ContextMenu.js" pinned="false" current-in-tab="false"> <file leaf-file-name="ContextMenu.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/ui/ContextMenu.js"> <entry file="file://$PROJECT_DIR$/js/ui/ContextMenu.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="159"> <state relative-caret-position="1665">
<caret line="101" column="8" selection-start-line="101" selection-start-column="8" selection-end-line="104" selection-end-column="0" /> <caret line="111" column="5" selection-start-line="111" selection-start-column="5" selection-end-line="111" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -37,74 +36,65 @@
<file leaf-file-name="plugin.contactimporter.js" pinned="false" current-in-tab="false"> <file leaf-file-name="plugin.contactimporter.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/plugin.contactimporter.js"> <entry file="file://$PROJECT_DIR$/js/plugin.contactimporter.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2670"> <state relative-caret-position="-231">
<caret line="80" column="0" selection-start-line="80" selection-start-column="0" selection-end-line="80" selection-end-column="0" /> <caret line="83" column="9" selection-start-line="83" selection-start-column="9" selection-end-line="83" selection-end-column="9" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="ABOUT.js" pinned="false" current-in-tab="false"> <file leaf-file-name="Actions.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/ABOUT.js"> <entry file="file://$PROJECT_DIR$/js/data/Actions.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375"> <state relative-caret-position="255">
<caret line="25" column="39" selection-start-line="25" selection-start-column="39" selection-end-line="25" selection-end-column="39" /> <caret line="17" column="26" selection-start-line="17" selection-start-column="22" selection-end-line="17" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="module.contact.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/module.contact.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="279">
<caret line="434" column="71" selection-start-line="434" selection-start-column="71" selection-end-line="434" selection-end-column="105" />
<folding> <folding>
<marker date="1480430157843" expanded="true" signature="1216:1220" ph="&lt;" /> <element signature="e#7#920#0#PHP" expanded="true" />
<marker date="1480430157843" expanded="true" signature="1246:1250" ph="&gt;" /> <element signature="e#1010#1043#0#PHP" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="config.php" pinned="false" current-in-tab="false"> <file leaf-file-name="ImportPanel.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="8" column="75" selection-start-line="8" selection-start-column="75" selection-end-line="8" selection-end-column="75" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="changelog.txt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/changelog.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="25" selection-start-line="17" selection-start-column="25" selection-end-line="17" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="manifest.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/manifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="22" selection-start-line="4" selection-start-column="22" selection-end-line="4" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="270">
<caret line="18" column="0" selection-start-line="18" selection-start-column="0" selection-end-line="21" selection-end-column="43" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ImportPanel.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js"> <entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="570"> <state relative-caret-position="287">
<caret line="581" column="8" selection-start-line="581" selection-start-column="8" selection-end-line="583" selection-end-column="8" /> <caret line="196" column="46" selection-start-line="196" selection-start-column="46" selection-end-line="196" selection-end-column="46" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ImportContentPanel.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportContentPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="474">
<caret line="44" column="20" selection-start-line="44" selection-start-column="20" selection-end-line="44" selection-end-column="55" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ResponseHandler.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/data/ResponseHandler.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="744">
<caret line="80" column="13" selection-start-line="80" selection-start-column="8" selection-end-line="80" selection-end-column="13" />
<folding> <folding>
<element signature="n#!!doc" expanded="true" /> <element signature="n#!!doc" expanded="true" />
</folding> </folding>
@ -120,20 +110,22 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/php/download.php" />
<option value="$PROJECT_DIR$/php/module.contact.php" />
<option value="$PROJECT_DIR$/php/plugin.contactimporter.php" />
<option value="$PROJECT_DIR$/config.php" /> <option value="$PROJECT_DIR$/config.php" />
<option value="$PROJECT_DIR$/js/ABOUT.js" /> <option value="$PROJECT_DIR$/js/ABOUT.js" />
<option value="$PROJECT_DIR$/js/dialogs/ImportContentPanel.js" /> <option value="$PROJECT_DIR$/js/dialogs/ImportContentPanel.js" />
<option value="$PROJECT_DIR$/js/dialogs/ImportPanel.js" />
<option value="$PROJECT_DIR$/js/data/ResponseHandler.js" /> <option value="$PROJECT_DIR$/js/data/ResponseHandler.js" />
<option value="$PROJECT_DIR$/php/upload.php" />
<option value="$PROJECT_DIR$/build.xml" /> <option value="$PROJECT_DIR$/build.xml" />
<option value="$PROJECT_DIR$/js/ui/ContextMenu.js" />
<option value="$PROJECT_DIR$/js/plugin.contactimporter.js" />
<option value="$PROJECT_DIR$/changelog.txt" /> <option value="$PROJECT_DIR$/changelog.txt" />
<option value="$PROJECT_DIR$/manifest.xml" /> <option value="$PROJECT_DIR$/manifest.xml" />
<option value="$PROJECT_DIR$/php/download.php" />
<option value="$PROJECT_DIR$/php/upload.php" />
<option value="$PROJECT_DIR$/php/helper.php" />
<option value="$PROJECT_DIR$/php/plugin.contactimporter.php" />
<option value="$PROJECT_DIR$/php/module.contact.php" />
<option value="$PROJECT_DIR$/js/plugin.contactimporter.js" />
<option value="$PROJECT_DIR$/js/ui/ContextMenu.js" />
<option value="$PROJECT_DIR$/js/data/Actions.js" />
<option value="$PROJECT_DIR$/js/dialogs/ImportPanel.js" />
</list> </list>
</option> </option>
</component> </component>
@ -175,11 +167,6 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope">
<subPane subId="Project Files" />
<subPane subId="Default" />
</pane>
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<PATH> <PATH>
@ -212,46 +199,6 @@
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" /> <option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="contactimporter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="contactimporter" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="languages" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="en_US.UTF-8" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="contactimporter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="contactimporter" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="languages" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="en_US.UTF-8" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="LC_MESSAGES" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH> <PATH>
<PATH_ELEMENT> <PATH_ELEMENT>
<option name="myItemId" value="contactimporter" /> <option name="myItemId" value="contactimporter" />
@ -336,13 +283,23 @@
</PATH> </PATH>
</subPane> </subPane>
</pane> </pane>
<pane id="Scope">
<subPane subId="Project Files" />
<subPane subId="Default" />
</pane>
<pane id="Scratches" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../calendarimporter" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="js-jscs-nodeInterpreter" value="/usr/bin/node" /> <property name="js-jscs-nodeInterpreter" value="/usr/bin/node" />
</component> </component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/js/data" />
</key>
</component>
<component name="RunManager"> <component name="RunManager">
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug"> <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method /> <method />
@ -403,12 +360,13 @@
<updated>1480428196914</updated> <updated>1480428196914</updated>
<workItem from="1480428199144" duration="44000" /> <workItem from="1480428199144" duration="44000" />
<workItem from="1480428259775" duration="69000" /> <workItem from="1480428259775" duration="69000" />
<workItem from="1480428330068" duration="6578000" /> <workItem from="1480428330068" duration="6691000" />
<workItem from="1480504955898" duration="4182000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="6691000" /> <option name="totallyTimeSpent" value="10986000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="65" y="24" width="1792" height="999" extended-state="6" /> <frame x="65" y="24" width="1792" height="999" extended-state="6" />
@ -418,6 +376,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" 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" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32900432" sideWeight="0.5" order="1" 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" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" 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" show_stripe_button="true" 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" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" 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="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@ -428,7 +387,6 @@
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" 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" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" 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" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" 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" show_stripe_button="true" 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" show_stripe_button="true" weight="0.25" 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" show_stripe_button="true" 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" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout> </layout>
@ -446,126 +404,38 @@
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<option name="time" value="1" /> <option name="time" value="2" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/languages/de_DE.UTF-8/language.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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$/resources/css/contactimporter-main.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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/dialogs/fields.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3900">
<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/dialogs/ImportContentPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="474">
<caret line="44" column="20" selection-start-line="44" selection-start-column="20" selection-end-line="44" selection-end-column="55" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/data/ResponseHandler.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1200">
<caret line="80" column="13" selection-start-line="80" selection-start-column="8" selection-end-line="80" selection-end-column="13" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/download.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-225">
<caret line="3" column="15" selection-start-line="3" selection-start-column="15" selection-end-line="3" selection-end-column="57" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/module.contact.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-16319">
<caret line="25" column="0" selection-start-line="25" selection-start-column="0" selection-end-line="25" selection-end-column="0" />
<folding>
<element signature="e#6#919#0#PHP" expanded="true" />
<element signature="e#959#992#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.contactimporter.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="675">
<caret line="84" column="83" selection-start-line="84" selection-start-column="83" selection-end-line="84" selection-end-column="83" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/upload.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="780">
<caret line="72" column="1" selection-start-line="72" selection-start-column="1" selection-end-line="72" selection-end-column="1" />
<folding>
<element signature="e#6#911#0#PHP" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/languages/en_US.UTF-8/LC_MESSAGES/plugin_calendarimporter.po">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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$/build.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="167" column="18" selection-start-line="167" selection-start-column="18" selection-end-line="167" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="570">
<caret line="581" column="8" selection-start-line="581" selection-start-column="8" selection-end-line="583" selection-end-column="8" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/ContextMenu.js"> <entry file="file://$PROJECT_DIR$/js/ui/ContextMenu.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="159"> <state relative-caret-position="1515">
<caret line="101" column="8" selection-start-line="101" selection-start-column="8" selection-end-line="104" selection-end-column="0" /> <caret line="101" column="8" selection-start-line="101" selection-start-column="8" selection-end-line="104" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/plugin.contactimporter.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1200">
<caret line="80" column="0" selection-start-line="80" selection-start-column="0" selection-end-line="80" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ABOUT.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="25" column="39" selection-start-line="25" selection-start-column="39" selection-end-line="25" selection-end-column="39" />
<folding>
<marker date="1480430157843" expanded="true" signature="1216:1220" ph="&lt;" />
<marker date="1480430157843" expanded="true" signature="1246:1250" ph="&gt;" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php"> <entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120"> <state relative-caret-position="120">
@ -574,6 +444,14 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/changelog.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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$/manifest.xml"> <entry file="file://$PROJECT_DIR$/manifest.xml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60"> <state relative-caret-position="60">
@ -593,14 +471,65 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/plugin.contactimporter.js"> <entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2670"> <state relative-caret-position="8415">
<caret line="80" column="0" selection-start-line="80" selection-start-column="0" selection-end-line="80" selection-end-column="0" /> <caret line="581" column="8" selection-start-line="581" selection-start-column="8" selection-end-line="583" selection-end-column="8" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/languages/de_DE.UTF-8/language.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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$/resources/css/contactimporter-main.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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/dialogs/fields.txt" />
<entry file="file://$PROJECT_DIR$/languages/en_US.UTF-8/LC_MESSAGES/plugin_calendarimporter.po">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<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$/build.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="167" column="18" selection-start-line="167" selection-start-column="18" selection-end-line="167" selection-end-column="18" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/manifest.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="22" selection-start-line="4" selection-start-column="22" selection-end-line="4" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="270">
<caret line="18" column="0" selection-start-line="18" selection-start-column="0" selection-end-line="21" selection-end-column="43" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ABOUT.js"> <entry file="file://$PROJECT_DIR$/js/ABOUT.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375"> <state relative-caret-position="375">
@ -620,6 +549,115 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/php/download.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615">
<caret line="41" column="9" selection-start-line="41" selection-start-column="9" selection-end-line="41" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/upload.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="3" selection-start-line="22" selection-start-column="3" selection-end-line="22" selection-end-column="3" />
<folding>
<element signature="e#7#912#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="38" selection-start-line="5" selection-start-column="8" selection-end-line="5" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/helper.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding>
<element signature="e#7#912#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/plugin.contactimporter.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420">
<caret line="28" column="31" selection-start-line="28" selection-start-column="31" selection-end-line="28" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/module.contact.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="279">
<caret line="434" column="71" selection-start-line="434" selection-start-column="71" selection-end-line="434" selection-end-column="105" />
<folding>
<element signature="e#7#920#0#PHP" expanded="true" />
<element signature="e#1010#1043#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/ContextMenu.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1665">
<caret line="111" column="5" selection-start-line="111" selection-start-column="5" selection-end-line="111" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/data/Actions.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="26" selection-start-line="17" selection-start-column="22" selection-end-line="17" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/plugin.contactimporter.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-231">
<caret line="83" column="9" selection-start-line="83" selection-start-column="9" selection-end-line="83" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportContentPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="474">
<caret line="44" column="20" selection-start-line="44" selection-start-column="20" selection-end-line="44" selection-end-column="55" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/data/ResponseHandler.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="744">
<caret line="80" column="13" selection-start-line="80" selection-start-column="8" selection-end-line="80" selection-end-column="13" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/dialogs/ImportPanel.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="287">
<caret line="196" column="46" selection-start-line="196" selection-start-column="46" selection-end-line="196" selection-end-column="46" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component> </component>
<component name="masterDetails"> <component name="masterDetails">
<states> <states>

227
js/data/Actions.js Normal file
View File

@ -0,0 +1,227 @@
/**
* Actions.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
Ext.namespace('Zarafa.plugins.contactimporter.data');
/**
* @class Zarafa.plugins.contactimporter.data.Actions
* Common actions which can be used within {@link Ext.Button buttons}
* or other {@link Ext.Component components} with action handlers.
* @singleton
*/
Zarafa.plugins.contactimporter.data.Actions = {
/**
* Generates a request to download the selected records as vCard.
*
* @param storeId
* @param recordIds
*/
exportToVCF: function (storeId, recordIds, recordFolder) {
if ((typeof recordIds != "undefined" && recordIds.length < 1) || (typeof recordFolder != "undefined" && recordFolder.get('content_count') < 1)) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Error'),
msg: dgettext('plugin_contactimporter', 'No contacts found. Export skipped!'),
icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
successCallback: Zarafa.plugins.contactimporter.data.Actions.downloadVCF
});
var recordcount = 0;
var exportPayload = {
storeid: storeId,
records: undefined,
folder: undefined
};
if (typeof recordIds != "undefined") {
exportPayload.records = recordIds;
recordcount = recordIds.length;
}
if (typeof recordFolder != "undefined") {
exportPayload.folder = recordFolder.get("entryid");
recordcount = recordFolder.get('content_count');
}
// Notify user
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Contact Export'), String.format(dgettext('plugin_contactimporter', 'Exporting {0} contacts. Please wait...'), recordcount));
// request attachment preperation
container.getRequest().singleRequest(
'contactmodule',
'export',
exportPayload,
responseHandler
);
}
},
/**
* Callback for the export request.
* @param {Object} response
*/
downloadVCF: function (response) {
if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Warning'),
msg: response.message,
icon: Zarafa.common.dialogs.MessageBox.WARNING,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
var url = document.URL;
var link = url.substring(0, url.lastIndexOf('/') + 1);
link += "index.php?sessionid=" + container.getUser().getSessionId() + "&load=custom&name=download_vcf";
link = Ext.urlAppend(link, "token=" + encodeURIComponent(response.download_token));
link = Ext.urlAppend(link, "filename=" + encodeURIComponent(response.filename));
downloadFrame.dom.contentWindow.location = link;
}
},
/**
* Get all contact folders.
* @param {boolean} asDropdownStore If true, a simple array store will be returned.
* @returns {*}
*/
getAllContactFolders: function (asDropdownStore) {
asDropdownStore = Ext.isEmpty(asDropdownStore) ? false : asDropdownStore;
var allFolders = [];
var defaultContactFolder = container.getHierarchyStore().getDefaultFolder('contact');
var inbox = container.getHierarchyStore().getDefaultStore();
var pub = container.getHierarchyStore().getPublicStore();
if (!Ext.isEmpty(inbox.subStores) && inbox.subStores.folders.totalLength > 0) {
for (var i = 0; i < inbox.subStores.folders.totalLength; i++) {
var folder = inbox.subStores.folders.getAt(i);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Contact") {
if (asDropdownStore) {
allFolders.push([
folder.get("entryid"),
folder.get("display_name")
]);
} else {
allFolders.push({
display_name: folder.get("display_name"),
entryid: folder.get("entryid"),
store_entryid: folder.get("store_entryid"),
is_public: false
});
}
}
}
}
if (!Ext.isEmpty(pub.subStores) && pub.subStores.folders.totalLength > 0) {
for (var j = 0; j < pub.subStores.folders.totalLength; j++) {
var folder = pub.subStores.folders.getAt(j);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Contact") {
if (asDropdownStore) {
allFolders.push([
folder.get("entryid"),
folder.get("display_name") + " (Public)"
]);
} else {
allFolders.push({
display_name: folder.get("display_name"),
entryid: folder.get("entryid"),
store_entryid: folder.get("store_entryid"),
is_public: true
});
}
}
}
}
if (asDropdownStore) {
return allFolders.sort(Zarafa.plugins.contactimporter.data.Actions.dynamicSort(1));
} else {
return allFolders;
}
},
/**
* Dynamic sort function, sorts by property name.
* @param {string|int} property
* @returns {Function}
*/
dynamicSort: function (property) {
var sortOrder = 1;
if (property[0] === "-") {
sortOrder = -1;
property = property.substr(1);
}
return function (a, b) {
var result = (a[property].toLowerCase() < b[property].toLowerCase()) ? -1 : (a[property].toLowerCase() > b[property].toLowerCase()) ? 1 : 0;
return result * sortOrder;
}
},
/**
* Return a contact folder element by name.
* @param {string} name
* @returns {*}
*/
getContactFolderByName: function (name) {
var folders = Zarafa.plugins.contactimporter.data.Actions.getAllContactFolders(false);
for (var i = 0; i < folders.length; i++) {
if (folders[i].display_name == name) {
return folders[i];
}
}
return container.getHierarchyStore().getDefaultFolder('contact');
},
/**
* Return a contact folder element by entryid.
* @param {string} entryid
* @returns {*}
*/
getContactFolderByEntryid: function (entryid) {
var folders = Zarafa.plugins.contactimporter.data.Actions.getAllContactFolders(false);
for (var i = 0; i < folders.length; i++) {
if (folders[i].entryid == entryid) {
return folders[i];
}
}
return container.getHierarchyStore().getDefaultFolder('contact');
}
};

View File

@ -132,121 +132,6 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
}; };
}, },
/**
* Get all contact folders.
* @param {boolean} asDropdownStore If true, a simple array store will be returned.
* @returns {*}
*/
getAllContactFolders: function (asDropdownStore) {
asDropdownStore = Ext.isEmpty(asDropdownStore) ? false : asDropdownStore;
var allFolders = [];
var defaultContactFolder = container.getHierarchyStore().getDefaultFolder('contact');
var inbox = container.getHierarchyStore().getDefaultStore();
var pub = container.getHierarchyStore().getPublicStore();
if (!Ext.isEmpty(inbox.subStores) && inbox.subStores.folders.totalLength > 0) {
for (var i = 0; i < inbox.subStores.folders.totalLength; i++) {
var folder = inbox.subStores.folders.getAt(i);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Contact") {
if (asDropdownStore) {
allFolders.push([
folder.get("entryid"),
folder.get("display_name")
]);
} else {
allFolders.push({
display_name: folder.get("display_name"),
entryid: folder.get("entryid"),
store_entryid: folder.get("store_entryid"),
is_public: false
});
}
}
}
}
if (!Ext.isEmpty(pub.subStores) && pub.subStores.folders.totalLength > 0) {
for (var j = 0; j < pub.subStores.folders.totalLength; j++) {
var folder = pub.subStores.folders.getAt(j);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Contact") {
if (asDropdownStore) {
allFolders.push([
folder.get("entryid"),
folder.get("display_name") + " (Public)"
]);
} else {
allFolders.push({
display_name: folder.get("display_name"),
entryid: folder.get("entryid"),
store_entryid: folder.get("store_entryid"),
is_public: true
});
}
}
}
}
if (asDropdownStore) {
return allFolders.sort(this.dynamicSort(1));
} else {
return allFolders;
}
},
/**
* Dynamic sort function, sorts by property name.
* @param {string|int} property
* @returns {Function}
*/
dynamicSort: function (property) {
var sortOrder = 1;
if (property[0] === "-") {
sortOrder = -1;
property = property.substr(1);
}
return function (a, b) {
var result = (a[property].toLowerCase() < b[property].toLowerCase()) ? -1 : (a[property].toLowerCase() > b[property].toLowerCase()) ? 1 : 0;
return result * sortOrder;
}
},
/**
* Return a contact folder element by name.
* @param {string} name
* @returns {*}
*/
getContactFolderByName: function (name) {
var folders = this.getAllContactFolders(false);
for (var i = 0; i < folders.length; i++) {
if (folders[i].display_name == name) {
return folders[i];
}
}
return container.getHierarchyStore().getDefaultFolder('contact');
},
/**
* Return a contact folder element by entryid.
* @param {string} entryid
* @returns {*}
*/
getContactFolderByEntryid: function (entryid) {
var folders = this.getAllContactFolders(false);
for (var i = 0; i < folders.length; i++) {
if (folders[i].entryid == entryid) {
return folders[i];
}
}
return container.getHierarchyStore().getDefaultFolder('contact');
},
/** /**
* Reloads the data of the grid * Reloads the data of the grid
* @private * @private
@ -309,18 +194,18 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
}, },
/** /**
* Generate the UI calendar select box. * Generate the UI addressbook select box.
* @returns {*} * @returns {*}
*/ */
createSelectBox: function () { createSelectBox: function () {
var myStore = this.getAllContactFolders(true); var myStore = Zarafa.plugins.contactimporter.data.Actions.getAllContactFolders(true);
return { return {
xtype: "selectbox", xtype: "selectbox",
ref: 'addressbookSelector', ref: 'addressbookSelector',
editable: false, editable: false,
name: "choosen_addressbook", name: "choosen_addressbook",
value: Ext.isEmpty(this.folder) ? this.getContactFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/default_addressbook")).entryid : this.folder, value: Ext.isEmpty(this.folder) ? Zarafa.plugins.contactimporter.data.Actions.getContactFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/default_addressbook")).entryid : this.folder,
width: 100, width: 100,
fieldLabel: dgettext('plugin_contactimporter', 'Select folder'), fieldLabel: dgettext('plugin_contactimporter', 'Select folder'),
store: myStore, store: myStore,
@ -430,7 +315,7 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
this.submitAllButton.disable(); this.submitAllButton.disable();
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Error'), title: dgettext('plugin_contactimporter', 'Error'),
msg: _(action.result.error), msg: action.result.error,
icon: Zarafa.common.dialogs.MessageBox.ERROR, icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK buttons: Zarafa.common.dialogs.MessageBox.OK
}); });
@ -542,7 +427,7 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
buttons: Zarafa.common.dialogs.MessageBox.OK buttons: Zarafa.common.dialogs.MessageBox.OK
}); });
} else { } else {
var contactFolder = this.getContactFolderByEntryid(folderValue); var contactFolder = Zarafa.plugins.contactimporter.data.Actions.getContactFolderByEntryid(folderValue);
this.loadMask.show(); this.loadMask.show();
var uids = []; var uids = [];

View File

@ -83,55 +83,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
recordIds.push(btn.records[i].get("entryid")); recordIds.push(btn.records[i].get("entryid"));
} }
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({ Zarafa.plugins.contactimporter.data.Actions.exportToVCF(btn.records[0].get("store_entryid"), recordIds, undefined);
successCallback: this.downloadVCF,
scope: this
});
// Notify user
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Contact Export'), String.format(dgettext('plugin_contactimporter', 'Exporting {0} contacts. Please wait...'), recordIds.length));
// request attachment preperation
container.getRequest().singleRequest(
'contactmodule',
'export',
{
storeid: btn.records[0].get("store_entryid"),
records: recordIds
},
responseHandler
);
},
/**
* Callback for the export request.
* @param {Object} response
*/
downloadVCF: function (response) {
if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Warning'),
msg: response.message,
icon: Zarafa.common.dialogs.MessageBox.WARNING,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
var url = document.URL;
var link = url.substring(0, url.lastIndexOf('/') + 1);
link += "index.php?sessionid=" + container.getUser().getSessionId() + "&load=custom&name=download_vcf";
link = Ext.urlAppend(link, "token=" + encodeURIComponent(response.download_token));
link = Ext.urlAppend(link, "filename=" + encodeURIComponent(response.filename));
downloadFrame.dom.contentWindow.location = link;
}
}, },
/** /**

View File

@ -94,25 +94,7 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
* @private * @private
*/ */
onContextItemExport: function () { onContextItemExport: function () {
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({ Zarafa.plugins.contactimporter.data.Actions.exportToVCF(this.records.get("store_entryid"), undefined, this.records);
successCallback: this.downloadVCF,
scope: this
});
// Notify user
// # TRANSLATORS: {0} will be replaced by the number of contacts that will be exported
container.getNotifier().notify('info', dgettext('plugin_contactimporter', 'Contact Export'), String.format(dgettext('plugin_contactimporter', 'Exporting {0} contacts. Please wait...'), this.records.get('content_count')));
// request attachment preperation
container.getRequest().singleRequest(
'contactmodule',
'export',
{
storeid: this.records.get("store_entryid"),
folder: this.records.get("entryid")
},
responseHandler
);
}, },
/** /**
@ -127,35 +109,6 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
}; };
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config); Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
},
/**
* Callback for the export request.
* @param {Object} response
*/
downloadVCF: function (response) {
if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Warning'),
msg: response.message,
icon: Zarafa.common.dialogs.MessageBox.WARNING,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
var url = document.URL;
var link = url.substring(0, url.lastIndexOf('/') + 1);
link += "index.php?sessionid=" + container.getUser().getSessionId() + "&load=custom&name=download_vcf";
link = Ext.urlAppend(link, "token=" + encodeURIComponent(response.download_token));
link = Ext.urlAppend(link, "filename=" + encodeURIComponent(response.filename));
downloadFrame.dom.contentWindow.location = link;
}
} }
}); });

View File

@ -25,6 +25,7 @@ class DownloadHandler
{ {
/** /**
* Download the given vcf file. * Download the given vcf file.
* @return boolean
*/ */
public static function doDownload() public static function doDownload()
{ {
@ -41,7 +42,7 @@ class DownloadHandler
} }
// validate token // validate token
if (!ctype_alnum($token)) { // token is a md5 hash if (!preg_match('/^[a-zA-Z0-9]+$/', $token)) { // token is a md5 hash
return false; return false;
} }
@ -67,5 +68,7 @@ class DownloadHandler
readfile($file); readfile($file);
ignore_user_abort(true); ignore_user_abort(true);
unlink($file); unlink($file);
return true;
} }
} }

62
php/helper.php Normal file
View File

@ -0,0 +1,62 @@
<?php
/**
* helper.php, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
namespace contactimporter;
class Helper
{
/**
* Generates a random string with variable length.
*
* @param $length the lenght of the generated string, defaults to 6
* @return string a random string
*/
public static function randomstring($length = 6)
{
// $chars - all allowed charakters
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
srand((double)microtime() * 1000000);
$i = 0;
$pass = "";
while ($i < $length) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
/**
* respond/echo JSON
*
* @param $arr
* @return string JSON encoded string
*/
public static function respondJSON($arr)
{
echo json_encode($arr);
}
}

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* module.contact.php, Kopano Webapp contact to vcf im/exporter * module.contact.php, Kopano Webapp contact to vcf im/exporter
* *
@ -21,11 +22,14 @@
* *
*/ */
include_once('vendor/autoload.php'); include_once(__DIR__ . "/vendor/autoload.php");
require_once(__DIR__ . "/helper.php");
use JeroenDesloovere\VCard\VCard; use JeroenDesloovere\VCard\VCard;
use JeroenDesloovere\VCard\VCardParser; use JeroenDesloovere\VCard\VCardParser;
use contactimporter\Helper;
class ContactModule extends Module class ContactModule extends Module
{ {
@ -44,6 +48,7 @@ class ContactModule extends Module
/** /**
* Executes all the actions in the $data variable. * Executes all the actions in the $data variable.
* Exception part is used for authentication errors also * Exception part is used for authentication errors also
*
* @return boolean true on success or false on failure. * @return boolean true on success or false on failure.
*/ */
public function execute() public function execute()
@ -93,30 +98,9 @@ class ContactModule extends Module
return $result; return $result;
} }
/**
* Generates a random string with variable length.
* @param $length the lenght of the generated string
* @return string a random string
*/
private function randomstring($length = 6)
{
// $chars - all allowed charakters
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
srand((double)microtime() * 1000000);
$i = 0;
$pass = "";
while ($i < $length) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
/** /**
* Add an attachment to the give contact * Add an attachment to the give contact
*
* @param $actionType * @param $actionType
* @param $actionData * @param $actionData
*/ */
@ -124,21 +108,21 @@ class ContactModule extends Module
{ {
// Get uploaded vcf path // Get uploaded vcf path
$vcffile = false; $vcfFile = false;
if (isset($actionData["vcf_filepath"])) { if (isset($actionData["vcf_filepath"])) {
$vcffile = $actionData["vcf_filepath"]; $vcfFile = $actionData["vcf_filepath"];
} }
// Get store id // Get store id
$storeid = false; $storeId = false;
if (isset($actionData["storeid"])) { if (isset($actionData["storeid"])) {
$storeid = $actionData["storeid"]; $storeId = $actionData["storeid"];
} }
// Get folder entryid // Get folder entryid
$folderid = false; $folderId = false;
if (isset($actionData["folderid"])) { if (isset($actionData["folderid"])) {
$folderid = $actionData["folderid"]; $folderId = $actionData["folderid"];
} }
// Get uids // Get uids
@ -149,27 +133,27 @@ class ContactModule extends Module
$response = array(); $response = array();
$error = false; $error = false;
$error_msg = ""; $errorMsg = "";
// parse the vcf file a last time... // parse the vcf file a last time...
$parser = null; $parser = null;
try { try {
$parser = VCardParser::parseFromFile($vcffile); $parser = VCardParser::parseFromFile($vcfFile);
} catch (Exception $e) { } catch (Exception $e) {
$error = true; $error = true;
$error_msg = $e->getMessage(); $errorMsg = $e->getMessage();
} }
$contacts = array(); $contacts = array();
if (!$error && iterator_count($parser) > 0) { if (!$error && iterator_count($parser) > 0) {
$contacts = $this->parseContactsToArray($parser); $contacts = $this->parseContactsToArray($parser);
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId));
$folder = mapi_msgstore_openentry($store, hex2bin($folderid)); $folder = mapi_msgstore_openentry($store, hex2bin($folderId));
$importall = false; $importAll = false;
if (count($uids) == count($contacts)) { if (count($uids) == count($contacts)) {
$importall = true; $importAll = true;
} }
$propValuesMAPI = array(); $propValuesMAPI = array();
@ -179,7 +163,7 @@ class ContactModule extends Module
// iterate through all contacts and import them :) // iterate through all contacts and import them :)
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
if (isset($contact["display_name"]) && ($importall || in_array($contact["internal_fields"]["contact_uid"], $uids))) { if (isset($contact["display_name"]) && ($importAll || in_array($contact["internal_fields"]["contact_uid"], $uids))) {
// parse the arraykeys // parse the arraykeys
// TODO: this is very slow... // TODO: this is very slow...
foreach ($contact as $key => $value) { foreach ($contact as $key => $value) {
@ -242,7 +226,7 @@ class ContactModule extends Module
} else { } else {
$response['status'] = false; $response['status'] = false;
$response['count'] = 0; $response['count'] = 0;
$response['message'] = $error ? $error_msg : dgettext("plugin_contactimporter", "VCF file is empty!"); $response['message'] = $error ? $errorMsg : dgettext("plugin_contactimporter", "VCF file is empty!");
} }
$this->addActionData($actionType, $response); $this->addActionData($actionType, $response);
@ -252,20 +236,20 @@ class ContactModule extends Module
/** /**
* Get a property from the array. * Get a property from the array.
* @param $props * @param $props
* @param $propname * @param $propName
* @return string * @return string
*/ */
private function getProp($props, $propname) private function getProp($props, $propName)
{ {
$p = $this->getProperties(); if (isset($props["props"][$propName])) {
if (isset($props["props"][$propname])) { return $props["props"][$propName];
return $props["props"][$propname];
} }
return ""; return "";
} }
/** /**
* Export selected contacts to vCard. * Export selected contacts to vCard.
*
* @param $actionType * @param $actionType
* @param $actionData * @param $actionData
* @return bool * @return bool
@ -273,9 +257,9 @@ class ContactModule extends Module
private function exportContacts($actionType, $actionData) private function exportContacts($actionType, $actionData)
{ {
// Get store id // Get store id
$storeid = false; $storeId = false;
if (isset($actionData["storeid"])) { if (isset($actionData["storeid"])) {
$storeid = $actionData["storeid"]; $storeId = $actionData["storeid"];
} }
// Get records // Get records
@ -295,17 +279,17 @@ class ContactModule extends Module
$error_msg = ""; $error_msg = "";
// write csv // write csv
$token = $this->randomstring(16); $token = Helper::randomstring(16);
$file = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "vcf_" . $token . ".vcf"; $file = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "vcf_" . $token . ".vcf";
file_put_contents($file, ""); file_put_contents($file, "");
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId));
if ($store) { if ($store) {
// load folder first // load folder first
if ($folder !== false) { if ($folder !== false) {
$mapifolder = mapi_msgstore_openentry($store, hex2bin($folder)); $mapiFolder = mapi_msgstore_openentry($store, hex2bin($folder));
$table = mapi_folder_getcontentstable($mapifolder); $table = mapi_folder_getcontentstable($mapiFolder);
$list = mapi_table_queryallrows($table, array(PR_ENTRYID)); $list = mapi_table_queryallrows($table, array(PR_ENTRYID));
foreach ($list as $item) { foreach ($list as $item) {
@ -314,7 +298,7 @@ class ContactModule extends Module
} }
for ($index = 0, $count = count($records); $index < $count; $index++) { for ($index = 0, $count = count($records); $index < $count; $index++) {
// define vcard // define vcard
$vcard = new VCard(); $vCard = new VCard();
$message = mapi_msgstore_openentry($store, hex2bin($records[$index])); $message = mapi_msgstore_openentry($store, hex2bin($records[$index]));
@ -324,118 +308,118 @@ class ContactModule extends Module
$messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext); $messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext);
// define variables // define variables
$firstname = $this->getProp($messageProps, "given_name"); $firstName = $this->getProp($messageProps, "given_name");
$lastname = $this->getProp($messageProps, "surname"); $lastName = $this->getProp($messageProps, "surname");
$additional = $this->getProp($messageProps, "middle_name"); $additional = $this->getProp($messageProps, "middle_name");
$prefix = $this->getProp($messageProps, "display_name_prefix"); $prefix = $this->getProp($messageProps, "display_name_prefix");
$suffix = ''; $suffix = '';
// add personal data // add personal data
$vcard->addName($lastname, $firstname, $additional, $prefix, $suffix); $vCard->addName($lastName, $firstName, $additional, $prefix, $suffix);
$company = $this->getProp($messageProps, "company_name"); $company = $this->getProp($messageProps, "company_name");
if (!empty($company)) { if (!empty($company)) {
$vcard->addCompany($company); $vCard->addCompany($company);
} }
$jobtitle = $this->getProp($messageProps, "title"); $jobTitle = $this->getProp($messageProps, "title");
if (!empty($jobtitle)) { if (!empty($jobTitle)) {
$vcard->addJobtitle($jobtitle); $vCard->addJobtitle($jobTitle);
} }
// MAIL // MAIL
$mail = $this->getProp($messageProps, "email_address_1"); $mail = $this->getProp($messageProps, "email_address_1");
if (!empty($mail)) { if (!empty($mail)) {
$vcard->addEmail($mail); $vCard->addEmail($mail);
} }
$mail = $this->getProp($messageProps, "email_address_2"); $mail = $this->getProp($messageProps, "email_address_2");
if (!empty($mail)) { if (!empty($mail)) {
$vcard->addEmail($mail); $vCard->addEmail($mail);
} }
$mail = $this->getProp($messageProps, "email_address_3"); $mail = $this->getProp($messageProps, "email_address_3");
if (!empty($mail)) { if (!empty($mail)) {
$vcard->addEmail($mail); $vCard->addEmail($mail);
} }
// PHONE // PHONE
$wphone = $this->getProp($messageProps, "business_telephone_number"); $wPhone = $this->getProp($messageProps, "business_telephone_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'WORK'); $vCard->addPhoneNumber($wPhone, 'WORK');
} }
$wphone = $this->getProp($messageProps, "home_telephone_number"); $wPhone = $this->getProp($messageProps, "home_telephone_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'HOME'); $vCard->addPhoneNumber($wPhone, 'HOME');
} }
$wphone = $this->getProp($messageProps, "cellular_telephone_number"); $wPhone = $this->getProp($messageProps, "cellular_telephone_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'CELL'); $vCard->addPhoneNumber($wPhone, 'CELL');
} }
$wphone = $this->getProp($messageProps, "business_fax_number"); $wPhone = $this->getProp($messageProps, "business_fax_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'FAX'); $vCard->addPhoneNumber($wPhone, 'FAX');
} }
$wphone = $this->getProp($messageProps, "pager_telephone_number"); $wPhone = $this->getProp($messageProps, "pager_telephone_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'PAGER'); $vCard->addPhoneNumber($wPhone, 'PAGER');
} }
$wphone = $this->getProp($messageProps, "car_telephone_number"); $wPhone = $this->getProp($messageProps, "car_telephone_number");
if (!empty($wphone)) { if (!empty($wPhone)) {
$vcard->addPhoneNumber($wphone, 'CAR'); $vCard->addPhoneNumber($wPhone, 'CAR');
} }
// ADDRESS // ADDRESS
$addr = $this->getProp($messageProps, "business_address"); $address = $this->getProp($messageProps, "business_address");
if (!empty($addr)) { if (!empty($address)) {
$vcard->addAddress(null, null, $this->getProp($messageProps, "business_address_street"), $this->getProp($messageProps, "business_address_city"), $this->getProp($messageProps, "business_address_state"), $this->getProp($messageProps, "business_address_postal_code"), $this->getProp($messageProps, "business_address_country"), "WORK"); $vCard->addAddress(null, null, $this->getProp($messageProps, "business_address_street"), $this->getProp($messageProps, "business_address_city"), $this->getProp($messageProps, "business_address_state"), $this->getProp($messageProps, "business_address_postal_code"), $this->getProp($messageProps, "business_address_country"), "WORK");
} }
$addr = $this->getProp($messageProps, "home_address"); $address = $this->getProp($messageProps, "home_address");
if (!empty($addr)) { if (!empty($address)) {
$vcard->addAddress(null, null, $this->getProp($messageProps, "home_address_street"), $this->getProp($messageProps, "home_address_city"), $this->getProp($messageProps, "home_address_state"), $this->getProp($messageProps, "home_address_postal_code"), $this->getProp($messageProps, "home_address_country"), "HOME"); $vCard->addAddress(null, null, $this->getProp($messageProps, "home_address_street"), $this->getProp($messageProps, "home_address_city"), $this->getProp($messageProps, "home_address_state"), $this->getProp($messageProps, "home_address_postal_code"), $this->getProp($messageProps, "home_address_country"), "HOME");
} }
$addr = $this->getProp($messageProps, "other_address"); $address = $this->getProp($messageProps, "other_address");
if (!empty($addr)) { if (!empty($address)) {
$vcard->addAddress(null, null, $this->getProp($messageProps, "other_address_street"), $this->getProp($messageProps, "other_address_city"), $this->getProp($messageProps, "other_address_state"), $this->getProp($messageProps, "other_address_postal_code"), $this->getProp($messageProps, "other_address_country"), "OTHER"); $vCard->addAddress(null, null, $this->getProp($messageProps, "other_address_street"), $this->getProp($messageProps, "other_address_city"), $this->getProp($messageProps, "other_address_state"), $this->getProp($messageProps, "other_address_postal_code"), $this->getProp($messageProps, "other_address_country"), "OTHER");
} }
// MISC // MISC
$url = $this->getProp($messageProps, "webpage"); $url = $this->getProp($messageProps, "webpage");
if (!empty($url)) { if (!empty($url)) {
$vcard->addURL($url); $vCard->addURL($url);
} }
$bday = $this->getProp($messageProps, "birthday"); $birthday = $this->getProp($messageProps, "birthday");
if (!empty($bday)) { if (!empty($birthday)) {
$vcard->addBirthday(date("Y-m-d", $bday)); $vCard->addBirthday(date("Y-m-d", $birthday));
} }
$notes = $this->getProp($messageProps, "body"); $notes = $this->getProp($messageProps, "body");
if (!empty($notes)) { if (!empty($notes)) {
$vcard->addNote($notes); $vCard->addNote($notes);
} }
$haspicture = $this->getProp($messageProps, "has_picture"); $hasPicture = $this->getProp($messageProps, "has_picture");
if (!empty($haspicture) && $haspicture === true) { if (!empty($hasPicture) && $hasPicture === true) {
$attachnum = -1; $attachNum = -1;
if (isset($messageProps["attachments"]) && isset($messageProps["attachments"]["item"])) { if (isset($messageProps["attachments"]) && isset($messageProps["attachments"]["item"])) {
foreach ($messageProps["attachments"]["item"] as $attachment) { foreach ($messageProps["attachments"]["item"] as $attachment) {
if ($attachment["props"]["attachment_contactphoto"] == true) { if ($attachment["props"]["attachment_contactphoto"] == true) {
$attachnum = $attachment["props"]["attach_num"]; $attachNum = $attachment["props"]["attach_num"];
break; break;
} }
} }
} }
if ($attachnum >= 0) { if ($attachNum >= 0) {
$attachment = $this->getAttachmentByAttachNum($message, $attachnum); // get first attachment only $attachment = $this->getAttachmentByAttachNum($message, $attachNum); // get first attachment only
$phototoken = $this->randomstring(16); $photoToken = Helper::randomstring(16);
$tmpphoto = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "photo_" . $phototoken . ".jpg"; $tmpPhoto = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "photo_" . $photoToken . ".jpg";
$this->storeSavedAttachment($tmpphoto, $attachment); $this->storeSavedAttachment($tmpPhoto, $attachment);
$vcard->addPhoto($tmpphoto, true); $vCard->addPhoto($tmpPhoto, true);
unlink($tmpphoto); unlink($tmpPhoto);
} }
} }
// write combined vcf // write combined vcf
file_put_contents($file, file_get_contents($file) . $vcard->getOutput()); file_put_contents($file, file_get_contents($file) . $vCard->getOutput());
} }
} else { } else {
return false; return false;
@ -453,11 +437,14 @@ class ContactModule extends Module
$this->addActionData($actionType, $response); $this->addActionData($actionType, $response);
$GLOBALS["bus"]->addData($this->getResponseData()); $GLOBALS["bus"]->addData($this->getResponseData());
return true;
} }
/** /**
* Returns attachment based on specified attachNum, additionally it will also get embedded message * Returns attachment based on specified attachNum, additionally it will also get embedded message
* if we want to get the inline image attachment. * if we want to get the inline image attachment.
*
* @param $message * @param $message
* @param array $attachNum * @param array $attachNum
* @return MAPIAttach embedded message attachment or attachment that is requested * @return MAPIAttach embedded message attachment or attachment that is requested
@ -473,10 +460,11 @@ class ContactModule extends Module
/** /**
* Function will open passed attachment and generate response for that attachment to send it to client. * Function will open passed attachment and generate response for that attachment to send it to client.
* This should only be used to download attachment that is already saved in MAPIMessage. * This should only be used to download attachment that is already saved in MAPIMessage.
*
* @param MAPIAttach $attachment attachment which will be dumped to client side * @param MAPIAttach $attachment attachment which will be dumped to client side
* @return Response response to sent to client including attachment data * @return Response response to sent to client including attachment data
*/ */
private function storeSavedAttachment($temppath, $attachment) private function storeSavedAttachment($tempPath, $attachment)
{ {
// Check if the attachment is opened // Check if the attachment is opened
if ($attachment) { if ($attachment) {
@ -490,12 +478,13 @@ class ContactModule extends Module
$body .= mapi_stream_read($stream, BLOCK_SIZE); $body .= mapi_stream_read($stream, BLOCK_SIZE);
} }
file_put_contents($temppath, $body); file_put_contents($tempPath, $body);
} }
} }
/** /**
* Replace String Property Tags * Replace String Property Tags
*
* @param $store * @param $store
* @param $properties * @param $properties
* @return array * @return array
@ -563,7 +552,7 @@ class ContactModule extends Module
/** /**
* A simple Property map initialization * A simple Property map initialization
* *
* @return [array] the propertyarray * @return array the propertyarray
*/ */
private function getProperties() private function getProperties()
{ {
@ -708,7 +697,7 @@ class ContactModule extends Module
private function loadContacts($actionType, $actionData) private function loadContacts($actionType, $actionData)
{ {
$error = false; $error = false;
$error_msg = ""; $errorMsg = "";
if (is_readable($actionData["vcf_filepath"])) { if (is_readable($actionData["vcf_filepath"])) {
$parser = null; $parser = null;
@ -717,11 +706,11 @@ class ContactModule extends Module
$parser = VCardParser::parseFromFile($actionData["vcf_filepath"]); $parser = VCardParser::parseFromFile($actionData["vcf_filepath"]);
} catch (Exception $e) { } catch (Exception $e) {
$error = true; $error = true;
$error_msg = $e->getMessage(); $errorMsg = $e->getMessage();
} }
if ($error) { if ($error) {
$response['status'] = false; $response['status'] = false;
$response['message'] = $error_msg; $response['message'] = $errorMsg;
} else { } else {
if (iterator_count($parser) == 0) { if (iterator_count($parser) == 0) {
$response['status'] = false; $response['status'] = false;
@ -750,8 +739,8 @@ class ContactModule extends Module
/** /**
* Create a array with contacts * Create a array with contacts
* *
* @param contacts vcard or csv contacts * @param VCard $contacts or csv contacts
* @param csv optional, true if contacts are csv contacts * @param bool|optional $csv true if contacts are csv contacts
* @return array parsed contacts * @return array parsed contacts
* @private * @private
*/ */
@ -818,13 +807,13 @@ class ContactModule extends Module
} }
} }
if (isset($vCard->email) && count($vCard->email) > 0) { if (isset($vCard->email) && count($vCard->email) > 0) {
$emailcount = 0; $emailCount = 0;
$properties["address_book_long"] = 0; $properties["address_book_long"] = 0;
foreach ($vCard->email as $type => $email) { foreach ($vCard->email as $type => $email) {
foreach ($email as $mail) { foreach ($email as $mail) {
$fileas = $mail; $fileAs = $mail;
if (isset($properties["fileas"]) && !empty($properties["fileas"])) { if (isset($properties["fileas"]) && !empty($properties["fileas"])) {
$fileas = $properties["fileas"]; // set to real name $fileAs = $properties["fileas"]; // set to real name
} }
// we only have storage for 3 mail addresses! // we only have storage for 3 mail addresses!
@ -841,24 +830,24 @@ class ContactModule extends Module
* address_book_long stores sum of the flags * address_book_long stores sum of the flags
* these both properties should be in sync always * these both properties should be in sync always
*/ */
switch ($emailcount) { switch ($emailCount) {
case 0: case 0:
$properties["email_address_1"] = $mail; $properties["email_address_1"] = $mail;
$properties["email_address_display_name_1"] = $fileas . " (" . $mail . ")"; $properties["email_address_display_name_1"] = $fileAs . " (" . $mail . ")";
$properties["email_address_display_name_email_1"] = $mail; $properties["email_address_display_name_email_1"] = $mail;
$properties["address_book_mv"][] = 0; // this is needed for adding the contact to the email address book, 0 = email 1 $properties["address_book_mv"][] = 0; // this is needed for adding the contact to the email address book, 0 = email 1
$properties["address_book_long"] += 1; // this specifies the number of elements in address_book_mv $properties["address_book_long"] += 1; // this specifies the number of elements in address_book_mv
break; break;
case 1: case 1:
$properties["email_address_2"] = $mail; $properties["email_address_2"] = $mail;
$properties["email_address_display_name_2"] = $fileas . " (" . $mail . ")"; $properties["email_address_display_name_2"] = $fileAs . " (" . $mail . ")";
$properties["email_address_display_name_email_2"] = $mail; $properties["email_address_display_name_email_2"] = $mail;
$properties["address_book_mv"][] = 1; // this is needed for adding the contact to the email address book, 1 = email 2 $properties["address_book_mv"][] = 1; // this is needed for adding the contact to the email address book, 1 = email 2
$properties["address_book_long"] += 2; // this specifies the number of elements in address_book_mv $properties["address_book_long"] += 2; // this specifies the number of elements in address_book_mv
break; break;
case 2: case 2:
$properties["email_address_3"] = $mail; $properties["email_address_3"] = $mail;
$properties["email_address_display_name_3"] = $fileas . " (" . $mail . ")"; $properties["email_address_display_name_3"] = $fileAs . " (" . $mail . ")";
$properties["email_address_display_name_email_3"] = $mail; $properties["email_address_display_name_email_3"] = $mail;
$properties["address_book_mv"][] = 2; // this is needed for adding the contact to the email address book, 2 = email 3 $properties["address_book_mv"][] = 2; // this is needed for adding the contact to the email address book, 2 = email 3
$properties["address_book_long"] += 4; // this specifies the number of elements in address_book_mv $properties["address_book_long"] += 4; // this specifies the number of elements in address_book_mv
@ -866,7 +855,7 @@ class ContactModule extends Module
default: default:
break; break;
} }
$emailcount++; $emailCount++;
} }
} }
} }
@ -936,7 +925,7 @@ class ContactModule extends Module
if (!is_writable(TMP_PATH . "/")) { if (!is_writable(TMP_PATH . "/")) {
error_log("Can not write to export tmp directory!"); error_log("Can not write to export tmp directory!");
} else { } else {
$tmppath = TMP_PATH . "/" . $this->randomstring(15); $tmppath = TMP_PATH . "/" . Helper::randomstring(15);
if (isset($vCard->rawPhoto)) { if (isset($vCard->rawPhoto)) {
if (file_put_contents($tmppath, $vCard->rawPhoto)) { if (file_put_contents($tmppath, $vCard->rawPhoto)) {
$properties["internal_fields"]["x_photo_path"] = $tmppath; $properties["internal_fields"]["x_photo_path"] = $tmppath;
@ -968,14 +957,14 @@ class ContactModule extends Module
} }
/** /**
* Generate the whole addressstring * Generate the whole address string
* *
* @param street * @param street
* @param zip * @param zip
* @param city * @param city
* @param state * @param state
* @param country * @param country
* @return string the concatinated address string * @return string the concatenated address string
* @private * @private
*/ */
private function buildAddressString($street, $zip, $city, $state, $country) private function buildAddressString($street, $zip, $city, $state, $country)
@ -1009,6 +998,7 @@ class ContactModule extends Module
/** /**
* Store the file to a temporary directory * Store the file to a temporary directory
*
* @param $actionType * @param $actionType
* @param $actionData * @param $actionData
* @private * @private
@ -1016,15 +1006,15 @@ class ContactModule extends Module
private function getAttachmentPath($actionType, $actionData) private function getAttachmentPath($actionType, $actionData)
{ {
// Get store id // Get store id
$storeid = false; $storeId = false;
if (isset($actionData["store"])) { if (isset($actionData["store"])) {
$storeid = $actionData["store"]; $storeId = $actionData["store"];
} }
// Get message entryid // Get message entryid
$entryid = false; $entryId = false;
if (isset($actionData["entryid"])) { if (isset($actionData["entryid"])) {
$entryid = $actionData["entryid"]; $entryId = $actionData["entryid"];
} }
// Check which type isset // Check which type isset
@ -1037,13 +1027,13 @@ class ContactModule extends Module
} }
// Check if storeid and entryid isset // Check if storeid and entryid isset
if ($storeid && $entryid) { if ($storeId && $entryId) {
// Open the store // Open the store
$store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId));
if ($store) { if ($store) {
// Open the message // Open the message
$message = mapi_msgstore_openentry($store, hex2bin($entryid)); $message = mapi_msgstore_openentry($store, hex2bin($entryId));
if ($message) { if ($message) {
$attachment = false; $attachment = false;
@ -1053,10 +1043,10 @@ class ContactModule extends Module
// Loop through the attachNums, message in message in message ... // Loop through the attachNums, message in message in message ...
for ($i = 0; $i < (count($attachNum) - 1); $i++) { for ($i = 0; $i < (count($attachNum) - 1); $i++) {
// Open the attachment // Open the attachment
$tempattach = mapi_message_openattach($message, (int)$attachNum[$i]); $tempAttach = mapi_message_openattach($message, (int)$attachNum[$i]);
if ($tempattach) { if ($tempAttach) {
// Open the object in the attachment // Open the object in the attachment
$message = mapi_attach_openobj($tempattach); $message = mapi_attach_openobj($tempAttach);
} }
} }
@ -1100,7 +1090,7 @@ class ContactModule extends Module
$ext_found = false; $ext_found = false;
while (!feof($fh) && !$ext_found) { while (!feof($fh) && !$ext_found) {
$line = fgets($fh); $line = fgets($fh);
preg_match("/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i", $line, $result); preg_match('/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i', $line, $result);
if ($extension == $result[1]) { if ($extension == $result[1]) {
$ext_found = true; $ext_found = true;
$contentType = $result[2]; $contentType = $result[2];
@ -1112,25 +1102,26 @@ class ContactModule extends Module
} }
$tmpname = tempnam(TMP_PATH, stripslashes($filename)); $tmpName = tempnam(TMP_PATH, stripslashes($filename));
// Open a stream to get the attachment data // Open a stream to get the attachment data
$stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN); $stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN);
$stat = mapi_stream_stat($stream); $stat = mapi_stream_stat($stream);
// File length = $stat["cb"] // File length = $stat["cb"]
$fhandle = fopen($tmpname, 'w'); $fHandle = fopen($tmpName, 'w');
$buffer = null; $buffer = null;
for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) { for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) {
// Write stream // Write stream
$buffer = mapi_stream_read($stream, BLOCK_SIZE); $buffer = mapi_stream_read($stream, BLOCK_SIZE);
fwrite($fhandle, $buffer, strlen($buffer)); fwrite($fHandle, $buffer, strlen($buffer));
} }
fclose($fhandle); fclose($fHandle);
$response = array(); $response = array();
$response['tmpname'] = $tmpname; $response['tmpname'] = $tmpName;
$response['filename'] = $filename; $response['filename'] = $filename;
$response['contenttype'] = $contentType;
$response['status'] = true; $response['status'] = true;
$this->addActionData($actionType, $response); $this->addActionData($actionType, $response);
$GLOBALS["bus"]->addData($this->getResponseData()); $GLOBALS["bus"]->addData($this->getResponseData());
@ -1152,6 +1143,7 @@ class ContactModule extends Module
/** /**
* Check if string starts with other string. * Check if string starts with other string.
*
* @param $haystack * @param $haystack
* @param $needle * @param $needle
* @return bool * @return bool

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* plugin.contactimporter.php, Kopano Webapp contact to vcf im/exporter * plugin.contactimporter.php, Kopano Webapp contact to vcf im/exporter
* *
@ -20,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
require_once __DIR__ . "/download.php"; require_once(__DIR__ . "/download.php");
/** /**
* contactimporter Plugin * contactimporter Plugin

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* upload.php, Kopano Webapp contact to vcf im/exporter * upload.php, Kopano Webapp contact to vcf im/exporter
* *
@ -21,53 +22,35 @@
* *
*/ */
require_once("../config.php"); require_once(__DIR__ . "/../config.php");
require_once(__DIR__ . "/helper.php");
require_once(__DIR__ . '/../../../init.php');
require_once(__DIR__ . "/../../../server/includes/core/class.webappauthentication.php"); // for checking the session
use contactimporter\Helper;
/* disable error printing - otherwise json communication might break... */ /* disable error printing - otherwise json communication might break... */
ini_set('display_errors', '0'); ini_set('display_errors', '0');
/** // check session
* respond/echo JSON // otherwise a DOS attack might be possible
* @param $arr if (!WebAppAuthentication::getUserName() || WebAppAuthentication::getUserName() == "") {
*/ Helper::respondJSON(array('success' => false, 'error' => dgettext("plugin_contactimporter", "Not authenticated!")));
function respondJSON($arr) die();
{
echo json_encode($arr);
} }
/**
* Generates a random string with variable length.
* @param $length the lenght of the generated string
* @return string a random string
*/
function randomstring($length = 6)
{
// $chars - all allowed charakters
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
srand((double)microtime() * 1000000);
$i = 0;
$pass = "";
while ($i < $length) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$destpath = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD;
$destpath .= $_FILES['vcfdata']['name'] . randomstring();
if (is_readable($_FILES['vcfdata']['tmp_name'])) { if (is_readable($_FILES['vcfdata']['tmp_name'])) {
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'], $destpath); $dstPath = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD;
$dstPath .= $_FILES['vcfdata']['name'] . Helper::randomstring();
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'], $dstPath);
if ($result) { if ($result) {
respondJSON(array('success' => true, 'vcf_file' => $destpath)); Helper::respondJSON(array('success' => true, 'vcf_file' => $dstPath));
} else { } else {
respondJSON(array('success' => false, 'error' => dgettext("plugin_contactimporter", "File could not be moved to TMP path! Check plugin config and folder permissions!"))); Helper::respondJSON(array('success' => false, 'error' => dgettext("plugin_contactimporter", "File could not be moved to TMP path! Check plugin config and folder permissions!")));
} }
} else { } else {
respondJSON(array('success' => false, 'error' => dgettext("plugin_contactimporter", "File could not be read by server, upload error!"))); Helper::respondJSON(array('success' => false, 'error' => dgettext("plugin_contactimporter", "File could not be read by server, upload error!")));
} }